:root {
  --bg: #0b0f14;
  --bg-soft: #121821;
  --panel: #161e29;
  --line: #243140;
  --text: #e6edf3;
  --muted: #8aa0b2;
  --accent: #63f2c5;
  --accent-dim: #2fae8a;
  --danger: #ff7b72;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(99, 242, 197, 0.08), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(99, 242, 197, 0.05), transparent 60%),
    var(--bg);
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}

/* ── topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 5px;
  background:
    linear-gradient(135deg, var(--accent), var(--accent-dim));
  box-shadow: 0 0 18px rgba(99, 242, 197, 0.45);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 5px;
  border-radius: 2px;
  background: var(--bg);
  clip-path: polygon(0 0, 40% 0, 40% 40%, 0 40%, 0 0,
                     60% 60%, 100% 60%, 100% 100%, 60% 100%, 60% 60%);
}
.brand-name { font-size: 20px; letter-spacing: 0.5px; font-weight: 500; }
.brand-name b { color: var(--accent); font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 13px; font-family: var(--mono); }

/* ── views ──────────────────────────────────────────────── */
.view { animation: fade 0.25s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.lead { color: var(--muted); font-size: 16px; margin: 4px 0 18px; }
.footnote { color: var(--muted); font-size: 13px; margin-top: 26px; line-height: 1.5; }

/* ── home cards ─────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.card {
  display: flex; flex-direction: column; gap: 8px;
  text-align: left;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-dim);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
.card-icon {
  font-size: 26px; line-height: 1;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgba(99, 242, 197, 0.1);
  color: var(--accent);
}
.card-title { font-size: 18px; font-weight: 600; }
.card-desc { color: var(--muted); font-size: 14px; line-height: 1.45; }

/* ── settings ───────────────────────────────────────────── */
.settings {
  margin-top: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 16px;
}
.settings summary { cursor: pointer; padding: 12px 0; color: var(--text); font-weight: 500; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  padding: 8px 0 14px;
}
.settings label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); }
.settings select, .settings input[type="range"] {
  font: inherit;
  accent-color: var(--accent);
}
.settings select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 10px;
}
.hint { color: var(--muted); font-family: var(--mono); font-size: 12px; margin: 0 0 8px; }

/* ── buttons ────────────────────────────────────────────── */
.primary, .ghost, .back {
  font: inherit;
  cursor: pointer;
  border-radius: 11px;
  transition: filter 0.15s, background 0.15s, border-color 0.15s, opacity 0.15s;
}
.primary {
  margin-top: 16px;
  padding: 13px 22px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #06251c;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(99, 242, 197, 0.22);
}
.primary:hover { filter: brightness(1.07); }
.primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.ghost {
  margin-top: 22px;
  padding: 11px 18px;
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--accent-dim);
}
.ghost:hover { background: rgba(99, 242, 197, 0.08); }

.view-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.view-head h2 { margin: 0; font-size: 22px; font-weight: 600; }
.back {
  padding: 8px 14px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}
.back:hover { border-color: var(--accent-dim); }

/* ── file pick ──────────────────────────────────────────── */
.pick { display: flex; flex-direction: column; align-items: flex-start; }
.filedrop {
  display: block; width: 100%;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.filedrop:hover { border-color: var(--accent-dim); background: var(--bg-soft); }
.filedrop input { display: none; }
.filedrop-label { color: var(--muted); font-size: 15px; }
.filedrop-label.set { color: var(--accent); font-family: var(--mono); }

/* ── live stage ─────────────────────────────────────────── */
.stage {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  align-items: start;
}
.stage-lb { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .stage { grid-template-columns: 1fr; } }

.qr-panel, .cam-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.qr-panel { background: #fff; }
.qr {
  width: 100%;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
  border-radius: 6px;
  display: block;
}
.qr-cap, .cam-cap {
  font-size: 12px; text-align: center;
  font-family: var(--mono);
}
.qr-cap { color: #475; }
.cam-cap { color: var(--muted); }
.cam-wrap { position: relative; }
.cam {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #000;
  border-radius: 6px;
}
.cam.mirrored { transform: scaleX(-1); } /* selfie-style preview; capture stays unflipped */
.flip {
  position: absolute;
  right: 8px; bottom: 8px;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 19px; line-height: 1;
  color: var(--text);
  background: rgba(11, 15, 20, 0.62);
  border: 1px solid rgba(230, 237, 243, 0.25);
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(3px);
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.flip:hover { background: rgba(11, 15, 20, 0.85); border-color: var(--accent); color: var(--accent); }
.flip:active { transform: rotate(-90deg); }

/* ── status / progress ──────────────────────────────────── */
.status { margin-top: 18px; }
.status-line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 14px; margin-bottom: 8px;
}
.status-line span:first-child { color: var(--text); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.status-line span:last-child { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.bar {
  height: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 99px;
  transition: width 0.2s ease;
}
.msg { color: var(--muted); font-size: 13px; margin-top: 10px; min-height: 1.2em; font-family: var(--mono); }
.msg.ok { color: var(--accent); }
.msg.err { color: var(--danger); }
.download { display: inline-block; text-decoration: none; }

/* ── boot ───────────────────────────────────────────────── */
.boot { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 60px 0; color: var(--muted); }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
