:root {
  color-scheme: dark;
  --bg: #070b14;
  --panel: #0e1626;
  --ink: #e8eef8;
  --muted: #93a0b8;
  --accent: #2ec4b6;
  --danger: #f07178;
  --ok: #7bd88f;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  min-height: 100dvh;
  padding: calc(0.65rem + var(--safe-top)) 0.75rem calc(0.75rem + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.top {
  width: min(100%, 28rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.brand-title {
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

button,
.file-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: #1a2438;
  color: var(--ink);
}

button.primary,
.file-btn.primary {
  background: var(--accent);
  color: #06241f;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid #243049;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.file-btn {
  display: inline-flex;
  align-items: center;
}

.file-btn input {
  display: none;
}

.stage {
  position: relative;
  width: min(92vw, 28rem);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid #1d2a40;
}

body.has-result .reticle,
body.has-result .stage video {
  display: none;
}

.stage video,
.stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.stage canvas.hit-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.stage video[hidden],
.stage img[hidden],
.stage canvas[hidden] {
  display: none;
}

.reticle {
  pointer-events: none;
  position: absolute;
  inset: 14%;
  border: 2px solid rgba(46, 196, 182, 0.9);
  border-radius: 16px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.38);
}

.hint {
  margin: 0;
  width: min(100%, 28rem);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.hint.error {
  color: var(--danger);
}

.hint.ok {
  color: var(--ok);
}

.panel {
  width: min(100%, 28rem);
  background: var(--panel);
  border: 1px solid #1d2a40;
  border-radius: var(--radius);
  padding: 0.85rem;
  display: grid;
  gap: 0.65rem;
}

.panel[hidden] {
  display: none;
}

.panel.result {
  flex: 1 1 auto;
  align-content: start;
}

.panel label {
  font-size: 0.82rem;
  color: var(--muted);
}

.panel textarea {
  width: 100%;
  min-height: 8rem;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid #243049;
  background: #0a1220;
  color: var(--ink);
  padding: 0.65rem 0.75rem;
  font: 0.95rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.hit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.hit-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.45rem;
  align-items: start;
  margin: 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid #243049;
  border-radius: 10px;
  background: #0a1220;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}

.hit-item.is-active {
  border-color: var(--accent);
}

.hit-num {
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 999px;
  background: var(--accent);
  color: #06241f;
  font-weight: 700;
  font-size: 0.75rem;
  display: grid;
  place-items: center;
}

.hit-fmt {
  margin: 0 0 0.12rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.hit-text {
  margin: 0;
  font: 0.85rem/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

.install-card {
  width: min(100%, 28rem);
}
