:root {
  --bg: #07090d;
  --surface: rgba(20, 24, 33, 0.72);
  --surface-solid: #11151d;
  --surface-2: #171c27;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #eef1f7;
  --muted: #8f98ad;
  --mint: #6ee7b7;
  --sky: #60a5fa;
  --amber: #fbbf24;
  --red: #f87171;
  --grad: linear-gradient(135deg, #6ee7b7 0%, #60a5fa 100%);
  --top: calc(56px + env(safe-area-inset-top));
  --tab: calc(66px + env(safe-area-inset-bottom));
  --radius: 20px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --plate-font: 'Roboto Condensed', 'sans-serif-condensed', 'Arial Narrow', 'DejaVu Sans Condensed', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--bg); }
body {
  color: var(--text);
  font: 15px/1.45 Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; flex: none; }

.app { position: fixed; inset: 0; overflow: hidden; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: absolute; z-index: 20; top: 0; left: 0; right: 0;
  height: var(--top); padding: env(safe-area-inset-top) 12px 0 16px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(to bottom, rgba(7, 9, 13, .92), rgba(7, 9, 13, .72));
  backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--line);
  transition: background .3s, border-color .3s;
}
.app[data-mode="scan"] .topbar {
  background: linear-gradient(to bottom, rgba(0, 0, 0, .6), rgba(0, 0, 0, 0));
  border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 18px; letter-spacing: .1px; flex: 1; }
.brand__mark {
  width: 28px; height: 28px; border-radius: 9px; background: var(--grad); position: relative;
  box-shadow: 0 4px 14px rgba(96, 165, 250, .35);
}
.brand__mark::before { content: ''; position: absolute; left: 6px; right: 6px; top: 10.5px; height: 7px; border-radius: 2px; background: #07231b; }
.brand__mark::after { content: ''; position: absolute; inset: 4px; border-radius: 5px; border: 1.5px solid rgba(7, 35, 27, .55); border-left-color: transparent; border-right-color: transparent; }
.status {
  display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line-2); padding: 5px 10px; border-radius: 99px; background: rgba(0, 0, 0, .25);
  max-width: 52vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status span { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.status[data-state="ready"] .dot { background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.status[data-state="loading"] .dot { background: var(--amber); animation: pulse 1.2s ease-in-out infinite; }
.status[data-state="error"] .dot { background: var(--red); }
.icon-btn { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: var(--text); }
.icon-btn:active { background: rgba(255, 255, 255, .08); }
.icon-btn--debug { color: var(--amber); }
.is-debug .brand > span:last-child { display: none; }
.is-debug .brand::after {
  content: 'DEBUG'; font: 800 10px/1 Roboto, system-ui, sans-serif; letter-spacing: .9px; color: #2a1b00;
  background: var(--amber); padding: 4px 6px; border-radius: 6px;
}

/* ------------------------------------------------------------------ views */
.views { position: absolute; inset: 0; }
.view { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.view--scan { overflow: hidden; }
.pane { padding: calc(var(--top) + 18px) 16px calc(var(--tab) + 28px); max-width: 640px; margin: 0 auto; }
.view:not([hidden]) .pane { animation: rise .35s var(--ease); }

/* ------------------------------------------------------------------ tab bar */
.tabbar {
  position: absolute; z-index: 20; left: 0; right: 0; bottom: 0; height: var(--tab);
  padding: 6px 8px env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(10, 12, 17, .86); backdrop-filter: blur(20px) saturate(150%); -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-top: 1px solid var(--line);
}
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); padding-top: 4px; }
.tabbar button span { width: 58px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: background .25s, color .25s; }
.tabbar button b { font-size: 11.5px; font-weight: 600; letter-spacing: .2px; }
.tabbar button.on { color: var(--text); }
.tabbar button.on span { background: linear-gradient(135deg, rgba(110, 231, 183, .2), rgba(96, 165, 250, .22)); color: var(--mint); }

/* ------------------------------------------------------------------ scan */
.viewfinder { position: absolute; inset: 0; background: #000; overflow: hidden; }
.viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 12px; padding: calc(var(--top) + 20px) 32px calc(var(--tab) + 120px);
  background:
    radial-gradient(60% 40% at 50% 35%, rgba(96, 165, 250, .16), transparent 70%),
    radial-gradient(50% 35% at 30% 70%, rgba(110, 231, 183, .10), transparent 70%),
    var(--bg);
}
.cam-empty h2 { font-size: 22px; font-weight: 750; margin-top: 8px; }
.cam-empty p { color: var(--muted); max-width: 320px; }
.cam-empty .btn { margin-top: 10px; min-width: 200px; }
.hero-icon {
  width: 92px; height: 92px; border-radius: 30px; display: grid; place-items: center; position: relative;
  background: linear-gradient(145deg, rgba(110, 231, 183, .18), rgba(96, 165, 250, .18));
  border: 1px solid rgba(255, 255, 255, .1); color: var(--mint);
  box-shadow: 0 20px 50px rgba(96, 165, 250, .18);
}
.hero-icon .ic { width: 40px; height: 40px; stroke-width: 1.7; }

.reticle {
  position: absolute; left: 50%; top: 44%; width: min(72vw, 360px); aspect-ratio: 4.2 / 1;
  transform: translate(-50%, -50%); pointer-events: none; animation: breathe 2.4s ease-in-out infinite;
}
.reticle i { position: absolute; width: 26px; height: 26px; border: 3px solid rgba(255, 255, 255, .85); }
.reticle i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 10px; }
.reticle i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 10px; }
.reticle i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 10px; }
.reticle i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 10px; }
.reticle p {
  position: absolute; top: calc(100% + 16px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 99px; background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hud {
  position: absolute; left: 12px; top: calc(var(--top) + 4px); font: 600 11px/1.35 ui-monospace, 'Roboto Mono', monospace;
  padding: 7px 9px 6px; border-radius: 11px; background: rgba(0, 0, 0, .55); color: #cfe7ff; letter-spacing: .2px;
  display: grid; gap: 6px; width: min(62vw, 250px); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#hudText { white-space: pre-line; }
#hudGraph { width: 100%; height: 30px; display: block; }
.tray {
  position: absolute; left: 0; right: 0; bottom: calc(var(--tab) + 104px);
  display: flex; gap: 8px; padding: 0 16px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
}
.tray::-webkit-scrollbar { display: none; }
.tray-chip {
  flex: none; scroll-snap-align: start; display: flex; align-items: center; gap: 9px; padding: 8px 10px 8px 8px;
  border-radius: 16px; background: rgba(12, 15, 21, .78); border: 1px solid var(--line-2);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: pop .35s var(--ease);
}
.tray-chip img { width: 46px; height: 30px; object-fit: cover; border-radius: 7px; background: #000; }
.tray-chip .meta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; }
.tray-chip.fresh { border-color: rgba(110, 231, 183, .7); box-shadow: 0 0 0 3px rgba(110, 231, 183, .18); }

.scan-controls {
  position: absolute; left: 0; right: 0; bottom: calc(var(--tab) + 16px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 24px;
}
.scan-controls .round-btn { grid-column: 1; }
.scan-controls .shutter { grid-column: 2; }
.scan-controls .zoom { grid-column: 3; }
.round-btn {
  justify-self: start; width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(12, 15, 21, .6); border: 1px solid var(--line-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.round-btn.on { background: var(--amber); color: #2a1b00; border-color: transparent; }
.shutter {
  width: 78px; height: 78px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .92);
  display: grid; place-items: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .45); transition: transform .15s;
}
.shutter:active { transform: scale(.94); }
.shutter span { width: 60px; height: 60px; border-radius: 50%; background: var(--grad); transition: all .3s var(--ease); }
.shutter.running span { width: 28px; height: 28px; border-radius: 8px; background: #ff5f6d; }
.shutter.running { animation: ring 1.8s ease-out infinite; }
.zoom {
  justify-self: end; display: flex; gap: 2px; padding: 3px; border-radius: 99px;
  background: rgba(12, 15, 21, .6); border: 1px solid var(--line-2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.zoom button { min-width: 38px; height: 34px; border-radius: 99px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.zoom button.on { background: rgba(255, 255, 255, .9); color: #0b0d12; }

/* ------------------------------------------------------------------ buttons */
.btn {
  height: 48px; padding: 0 20px; border-radius: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 650; letter-spacing: .1px; transition: transform .12s, filter .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn--lg { height: 58px; font-size: 16px; border-radius: 18px; }
.btn--primary { background: var(--grad); color: #04221a; box-shadow: 0 10px 30px rgba(96, 165, 250, .25); }
.btn--ghost { background: var(--surface-2); border: 1px solid var(--line-2); }
.btn--danger { background: rgba(248, 113, 113, .14); color: #ffb4b4; border: 1px solid rgba(248, 113, 113, .3); }
.chip-btn { height: 32px; padding: 0 12px; border-radius: 99px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line-2); }
.chip-btn .ic { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ photo / video */
.empty-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin: 6vh 0 30px; }
.empty-hero h2 { font-size: 23px; font-weight: 750; margin-top: 10px; }
.empty-hero p { color: var(--muted); max-width: 340px; }
.action-stack { display: grid; gap: 12px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: 22px; }
.media-card { border-radius: var(--radius); overflow: hidden; background: var(--surface-solid); border: 1px solid var(--line); }
.media-stage { position: relative; background: #000; line-height: 0; }
.media-stage img, .media-stage video { width: 100%; max-height: 58vh; object-fit: contain; display: block; }
.scanline {
  position: absolute; left: 0; right: 0; top: 0; height: 3px; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--mint), var(--sky), transparent); box-shadow: 0 0 18px var(--mint);
}
.scanning .scanline { opacity: 1; animation: sweep 1.4s ease-in-out infinite alternate; }
.progress { height: 4px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--grad); transition: width .25s linear; }
.progress--lg { height: 8px; border-radius: 99px; margin: 20px 0 10px; }
.progress--lg div { border-radius: 99px; }
.video-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; font-size: 13.5px; color: var(--muted); }
.result-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.result-head h3 { font-size: 17px; font-weight: 700; }
.result-head span { color: var(--muted); font-size: 13px; }
.results { display: grid; gap: 10px; }
.card {
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: 18px; padding: 14px;
  display: grid; gap: 12px; animation: rise .35s var(--ease) both;
}
.card__top { display: flex; align-items: center; gap: 12px; }
.card__top .plate { margin-right: auto; }
.card__thumb { width: 100%; height: 86px; object-fit: cover; border-radius: 12px; background: #000; }
.badge-n { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--grad); color: #04221a; flex: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12.5px; padding: 4px 9px; border-radius: 99px; background: rgba(255, 255, 255, .06); color: #cdd3e1; border: 1px solid var(--line); }
.tag--ok { color: var(--mint); border-color: rgba(110, 231, 183, .35); background: rgba(110, 231, 183, .08); }
.tag--warn { color: var(--amber); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }
.card__actions { display: flex; gap: 8px; }
.card__actions .chip-btn { flex: 1; justify-content: center; }
.ring {
  --p: 0; width: 44px; height: 44px; border-radius: 50%; flex: none; position: relative; display: grid; place-items: center;
  background: conic-gradient(var(--mint) calc(var(--p) * 1%), rgba(255, 255, 255, .08) 0);
}
.ring::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface-solid); }
.ring span { position: relative; font-size: 11.5px; font-weight: 800; }
.ring--warn { background: conic-gradient(var(--amber) calc(var(--p) * 1%), rgba(255, 255, 255, .08) 0); }
.none { text-align: center; color: var(--muted); padding: 26px 10px; border: 1px dashed var(--line-2); border-radius: 18px; }
.none b { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

/* ------------------------------------------------------------------ plate */
.plate {
  display: inline-flex; align-items: stretch; border-radius: 6px; overflow: hidden; flex: none;
  background: #f7f6f1; color: #121212; border: 1.5px solid #1a1a1a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 6px 16px rgba(0, 0, 0, .35);
  font-family: var(--plate-font); font-stretch: condensed; user-select: text; -webkit-user-select: text;
}
.plate--uk { background: #f6c521; }
.plate__band { background: #1a4fb4; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 3px 3px 3px; min-width: 21px; }
.plate__band .stars { width: 14px; height: 14px; fill: #ffd83b; }
.plate__band b { font: 800 8px/1 Roboto, system-ui, sans-serif; letter-spacing: .02em; }
.plate__body { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 3px 11px; }
.plate__body small { font: 700 6.5px/1 Roboto, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; opacity: .72; margin-bottom: 2px; }
.plate__body strong { font-weight: 700; font-size: 21px; letter-spacing: .07em; line-height: 1.05; white-space: nowrap; }
.plate--sm .plate__body { padding: 2px 8px; }
.plate--sm .plate__body strong { font-size: 15px; }
.plate--sm .plate__body small { display: none; }
.plate--sm .plate__band { min-width: 15px; padding: 2px; }
.plate--sm .plate__band .stars { width: 10px; height: 10px; }
.plate--sm .plate__band b { font-size: 6px; }
.plate--lg { border-radius: 9px; border-width: 2px; }
.plate--lg .plate__body { padding: 6px 18px; }
.plate--lg .plate__body strong { font-size: 34px; }
.plate--lg .plate__body small { font-size: 9px; }
.plate--lg .plate__band { min-width: 32px; padding: 6px 4px 5px; }
.plate--lg .plate__band .stars { width: 22px; height: 22px; }
.plate--lg .plate__band b { font-size: 12px; }
.plate--unsure { outline: 2px dashed rgba(251, 191, 36, .75); outline-offset: 3px; }

/* ------------------------------------------------------------------ history */
.history-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.history-top h2 { font-size: 24px; font-weight: 800; }
.history-top .count { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.history-actions { display: flex; gap: 4px; }
.search {
  display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; border-radius: 15px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); margin-bottom: 8px;
}
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 16px; color: var(--text); }
.search:focus-within { border-color: rgba(96, 165, 250, .6); }
.hist-day {
  position: sticky; top: 0; z-index: 2; padding: 16px 4px 8px; font-size: 12px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted); background: linear-gradient(var(--bg) 70%, transparent);
}
.hist-item {
  width: 100%; display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; align-items: center; gap: 12px; text-align: left;
  padding: 10px; border-radius: 16px; background: var(--surface-solid); border: 1px solid var(--line); margin-bottom: 8px;
}
.hist-item:active { background: var(--surface-2); }
.hist-item img, .hist-item .noimg { width: 74px; height: 46px; object-fit: cover; border-radius: 10px; background: #000; }
.hist-item .noimg { display: grid; place-items: center; color: var(--muted); background: var(--surface-2); }
.hist-item > span { min-width: 0; }
.hist-item .meta { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item .ic { color: var(--muted); width: 18px; height: 18px; }
.hist-empty { text-align: center; color: var(--muted); margin-top: 14vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hist-empty b { color: var(--text); font-size: 18px; }

/* ------------------------------------------------------------------ sheets */
.backdrop { position: absolute; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .3s; }
.backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute; z-index: 50; left: 0; right: 0; bottom: 0; max-height: 90%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-solid); border-top: 1px solid var(--line-2); border-radius: 26px 26px 0 0;
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .38s var(--ease);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .5);
}
.sheet.open { transform: translateY(0); }
.sheet__grip { width: 42px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .2); margin: 2px auto 12px; }
.sheet__title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet__title h2 { font-size: 20px; font-weight: 800; }
.detail-hero { display: grid; justify-items: center; gap: 14px; padding: 6px 0 16px; }
.detail-hero img { width: 100%; max-height: 170px; object-fit: contain; border-radius: 16px; background: #000; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.info { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.info span { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.info b { display: block; margin-top: 3px; font-size: 14.5px; font-weight: 650; }
.detail-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.detail-actions .btn { height: 52px; flex-direction: column; gap: 3px; font-size: 12px; padding: 0; }

.settings { display: grid; gap: 18px; padding-bottom: 6px; }
.group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); margin: 0 4px 8px; font-weight: 700; }
.group__box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; min-height: 56px; }
.row + .row { border-top: 1px solid var(--line); }
.row__text { flex: 1; min-width: 0; }
.row__text b { display: block; font-weight: 600; font-size: 15px; }
.row__text small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.row__text small b { display: inline; font-size: inherit; font-weight: 700; }
b.hl { color: var(--mint); }
.row--stack { flex-direction: column; align-items: stretch; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: rgba(0, 0, 0, .3); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { height: 36px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.seg button.on { background: rgba(255, 255, 255, .92); color: #0b0d12; }
.switch { width: 50px; height: 30px; border-radius: 99px; background: rgba(255, 255, 255, .16); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.switch[aria-checked="true"] { background: var(--mint); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.about { font-size: 13px; color: var(--muted); line-height: 1.55; padding: 0 4px; }
.about b { color: var(--text); }
.about .muted { color: var(--muted); }
.linkish { color: var(--sky); font-weight: 650; padding: 0; font-size: inherit; }
.btn:disabled { opacity: .45; pointer-events: none; }
.card--low { opacity: .82; }

/* ------------------------------------------------------------------ toast + boot */
.toast {
  position: absolute; z-index: 70; left: 50%; top: calc(var(--top) + 10px); transform: translate(-50%, -16px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px); padding: 11px 12px 11px 16px; border-radius: 16px;
  background: rgba(24, 29, 40, .96); border: 1px solid var(--line-2); box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  font-size: 14px; font-weight: 550; transition: all .3s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: var(--mint); font-weight: 750; padding: 4px 6px; white-space: nowrap; }
.boot {
  position: absolute; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(70% 50% at 50% 30%, rgba(96, 165, 250, .16), transparent 70%), var(--bg);
}
.boot__card { width: min(100%, 380px); text-align: center; }
.boot__logo { width: 76px; height: 76px; margin: 0 auto 22px; border-radius: 24px; background: var(--grad); position: relative; box-shadow: 0 20px 60px rgba(96, 165, 250, .35); animation: breathe 2.4s ease-in-out infinite; }
.boot__logo::before { content: ''; position: absolute; left: 16px; right: 16px; top: 29px; height: 18px; border-radius: 4px; background: #07231b; }
.boot h2 { font-size: 22px; font-weight: 800; }
.boot p { color: var(--muted); margin-top: 8px; }
.boot__meta { font: 600 12.5px/1.4 ui-monospace, 'Roboto Mono', monospace; color: #b6c2d8 !important; }
.boot__meta--details {
  text-align: left; white-space: pre-wrap; word-break: break-word; font-size: 11px !important; font-weight: 500 !important;
  max-height: 30vh; overflow-y: auto; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line);
  user-select: text; -webkit-user-select: text;
}
.boot .btn { margin-top: 18px; }

/* ------------------------------------------------------------------ motion */
@keyframes pulse { 50% { opacity: .35; } }
@keyframes breathe { 50% { transform: translate(-50%, -50%) scale(1.03); opacity: .85; } }
.boot__logo { animation-name: breathe-logo; }
@keyframes breathe-logo { 50% { transform: scale(1.05); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }
@keyframes sweep { from { top: 0; } to { top: calc(100% - 3px); } }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255, 95, 109, .45), 0 8px 30px rgba(0, 0, 0, .45); } 100% { box-shadow: 0 0 0 18px rgba(255, 95, 109, 0), 0 8px 30px rgba(0, 0, 0, .45); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media (min-width: 700px) {
  .scan-controls { max-width: 640px; margin: 0 auto; }
}

/* ------------------------------------------------------------------ first launch */
.boot__parts { list-style: none; padding: 0; margin: 6px 0 4px; display: grid; gap: 9px; text-align: left; }
.boot__parts li { display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; font-size: 13px; color: var(--muted); }
.bp__name { color: var(--text); font-weight: 600; }
.bp__size { font-variant-numeric: tabular-nums; }
.bp__bar { grid-column: 1 / -1; height: 3px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.bp__bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .25s linear; }
.boot__parts li.done .bp__name::after { content: '  ✓'; color: var(--mint); }

/* ------------------------------------------------------------------ history notes */
.hist-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 12px 0; }
.hist-note {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 12px; border-radius: 14px; font-size: 13px;
  background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .3);
}
.hist-note span { flex: 1; display: flex; gap: 8px; align-items: center; }
.hist-note .ic { color: var(--amber); width: 18px; height: 18px; }

/* ------------------------------------------------------------------ what's new */
.new__lead { color: var(--muted); font-size: 13px; margin: 0 2px 12px; }
.new__list { list-style: none; padding: 0; display: grid; gap: 14px; margin-bottom: 20px; }
.new__list li { display: flex; gap: 12px; align-items: flex-start; }
.new__ic {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none; color: var(--mint);
  background: linear-gradient(145deg, rgba(110, 231, 183, .18), rgba(96, 165, 250, .18)); border: 1px solid var(--line);
}
.new__ic .ic { width: 20px; height: 20px; }
.new__list b { display: block; font-size: 15px; }
.new__list small { color: var(--muted); font-size: 13px; line-height: 1.45; }
#sheetNew .btn { width: 100%; }

/* ------------------------------------------------------------------ field test + read inspector */
.ft {
  margin-top: 16px; padding: 14px; border-radius: 18px; display: grid; gap: 12px;
  background: linear-gradient(145deg, rgba(110, 231, 183, .07), rgba(96, 165, 250, .07)); border: 1px solid rgba(110, 231, 183, .22);
}
.ft__head { display: flex; gap: 10px; align-items: flex-start; }
.ft__head .ic { color: var(--mint); margin-top: 1px; }
.ft__head b { display: block; }
.ft__head small { color: var(--muted); font-size: 12.5px; }
.ft__btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn--ok { background: rgba(110, 231, 183, .14); color: var(--mint); border: 1px solid rgba(110, 231, 183, .35); }
.btn--bad { background: rgba(248, 113, 113, .12); color: #ffb4b4; border: 1px solid rgba(248, 113, 113, .3); }
.ft__fix label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.ft__row { display: flex; gap: 8px; }
.ft__row input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2);
  font: 700 20px var(--plate-font); letter-spacing: .08em; text-transform: uppercase; outline: 0;
}
.ft__row input:focus { border-color: rgba(96, 165, 250, .6); }
.ft__done p { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.ft__done p .ic { color: var(--mint); width: 18px; height: 18px; }
.ft__done p span { flex: 1; }
.ft__done .diff { margin-bottom: 8px; }
.diff { font: 700 18px/1.2 var(--plate-font); letter-spacing: .06em; }
.diff .d-sub, .diff .d-ins { color: var(--amber); }
.diff .d-ins { text-decoration: underline; text-underline-offset: 3px; }
.diff s { color: var(--red); text-decoration-thickness: 2px; font-size: .72em; margin-right: 1px; }

.insp { margin-top: 14px; padding: 14px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); }
.insp h4 { display: flex; align-items: center; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 12px; }
.insp h4 .ic { width: 18px; height: 18px; color: var(--sky); }
.insp--empty { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.insp--empty .ic { color: var(--sky); }
.insp__input { margin: 0 0 12px; }
.insp__input img { width: 100%; max-width: 384px; aspect-ratio: 2 / 1; image-rendering: pixelated; border-radius: 8px; display: block; background: #000; }
.insp__input figcaption { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.insp__chars { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.ch { display: grid; justify-items: center; gap: 3px; min-width: 32px; }
.ch b { font: 700 21px/1 var(--plate-font); }
.ch i { width: 10px; height: 44px; border-radius: 5px; background: rgba(255, 255, 255, .07); display: flex; align-items: flex-end; overflow: hidden; }
.ch i span { width: 100%; border-radius: 5px; background: var(--mint); }
.ch--meh i span { background: var(--amber); }
.ch--bad i span { background: var(--red); }
.ch--meh b { color: var(--amber); }
.ch--bad b { color: var(--red); }
.ch small, .ch em { font: 600 10px/1.2 ui-monospace, 'Roboto Mono', monospace; color: var(--muted); font-style: normal; white-space: nowrap; }
.ch em { color: #7b859b; }
.insp__note { font-size: 11.5px; color: var(--muted); margin: 8px 0 12px; }
.insp__kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 9px 0; border-top: 1px solid var(--line); }
.insp__kv span { color: var(--muted); }
.insp__kv b { text-align: right; font-weight: 600; }
.insp__facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0 12px; }
.insp__facts > div { background: rgba(0, 0, 0, .22); border-radius: 10px; padding: 7px 10px; }
.insp__facts span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.insp__facts b { font-size: 13.5px; }
.insp__votes h5 { font-size: 12px; color: var(--muted); font-weight: 650; margin: 4px 0 8px; }
.vote { display: grid; grid-template-columns: 100px 1fr; gap: 3px 10px; align-items: center; margin-bottom: 9px; }
.vote code { font: 700 13.5px ui-monospace, 'Roboto Mono', monospace; letter-spacing: .05em; user-select: text; }
.vote i { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.vote i span { display: block; height: 100%; background: var(--grad); border-radius: 99px; }
.vote small { grid-column: 2; font-size: 11px; color: var(--muted); }

/* ------------------------------------------------------------------ debug panel */
.sheet--tall { height: 92%; }
.dtabs {
  position: sticky; top: -8px; z-index: 3; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 3px;
  margin: 2px -2px 14px; border-radius: 13px; background: #0b0e14; box-shadow: 0 8px 14px var(--surface-solid);
}
.dtabs button { height: 36px; border-radius: 10px; font-size: 13px; font-weight: 650; color: var(--muted); }
.dtabs button.on { background: rgba(255, 255, 255, .92); color: #0b0d12; }
.dsec { margin-bottom: 20px; }
.dsec h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); margin: 0 4px 8px; font-weight: 700; }
.kv { display: grid; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.kv > div { display: grid; grid-template-columns: minmax(96px, 38%) 1fr; gap: 10px; padding: 8px 12px; font-size: 13px; }
.kv > div + div { border-top: 1px solid var(--line); }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; word-break: break-word; user-select: text; -webkit-user-select: text; }
.dtable { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.dtable th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.dtable td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.dtable td small { display: block; color: var(--muted); font-size: 11px; }
.dtable tr.best td { color: var(--mint); }
.dnote { color: var(--muted); font-size: 12.5px; margin: 6px 2px 10px; }
.dnote b { color: var(--text); }
.dpre {
  font: 11px/1.4 ui-monospace, 'Roboto Mono', monospace; white-space: pre-wrap; word-break: break-word; margin-top: 8px; padding: 8px 10px;
  background: rgba(248, 113, 113, .06); border: 1px solid rgba(248, 113, 113, .25); border-radius: 10px; user-select: text; -webkit-user-select: text;
}
.dgraph { width: 100%; height: 72px; display: block; background: rgba(0, 0, 0, .3); border-radius: 12px; border: 1px solid var(--line); }
.dlegend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11.5px; color: var(--muted); margin: 8px 2px 10px; }
.dlegend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.dlegend i.dash { background: none; border-top: 1.5px dashed rgba(255, 255, 255, .6); height: 0; width: 14px; border-radius: 0; vertical-align: 3px; }
.dactions, .dbtns { display: flex; gap: 8px; margin-top: 10px; }
.dactions .btn, .dbtns .btn { flex: 1; height: 46px; font-size: 14px; padding: 0 12px; }
.dbtns--wrap { flex-wrap: wrap; }
.dbtns--wrap .btn { flex: 1 1 calc(50% - 4px); }
.dsec .group__box { margin-top: 2px; }
.dfilters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; }
.dfilters::-webkit-scrollbar { display: none; }
.dfilters button { flex: none; height: 30px; padding: 0 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line-2); }
.dfilters button.on { background: rgba(255, 255, 255, .92); color: #0b0d12; border-color: transparent; }
.dlog { display: grid; gap: 3px; font: 11.5px/1.4 ui-monospace, 'Roboto Mono', monospace; }
.lg { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, .03); user-select: text; -webkit-user-select: text; }
.lg time { color: #6b7488; }
.lg b { font-weight: 700; color: var(--sky); text-transform: uppercase; font-size: 9.5px; letter-spacing: .5px; padding-top: 1.5px; }
.lg span { color: #d9dfeb; word-break: break-word; }
.lg pre { grid-column: 1 / -1; white-space: pre-wrap; word-break: break-all; color: #9fb0cc; margin: 2px 0 0; font: inherit; font-size: 10.5px; }
.lg--error { background: rgba(248, 113, 113, .09); }
.lg--error b { color: var(--red); }
.lg--perf b { color: #c084fc; }
.lg--track b, .lg--scan b, .lg--photo b, .lg--video b { color: var(--mint); }
.lg--data b, .lg--app b { color: var(--amber); }
.dstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.dstats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; }
.dstats b { display: block; font-size: 24px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dstats span { font-size: 11.5px; color: var(--muted); }
.dsrc { margin-bottom: 16px; }
.dchart { width: 100%; height: auto; display: block; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: 12px; }
.dchart text { fill: #7b859b; font: 9px ui-monospace, 'Roboto Mono', monospace; }
.dchart .g { stroke: rgba(255, 255, 255, .07); }
.dchart polyline { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.dchart .acc { stroke: var(--mint); }
.dchart .cov { stroke: var(--sky); stroke-dasharray: 4 3; }
.dchart line.sug { stroke: var(--amber); stroke-dasharray: 3 3; }
.dchart text.sug { fill: var(--amber); }
.dchart line.cur { stroke: rgba(255, 255, 255, .5); }
.dchart text.cur { fill: #fff; }
.misses { display: grid; gap: 8px; }
.miss { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.miss img { width: 84px; height: 30px; object-fit: cover; border-radius: 6px; background: #000; }
.miss small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.miss .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.miss .diff { font-size: 16px; }
.dempty { text-align: center; display: grid; justify-items: center; gap: 10px; padding: 34px 12px; color: var(--muted); font-size: 13.5px; }
.dempty .ic { width: 42px; height: 42px; color: var(--mint); stroke-width: 1.6; }
.dempty b { color: var(--text); font-size: 17px; }
.dempty em { color: var(--text); font-style: normal; font-weight: 650; }
