:root {
  --bg: #06121c;
  --panel: #0d2030;
  --panel-2: #12293c;
  --line: #1f3d55;
  --text: #e6f3fa;
  --muted: #8fabbd;
  --accent: #5fe6ff;
  --accent-ink: #032029;
  --good: #63e6a0;
  --warn: #ffc65a;
  --bad: #ff7a7a;
  --radius: 16px;
}

* { 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;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 50% -10%, #12314a 0%, transparent 70%),
    var(--bg);
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

[hidden] { display: none !important; }

h1 { font-size: 1.9rem; margin: 10px 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin: 6px 0 14px; }

.hero { text-align: center; padding: 18px 0 8px; }
.lede { color: var(--muted); margin: 0 auto 8px; max-width: 34ch; }

.logo {
  width: 84px; height: 84px; margin: 0 auto;
  border-radius: 24px;
  background: var(--panel) url("../icon.svg") center / cover no-repeat;
  box-shadow: 0 0 0 1px var(--line), 0 0 40px #5fe6ff33;
}

.actions { display: grid; gap: 10px; margin: 18px 0 8px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 15px 18px;
  border-radius: var(--radius);
  min-height: 54px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible, .chip:focus-visible, .link:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #ffffffaa; outline-offset: 2px;
}

.link {
  appearance: none; background: none; border: 0; padding: 8px 0;
  color: var(--accent); font: inherit; font-size: 0.92rem; text-decoration: underline; cursor: pointer;
}
.link.danger { color: var(--bad); }
.file-link { display: block; text-align: center; margin-top: 6px; }

.hint { color: var(--muted); font-size: 0.93rem; margin: 8px 0; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }
.section-title { margin-top: 26px; font-size: 1.05rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.count { color: var(--text); }

.print-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.print-card {
  display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
}
.print-card canvas { width: 58px; height: 76px; border-radius: 10px; background: #020a10; display: block; }
.print-name { font-weight: 700; }
.print-meta { color: var(--muted); font-size: 0.88rem; }
.icon-btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  width: 44px; height: 44px; border-radius: 12px; font-size: 1.2rem; cursor: pointer;
}

.foot { margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.foot p { margin: 0 0 10px; }
.switch { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

.field { display: grid; gap: 6px; margin: 0 0 14px; }
.field span { color: var(--muted); font-size: 0.9rem; }
.field.inline { grid-template-columns: auto 1fr; align-items: center; gap: 12px; margin: 0; flex: 1; }
input[type="text"], select {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px; min-height: 50px; width: 100%;
}

/* viewfinder */
.finder {
  position: relative; border-radius: 22px; overflow: hidden; background: #000;
  border: 1px solid var(--line); aspect-ratio: 3 / 4;
}
.finder canvas { width: 100%; height: 100%; display: block; }
.status {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: #06121ccc; border: 1px solid var(--line); color: var(--text);
  padding: 7px 14px; border-radius: 999px; font-size: 0.92rem; white-space: nowrap; max-width: 92%;
  overflow: hidden; text-overflow: ellipsis;
}
.status.good { border-color: var(--good); color: var(--good); }
.status.warn { border-color: var(--warn); color: var(--warn); }

.meter { height: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; margin: 12px 0 4px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--warn); border-radius: 999px; transition: width 0.2s linear, background-color 0.2s linear; }
.meter-fill.good { background: var(--good); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 0; }
.chip {
  appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-size: 0.92rem; padding: 10px 14px; border-radius: 999px; min-height: 44px; cursor: pointer;
}
.chip.on { background: var(--warn); border-color: var(--warn); color: #2b1c00; }
.zoom { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 160px; color: var(--muted); font-size: 0.9rem; }
.zoom input { flex: 1; accent-color: var(--accent); min-height: 44px; }

#video { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }

/* processing and result */
.stage {
  position: relative; border-radius: 22px; overflow: hidden; background: #020a10;
  border: 1px solid var(--line); aspect-ratio: 3 / 4; width: min(100%, calc(62dvh * 0.75)); margin: 0 auto;
}
.layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 0.6s ease; }
.layer.show { opacity: 1; }
.sweep {
  position: absolute; left: 0; right: 0; height: 3px; top: 0;
  background: var(--accent); box-shadow: 0 0 18px 4px #5fe6ff88;
  animation: sweep 1.6s ease-in-out infinite alternate;
}
@keyframes sweep { from { top: 2%; } to { top: 97%; } }

.caption { text-align: center; color: var(--muted); min-height: 1.5em; margin: 10px 0 0; }

.verdict { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 12px; }
.verdict.match { border-color: var(--good); }
.verdict.maybe { border-color: var(--warn); }
.verdict.none { border-color: var(--bad); }
.verdict-head { font-size: 1.5rem; font-weight: 800; }
.verdict.match .verdict-head { color: var(--good); }
.verdict.maybe .verdict-head { color: var(--warn); }
.verdict.none .verdict-head { color: var(--bad); }
.verdict-sub { color: var(--muted); margin-top: 2px; }

.rows { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.rows li { display: grid; grid-template-columns: 1fr 44px; gap: 4px 10px; align-items: center; font-size: 0.92rem; }
.rows .bar { grid-column: 1 / -1; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.rows .bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.5s ease; }
.rows .pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.tech { margin-top: 16px; color: var(--muted); font-size: 0.88rem; }
.tech summary { cursor: pointer; padding: 8px 0; }
.tech dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 6px 0; }
.tech dt { color: var(--muted); }
.tech dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .sweep { animation: none; top: 50%; }
  .layer, .meter-fill, .rows .bar i { transition: none; }
}

@media (min-width: 700px) {
  #app { padding-top: 34px; }
}
