:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #16181d;
  --muted: #667085;
  --border: #e3e6eb;
  --accent: #15803d;
  --accent-soft: #e7f5ec;
  --good: #15803d;
  --mid: #b45309;
  --bad: #c2410c;
  --good-bg: #e7f5ec;
  --mid-bg: #fdf3e2;
  --bad-bg: #fdece4;
  --review: #1d4ed8;
  --input: #7c3aed;
  --gate: #b91c1c;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --text: #e8eaee;
    --muted: #98a2b3;
    --border: #2a2f38;
    --accent: #4ade80;
    --accent-soft: #15301f;
    --good: #4ade80;
    --mid: #fbbf24;
    --bad: #fb923c;
    --good-bg: #15301f;
    --mid-bg: #33280f;
    --bad-bg: #3a1f12;
    --review: #60a5fa;
    --input: #a78bfa;
    --gate: #f87171;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .4rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { margin: .2rem 0 .6rem; }
h4 { margin: 1.2rem 0 .5rem; }
code { background: var(--surface-2); padding: 0 .3em; border-radius: 4px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); display: flex; gap: .5rem; align-items: center; }
.badge { background: var(--accent); color: var(--surface); border-radius: 6px; padding: 0 .45em; font-size: .85rem; }
.topbar nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--muted); }
.topbar nav a:hover { color: var(--text); }

.wrap { max-width: 1000px; margin: 0 auto; padding: 1.2rem 16px 4rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: .4rem; }
.en { font-family: Georgia, "Times New Roman", serif; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: .8rem 0; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

.btn, button {
  font: inherit; font-size: .92rem; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: .35rem .8rem;
  text-decoration: none; display: inline-block;
}
.btn:hover, button:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: wait; }
input[type=text], input:not([type]), textarea, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; max-width: 100%;
}
textarea { width: 100%; resize: vertical; }

.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar.big { height: 10px; margin: .6rem 0 1.4rem; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.hero-stats { display: flex; align-items: center; gap: 1rem; }
.stat b { font-size: 1.8rem; }
.stat span { color: var(--muted); margin-left: .3rem; }

.week { margin-bottom: 1.8rem; }
.week h2 { margin-bottom: .7rem; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .7rem; }
.daycard {
  display: flex; flex-direction: column; gap: .4rem; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .8rem; border-top: 4px solid var(--accent);
}
.daycard:hover { border-color: var(--muted); }
.daycard.t-review { border-top-color: var(--review); }
.daycard.t-input { border-top-color: var(--input); }
.daycard.t-gate, .daycard.t-final { border-top-color: var(--gate); }
.daycard.done { background: var(--accent-soft); }
.daynum { font-weight: 800; font-size: 1.3rem; }
.daynum.big { font-size: 1.6rem; color: var(--accent); margin-right: .3rem; }
.daytitle { font-size: .9rem; flex: 1; }
.daymeta { display: flex; gap: .3rem; }
.tag { font-size: .72rem; background: var(--surface-2); border-radius: 99px; padding: .05rem .5rem; color: var(--muted); }
.tag.warn { color: var(--mid); background: var(--mid-bg); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin: .8rem 0; }
.panel.soft { background: var(--surface-2); border: none; }
.panel.warn { background: var(--mid-bg); border-color: transparent; }
details.panel summary { cursor: pointer; font-weight: 600; }
.prose table, .tbl { border-collapse: collapse; width: 100%; margin: .6rem 0; font-size: .92rem; }
.prose td, .prose th, .tbl td, .tbl th { border-bottom: 1px solid var(--border); padding: .4rem .5rem; text-align: left; vertical-align: top; }
.tbl-wrap { overflow-x: auto; }

.daynav { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.daynav a { text-decoration: none; }
.day-head { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; }
.voice-row { margin-top: .4rem; }

.block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 1rem; }
.block > header { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .8rem 1.2rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.block.is-done > header { background: var(--accent-soft); border-radius: var(--radius) var(--radius) 0 0; }
.block-body { padding: .8rem 1.2rem 1.2rem; }
.idx { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--surface-2); font-size: .85rem; margin-right: .3rem; }
.mins { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: .3rem; }
.done-toggle { font-size: .9rem; cursor: pointer; }

.examples, .shadow-list, .dict-list { padding-left: 1.2rem; }
.examples li, .shadow-list li, .dict-list li { margin: .45rem 0; }
.say-group { display: inline-flex; gap: .2rem; vertical-align: middle; }
.say { padding: .1rem .5rem; font-size: .8rem; border-radius: 99px; }
.say.playing { background: var(--accent); color: var(--surface); }

.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.vcard { background: var(--surface-2); border-radius: 10px; padding: .7rem; display: flex; flex-direction: column; gap: .3rem; }
.vcard .rec { margin: 0; }
.vcard .rec-btn { font-size: .8rem; padding: .15rem .6rem; }

.rec { margin: .4rem 0; }
.rec-btn.recording { background: var(--bad); color: var(--surface); border-color: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .7; } }
.rec-timer { margin-left: .5rem; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.rec-out { margin-top: .4rem; }
.rec-out audio, .hist audio { height: 34px; margin-top: .3rem; max-width: 100%; }
.transcript { margin: .3rem 0; }
.cmp { line-height: 2; }
.w { padding: .1rem .3rem; border-radius: 5px; }
.w.ok { background: var(--good-bg); color: var(--good); }
.w.weak { background: var(--mid-bg); color: var(--mid); }
.w.missed { background: var(--bad-bg); color: var(--bad); text-decoration: line-through; }
.w sup { text-decoration: none; display: inline-block; margin-left: .2rem; }
.score { margin-right: .4rem; }
.good { color: var(--good); }
.mid { color: var(--mid); }
.bad { color: var(--bad); }
.metrics { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .92rem; margin: .3rem 0; }
.hist { border-top: 1px solid var(--border); padding: .6rem 0; }

.hints { margin: .6rem 0; display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.chip { background: var(--surface-2); border-radius: 99px; padding: .1rem .6rem; font-size: .9rem; }

.dict input { width: min(420px, 100%); margin: 0 .3rem; }
.dict-out { margin-top: .3rem; }
.d-ok { color: var(--good); }
.d-missing { color: var(--bad); text-decoration: underline wavy; }
.d-extra { color: var(--mid); text-decoration: line-through; }

.quiz .q { border: 1px solid var(--border); border-radius: 10px; margin: .5rem 0; padding: .5rem .8rem; }
.quiz legend { font-weight: 600; padding: 0 .3rem; }
.quiz label { display: inline-block; margin: .2rem 1rem .2rem 0; cursor: pointer; }
.quiz .q.right { border-color: var(--good); }
.quiz .q.wrong { border-color: var(--bad); background: var(--bad-bg); }
.quiz .q.wrong label.correct { color: var(--good); font-weight: 600; }
.quiz .explain { font-size: .88rem; color: var(--muted); margin: .3rem 0 0; }
.qn { color: var(--muted); }

.flash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .5rem; }
.flash { min-height: 80px; text-align: center; }
.flash .back { display: none; }
.flash.flipped { background: var(--accent-soft); }
.flash.flipped .front { display: none; }
.flash.flipped .back { display: block; }

.mistake-form { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0; }
.mistake-form input { flex: 1 1 180px; }
.gate-topic { border-top: 1px solid var(--border); padding-top: .4rem; }
.reading { background: var(--surface-2); border-radius: 10px; padding: .6rem 1rem; }
.links li { margin: .3rem 0; }
.steps li { margin: .3rem 0; }
.wc.good { color: var(--good); font-weight: 600; }
@media (max-width: 600px) {
  .tbl { display: block; overflow-x: auto; }
  .block-body, .block > header { padding-left: .8rem; padding-right: .8rem; }
}

.ipa { font-family: "Charis SIL", "Doulos SIL", "Noto Sans", "DejaVu Sans", sans-serif; }
.ipa.big { font-size: 1.2rem; }
.phon { display: flex; flex-direction: column; gap: .35rem; margin: .3rem 0; }
.pw-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.pw { display: inline-flex; flex-direction: column; align-items: center; padding: .15rem .45rem; border-radius: 6px; line-height: 1.3; }
.pw small { font-size: .78rem; opacity: .85; }
.pw.ok { background: var(--good-bg); color: var(--good); }
.pw.weak { background: var(--mid-bg); color: var(--mid); }
.pw.bad { background: var(--bad-bg); color: var(--bad); }
.issues, .tips { margin: 0; padding-left: 1.2rem; }
.tips { color: var(--muted); }
.toc { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0 0; }
.toc a { background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: .15rem .7rem; text-decoration: none; font-size: .88rem; }
.pair-quiz { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.pq-score { width: 100%; }
.tbl.pairs td { width: 50%; }

.btn.tiny { font-size: .75rem; padding: .05rem .45rem; }
.ai-feedback { margin: .6rem 0; }
.ai-list { padding-left: 1.2rem; }
.ai-list li { margin: .5rem 0; }
.chat { background: var(--surface-2); border-radius: 10px; padding: .6rem .9rem; margin-top: 1rem; }
.chat summary { cursor: pointer; }
.chat-log { display: flex; flex-direction: column; gap: .5rem; max-height: 460px; overflow-y: auto; margin: .6rem 0; }
.bubble { max-width: 85%; padding: .45rem .75rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.bubble.user { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.bubble.assistant { align-self: flex-start; }
.bubble.wait { color: var(--muted); }
.bubble.error { align-self: center; color: var(--bad); background: var(--bad-bg); border: none; font-size: .9rem; }
.correction { margin-top: .35rem; padding-top: .35rem; border-top: 1px dashed var(--border); color: var(--mid); }
.chat-form { display: flex; gap: .4rem; flex: 1 1 260px; }
.chat-form input { flex: 1; }
.chat-controls .rec { margin: 0; }
[hidden] { display: none !important; }

/* ---------- Kuzatuv: jurnal, progress ---------- */
:root { --series-1: #2a78d6; }
@media (prefers-color-scheme: dark) { :root { --series-1: #3987e5; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; margin: 1rem 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; }
.tile b { display: block; font-size: 1.7rem; line-height: 1.2; }
.tile span { color: var(--muted); font-size: .88rem; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-top: 1rem; }
.chart-card { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; min-width: 0; }
.chart { position: relative; margin: .5rem 0; }
.chart-svg { display: block; max-width: 100%; height: auto; outline: none; touch-action: pan-y; }
.chart-svg:focus-visible { box-shadow: 0 0 0 2px var(--series-1); border-radius: 6px; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis { fill: var(--muted); font-size: 11px; }
.chart-svg .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart-svg .cross { stroke: var(--muted); stroke-width: 1; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .25rem .55rem; font-size: .85rem; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.12); color: var(--text); }
.chart-tip span { color: var(--muted); }
.chart-empty { padding: 2rem 0; text-align: center; }
.journal-lines { background: var(--surface-2); border-radius: 8px; padding: .7rem .9rem; white-space: pre-wrap; font-size: .9rem; }
.diag { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .6rem; }
.diag label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: .2rem; }
input.wide { width: 100%; }
.pass-yes { color: var(--good); font-weight: 700; }
.pass-no { color: var(--bad); font-weight: 700; }
.pass-unk { color: var(--muted); font-weight: 700; }
.login-box { max-width: 420px; margin: 3rem auto; }

/* ---------- 5-bosqich: mashqlar, o'qish, SRS ---------- */
.count { background: var(--accent); color: var(--surface); border-radius: 99px; font-size: .72rem; padding: 0 .4rem; margin-left: .15rem; }
.exercises .ex { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .8rem; margin: .5rem 0; }
.exercises .ex.right { border-color: var(--good); }
.exercises .ex.wrong { border-color: var(--bad); background: var(--bad-bg); }
.ex-head { display: flex; gap: .4rem; align-items: center; margin-bottom: .3rem; }
.ex-q { line-height: 2; }
.ex-input { margin: 0 .2rem; }
.ex-fix .ex-input { width: 100%; }
.ex-out { margin-top: .35rem; }
.exercises label { margin-right: 1rem; cursor: pointer; }
.order-line { min-height: 2.4rem; border: 1px dashed var(--border); border-radius: 8px; padding: .25rem; display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .35rem; }
.order-bank { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.chip-btn { border-radius: 99px; padding: .15rem .7rem; }
.order-line .chip-btn { background: var(--accent-soft); border-color: transparent; }
.reading-box { margin-bottom: 1rem; }
.reading-box h3 { margin: 0; }
.reading { font-size: 1.08rem; line-height: 1.8; margin: .6rem 0; }
.sent { cursor: pointer; border-radius: 4px; transition: background .15s; }
.sent:hover { background: var(--surface); }
.sent.reading-now { background: var(--accent-soft); }
.gloss, .gloss-demo { border-bottom: 2px dotted var(--series-1); cursor: help; position: relative; }
.gloss.open::after {
  content: attr(data-uz); position: absolute; left: 0; top: 100%; z-index: 5; white-space: nowrap;
  background: var(--text); color: var(--surface); font: .82rem/1.4 system-ui, sans-serif; padding: .15rem .5rem; border-radius: 6px;
}
.gloss-list { columns: 2; padding-left: 1.2rem; }
.srs-front { font-size: 1.35rem; margin: .4rem 0; }
.srs-uz { color: var(--muted); margin-bottom: .6rem; }
.srs-input { font-size: 1.1rem; min-width: 220px; }
.srs-back { margin-top: .6rem; display: flex; flex-direction: column; gap: .45rem; }
.srs-word { font-size: 1.3rem; }
.srs-grades .grade { display: inline-flex; flex-direction: column; align-items: center; min-width: 86px; }
.srs-grades .grade small { color: var(--muted); font-size: .75rem; }
.grade.suggested { outline: 2px solid var(--accent); }
.grade.g0 b { color: var(--bad); }
.grade.g2 b, .grade.g3 b { color: var(--good); }
.ex-q .ex-input { padding: .1rem .45rem; line-height: 1.4; height: auto; vertical-align: baseline; width: 9em; }

/* ---------- Tuzilmali grammatika darsi ---------- */
:root {
  --k-subj: #2a78d6; --k-verb: #eb6834; --k-neg: #e34948; --k-q: #4a3aa7;
  --k-obj: #1baf7a; --k-place: #008300; --k-time: #eda100; --k-rest: #8a8f98;
}
@media (prefers-color-scheme: dark) {
  :root {
    --k-subj: #3987e5; --k-verb: #d95926; --k-neg: #e66767; --k-q: #9085e9;
    --k-obj: #199e70; --k-place: #2f9e2f; --k-time: #c98500; --k-rest: #7d838c;
  }
}
.lesson h3 { font-size: 1.25rem; }
.lesson-intro { font-size: 1.05rem; }
.lesson b.hl { color: var(--accent); }
.formulas { display: grid; gap: .6rem; }
.formula { background: var(--surface-2); border-radius: 10px; padding: .6rem .8rem; }
.f-label { font-weight: 700; font-size: .9rem; margin-bottom: .35rem; }
.f-parts { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-bottom: .4rem; }
.fp {
  --k: var(--k-rest);
  display: inline-block; padding: .15rem .6rem; border-radius: 6px; font-weight: 600; font-size: .95rem;
  background: color-mix(in srgb, var(--k) 16%, transparent); border-bottom: 3px solid var(--k); color: var(--text);
}
.fp.k-subj { --k: var(--k-subj); } .fp.k-verb { --k: var(--k-verb); } .fp.k-neg { --k: var(--k-neg); }
.fp.k-q { --k: var(--k-q); } .fp.k-obj { --k: var(--k-obj); } .fp.k-place { --k: var(--k-place); }
.fp.k-time { --k: var(--k-time); } .fp.k-rest { --k: var(--k-rest); }
.f-plus { color: var(--muted); font-weight: 700; }
.f-example { font-size: 1.05rem; }
.f-legend { display: flex; flex-wrap: wrap; gap: .3rem; margin: .5rem 0 .2rem; }
.f-legend .fp { font-size: .75rem; font-weight: 500; padding: 0 .45rem; }
.lesson-tbl td, .lesson-tbl th { text-align: left; }
.lesson-box { border-radius: 10px; padding: .6rem .9rem; margin: .9rem 0; border-left: 4px solid var(--border); background: var(--surface-2); }
.lesson-box .box-title { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; margin-bottom: .25rem; color: var(--muted); }
.lesson-box.compare { border-left-color: var(--k-subj); }
.lesson-box.remember { border-left-color: var(--accent); }
.lesson-box.remember ul { margin: 0; padding-left: 1.2rem; }
.lesson-box.note { border-left-color: var(--k-time); }
.lesson-examples { padding-left: 1.2rem; }
.lesson-examples li { margin: .45rem 0; }
.mistakes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; }
.mk { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem; }
.mk-wrong { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1px; }
.mk-right { color: var(--good); margin: .15rem 0 .25rem; }
.mk-right b.hl { color: inherit; text-decoration: underline; }
.formulas { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.level-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.level-tabs a { display: flex; flex-direction: column; align-items: center; min-width: 88px; padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--text); }
.level-tabs a small { color: var(--muted); font-size: .72rem; }
.level-tabs a.active { border-color: var(--accent); background: var(--accent-soft); }
.small-tabs a { min-width: 56px; padding: .25rem .6rem; }
