:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --track: #ebeae5;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0a8a0a;
  --good-bg: #e9f6e9;
  --warn: #b7791f;
  --warn-bg: #fff6df;
  --warn-line: #f1cf7a;
  --bad: #d03b3b;
  --bad-bg: #fbeaea;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --track: #2c2c2a;
    --accent: #3987e5;
    --good: #3cc23c;
    --good-bg: #12240f;
    --warn: #e9b949;
    --warn-bg: #2a2210;
    --warn-line: #5a4a1e;
    --bad: #ef6b6b;
    --bad-bg: #2d1515;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink2: #c3c2b7;
  --muted: #898781;
  --line: #2c2c2a;
  --track: #2c2c2a;
  --accent: #3987e5;
  --good: #3cc23c;
  --good-bg: #12240f;
  --warn: #e9b949;
  --warn-bg: #2a2210;
  --warn-line: #5a4a1e;
  --bad: #ef6b6b;
  --bad-bg: #2d1515;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.top, main, footer { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 24px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
.sub { margin: 0 0 16px; color: var(--ink2); }
.offline-status { margin: -8px 0 16px; color: var(--good); font-size: .9rem; }
h2 { font-size: 1.05rem; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.num {
  display: inline-flex; width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--accent); color: var(--accent-ink);
  align-items: center; justify-content: center; font-size: .85rem; font-weight: 600;
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.hidden { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.notice { display: flex; gap: 12px; align-items: flex-start; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--line); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.notice.err { background: var(--bad-bg); border-color: var(--bad); }
.ico {
  flex: none; width: 22px; height: 22px; border-radius: 50%; margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff; background: var(--warn);
}
.notice.err .ico { background: var(--bad); }

select {
  width: 100%; min-height: 44px; font: inherit; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.hint { margin: 8px 0 0; color: var(--ink2); font-size: .95rem; }
.model-status { margin-top: 12px; font-size: .9rem; color: var(--ink2); }
.model-status .bar { margin-bottom: 6px; }
.model-status.ready .fill { background: var(--good); }
.model-status.error .fill { background: var(--bad); }
.bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .2s ease; }

.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 120px; border: 2px dashed var(--line); border-radius: 12px; padding: 16px;
  text-align: center; cursor: pointer; color: var(--ink2);
}
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.drop-main { font-weight: 600; color: var(--ink); }
.drop-sub { font-size: .9rem; }
.samples { margin-top: 12px; font-size: .95rem; color: var(--ink2); }
.sample-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn {
  font: inherit; min-height: 44px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: default; }
.preview { margin: 16px 0 0; display: flex; gap: 12px; align-items: center; }
.preview img { width: 96px; height: 96px; object-fit: contain; background: #000; border-radius: 8px; flex: none; }
.preview figcaption { font-size: .9rem; color: var(--ink2); word-break: break-word; }

.progress .bar { height: 12px; }
.progress.done .fill { background: var(--good); }
.progress-label { margin-top: 8px; color: var(--ink2); font-size: .95rem; }
.progress.done .progress-label { color: var(--good); font-weight: 600; }
.convert-done { display: flex; gap: 14px; align-items: flex-start; margin-top: 14px; }
.convert-done canvas { width: 112px; height: 112px; border-radius: 8px; flex: none; border: 1px solid var(--line); }
.convert-done p { margin: 0; font-size: .92rem; color: var(--ink2); }

.working { display: flex; align-items: center; gap: 10px; color: var(--ink2); margin: 0; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.verdict { border-radius: 12px; padding: 14px 16px; border: 1px solid var(--line); border-left-width: 6px; }
.verdict.pos { border-left-color: var(--bad); background: var(--bad-bg); }
.verdict.neg { border-left-color: var(--good); background: var(--good-bg); }
.verdict-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .8rem; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 999px; color: #fff;
}
.pos .badge { background: var(--bad); }
.neg .badge { background: var(--good); }
.verdict-title { font-weight: 600; font-size: 1.1rem; }
.score { margin-top: 12px; }
.score-track { position: relative; height: 10px; border-radius: 999px; background: var(--track); }
.score-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s ease; }
.score-thresh { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--ink2); }
.score-text { margin-top: 6px; font-size: .92rem; color: var(--ink2); }
.context, .caveat { margin: 10px 0 0; font-size: .92rem; color: var(--ink2); }

footer { padding: 8px 16px 32px; color: var(--muted); font-size: .85rem; }
footer a { color: inherit; }
#test-output { white-space: pre-wrap; font-size: .8rem; padding: 0 16px 16px; }

@media (max-width: 480px) {
  .sample-row .btn { flex: 1 1 100%; }
  .preview img { width: 80px; height: 80px; }
}
@media (prefers-reduced-motion: reduce) {
  .fill, .score-fill { transition: none; }
  .spinner { animation-duration: 2s; }
}

/* sample gallery (samples/index.html) */
.g-steps { margin: 0 0 8px; padding-left: 1.3em; color: var(--ink2); }
.g-steps li { margin: 4px 0; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 0 0 16px; }
.g-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.g-card img { display: block; width: 100%; height: 150px; object-fit: cover; background: #000; }
.g-card figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; padding: 10px 12px; }
.g-truth { font-weight: 600; font-size: .9rem; }
.g-truth.neg { color: var(--good); }
.g-truth.pos { color: var(--bad); }
.g-dl { width: auto; flex: none; padding: 6px 12px; text-decoration: none; font-size: .85rem; }
.more-samples { display: inline-block; margin-top: 8px; font-size: .9rem; color: var(--accent); }
