:root{
  --bg:#faf6f1; --surface:#fff; --ink:#26211c; --muted:#857a6f;
  --line:#ece4d9; --accent:#b9472f; --accent-soft:#f6e6e0;
  --green:#1aa260; --lime:#7cb342; --amber:#f6a609; --red:#e3553b;
  --bar-h:78px;
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent}
/* The [hidden] attribute must win over component display rules (flex/grid). */
[hidden]{display:none !important}
html,body{margin:0; height:100%}
body{
  font-family:Inter,system-ui,sans-serif; color:var(--ink); background:var(--bg);
  display:flex; flex-direction:column; min-height:100dvh;
  padding-top:env(safe-area-inset-top);
}
h1,h2{font-family:Fraunces,Georgia,serif; font-weight:600; letter-spacing:-.01em}

/* top bar */
.m-top{
  display:flex; align-items:center; gap:10px; padding:14px 16px;
  position:sticky; top:0; z-index:10; background:rgba(250,246,241,.9); backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
}
.m-top h1{font-size:18px; margin:0; flex:1}
.m-logo{width:30px; height:30px; border-radius:9px; background:
  radial-gradient(circle at 34% 32%, #fff 0 20%, transparent 21%),
  radial-gradient(circle at 66% 50%, #fff 0 15%, transparent 16%),
  radial-gradient(circle at 42% 70%, #fff 0 16%, transparent 17%),
  linear-gradient(135deg,var(--accent),#d98a5f)}
.m-switch{font-size:20px; text-decoration:none; opacity:.7}

/* main scroll area */
.m-main{flex:1; overflow-y:auto; padding:18px 16px calc(var(--bar-h) + env(safe-area-inset-bottom) + 18px)}

/* home / hero */
.m-hero{text-align:center; padding:18px 6px 24px}
.m-hero-art{display:inline-grid; grid-template-columns:1fr 1fr; gap:9px; width:104px; height:104px; margin-bottom:18px}
.m-hero-art span{border-radius:50%; background:linear-gradient(135deg,#f3d9cd,#e6efe1); animation:mp 2.4s ease-in-out infinite}
.m-hero-art span:nth-child(2){animation-delay:.3s}.m-hero-art span:nth-child(3){animation-delay:.6s}.m-hero-art span:nth-child(4){animation-delay:.9s}
@keyframes mp{0%,100%{opacity:.5;transform:scale(.92)}50%{opacity:1;transform:scale(1)}}
.m-hero h2{font-size:28px; line-height:1.15; margin:0 0 10px}
.m-hero p{color:var(--muted); margin:0 auto; max-width:300px; line-height:1.5; font-size:15px}

/* preview */
.m-preview{position:relative; margin:8px 0 0; border-radius:22px; overflow:hidden; background:#1b1714; box-shadow:0 14px 40px -20px rgba(60,30,10,.5)}
.m-preview img{width:100%; max-height:62vh; object-fit:contain; display:block}
.m-clear{position:absolute; top:12px; right:12px; width:38px; height:38px; border:0; border-radius:50%;
  background:rgba(0,0,0,.55); color:#fff; font-size:16px; backdrop-filter:blur(4px)}

/* loading */
.m-loading{display:flex; flex-direction:column; align-items:center; gap:14px; padding:40px 16px; text-align:center}
.m-scanner{position:relative; width:78vw; max-width:320px; aspect-ratio:1; border-radius:22px; overflow:hidden; background:#1b1714}
.m-scanner img{width:100%; height:100%; object-fit:contain}
.m-scanline{position:absolute; left:0; right:0; height:3px;
  background:linear-gradient(90deg,transparent,var(--accent),transparent);
  box-shadow:0 0 16px 3px var(--accent); animation:mscan 1.8s ease-in-out infinite}
@keyframes mscan{0%,100%{top:6%}50%{top:94%}}
.m-loading p{font-family:Fraunces,serif; font-size:19px; margin:0}
.m-loading small{color:var(--muted)}

/* results */
.m-results{animation:mfade .35s ease}
@keyframes mfade{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}

/* hero verdict card */
.m-verdict{
  border-radius:24px; padding:24px 20px; color:#fff; text-align:center; position:relative; overflow:hidden;
  box-shadow:0 16px 40px -18px rgba(60,30,10,.55);
}
.m-verdict .m-ring{margin:0 auto 10px; display:block}
.m-verdict .gauge-num{font-family:Fraunces,serif; font-size:40px; fill:#fff; font-weight:600}
.m-verdict .gauge-cap{font-size:11px; fill:rgba(255,255,255,.8)}
.m-verdict h2{font-size:26px; margin:2px 0 4px}
.m-verdict .m-stage{opacity:.92; font-size:14.5px}
.m-agree{display:inline-block; margin-top:14px; font-size:12.5px; font-weight:600;
  background:rgba(255,255,255,.22); padding:6px 13px; border-radius:999px}

/* explanation card */
.m-card{background:var(--surface); border:1px solid var(--line); border-radius:20px; padding:20px; margin-top:14px}
.m-card h3{margin:0 0 8px; font-size:16px; color:var(--accent); font-family:Inter,sans-serif; font-weight:700}
.m-explain p{margin:0; line-height:1.6; font-size:15.5px}

/* segmented model switch */
.m-seg{display:flex; gap:6px; background:#efe7dc; padding:5px; border-radius:14px; margin-top:16px}
.m-seg button{flex:1; border:0; background:transparent; padding:10px; border-radius:10px;
  font-family:inherit; font-weight:600; font-size:14px; color:var(--muted)}
.m-seg button.active{background:var(--surface); color:var(--ink); box-shadow:0 2px 8px -3px rgba(0,0,0,.2)}
.m-pane{display:none; margin-top:14px}
.m-pane.active{display:block}

/* metrics as rows */
.m-stagehead{font-size:14px; color:var(--muted); margin:0 0 12px}
.metrics{display:flex; flex-direction:column; gap:8px; margin-bottom:14px}
.metric{display:flex; align-items:center; justify-content:space-between; font-size:14.5px;
  padding:13px 15px; background:#faf7f3; border:1px solid var(--line); border-radius:13px}
.metric-label{color:var(--muted); display:flex; align-items:center; gap:6px}
.metric-value{font-weight:600}
.hint{display:none}
.obs{margin:0; padding-left:20px; line-height:1.6; font-size:14.5px}
.obs li{margin:5px 0}
.badge{display:inline-block; color:#fff; font-size:12px; font-weight:600; padding:4px 12px; border-radius:999px; margin-bottom:10px}
.model-meta{font-size:11px; color:var(--muted); margin:12px 0 0}
.model-err{color:var(--accent); font-size:14px}

.m-reviews-intro{margin:0 0 12px; font-size:13px; color:var(--muted)}
.m-next-lead{margin:0; font-size:14.5px; line-height:1.55}
.m-ask ul{margin:10px 0 0; padding-left:20px; line-height:1.6; font-size:14.5px; color:var(--muted)}
.m-disclaimer{font-size:12.5px; color:var(--muted); line-height:1.55; padding:16px; margin-top:14px;
  background:#fdf8f2; border:1px dashed var(--line); border-radius:14px}

/* sticky bottom bar */
.m-bar{
  position:fixed; left:0; right:0; bottom:0; z-index:20;
  display:flex; gap:10px; padding:12px 14px calc(12px + env(safe-area-inset-bottom));
  background:rgba(255,255,255,.92); backdrop-filter:blur(12px); border-top:1px solid var(--line);
}
.m-btn{flex:1; border:0; border-radius:15px; padding:15px 8px; font-family:inherit; font-weight:600; font-size:14px;
  display:flex; flex-direction:column; align-items:center; gap:3px}
.m-btn span{font-size:19px}
.m-btn-ghost{background:#f0e8dd; color:var(--ink)}
.m-btn-ghost:active{background:#e7ddcf}
.m-btn-go{flex:1.4; background:var(--accent); color:#fff; font-size:16px; justify-content:center}
.m-btn-go:disabled{opacity:.4}
.m-btn-go:active:not(:disabled){background:#a23c26}

/* the analyse-only / new-scan states swap visible buttons via .hidden */
.hidden{display:none !important}
