/* styles.css — мобайл-фёрст, крупно и контрастно: телефон в ярком зале,
   человек часто смотрит стоя и одной рукой. Кнопки от 56px. */

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-mute: #7c8797;
  --line: #dde3ec;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --accent: #0f766e;
  --ok: #157347;
  --ok-bg: #e7f6ec;
  --no: #b42318;
  --no-bg: #fdecea;
  --warn-bg: #fff6e5;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 18px rgba(15, 23, 42, .06);
  --r: 16px;
  --base: 18px;
  --tap: 56px;
}
html[data-font="b"] { --base: 20px; --tap: 60px; }
html[data-font="xb"] { --base: 23px; --tap: 66px; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #131c2e; --ink: #f1f5f9; --ink-soft: #b6c2d4;
    --ink-mute: #8b98ad; --line: #26334a; --brand: #3b82f6; --accent: #14b8a6;
    --ok: #34d399; --ok-bg: #10281f; --no: #f87171; --no-bg: #2a1417; --warn-bg: #2b2312;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: var(--base)/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: 84px;
  overflow-x: hidden;
}

/* ---------- шапка ---------- */
#hdr {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
#hdr h1 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 700; text-align: center; }
.hdr-btn {
  min-width: 48px; height: 44px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink); font-size: 1.2rem; font-weight: 700;
}
.hdr-lang { font-size: .8rem; background: var(--brand); color: var(--brand-ink); padding: 0 10px; }

main { padding: 14px 12px 24px; max-width: 640px; margin: 0 auto; }
.screen { display: flex; flex-direction: column; gap: 12px; }

/* ---------- общие блоки ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.card-title { font-size: 1.1rem; font-weight: 700; }
.card-sub, .card-text { color: var(--ink-soft); font-size: .95rem; }
.card-label { color: var(--ink-mute); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.muted-line { color: var(--ink-mute); font-size: .88rem; }
.note {
  background: var(--card); border: 1px dashed var(--line); border-radius: 12px;
  padding: 12px; color: var(--ink-soft); font-size: .92rem;
}
.note-warn { background: var(--warn-bg); border-style: solid; }
.section { display: flex; flex-direction: column; gap: 8px; }

/* ---------- кнопки ---------- */
.btn {
  min-height: var(--tap); padding: 0 18px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 1rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn-danger { background: var(--no-bg); color: var(--no); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn.small { min-height: 44px; font-size: .9rem; }
.btn-round { min-height: 48px; width: 48px; padding: 0; border-radius: 50%; font-size: 1.2rem; flex: 0 0 auto; }
.btn-next { margin-top: 6px; }
.btn-big-listen { min-height: 76px; font-size: 1.15rem; background: var(--brand); color: var(--brand-ink); border-color: transparent; }

.big {
  display: flex; align-items: center; gap: 14px; text-align: left;
  min-height: 78px; padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); box-shadow: var(--shadow); cursor: pointer;
}
.big-icon { font-size: 1.6rem; flex: 0 0 auto; }
.big-text { display: flex; flex-direction: column; }
.big-title { font-size: 1.12rem; font-weight: 700; }
.big-sub { font-size: .88rem; color: var(--ink-soft); }
.big-primary { background: var(--brand); border-color: transparent; }
.big-primary .big-title, .big-primary .big-sub, .big-primary .big-icon { color: var(--brand-ink); }
.big-accent { border-left: 6px solid var(--accent); }
.big-muted { opacity: .75; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 96px; padding: 14px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); box-shadow: var(--shadow); text-align: left; cursor: pointer;
}
.tile-icon { font-size: 1.4rem; }
.tile-title { font-weight: 700; }
.tile-sub { font-size: .8rem; color: var(--ink-mute); }

/* ---------- главная ---------- */
.hello { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hello-name { font-size: 1.25rem; font-weight: 700; }
.streak-n { font-weight: 700; }
.streak-t { color: var(--ink-mute); font-size: .85rem; }
.progress-block { display: flex; flex-direction: column; gap: 6px; }
.progress-text { font-size: .9rem; color: var(--ink-soft); }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-thin { height: 6px; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .25s; }
.card-grammar { border-left: 6px solid var(--accent); }

/* ---------- урок ---------- */
.screen-lesson { gap: 14px; }
.lesson-top { display: flex; flex-direction: column; gap: 6px; }
.lesson-count { font-size: .82rem; color: var(--ink-mute); }
.task-head { display: flex; flex-direction: column; gap: 2px; }
.task-type { font-weight: 700; font-size: 1.05rem; }
.task-instr { color: var(--ink-soft); font-size: .92rem; }
.task-body { display: flex; flex-direction: column; gap: 12px; }

.target-ru { font-size: 1.35rem; font-weight: 700; line-height: 1.3; }
.target-word { font-size: 1.9rem; font-weight: 800; letter-spacing: .01em; }
.target-uz { color: var(--ink-soft); font-size: 1rem; }
.target-uz.small { font-size: .88rem; }
.big-uz { font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.target-wrong { font-size: 1.3rem; font-weight: 700; color: var(--no); }
.q-hint { color: var(--accent); font-weight: 700; }
.stem { font-weight: 800; }
.blank { display: inline-block; min-width: 42px; border-bottom: 3px solid var(--brand); text-align: center; }
.blank-filled { color: var(--brand); font-weight: 800; border-bottom-color: transparent; min-width: 0; }

.speaker-row { display: flex; gap: 8px; flex-wrap: wrap; }
.speaker-row .btn { min-height: 48px; padding: 0 14px; font-size: .92rem; }

.options { display: flex; flex-direction: column; gap: 10px; }
.options-gender, .options-syl { flex-direction: row; flex-wrap: wrap; }
.options-gender .btn-option { flex: 1 1 30%; }
.options-syl .btn-option { flex: 0 0 auto; min-width: 84px; font-size: 1.3rem; font-weight: 800; }
.btn-option { justify-content: flex-start; text-align: left; }
.options-gender .btn-option, .options-syl .btn-option { justify-content: center; text-align: center; }
.options.locked .btn-option { opacity: .65; }
.opt-right { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); opacity: 1 !important; font-weight: 700; }
.opt-wrong { background: var(--no-bg); border-color: var(--no); color: var(--no); opacity: 1 !important; }

.speak-box { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.btn-mic { min-height: 72px; font-size: 1.1rem; background: var(--accent); color: #fff; border-color: transparent; }
.btn-mic.listening { animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }
.speak-status { color: var(--ink-mute); font-size: .88rem; min-height: 1em; }
.btn-done { opacity: .5; }

.fb { border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.fb-ok { background: var(--ok-bg); border: 1px solid var(--ok); }
.fb-no { background: var(--no-bg); border: 1px solid var(--no); }
.fb-title { font-weight: 800; }
.fb-ok .fb-title { color: var(--ok); }
.fb-no .fb-title { color: var(--no); }
.fb-label { color: var(--ink-mute); font-size: .85rem; }
.fb-wrong { text-decoration: line-through; }
.fb-right { font-weight: 800; }
.fb-why, .fb-uz { font-size: .92rem; color: var(--ink-soft); }
.result-slot { display: flex; flex-direction: column; gap: 10px; }

.marks { display: flex; flex-wrap: wrap; gap: 4px; }
.mark { padding: 2px 6px; border-radius: 8px; font-weight: 700; }
.mark-ok { background: transparent; color: var(--ok); }
.mark-ending { background: var(--warn-bg); color: #a15c07; text-decoration: underline; }
.mark-miss { background: var(--no-bg); color: var(--no); }

.build-line {
  min-height: 60px; border: 2px dashed var(--line); border-radius: 14px; padding: 8px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start;
}
.build-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 1rem; font-weight: 600; cursor: pointer;
}
.chip-picked { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.chip-filter { min-height: 44px; font-size: .9rem; }
.chip-on { background: var(--ink); color: var(--bg); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.dialog-title { font-weight: 700; color: var(--ink-soft); }
.dialog-log { display: flex; flex-direction: column; gap: 10px; }
.dline { border-radius: 14px; padding: 10px 12px; }
.dline-client { background: var(--card); border: 1px solid var(--line); }
.dline-master { background: var(--ok-bg); border: 1px solid var(--ok); }
.dwho { font-size: .75rem; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .04em; }
.dtext { font-size: 1.1rem; font-weight: 600; }
.dialog-stage { display: flex; flex-direction: column; gap: 10px; }

.card-result { align-items: stretch; }
.stat-line { display: flex; align-items: baseline; gap: 10px; }
.stat-n { font-size: 1.6rem; font-weight: 800; color: var(--brand); min-width: 64px; }
.stat-l { color: var(--ink-soft); }

/* ---------- словарь ---------- */
.input {
  width: 100%; min-height: var(--tap); padding: 0 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 1rem;
}
.input[type="file"] { padding: 12px; height: auto; }
.input-search { font-size: 1.05rem; }
.tabs { display: flex; gap: 8px; }
.tab { flex: 1; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); font-weight: 700; }
.tab-on { background: var(--ink); color: var(--bg); border-color: transparent; }
.dict-list { display: flex; flex-direction: column; gap: 8px; }
.row { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.row-head { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.row-left { flex: 1; min-width: 0; }
.row-ru { font-size: 1.12rem; font-weight: 700; }
.row-uz { color: var(--ink-soft); font-size: .95rem; }
.row-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge { font-size: .72rem; padding: 3px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-soft); border: 1px solid var(--line); }
.badge-m { color: #1d4ed8; } .badge-f { color: #b4148a; } .badge-n { color: #0f766e; }
.badge-core { border-color: var(--brand); } .badge-work { border-color: var(--accent); } .badge-life { border-color: #b4148a; }
.row-det { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.det-title { font-size: .8rem; color: var(--ink-mute); text-transform: uppercase; font-weight: 700; margin-bottom: 6px; }
.det-line { display: flex; gap: 8px; margin-top: 6px; }
.forms { display: flex; flex-direction: column; }
.form-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.form-row:last-child { border-bottom: 0; }
.form-left { display: flex; flex-direction: column; min-width: 0; }
.form-case { font-size: .85rem; color: var(--ink-soft); }
.form-q { font-size: .76rem; color: var(--ink-mute); }
.form-uz {
  align-self: flex-start; margin-top: 2px; font-size: .74rem; color: var(--accent);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px;
}
.form-val { flex: 0 1 auto; font-weight: 800; font-size: 1.08rem; text-align: right; overflow-wrap: anywhere; }

/* ---------- падежи и ошибки ---------- */
.card-case { border-left: 6px solid var(--brand); }
.case-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.case-ru { font-size: 1.15rem; font-weight: 700; }
.case-q { color: var(--accent); font-weight: 700; }
.case-uz { color: var(--ink-soft); }
.uz-tag { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; font-size: .9rem; }
.card-err { gap: 8px; }
.err-head { display: flex; justify-content: space-between; align-items: baseline; }
.err-tag { font-weight: 700; }
.err-n { color: var(--ink-mute); font-size: .85rem; }
.err-pair { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.err-wrong { color: var(--no); text-decoration: line-through; }
.err-right { color: var(--ok); font-weight: 700; }
.err-why { font-size: .88rem; color: var(--ink-soft); }
.err-why-uz { color: var(--accent); }
.x { text-decoration: none; }
.v { text-decoration: none; }

/* ---------- нижняя навигация ---------- */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; min-height: 62px; border: 0; background: transparent; color: var(--ink-mute);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.nav-icon { font-size: 1.2rem; }
.nav-label { font-size: .68rem; }
.nav-on { color: var(--brand); font-weight: 700; }

.card-profile { text-align: left; cursor: pointer; border: 1px solid var(--line); }
.h2 { margin: 4px 0 2px; font-size: 1.3rem; }

/* ---------- сессия, речь, эхо-повтор ---------- */
.card-speech { gap: 8px; }
.speech-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.speech-val { font-size: 1.15rem; font-weight: 800; }
.bar-speech { background: var(--accent); }
.more-row { display: flex; gap: 8px; flex-wrap: wrap; }
.more-row .btn { flex: 1 1 auto; }

.hud { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud-item {
  font-size: .82rem; color: var(--ink-soft); background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}
.hud-mic { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }
.hud-pause { margin-left: auto; min-height: 40px; width: 44px; padding: 0; font-size: 1rem; }
.hud-stop { min-height: 40px; padding: 0 12px; }
.card-block { border-left: 6px solid var(--accent); }

.shadow-stage { display: flex; flex-direction: column; gap: 12px; }
.shadow-strip { display: flex; flex-wrap: wrap; gap: 6px; min-height: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--ok); }
.dot-no { background: var(--no); }
.card-warn { background: var(--warn-bg); border-color: #e0b356; }
.code-box {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.code-label { font-size: .82rem; color: var(--ink-mute); }
.code-val { font-size: 1.15rem; font-weight: 800; letter-spacing: .04em; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- письменные задания ---------- */
.write-box { display: flex; flex-direction: column; gap: 8px; }
.input-write { font-size: 1.2rem; font-weight: 600; text-align: center; }
.write-hint { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.hint-word {
  font-size: 1.25rem; font-weight: 800;
  border-bottom: 2px dashed var(--ink-mute); padding-bottom: 1px;
}
.subject { font-weight: 800; }
.diff { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; }
.diff-row { font-size: 1.1rem; }
.diff-stem { font-weight: 700; }
.diff-bad { font-weight: 800; color: var(--no); text-decoration: underline; }
.diff-good { font-weight: 800; color: var(--ok); text-decoration: underline; }

/* ---------- аудиорежим ---------- */
.audio-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.audio-stage {
  display: flex; flex-direction: column; gap: 10px; justify-content: center;
  min-height: 190px; padding: 18px 0;
}
.audio-ru { font-size: 1.7rem; line-height: 1.25; }
.audio-uz { font-size: 1.1rem; }
.audio-controls { display: flex; gap: 8px; }
.audio-controls .btn { flex: 1; }
.btn-play { flex: 2 !important; }
.audio-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.chip-label { font-size: .85rem; color: var(--ink-soft); align-self: center; margin-right: 4px; }
.btn-on { border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* ---------- уровни и упрощённая главная ---------- */
.card-level { gap: 10px; }
.lv-top { display: flex; align-items: center; gap: 12px; }
.lv-badge {
  width: 54px; height: 54px; border-radius: 16px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; color: #fff; background: var(--accent);
}
.lv-vip { background: linear-gradient(135deg, #b8860b, #ffd700); color: #3a2c00; }
.lv-legend { background: linear-gradient(135deg, #6d28d9, #a855f7); }
.lv-names { min-width: 0; }
.lv-name { font-size: 1.4rem; font-weight: 800; line-height: 1.15; }
.lv-sub { font-size: .9rem; color: var(--ink-soft); }
.bar-level { background: var(--accent); }
.lv-stats { font-size: 1.05rem; font-weight: 700; }

.card-levelup { align-items: center; text-align: center; gap: 12px; padding: 28px 18px; }
.lv-up-badge { font-size: 4rem; line-height: 1; }
.lv-up-name { font-size: 1.5rem; font-weight: 800; }

.huge {
  width: 100%; border: 0; border-radius: 22px; background: var(--accent); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 30px 16px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.16);
}
.huge:active { transform: scale(.99); }
.huge-icon { font-size: 2.6rem; line-height: 1; }
.huge-title { font-size: 1.9rem; font-weight: 800; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid3 .tile { align-items: center; text-align: center; padding: 16px 6px; }
.grid3 .tile-icon { font-size: 2rem; }
.grid3 .tile-title { font-size: 1rem; }
.grid3 .tile-sub { display: none; }

/* ---------- картинки к словам, категории ---------- */
.row-emoji { font-size: 1.8rem; line-height: 1; margin-right: 10px; flex: none; }
.task-emoji { font-size: 3.4rem; line-height: 1; text-align: center; }
.chips-cats { margin-top: -2px; }
.chips-cats .chip { font-size: .92rem; }
.badge-topic { white-space: nowrap; }

/* лента категорий: один ряд с прокруткой, чтобы не съедать пол-экрана */
.chips-cats {
  display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px;
  padding-bottom: 4px; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips-cats::-webkit-scrollbar { display: none; }
.chips-cats .chip { flex: none; }
