:root {
  --bg: #f6f4ee; --surface: #ffffff; --ink: #1f2a22; --muted: #5c6b60; --line: #d9ddd3;
  --brand: #2f6b3a; --brand-ink: #ffffff; --brand-soft: #e3f0dc; --ok: #1f7a3d; --ok-soft: #dcf2e2; --bad: #b3261e; --bad-soft: #fbe3e1; --soil: #a9784b;
  --radius: 14px; --tabs-h: 64px; --fs: 17px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131815; --surface: #1c2420; --ink: #e8efe9; --muted: #a3b2a7; --line: #2f3a33;
    --brand: #7dc48a; --brand-ink: #0e1a11; --brand-soft: #22372a; --ok: #7dd598; --ok-soft: #17362a; --bad: #ff8a80; --bad-soft: #3d1f1d; --soil: #d3a477;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] { --bg: #131815; --surface: #1c2420; --ink: #e8efe9; --muted: #a3b2a7; --line: #2f3a33; --brand: #7dc48a; --brand-ink: #0e1a11; --brand-soft: #22372a; --ok: #7dd598; --ok-soft: #17362a; --bad: #ff8a80; --bad-soft: #3d1f1d; color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--fs)/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
body.board { --fs: 24px; --tabs-h: 84px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.35em; } h3 { font-size: 1.1em; } h4 { font-size: 1em; margin-top: .6em; }
p { margin: 0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }

.top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 2; }
.top h1 { font-size: 1.1em; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: url(icons/icon.svg) center/cover; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
body.board .wrap { max-width: 1400px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.muted { color: var(--muted); } .small { font-size: .85em; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.season { color: var(--muted); font-weight: 600; }

/* Bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); z-index: 3; }
.tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .75em; color: var(--muted); cursor: pointer; min-width: 0; }
.tab .ico svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.board .tab .ico svg { width: 36px; height: 36px; }
.tab.on { color: var(--brand); font-weight: 700; }

/* Buttons */
button { cursor: pointer; }
.primary, .secondary, .danger, .ok-btn, .bad-btn { border-radius: 12px; padding: 12px 18px; min-height: 48px; border: 1px solid transparent; font-weight: 600; }
.primary { background: var(--brand); color: var(--brand-ink); }
.secondary { background: var(--surface); border-color: var(--line); }
.danger { background: none; border-color: var(--bad); color: var(--bad); justify-self: start; }
.ok-btn { background: var(--ok); color: var(--surface); } .bad-btn { background: var(--bad); color: var(--surface); }
button:disabled { opacity: .45; cursor: not-allowed; }
.wide { width: 100%; }
.link { background: none; border: 0; padding: 6px 0; color: var(--brand); font-weight: 600; justify-self: start; }
.link.on { color: var(--ink); } .danger-text { color: var(--bad); }
:focus-visible { outline: 3px solid var(--soil); outline-offset: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); justify-self: start; }
.seg button { border: 0; background: none; padding: 10px 16px; min-height: 44px; }
.seg button.on { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.badge { background: var(--brand-soft); border-radius: 10px; padding: 8px 12px; justify-self: start; }
.badge.ok { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.badge.inline { display: inline-block; margin-left: 8px; padding: 2px 8px; font-size: .8em; }

.student-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.student-bar label { color: var(--muted); }
.student-bar select { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); min-height: 44px; }
.station { margin-top: 8px; color: var(--brand); }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
body.board .deck-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.deck-card { text-align: left; display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.deck-card.ready { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.deck-card .kind { font-size: .75em; text-transform: uppercase; letter-spacing: .05em; color: var(--soil); font-weight: 700; }
.deck-card .meta { font-size: .85em; color: var(--muted); }
.big-actions { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.big-actions button { display: grid; gap: 4px; text-align: left; padding: 16px; }
.big-actions small { font-weight: 400; opacity: .9; }

/* Run */
.run { display: grid; gap: 14px; }
.run-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; color: var(--muted); }
.score .ok { color: var(--ok); } .score .bad { color: var(--bad); }
.front { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; }
.front img { width: 100%; max-height: 52vh; object-fit: contain; background: #000; display: block; }
body.board .front img { max-height: 58vh; }
.front.qa { padding: 28px 20px; font-size: 1.3em; font-weight: 600; text-align: center; min-height: 160px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { display: grid; gap: 2px; text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); min-height: 56px; font-weight: 600; }
.choice small { font-weight: 400; font-style: italic; color: var(--muted); }
.choice.right { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.dim { opacity: .55; }
.feedback { font-weight: 700; } .feedback.ok { color: var(--ok); } .feedback.bad { color: var(--bad); }
.feedback small { font-weight: 400; color: var(--muted); }
.back { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 8px; }
.back .answer { font-size: 1.15em; font-weight: 600; }
.names { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.names li { display: flex; gap: 10px; align-items: baseline; font-weight: 600; }
.lang { font-size: .7em; font-weight: 700; color: var(--brand-ink); background: var(--brand); border-radius: 6px; padding: 1px 6px; }
.sci { color: var(--muted); } .notes { font-size: .92em; } .credit { font-size: .78em; color: var(--muted); }
.done { text-align: center; justify-items: center; }
.big-number { font-size: 3.4em; font-weight: 800; color: var(--brand); } .big-number.ok { color: var(--ok); }

/* Progress */
.curve svg { width: 100%; max-width: 560px; height: auto; }
.curve .line { fill: none; stroke: var(--brand); stroke-width: 2.5; }
.curve .dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2; } .curve .dot.whole { fill: var(--brand); }
.curve .goal { stroke: var(--ok); stroke-dasharray: 5 4; } .curve .axis { stroke: var(--line); }
.curve .lbl { fill: var(--ok); font-size: 11px; font-weight: 700; }
.hard { margin: 4px 0 0; padding-left: 20px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; font-size: .9em; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; white-space: nowrap; }
thead th { font-weight: 600; color: var(--muted); white-space: normal; min-width: 90px; }
td.ok { color: var(--ok); font-weight: 700; }

/* Make */
.field { display: grid; gap: 4px; }
.field span { font-size: .85em; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea, form.row input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-height: 44px; width: 100%; }
form.row input { flex: 1; min-width: 160px; width: auto; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.thumb { display: grid; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; font-size: .85em; }
.thumb img { aspect-ratio: 1; object-fit: cover; border-radius: 8px; width: 100%; }
.preview { max-height: 240px; object-fit: contain; border-radius: 10px; justify-self: start; }
.preview[src=""] { display: none; }
.file-btn { display: inline-flex; align-items: center; justify-self: start; cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.students { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.students li { display: flex; justify-content: space-between; align-items: center; }
.guide p { margin-top: 6px; }

@media (max-width: 560px) {
  .choices, .two { grid-template-columns: 1fr; }
  .tab { font-size: .68em; }
}
