@font-face {
  font-family: "Keyrune";
  src: url("Keyrune.ttf") format("truetype");
  font-display: swap;
}
.ss { font-family: "Keyrune", system-ui; }   /* set-symbol */

:root {
  --bg: #0a0a14;
  --bg-panel: #16161f;
  --bg-elev: #1f1f2c;
  --text: #f5f5f7;
  --subtext: #a8a8b3;
  --dim: #5a5a6a;
  --accent: #8a5cf6;
  --accent-2: #ec4899;
  --success: #34d399;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
               "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  /* Block pinch-zoom and double-tap zoom — the camera UI needs stable
     layout while the user holds a card up. Vertical scroll still works. */
  touch-action: pan-y;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font-family: inherit; }

/* Phone in landscape → ask to rotate. The card-shaped viewfinder
   doesn't fit landscape well. */
@media (orientation: landscape) and (max-height: 600px) {
  body::before {
    content: "Please rotate your phone to portrait";
    position: fixed; inset: 0;
    background: var(--bg); color: var(--text);
    display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 24px;
    font-size: 18px; font-weight: 600;
    z-index: 2000;
  }
}

/* Buttons that hold an <img> or <svg> icon */
.overlay-btn.icon-btn { padding: 0; }
.overlay-btn.icon-btn img,
.overlay-btn.icon-btn svg {
  width: 26px; height: 26px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  pointer-events: none;
  color: currentColor;
}

/* ===== Splash — Card Cameo brand intro ===== */
/* Cameo aesthetic: gold oval frame on a deep-teal field with a
   cream-ivory relief portrait. Same dark base as the rest of the app
   so the splash dissolves into the camera view without a colour pop. */
.splash {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, #15252a, #050309 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 1000;
  pointer-events: none;
  transition: opacity 0.6s, transform 0.6s;
}
.splash.hide { opacity: 0; transform: scale(1.05); pointer-events: none; }
.splash-cameo {
  width: min(58vw, 220px);
  height: auto;
  filter: drop-shadow(0 12px 36px rgba(255, 215, 107, 0.25));
  animation: cameoIntro 1s cubic-bezier(.2, 1.1, .3, 1) both;
}
@keyframes cameoIntro {
  0%   { transform: scale(0.6) rotate(-4deg); opacity: 0; }
  60%  { transform: scale(1.04) rotate(0); opacity: 1; }
  100% { transform: scale(1); }
}
.splash-wordmark {
  text-align: center;
  font-family: "Cormorant Garamond", "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: 44px;
  line-height: 0.95;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #ffe4a3, #c79a4c 60%, #ffe4a3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(255, 215, 107, 0.35));
}
.splash-wordmark span { display: inline-block; }
.splash-tagline {
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: #c79a4c;
  opacity: 0.85;
}

/* Inline cameo mark — gold oval w/ ivory profile. Used in the topbar
   and nav drawer. */
.cameo-mark { display: block; flex: 0 0 auto; }

/* ===== First-time setup ===== */
.setup {
  position: fixed; inset: 0;
  background: rgba(8, 8, 14, 0.95);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: 24px;
}
.setup[hidden] { display: none !important; }
.setup-card {
  background: var(--bg-panel);
  border: 1px solid #2a2a3a;
  border-radius: 18px;
  max-width: 380px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6);
}
.setup-card h2 {
  margin: 0 0 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 22px;
}
.setup-card p {
  margin: 0 0 18px;
  color: var(--subtext);
  font-size: 14px;
  line-height: 1.4;
}
.setup-bar {
  width: 100%;
  height: 12px;
  background: var(--bg-elev);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.setup-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s;
}
.setup-status {
  font-size: 12px;
  color: var(--subtext);
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px 8px;
  padding-top: max(12px, env(safe-area-inset-top));   /* iPhone notch */
  padding-left:  max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  border-bottom: 1px solid #20202c;
  position: sticky; top: 0; z-index: 5;
  background: rgba(10, 10, 20, 0.92);
  backdrop-filter: blur(10px);
}
/* Card Cameo wordmark in the topbar — serif italics, gold cameo gradient.
   Reads as a luxury jewelry brand rather than a tech logo, matching the
   "every card a cameo" framing. */
.topbar h1 {
  font-size: 19px;
  margin: 0; flex: 0 0 auto;
  letter-spacing: 0.01em;
  font-family: "Cormorant Garamond", "Playfair Display", Georgia, serif;
  font-style: italic;
  background: linear-gradient(135deg, #ffe4a3, #c79a4c 70%, #ffe4a3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}
.logo {
  width: 36px; height: 36px;
  display: block;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 10px rgba(255, 215, 107, 0.35));
}

/* ── Hamburger menu button (upper-left of topbar) ──────────────── */
.hamburger {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg-elev, #12121d);
  border: 1px solid var(--line, #2a2a3a);
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.hamburger:hover { background: #1f1f2e; }
.hamburger:active { transform: scale(0.94); }
.hamburger span {
  display: block; width: 16px; height: 2px;
  background: var(--text, #e8e8f0);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ── Slide-in nav drawer ────────────────────────────────────────── */
.nav-drawer { position: fixed; inset: 0; z-index: 100; }
.nav-drawer[hidden] { display: none !important; }
.nav-drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  animation: navBackdropIn 0.2s ease both;
}
@keyframes navBackdropIn { from { opacity: 0; } to { opacity: 1; } }
.nav-drawer-panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: min(86vw, 320px);
  background: linear-gradient(180deg, #0e0e1a, #07070d);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  box-shadow: 6px 0 30px #000c;
  animation: navPanelIn 0.25s cubic-bezier(.22, 1.2, .36, 1) both;
}
@keyframes navPanelIn {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}
.nav-drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
}
.nav-drawer-head .nav-logo { width: 32px; height: 32px; }
.nav-drawer-head h2 {
  flex: 1; font-size: 18px; font-weight: 700;
  font-family: "Cormorant Garamond", "Playfair Display", Georgia, serif;
  font-style: italic;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #ffe4a3, #c79a4c 70%, #ffe4a3);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin: 0;
}
.nav-list { flex: 1; overflow-y: auto; padding: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: transparent; color: var(--text);
  border: 0; border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s;
}
.nav-item:hover, .nav-item:focus-visible {
  background: var(--bg-elev);
  outline: none;
}
.nav-item .nav-icon {
  flex: 0 0 32px; width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--bg-elev);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.nav-item .nav-icon img {
  width: 22px; height: 22px; object-fit: contain;
}
.nav-item .nav-title { font-size: 14px; font-weight: 600; }
.nav-item .nav-sub   { font-size: 11px; color: var(--subtext); margin-top: 1px; }
.nav-divider {
  height: 1px; background: var(--line);
  margin: 8px 14px;
}
.nav-foot {
  padding: 10px 14px 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  font-size: 10px; color: var(--subtext);
  border-top: 1px solid var(--line);
  text-align: center;
}
/* Sister-site links — thin band under the topbar, always visible */
.sister-bar {
  display: flex; align-items: center;
  gap: 14px;
  padding: 6px 14px;
  border-bottom: 1px solid #20202c;
  background: rgba(20, 20, 30, 0.85);
  font-size: 11px;
  color: var(--subtext);
  letter-spacing: 0.04em;
  flex-wrap: wrap;
}
.sister-label {
  text-transform: uppercase;
  font-weight: 700;
  color: var(--dim);
}
.sister-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0.9;
  transition: opacity 0.15s, transform 0.15s;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}
.sister-link:hover { opacity: 1; transform: translateY(-1px); }
.sister-link img {
  height: 18px; width: 18px;
  object-fit: contain;
  border-radius: 3px;
}

/* Torch button when active glows yellow */
.overlay-btn.torch-on { background: rgba(245, 158, 11, 0.85); border-color: var(--warn); color: #0a0a14; }
.ticker {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.tick-track {
  display: inline-flex;
  align-items: center;
  gap: 22px;
  white-space: nowrap;
  animation: ticker-scroll 40s linear infinite;
  will-change: transform;
}
.ticker:hover .tick-track { animation-play-state: paused; }
.tick-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
}
.tick-item img {
  width: 22px; height: 30px; object-fit: cover; border-radius: 3px;
  background: var(--bg-elev);
}
.tick-item .tn { color: var(--text); }
.tick-item .tc { color: var(--success); font-weight: 700; font-variant-numeric: tabular-nums; }
.tick-item .ts { color: var(--subtext); font-size: 10px; }
@keyframes ticker-scroll { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .tick-track { animation: none; } }
@media (max-width: 540px) { .ticker { display: none; } }
.status { font-size: 13px; color: var(--subtext); }
.status.ok    { color: var(--success); }
.status.warn  { color: var(--warn); }
.status.error { color: #f87171; }

.iconbtn {
  background: var(--bg-panel);
  color: var(--text);
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  width: 36px; height: 36px;
  font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.iconbtn.small { width: 32px; height: 32px; font-size: 14px; }
.iconbtn:hover { background: var(--bg-elev); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  border: 1px solid #2a2a3a;
  z-index: 100;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%,  0); }
}

/* ===== Scanner ===== */
.scanner { padding: 14px; max-width: 720px; margin: 0 auto; }

.video-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 3 / 4;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
#video { width: 100%; height: 100%; object-fit: cover; display: block; }

.viewfinder {
  position: absolute;
  /* Tight close-up viewfinder — forces user to hold card close so
     the bottom-left "NNN/NNN SNC" text scales up to OCR-readable pixels.
     Delver Lens uses the same trick: small viewfinder, close hold. */
  top: 5%; bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  aspect-ratio: 0.715;
  border: 4px solid rgba(168, 120, 255, 1);
  border-radius: 14px;
  pointer-events: none;
  transition: border-color 0.2s;
  /* Heavier vignette outside the viewfinder to focus the user's eye. */
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  filter: drop-shadow(0 0 8px rgba(138, 92, 246, 0.7));
}
/* (Corner-ID indicator removed — the trained MobileNet matcher reads
   the whole card, so the user doesn't need to align the ID text.) */
.viewfinder.matched { border-color: var(--success); }
.viewfinder.hidden  { opacity: 0; }

.title-strip {
  position: absolute;
  left: 2%; right: 2%;
  top: 2%; height: 18%;
  border: 2px solid var(--accent-2);
  border-radius: 6px;
  background: rgba(236, 72, 153, 0.08);
}
.track-overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.hint {
  position: absolute;
  bottom: 8%; left: 0; right: 0;
  text-align: center;
  pointer-events: none;
  font-size: 14px;
  color: var(--text);
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

/* Floating overlay buttons on the camera viewport. Tappable. */
.overlay-controls {
  position: absolute;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 4;
}
.overlay-tr { top: 12px; right: 12px; }
.overlay-tl { top: 12px; left:  12px; }
.overlay-btn {
  width: 48px; height: 48px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  border: 2px solid rgba(168, 168, 179, 0.6);
  font-size: 22px;          /* big, clear glyphs */
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
/* A/M button uses letters that need a slightly smaller font weight */
#am-btn { font-size: 18px; }
.overlay-btn:active { transform: scale(0.92); }
/* Per-mode color hints */
.overlay-btn.mode-auto    { background: rgba(138, 92, 246, 0.85); border-color: var(--accent); }
.overlay-btn.mode-foil    { background: rgba(236, 72, 153, 0.85); border-color: var(--accent-2); }
.overlay-btn.mode-etched  { background: rgba(245, 158, 11, 0.85); border-color: var(--warn); color: #0a0a14; }

/* ===== Controls ===== */
.controls {
  display: flex; gap: 10px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.btn-primary {
  flex: 2 1 200px;
  background: var(--accent);
  color: var(--text);
  border: 0;
  padding: 14px 22px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
}
.btn-primary:hover    { background: #9a6cff; }
.btn-primary:disabled { background: var(--dim); cursor: not-allowed; }
.btn-secondary {
  flex: 1 1 100px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid #2a2a3a;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
}
.btn-secondary.small { padding: 8px 12px; font-size: 12px; flex: 0 0 auto; }
.btn-secondary:hover { background: #2a2a3a; }
.btn-secondary.on    { background: var(--accent); border-color: var(--accent); }
.btn-secondary.foil-on   { background: var(--accent-2); border-color: var(--accent-2); }
.btn-secondary.etched-on { background: var(--warn); border-color: var(--warn); color: #0a0a14; }
.btn-danger {
  background: var(--danger);
  color: white;
  border: 0;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

/* ===== Debug log ===== */
.debug {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-panel);
  border: 1px solid #20202c;
  border-radius: 10px;
}
.debug h3 { margin: 0 0 4px; font-size: 11px; color: var(--subtext); text-transform: uppercase; letter-spacing: 0.06em; }
.debug pre { margin: 0; font: 12px/1.4 ui-monospace, SF Mono, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }

/* ===== Result card ===== */
.result {
  display: flex; gap: 14px;
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 14px;
  align-items: flex-start;
  border: 1px solid #20202c;
}
.result img {
  width: 100px; height: 140px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-elev);
  flex-shrink: 0;
}
.result-text  { flex: 1; min-width: 0; }
.result-name  { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.result-meta  { font-size: 13px; color: var(--subtext); margin-bottom: 8px; }
.result-price { font-size: 22px; font-weight: 800; color: var(--success); font-variant-numeric: tabular-nums; }

/* ===== Collection ===== */
.collection { margin-top: 22px; }
.collection-header {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 10px;
}
.collection-header h2 {
  flex: 1;
  font-size: 14px; font-weight: 700;
  color: var(--subtext);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.collection-actions { display: flex; align-items: center; gap: 8px; }
.ctotal {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--success);
  font-size: 14px;
}
.collection ul { list-style: none; padding: 0; margin: 0; }
.collection li {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-panel);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.collection li:hover { background: var(--bg-elev); }
.collection li img {
  width: 40px; height: 56px; object-fit: cover; border-radius: 4px;
  background: var(--bg-elev);
}
/* Sell / Keep / Hold verdict pill — derived from the 12-month predicted
   price change. Sits between the thumb and the card name so it's the
   first thing the eye lands on when scanning the list. */
.collection li .li-verdict {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 15px; line-height: 1;
  color: #0a0a14;
  box-shadow: 0 0 10px currentColor, inset 0 1px 0 #ffffff60;
  user-select: none;
}
.collection li .li-verdict.v-sell { background: #ff5d5d; color: #2a0000; }
.collection li .li-verdict.v-keep { background: #6cffa8; color: #003318; }
.collection li .li-verdict.v-hold { background: #ffd76b; color: #3a2400; }
/* Synthetic estimate — card has no real forecast in cardconclave yet.
   Soften the badge (lower opacity + dashed ring) so it reads as
   "placeholder" at a glance without losing the verdict color. */
.collection li .li-verdict.v-synth {
  opacity: 0.55;
  box-shadow: 0 0 0 1px currentColor, 0 0 6px currentColor;
  font-size: 12px;
  letter-spacing: -1px;     /* tighten so "S*" fits in the same 28px circle */
}

/* ── Card Curve panel in the inspect sheet ──────────────────────────
   Auto-plays a price history + 12-month forecast when you tap a card
   in the collection. Mirrors the standalone cardcurve_demo.html but
   sized down to fit inside the inspect sheet without scrolling. */
.curve-section {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
}
/* Card Cameo hero — the scanned card framed inside a gold oval so the
   inspect sheet reads as a literal cameo of that card. Concentric gold
   rings + deep-teal field match the splash brand mark. */
.curve-hero {
  position: relative;
  width: 160px; aspect-ratio: 1; margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 40% 30%, #2a5252, #0a1a1a 75%);
  box-shadow:
    0 0 0 3px #c79a4c,
    0 0 0 5px #1a3a3a,
    0 0 0 7px #ffe4a3,
    0 14px 36px #000a,
    0 0 24px rgba(255, 215, 107, 0.25);
}
/* Zoom into the card art (top third of a Scryfall image) so the cameo
   shows the artwork, not the title bar. */
.curve-hero img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 22%;
  transform: scale(1.4);
  display: block;
}
.curve-hero .curve-verdict {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 13px;
  box-shadow: 0 0 10px currentColor, inset 0 1px 0 #ffffff60;
}
.curve-verdict.v-sell { background: #ff5d5d; color: #2a0000; }
.curve-verdict.v-keep { background: #6cffa8; color: #003318; }
.curve-verdict.v-hold { background: #ffd76b; color: #3a2400; }
.curve-verdict.v-synth { opacity: 0.55; font-size: 12px; letter-spacing: -1px; }

/* Banner inside the inspect curve panel that calls out synthetic
   estimates. Sits between the hero card and the price readout. */
.curve-synth-banner {
  text-align: center;
  font-size: 10px; letter-spacing: 0.4px;
  color: #ffb87a;
  background: #ffb87a14;
  border: 1px dashed #ffb87a44;
  border-radius: 6px;
  padding: 4px 8px;
  margin: -4px auto 0;
  max-width: 90%;
}

.curve-readout {
  display: flex; justify-content: center; align-items: baseline; gap: 8px;
}
.curve-readout .curve-date  { color: var(--subtext); font-size: 11px; font-variant-numeric: tabular-nums; }
.curve-readout .curve-price {
  font-size: 22px; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px #ffd76b40;
}
.curve-readout .curve-delta {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: #00000060; border: 1px solid #ffffff20;
}
.curve-readout .curve-delta.up   { color: #6cffa8; border-color: #6cffa840; }
.curve-readout .curve-delta.down { color: #ff8a8a; border-color: #ff8a8a40; }

.curve-panel {
  position: relative; isolation: isolate;
  background: linear-gradient(180deg, #0a0a14, #15152a);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 10px 4px;
  overflow: hidden;
}
.curve-chart {
  position: relative; z-index: 1;
  width: 100%; height: 160px; display: block;
}
.curve-trail {
  position: absolute; z-index: 0; pointer-events: none;
}
.curve-chart .curve-grid line { stroke: #ffffff10; stroke-dasharray: 2 4; }
.curve-chart .curve-axis text { fill: var(--subtext); font-size: 9px; font-family: inherit; }
.curve-chart .curve-past {
  stroke: #6cc7ff; stroke-width: 2.4; fill: none;
  filter: drop-shadow(0 0 4px #6cc7ff);
}
.curve-chart .curve-future {
  stroke: #ff7ad9; stroke-width: 2.4; fill: none;
  stroke-dasharray: 5 4;
  filter: drop-shadow(0 0 4px #ff7ad9);
}
.curve-chart .curve-past-fill { fill: url(#curveFill); opacity: 0.42; }
.curve-rider { transform-box: fill-box; transform-origin: center; }

.curve-controls {
  display: flex; gap: 8px; align-items: stretch;
}
.curve-controls .seg { flex: 1; }
.curve-controls .seg button {
  flex: 1; background: transparent; border: 0;
  color: var(--subtext); padding: 6px 0;
  font-size: 11px; font-weight: 600;
  border-radius: 6px;
}
.curve-controls .seg button.active {
  background: linear-gradient(180deg, #3a2a5a, #1a1a2c);
  color: var(--text);
}
.curve-controls .seg {
  background: #0a0a14; border: 1px solid var(--line);
  border-radius: 9px; padding: 3px; gap: 3px;
}
.collection li .li-main { flex: 1; min-width: 0; }
.collection li .li-name { font-weight: 600; }
.collection li .li-name .li-finish { color: var(--accent-2); margin-left: 4px; font-size: 11px; }
.collection li .li-name .li-finish.etched { color: var(--warn); }
.collection li .li-meta { color: var(--subtext); font-size: 12px; }
.collection li .li-cond {
  border: 1px solid #2a2a3a;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--subtext);
  margin-right: 6px;
}
.collection li .li-price {
  color: var(--success);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.collection li .li-qty {
  color: var(--subtext);
  font-variant-numeric: tabular-nums;
  margin-left: 8px;
  min-width: 32px;
  text-align: right;
}

/* ===== Sheets ===== */
.sheet {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s;
}
/* Critical: the `display: flex` above overrides the HTML `hidden`
   attribute's default `display: none`. Force the closed state
   explicitly so `hidden` actually hides the sheet. */
.sheet[hidden] { display: none !important; }
.sheet-inner {
  background: var(--bg);
  border-top: 1px solid #2a2a3a;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow-y: auto;
  padding-bottom: 30px;
  animation: slideUp 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-header {
  display: flex; align-items: center;
  padding: 14px 14px 8px;
}
.sheet-header h2 { flex: 1; margin: 0; font-size: 18px; }
.sheet-section { padding: 8px 14px 12px; border-top: 1px solid #20202c; }
.sheet-section:first-of-type { border-top: 0; }
.section-label {
  font-size: 11px;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.row-toggle {
  display: flex; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #20202c;
}
.row-toggle:last-child { border-bottom: 0; }
.row-toggle span { flex: 1; }
.row-toggle input[type="checkbox"] {
  width: 44px; height: 26px;
  appearance: none;
  background: var(--bg-elev);
  border: 1px solid #2a2a3a;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.row-toggle input[type="checkbox"]::after {
  content: ""; position: absolute;
  width: 20px; height: 20px;
  border-radius: 999px;
  background: var(--text);
  top: 2px; left: 2px;
  transition: left 0.15s;
}
.row-toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.row-toggle input[type="checkbox"]:checked::after { left: 20px; }

.row-range { display: flex; align-items: center; padding: 10px 0; gap: 10px; }
.row-range span { flex: 0 0 auto; }
.row-range input { flex: 1; accent-color: var(--accent); }
.range-label { font-variant-numeric: tabular-nums; color: var(--subtext); width: 40px; text-align: right; }

.about { font-size: 12px; color: var(--subtext); line-height: 1.5; }

/* Segmented control (Inspect → Finish / Condition) */
.seg { display: flex; gap: 4px; background: var(--bg-elev); padding: 4px; border-radius: 8px; }
.seg button {
  flex: 1;
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 8px 10px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
.seg button.on { background: var(--accent); }
.qty { display: flex; align-items: center; gap: 16px; }
.qty button {
  width: 40px; height: 40px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
}
.qty span { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 30px; text-align: center; }

.inspect-row { display: flex; gap: 14px; align-items: flex-start; }
.inspect-row img { width: 120px; height: 168px; border-radius: 8px; object-fit: cover; background: var(--bg-elev); }
.inspect-meta { flex: 1; }

.session-name {
  background: transparent; color: var(--text);
  border: 1px solid #2a2a3a;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.session-name:hover { background: var(--bg-panel); }
.ccount {
  color: var(--subtext);
  font-size: 13px;
  font-weight: 600;
  margin-left: 8px;
}
.session-list { display: flex; flex-direction: column; gap: 6px; }
.session-list .row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-panel);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  border: 2px solid transparent;
}
.session-list .row:hover  { background: var(--bg-elev); }
.session-list .row.active { border-color: var(--accent); }
.session-list .row .sr-name { flex: 1; font-weight: 700; }
.session-list .row .sr-meta { color: var(--subtext); font-size: 12px; }
.session-list .row .sr-actions { display: flex; gap: 4px; }
.session-list .row .sr-del {
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.printing-list { display: flex; flex-direction: column; gap: 6px; }
.printing-list .row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-panel);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border: 2px solid transparent;
}
.printing-list .row:hover    { background: var(--bg-elev); }
.printing-list .row.active   { border-color: var(--accent); }
.printing-list .row img {
  width: 48px; height: 67px; object-fit: cover; border-radius: 4px;
  background: var(--bg-elev);
}
.printing-list .row .pr-main { flex: 1; min-width: 0; }
.printing-list .row .pr-set  { font-weight: 600; font-size: 14px; }
.printing-list .row .pr-cn   { font-size: 12px; color: var(--subtext); }
.printing-list .row .pr-price {
  font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--success);
}

.footnote {
  text-align: center;
  color: var(--dim);
  font-size: 11px;
  padding: 24px 14px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

/* ===== Showcase mode money-pop animation ===== */
.money-pop {
  position: fixed;
  pointer-events: none;
  font-size: 28px;
  font-weight: 800;
  z-index: 700;
  user-select: none;
  will-change: transform, opacity;
  animation: money-fly 1.4s ease-out forwards;
  text-shadow: 0 0 12px currentColor, 0 2px 6px rgba(0,0,0,0.6);
}
.money-pop.gold  { color: #f5c542; }
.money-pop.green { color: var(--success); }
.money-pop.pink  { color: var(--accent-2); }
@keyframes money-fly {
  0%   { transform: translate(-50%, -50%) scale(0.4) rotate(0deg); opacity: 0; }
  15%  { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(var(--dx, 0), var(--dy, -240px)) scale(0.7) rotate(var(--rot, 30deg)); opacity: 0; }
}

/* Big price flash overlay on the result */
.price-flash {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 650;
  animation: price-flash 1.4s ease-out forwards;
}
.price-flash .pf-amount {
  font-size: 96px;
  font-weight: 900;
  background: linear-gradient(180deg, #f5c542, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(245, 197, 66, 0.6);
}
@keyframes price-flash {
  0%   { opacity: 0; transform: scale(0.6); }
  20%  { opacity: 1; transform: scale(1.15); }
  60%  { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(0.95) translateY(-30px); }
}

/* Allow tap-to-focus on the video — the canvas overlay above it would
   otherwise eat clicks even though it has pointer-events:none. Make
   the video element clickable explicitly. */
#video { cursor: crosshair; }
@media (pointer: coarse) { #video { cursor: pointer; } }
