:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1b1f24; --muted: #5d6673; --border: #dde1e6;
  --accent: #1f4e8c; --accent-text: #ffffff; --good: #1d7a46; --again: #b4372f; --warn: #a15c00;
  --soft: #e8eef7; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a; --surface: #1b2028; --text: #e7eaee; --muted: #9aa3ae; --border: #2c333d;
    --accent: #6ea0e6; --accent-text: #0d1320; --good: #4cc282; --again: #f0786e; --warn: #f0b35a; --soft: #233046;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; } h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 96px; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.nav { display: flex; gap: 4px; overflow-x: auto; }
.nav a { padding: 6px 10px; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; }
.nav a.on { background: var(--soft); color: var(--text); font-weight: 600; }
@media (max-width: 560px) {
  .topbar { justify-content: center; }
  .brand { display: none; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; justify-content: space-around; background: var(--surface);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .topbar { position: static; padding: 0; border: 0; }
}
.panel, .hero, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.hero { text-align: center; padding: 24px 16px; }
.hero .big { font-size: 3.5rem; font-weight: 700; line-height: 1; }
.hero .row { justify-content: center; margin-top: 16px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.ok { color: var(--good); font-weight: 600; } .err { color: var(--again); }
.row { display: flex; align-items: center; } .gap { gap: 10px; } .wrap-row { flex-wrap: wrap; align-items: end; }
.center-row { justify-content: center; } .grow { flex: 1 1 200px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; min-width: 0; }
textarea { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }
input.short { width: 6.5rem; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
legend { color: var(--muted); font-size: .85rem; padding: 0 4px; }
.btn { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--again); }
.btn.lg { padding: 16px 20px; font-size: 1.1rem; flex: 1; min-height: 56px; }
.btn.block { width: 100%; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.again { background: var(--again); border-color: var(--again); color: #fff; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: center; }
.tile .num { font-size: 1.6rem; font-weight: 700; } .tile .lbl { color: var(--muted); font-size: .85rem; }
.upcoming { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.upcoming li { display: grid; grid-template-columns: 3.5rem 1fr 2.5rem; align-items: center; gap: 8px; font-size: .9rem; }
.upcoming .bar { height: 10px; border-radius: 5px; background: var(--accent); width: var(--w); min-width: 4px; }
.upcoming .n { text-align: right; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
.units .meter { width: 35%; position: relative; }
.units .meter span { position: absolute; left: 8px; top: 50%; height: 8px; margin-top: -4px; border-radius: 4px; width: calc((100% - 16px) * var(--w) / 100); }
.units .meter .seen { background: var(--soft); } .units .meter .solid { background: var(--good); }
.scroll-x { overflow-x: auto; }
.preview .st-new td:first-child { color: var(--good); } .preview .st-updated td:first-child { color: var(--warn); }
.preview .st-unchanged { color: var(--muted); } .preview .st-error td:first-child { color: var(--again); }
.cardlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.cardlist li a { display: block; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text); }
.cardlist li.suspended { opacity: .55; }
.cl-fi { font-weight: 600; } .cl-puhe { color: var(--muted); font-style: italic; } .cl-en { margin-top: 2px; }
.cl-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.pill { background: var(--soft); color: var(--text); border-radius: 999px; padding: 0 8px; }
/* review + drill */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.card { position: relative; min-height: 260px; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 28px 20px; margin-top: 8px; }
.card .meta { position: absolute; top: 10px; left: 14px; right: 14px; display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; }
.prompt { font-size: 1.7rem; font-weight: 600; line-height: 1.25; }
.prompt-sub { color: var(--muted); font-style: italic; margin-top: 6px; font-size: 1.1rem; }
.answer { margin-top: 20px; padding-top: 20px; border-top: 1px dashed var(--border); }
.ans-main { font-size: 1.4rem; font-weight: 600; }
.ans-sub { color: var(--muted); font-style: italic; margin-top: 4px; }
.ans-sub::before { content: "puhekieli: "; font-style: normal; font-size: .8rem; }
.ans-sub:empty::before { content: none; }
.tags { margin-top: 10px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.tags span { background: var(--soft); border-radius: 999px; padding: 1px 10px; font-size: .8rem; }
.notes { color: var(--muted); font-size: .9rem; margin-top: 8px; }
.speak { position: absolute; bottom: 10px; right: 12px; border: 0; background: none; font-size: 1.4rem; cursor: pointer; }
.actions { margin-top: 12px; }
.actions .row .btn { flex: 1; }
.keys { margin-top: 16px; }
@media (hover: none) { .keys { display: none; } }
.type-in { width: 100%; font-size: 1.3rem; text-align: center; margin-top: 20px; padding: 14px; }
.chars { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.chip { font: inherit; font-size: 1.1rem; min-width: 44px; min-height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
.feedback { margin-top: 16px; }
.verdict { font-weight: 700; font-size: 1.2rem; margin-bottom: 8px; }
.verdict.correct { color: var(--good); } .verdict.wrong { color: var(--again); } .verdict.marks, .verdict.close { color: var(--warn); }
.expected { font-size: 1.3rem; margin-bottom: 4px; }
.expected .miss { background: color-mix(in srgb, var(--again) 22%, transparent); border-radius: 4px; padding: 0 2px; }
.feedback .btn { margin-top: 14px; }
/* story */
.story-hero h1 { margin-top: 4px; }
.scene { font-style: italic; color: var(--text); border-left: 3px solid var(--accent); padding-left: 10px; margin: 10px 0; text-align: left; }
.story-hero .scene { max-width: 34rem; margin: 12px auto; }
.overall { max-width: 22rem; margin: 18px auto 0; }
.story-card { display: block; text-decoration: none; color: var(--text); }
.story-card .sc-title { font-weight: 700; font-size: 1.1rem; margin: 2px 0; }
.story-card .progress { margin: 10px 0 0; }
.timeline { list-style: none; margin: 0 0 16px; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 14px 50px; }
.tl-dot { position: absolute; left: 0; top: 10px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: .9rem; background: var(--surface); border: 2px solid var(--border); color: var(--muted); }
.tl-item.done .tl-dot { background: var(--good); border-color: var(--good); color: #fff; }
.tl-item.current .tl-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 4px var(--soft); }
.tl-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tl-item.current .tl-body { border-color: var(--accent); }
.tl-item.upcoming .tl-body { opacity: .8; }
.tl-item.review .tl-body { background: transparent; border-style: dashed; }
.tl-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-head a { color: var(--text); }
.tl-title { font-weight: 700; }
.tl-story { margin: 6px 0; }
.tl-item p { margin: 4px 0; }
.tl-bars { display: grid; gap: 4px; margin-top: 8px; }
.tl-bars > div { display: grid; grid-template-columns: 4.5rem 1fr auto; gap: 8px; align-items: center; }
.lbl { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; font-style: normal; margin-right: 4px; }
.minibar { position: relative; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.minibar > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.minibar.cards .seen { background: var(--soft); } .minibar.cards .solid { background: var(--good); }
@media (prefers-color-scheme: dark) { .minibar.cards .seen { background: #3a4b66; } }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 12px 0; }
.facts dt { color: var(--muted); font-size: .85rem; } .facts dd { margin: 0; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 6px; } }
.cast { margin: 0; padding-left: 18px; } .cast li { margin: 2px 0; }
.sessions { display: grid; gap: 8px; }
.sess { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; scroll-margin-top: 70px; }
.sess.next { border-color: var(--accent); }
.sess summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; }
.sess summary::-webkit-details-marker { display: none; }
.sess-mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .85rem;
  border: 2px solid var(--border); color: var(--muted); }
.sess.done .sess-mark { background: var(--good); border-color: var(--good); color: #fff; }
.sess.next .sess-mark { border-color: var(--accent); color: var(--accent); }
.sess-title { flex: 1; font-weight: 600; }
.sess.done .sess-title { color: var(--muted); }
.sess-body { padding: 0 14px 14px 50px; }
@media (max-width: 560px) { .sess-body { padding-left: 14px; } }
.sess-body p { margin: 8px 0; }
.goals { list-style: none; margin: 6px 0 10px; padding: 0; display: grid; gap: 6px; }
.goal { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.goal .box { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; }
.goal.ticked .box { background: var(--good); border-color: var(--good); color: #fff; }
.goal.ticked > span:last-child { color: var(--muted); }
.sess-body form { margin: 0; }
