:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #5b6676;
  --line: #dde2e8;
  --accent: #2f6fdd;
  --accent-text: #ffffff;
  --accent-soft: #e6eefc;
  --rec: #d64545;
  --warn: #9a5b00;
  --ok: #1f7a4a;
  --bar: #2f6fdd;
  --bar-bg: #e9edf2;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --panel: #1a1f26;
    --text: #e7ebf0;
    --muted: #9aa5b3;
    --line: #2c333d;
    --accent: #6c9cf0;
    --accent-text: #0d1117;
    --accent-soft: #1f2a3d;
    --rec: #ef6b6b;
    --warn: #e0a54a;
    --ok: #5cc28a;
    --bar: #6c9cf0;
    --bar-bg: #262d36;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.top { padding: 20px 16px 8px; max-width: 1100px; margin: 0 auto; }
h1 { margin: 0 0 4px; font-size: 1.6rem; }
.lead { margin: 0 0 10px; color: var(--muted); }
.steps { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0; padding: 0; list-style-position: inside; color: var(--muted); font-size: .9rem; }

.banner { max-width: 1100px; margin: 8px auto; padding: 10px 16px; background: var(--accent-soft); border-radius: 8px; }
.banner.error { background: transparent; border: 1px solid var(--rec); color: var(--rec); }

.layout {
  max-width: 1100px; margin: 0 auto; padding: 8px 16px 40px;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start;
}
.side { display: grid; gap: 16px; }
@media (max-width: 780px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
h2 { margin: 0 0 6px; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.num { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: .85rem; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: .92rem; }
.msg { margin: 8px 0 0; font-size: .92rem; min-height: 1.2em; }
.msg.warn { color: var(--warn); }
.msg.ok { color: var(--ok); }
code { font-size: .9em; }

button, .file-btn {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  display: inline-block; line-height: 1.3; touch-action: manipulation; user-select: none; position: relative;
}
button.secondary, .file-btn.secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, .file-btn:focus-within, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.icon { background: transparent; border-color: transparent; color: var(--muted); padding: 4px 8px; }
button.record.active { background: var(--rec); border-color: var(--rec); color: #fff; }

.class-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.class-card.dragover { border-color: var(--accent); background: var(--accent-soft); }
.class-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.class-name { flex: 1; min-width: 0; font: inherit; font-weight: 600; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--text); }
.count { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.class-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.thumbs img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; }
.thumbs .more { align-self: center; color: var(--muted); font-size: .85rem; padding-left: 4px; }

.camera { position: relative; width: 100%; max-width: 360px; aspect-ratio: 1; margin-bottom: 8px; border-radius: 10px; overflow: hidden; background: #000; }
.camera video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.camera-msg { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; color: #cfd6df; text-align: center; padding: 16px; }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.settings label { font-size: .9rem; color: var(--muted); display: grid; gap: 2px; }
.settings input { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--text); }
progress { width: 100%; margin-top: 10px; }

.test-img { display: block; max-width: 160px; max-height: 160px; margin-top: 10px; border-radius: 8px; }
.bars { display: grid; gap: 8px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 7em) 1fr 3.5em; align-items: center; gap: 8px; font-size: .92rem; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: block; height: 14px; background: var(--bar-bg); border-radius: 7px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--bar); width: 0; transition: width .15s; }
.bar-row .pct { text-align: right; font-variant-numeric: tabular-nums; }
.bar-row.best .name, .bar-row.best .pct { font-weight: 700; }
