/* ═════════ Qalam — dizayn tizimi ═════════ */
:root {
  --teal: #0E6B5C; --teal-2: #13806E; --deep: #0A3D36; --gold: #E0A526; --gold-2: #B7811A; --cream: #FFF8E7; --rust: #C2410C;
  --green: #16A34A; --red: #DC2626; --amber: #F59E0B;
  --bg: #F7F3EA; --surface: #FFFFFF; --surface-2: #F1EBDD; --text: #1C1917; --muted: #6B6458; --line: #E6DCC8;
  --ok-bg: #DCFCE7; --ok-tx: #166534; --bad-bg: #FEE2E2; --bad-tx: #991B1B;
  --primary: var(--teal); --accent: var(--gold);
  --shadow: 0 1px 2px rgba(28, 25, 23, .05), 0 8px 26px rgba(28, 25, 23, .08);
  --radius: 18px; --radius-sm: 12px;
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-ar: "Noto Naskh Arabic", "Amiri", "Traditional Arabic", "Segoe UI", serif;
  --veil: .55;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0B1412; --surface: #12201D; --surface-2: #1A2C28; --text: #EAE6DC; --muted: #9DB0AA; --line: #24403A;
  --ok-bg: #0F3A24; --ok-tx: #86EFAC; --bad-bg: #431818; --bad-tx: #FCA5A5;
  --primary: #14937E; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); -webkit-font-smoothing: antialiased; position: relative;
}
body.marketing, body.focus { padding-bottom: 0; }

/* ── Jonli fon ── */
#bg-canvas { position: fixed; inset: 0; z-index: -2; pointer-events: none; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--bg); opacity: var(--veil); pointer-events: none; }
body.bg-none::before { opacity: 1; }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 800; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); } h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
[data-theme="dark"] a { color: #5fd3bd; }
button { font-family: inherit; color: inherit; }
kbd { font-family: inherit; }
code { background: var(--surface-2); padding: 0 .3rem; border-radius: 5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.row { display: flex; gap: .5rem; align-items: center; } .row.wrap { flex-wrap: wrap; }
.row-center { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 99; }
.skip:focus { left: 1rem; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
main, main:focus, main:focus-visible { outline: none; }
.warn { color: var(--rust); }
.link { border: 0; background: none; color: var(--primary); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ── Arabcha matn ── */
.ar { font-family: var(--font-ar); direction: rtl; unicode-bidi: isolate; line-height: 1.9; }
.ar-cell { font-family: var(--font-ar); font-size: 1.35rem; direction: rtl; }
.big-ar { font-family: var(--font-ar); font-size: clamp(2.2rem, 9vw, 3.4rem); font-weight: 700; line-height: 1.6; direction: rtl; }
.translit { color: var(--gold-2); font-weight: 700; font-style: italic; }
[data-theme="dark"] .translit { color: var(--gold); }

/* ── Tugmalar ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 2px solid transparent; border-radius: 14px;
  padding: .6rem 1.1rem; font-size: 1rem; font-weight: 800; text-decoration: none; cursor: pointer;
  transition: transform .08s, background .15s, box-shadow .15s; background: var(--surface-2); color: var(--text) !important; white-space: nowrap;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.sm { padding: .3rem .55rem; font-size: .9rem; border-radius: 10px; }
.btn-lg { padding: .85rem 1.5rem; font-size: 1.05rem; }
.btn-primary { background: var(--primary); color: #fff !important; box-shadow: 0 4px 0 var(--deep); }
.btn-primary:active { box-shadow: 0 1px 0 var(--deep); }
.btn-primary:disabled { box-shadow: none; }
.btn-ghost { background: color-mix(in srgb, var(--surface) 70%, transparent); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-light { background: var(--cream); color: var(--deep) !important; }
.btn-ok { background: var(--green); color: #fff !important; box-shadow: 0 4px 0 #15803d; }
.btn-bad { background: var(--red); color: #fff !important; box-shadow: 0 4px 0 #991b1b; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red) !important; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; cursor: pointer; font-size: 1.15rem; text-decoration: none; flex: none; }
.icon-btn:hover { background: var(--surface-2); }

/* ── Yuqori panel va navigatsiya ── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .55rem max(1rem, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--deep) !important; font-weight: 900; font-size: 1.35rem; letter-spacing: -.5px; }
[data-theme="dark"] .brand { color: var(--cream) !important; }
.logo-mark { width: 36px; height: 36px; }
.top-actions { margin-left: auto; display: flex; gap: .5rem; }
.top-nav { display: none; gap: .25rem; margin-left: .5rem; }
.top-nav .nav-item { flex-direction: row; padding: .45rem .75rem; border-radius: 12px; font-size: .95rem; }
.top-stats { margin-left: auto; display: flex; align-items: center; gap: .3rem; }
.stat { display: inline-flex; align-items: center; gap: .25rem; padding: .3rem .6rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .95rem; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: .1rem; text-decoration: none; color: var(--muted) !important; font-weight: 700; font-size: .72rem; padding: .35rem .25rem; flex: 1; }
.nav-item.active { color: var(--primary) !important; }
[data-theme="dark"] .nav-item.active { color: #5fd3bd !important; }
.top-nav .nav-item.active { background: var(--surface-2); }
.nav-ic { position: relative; font-size: 1.3rem; line-height: 1; }
.nav-ic.ar { font-weight: 700; line-height: 1; }
.top-nav .nav-ic { font-size: 1.05rem; }
.dot { position: absolute; top: -6px; right: -12px; background: var(--rust); color: #fff; font-size: .62rem; font-weight: 800; border-radius: 999px; padding: 1px 5px; min-width: 18px; text-align: center; font-family: var(--font); }
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom)); }
.bottomnav:empty { display: none; }
body.focus .topbar, body.focus .bottomnav { display: none; }
@media (min-width: 980px) { .top-nav { display: flex; } .bottomnav { display: none; } body { padding-bottom: 0; } }
@media (max-width: 560px) { .hide-sm { display: none; } .top-stats .icon-btn[href="#/backgrounds"] { display: none; } }

/* ── Sahifa va kartalar ── */
main { max-width: 1080px; margin: 0 auto; padding: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem; box-shadow: var(--shadow); }
.page { max-width: 880px; margin: 0 auto; display: grid; gap: 1rem; }
.page.narrow, .narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.page-title { margin: .5rem 0 0; text-shadow: 0 1px 12px var(--bg); }
.page > p.muted, .page > section > h2 { text-shadow: 0 0 10px var(--bg); }
.grid2 { display: grid; gap: 1rem; }
@media (min-width: 700px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.center-card { text-align: center; max-width: 560px; margin: 1.5rem auto; padding: 2rem 1.25rem; }
.big-emoji { font-size: 3.5rem; line-height: 1; margin-bottom: .75rem; }
.note { background: var(--surface-2); border-radius: var(--radius-sm); padding: .75rem 1rem; }
.note.ok { background: var(--ok-bg); color: var(--ok-tx); }
.banner { background: linear-gradient(135deg, var(--gold), #f2c15a); color: #2b1d02; font-weight: 700; border: 0; }
.inp { width: 100%; font: inherit; font-size: 1.05rem; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .9rem; outline: none; transition: border-color .15s; }
.inp:focus { border-color: var(--teal-2); }
.inp.is-ok { border-color: var(--green); background: var(--ok-bg); }
.inp.is-bad { border-color: var(--red); background: var(--bad-bg); }
.inp-ar, .ar-inp { font-family: var(--font-ar); font-size: 1.4rem; direction: rtl; }
.inp.code { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
textarea.inp { resize: vertical; }
.progress { flex: 1; height: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--teal)); border-radius: 999px; transition: width .4s ease; }

/* ── Landing ── */
.hero { display: grid; gap: 2rem; align-items: center; padding: 1.5rem 0 2.5rem; }
@media (min-width: 860px) { .hero { grid-template-columns: 1.15fr 1fr; padding: 3rem 0 4rem; } }
.hero-text { background: color-mix(in srgb, var(--bg) 70%, transparent); border-radius: var(--radius); padding: 1rem; }
.pill { display: inline-block; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; font-weight: 700; font-size: .9rem; margin-bottom: 1rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 900; letter-spacing: -1px; margin-bottom: 1rem; }
.hl { color: var(--gold-2); }
[data-theme="dark"] .hl { color: var(--gold); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 34rem; }
.hero-cta { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.5rem 0 .75rem; }
.hero-art { position: relative; padding: 1.5rem 1rem; }
.demo { max-width: 400px; margin: 0 auto; transform: rotate(-2deg); text-align: center; }
.demo-word { font-size: 4rem !important; }
.demo-tiles { display: flex; gap: .5rem; justify-content: center; margin: .5rem 0 1rem; }
.demo-fb { background: var(--ok-bg); color: var(--ok-tx); border-radius: var(--radius-sm); padding: .7rem 1rem; font-weight: 800; }
.float-chip { position: absolute; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 999px; padding: .35rem .9rem; font-weight: 800; animation: bob 4s ease-in-out infinite; }
.float-chip.c1 { top: 0; right: 8%; }
.float-chip.c2 { bottom: 0; left: 4%; animation-delay: -2s; color: var(--teal); font-size: 1.2rem; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.section { padding: 2rem 0; }
.sec-title { text-align: center; font-size: clamp(1.5rem, 4vw, 2rem); margin-bottom: .5rem; text-shadow: 0 0 14px var(--bg); }
.ladder { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; align-items: end; margin-top: 1.5rem; }
.step-lvl { text-align: center; }
.step-bar { height: var(--h); background: var(--surface-2); border-radius: 12px 12px 4px 4px; display: grid; place-items: center; color: var(--muted); font-size: 1.1rem; }
.step-lvl.open .step-bar { background: linear-gradient(180deg, var(--gold), var(--teal)); color: #fff; }
.step-name { font-weight: 800; font-size: .8rem; margin-top: .4rem; }
.step-status { font-size: .72rem; color: var(--muted); }
@media (max-width: 520px) { .step-name { font-size: .62rem; } .step-status { font-size: .6rem; } }
.feats { display: grid; gap: 1rem; margin-top: 1.5rem; }
@media (min-width: 640px) { .feats { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .feats { grid-template-columns: repeat(3, 1fr); } }
.feat-ic { font-size: 2rem; margin-bottom: .5rem; }
.feat-ic.ar { color: var(--teal); font-size: 2.6rem; line-height: 1.2; }
.feat p { margin: 0; }
.act-chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1.25rem; }
.act-chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .45rem .9rem; font-weight: 700; }
.faq { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem 1.1rem; margin-top: .6rem; }
.faq summary { font-weight: 800; cursor: pointer; }
.faq p { margin: .6rem 0 0; color: var(--muted); }
.cta-band { text-align: center; background: linear-gradient(135deg, var(--deep), var(--teal)); color: #fff; border-radius: var(--radius); padding: 2.5rem 1rem; margin: 2rem 0; }
.cta-band h2 { font-size: clamp(1.4rem, 4vw, 2rem); margin-bottom: 1.2rem; }
.footer { display: flex; align-items: center; justify-content: center; gap: .6rem; color: var(--muted); font-size: .9rem; padding: 1rem 0 2rem; }
.footer .logo-mark { width: 22px; height: 22px; }

/* ── Onboarding ── */
.onb { max-width: 560px; margin: 1.5rem auto; padding: 1.5rem; display: grid; gap: 1rem; }
.onb-steps { display: flex; gap: .4rem; }
.onb-steps span { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); }
.onb-steps span.on { background: var(--primary); }
.onb-actions { display: flex; justify-content: space-between; align-items: center; margin-top: .5rem; }
.field { display: grid; gap: .35rem; font-weight: 700; }
.field-label { font-weight: 700; margin: .5rem 0 0; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.choice-list { display: grid; gap: .6rem; }
.choice { border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: .8rem 1rem; font-weight: 700; font-size: 1rem; cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--teal-2); }
.choice.sel { border-color: var(--primary); background: color-mix(in srgb, var(--teal) 12%, var(--surface)); }
.choice.row { display: grid; grid-template-columns: 1fr auto auto; gap: 1rem; align-items: center; }
.choice.big { display: flex; gap: 1rem; align-items: center; padding: 1rem; }
.ch-ic { font-size: 2rem; } .ch-ic.ar { color: var(--teal); font-size: 2.4rem; line-height: 1; }

/* ── Dashboard ── */
.dash { display: grid; gap: 1rem; max-width: 900px; margin: 0 auto; }
.hello { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: linear-gradient(135deg, var(--deep), var(--teal)); color: #fff; border: 0; }
.hello h1 { font-family: var(--font-ar), var(--font); margin-bottom: .25rem; }
.hello .muted { color: #cfe7e1; }
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: rgba(255, 255, 255, .2); }
.ring-fg { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.ring-txt { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.05; }
.ring-txt b { font-size: 1.3rem; } .ring-txt span { font-size: .7rem; opacity: .85; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .5rem; text-align: center; display: grid; gap: .05rem; }
.tile-ic { font-size: 1.3rem; } .tile b { font-size: 1.25rem; } .tile span:last-child { font-size: .75rem; color: var(--muted); }
.continue { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; border: 2px solid var(--gold); }
.continue .btn { grid-column: 1 / -1; }
@media (min-width: 640px) { .continue { grid-template-columns: auto 1fr auto; } .continue .btn { grid-column: auto; } }
.cont-ic { font-size: 2.4rem; width: 64px; height: 64px; display: grid; place-items: center; background: var(--surface-2); border-radius: 18px; }
.cont-txt h2 { margin: .1rem 0 .2rem; } .cont-txt p { margin: 0; }
.big-num { font-size: 2rem; font-weight: 900; color: var(--primary); }
.wod-word { font-size: 2rem; font-weight: 700; display: flex; align-items: center; gap: .25rem; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.wk { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; height: 160px; align-items: end; padding-top: 1rem; }
.wk-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .25rem; }
.wk-bar { width: 100%; max-width: 40px; background: var(--surface-2); border-radius: 8px 8px 4px 4px; transition: height .6s ease; }
.wk-bar.hit { background: linear-gradient(180deg, var(--gold), var(--teal)); }
.wk-col.today .wk-bar:not(.hit) { background: color-mix(in srgb, var(--gold) 50%, var(--surface-2)); }
.wk-val { font-size: .72rem; color: var(--muted); font-weight: 700; min-height: 1em; }
.wk-lbl { font-size: .78rem; font-weight: 800; color: var(--muted); }
.wk-col.today .wk-lbl { color: var(--text); }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; margin-top: .5rem; }
.tool { display: grid; gap: .1rem; padding: .9rem; border-radius: var(--radius-sm); background: var(--surface-2); text-decoration: none; color: var(--text) !important; transition: transform .1s; }
.tool:hover { transform: translateY(-2px); }
.tool > span { font-size: 1.5rem; } .tool > span.ar { color: var(--teal); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; margin-top: .5rem; }
.badge { display: grid; justify-items: center; text-align: center; gap: .15rem; padding: .8rem .5rem; border-radius: var(--radius-sm); background: var(--surface-2); opacity: .45; filter: grayscale(1); }
.badge.got { opacity: 1; filter: none; background: color-mix(in srgb, var(--gold) 15%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); }
.badge span { font-size: 1.8rem; } .badge b { font-size: .85rem; } .badge small { font-size: .7rem; color: var(--muted); }

/* ── Darslar xaritasi ── */
.level-block { display: grid; gap: .75rem; margin-bottom: 1rem; }
.level-head { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; background: color-mix(in srgb, var(--surface) 85%, transparent); border-radius: var(--radius); padding: .6rem .8rem; }
.level-head h2, .level-head p { margin: 0; }
.lvl-badge { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(135deg, var(--teal), var(--deep)); color: #fff; font-weight: 900; font-size: 1.2rem; flex: none; }
.lvl-badge.sm { width: 40px; height: 40px; font-size: .95rem; border-radius: 12px; }
.lvl-prog { margin-left: auto; display: flex; align-items: center; gap: .5rem; min-width: 160px; }
.level-block.soon { opacity: .7; } .level-block.soon .lvl-badge { background: var(--muted); }
.soon-tag { margin-left: auto; font-weight: 800; color: var(--muted); }
.module-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.module-head h3 { margin: 0; flex: 1; } .m-emoji { font-size: 1.6rem; }
.path { display: grid; gap: .5rem; }
.node { display: flex; align-items: center; gap: .8rem; padding: .7rem .8rem; border-radius: var(--radius-sm); border: 2px solid var(--line); text-decoration: none; color: var(--text) !important; background: var(--surface); transition: transform .1s, border-color .15s; }
a.node:hover { transform: translateX(3px); border-color: var(--teal-2); }
.node-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 1.25rem; flex: none; font-weight: 900; }
.node-txt { display: grid; } .node-txt .ar { line-height: 1.4; }
.node.done .node-ic { background: var(--green); color: #fff; }
.node.current { border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 25%, transparent); }
.node.current .node-ic { background: var(--primary); color: #fff; animation: pulse 2s infinite; }
.node.locked { opacity: .55; cursor: not-allowed; }
.node.test.done .node-ic { background: var(--gold); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(224, 165, 38, .6); } 50% { box-shadow: 0 0 0 8px rgba(224, 165, 38, 0); } }

/* ── Dars ── */
.lesson { max-width: 680px; margin: 0 auto; min-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.lesson-top { display: flex; align-items: center; gap: .75rem; padding: .25rem 0 1rem; position: relative; }
.lesson-xp { font-weight: 800; font-size: .95rem; min-width: 54px; text-align: right; }
.xp-float { position: absolute; right: 0; top: 2rem; font-weight: 900; color: var(--gold-2); animation: floatUp 1.1s ease forwards; pointer-events: none; }
@keyframes floatUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-28px); } }
.lesson-body { flex: 1; padding: 1rem; margin-bottom: 1rem; background: color-mix(in srgb, var(--bg) 78%, transparent); border-radius: var(--radius); }
.lesson-body.enter { animation: enter .25s ease; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
.lesson-foot { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: .75rem; flex-wrap: wrap; margin: 0 -1rem; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); min-height: 76px; }
.lesson-foot .btn-lg { min-width: 180px; }
.lesson-foot.ok { background: var(--ok-bg); color: var(--ok-tx); border-top-color: transparent; }
.lesson-foot.bad { background: var(--bad-bg); color: var(--bad-tx); border-top-color: transparent; }
.lesson-foot #ex-skip { margin-right: auto; }
.foot-hint { margin: 0 auto 0 0; color: var(--muted); font-size: .9rem; }
.fb { flex: 1; min-width: 200px; }
.fb-title { font-size: 1.2rem; font-weight: 900; }
.fb-expl { font-size: .92rem; opacity: .9; margin-top: .2rem; }
@media (max-width: 560px) { .lesson-foot .btn-lg { width: 100%; } }
.ex-label { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .5px; font-size: .78rem; margin-bottom: .6rem; }
.q { font-size: clamp(1.25rem, 4.5vw, 1.6rem); margin-bottom: 1.25rem; display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.q .ar { font-size: 1.35em; font-weight: 700; }
.q[dir="rtl"] { justify-content: flex-start; }
.uz-q { color: var(--primary); }
.blank { display: inline-block; min-width: 70px; padding: 0 .5rem; border-bottom: 3px dashed var(--gold); color: var(--muted); text-align: center; }
.blank.filled { color: var(--primary); border-bottom-style: solid; }
.options { display: grid; gap: .6rem; }
@media (min-width: 560px) { .options { grid-template-columns: 1fr 1fr; } }
.opt, .chip { display: flex; align-items: center; gap: .75rem; text-align: left; border: 2px solid var(--line); border-bottom-width: 4px; background: var(--surface); border-radius: var(--radius-sm); padding: .85rem 1rem; font-size: 1.08rem; font-weight: 700; cursor: pointer; transition: border-color .12s, background .12s, transform .08s; }
.opt-ar span, .chip.opt-ar span { font-size: 1.45rem; flex: 1; text-align: right; }
.opt:hover:not(:disabled), .chip:hover:not(:disabled) { border-color: var(--teal-2); }
.opt:active:not(:disabled), .chip:active:not(:disabled) { transform: translateY(2px); }
.opt:disabled, .chip:disabled { cursor: default; }
.opt kbd, .chip kbd { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 7px; font-size: .8rem; color: var(--muted); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: .6rem; }
.chip.sel { border-color: var(--primary); background: color-mix(in srgb, var(--teal) 14%, var(--surface)); }
.opt.is-ok, .chip.is-ok { border-color: var(--green); background: var(--ok-bg); color: var(--ok-tx); }
.opt.is-bad, .chip.is-bad { border-color: var(--red); background: var(--bad-bg); color: var(--bad-tx); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.tf-row .opt { justify-content: center; padding: 1.1rem; }
.timer { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.timer-bar { height: 100%; background: var(--gold); transform-origin: left; animation: timer linear forwards; }
@keyframes timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.listen-box { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: .5rem 0 1.5rem; }
.play { border: 0; cursor: pointer; border-radius: 50%; display: grid; place-items: center; transition: transform .1s; }
.play:active { transform: scale(.94); }
.play.big { width: 96px; height: 96px; font-size: 2.4rem; background: var(--primary); color: #fff; box-shadow: 0 6px 0 var(--deep); }
.play.slow { width: 56px; height: 56px; font-size: 1.5rem; background: var(--surface-2); }
.answer-input { display: flex; gap: .5rem; align-items: center; }
.answer-input .inp { padding: .7rem 1rem; }
.kb-wrap { margin-top: .75rem; }
.kb { display: grid; gap: .35rem; user-select: none; }
.kb-row { display: flex; gap: .3rem; justify-content: center; }
.kb-key { flex: 1; max-width: 48px; min-width: 0; height: 48px; border-radius: 9px; border: 1px solid var(--line); border-bottom-width: 3px; background: var(--surface); font-family: var(--font-ar); font-size: 1.3rem; cursor: pointer; padding: 0; transition: background .1s, transform .05s; }
.kb-key:active { transform: translateY(2px); }
.kb-key.wide { max-width: 160px; flex: 3; font-family: var(--font); font-size: .85rem; font-weight: 700; }
.kb-row.harakat .kb-key { background: color-mix(in srgb, var(--gold) 14%, var(--surface)); }
.kb-key.in-set { background: color-mix(in srgb, var(--teal) 16%, var(--surface)); border-color: var(--teal-2); }
.kb-key.hint { background: var(--gold); color: #fff; border-color: var(--gold); }
.kb-key.ok { background: var(--green); color: #fff; } .kb-key.bad { background: var(--red); color: #fff; }
@media (max-width: 420px) { .kb-key { height: 42px; font-size: 1.1rem; border-radius: 7px; } .kb-row { gap: .2rem; } }
.kb-target { text-align: center; margin-bottom: 1rem; }
.kb-letter { font-size: 5rem; font-weight: 700; line-height: 1.3; color: var(--primary); }
.build-line { min-height: 64px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .5rem 0; margin-bottom: 1.25rem; }
.build-line.is-ok { border-color: var(--green); } .build-line.is-bad { border-color: var(--red); }
.build-bank { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.tok { border: 2px solid var(--line); border-bottom-width: 4px; background: var(--surface); border-radius: 12px; padding: .35rem .9rem; font-size: 1.08rem; font-weight: 700; cursor: pointer; }
.tok.ar { font-size: 1.5rem; font-weight: 400; line-height: 1.7; }
.tok:hover:not(:disabled) { border-color: var(--teal-2); }
.tok.used { visibility: hidden; }
.letter-tok { min-width: 54px; }
.small-tok { font-size: 1.1rem !important; padding: .1rem .6rem; }
.spell-word { font-size: 4rem; text-align: center; min-height: 1.8em; padding: .5rem; border-radius: var(--radius); background: var(--surface); border: 2px dashed var(--line); margin-bottom: .75rem; color: var(--deep); }
[data-theme="dark"] .spell-word { color: var(--cream); }
.spell-word.is-ok { border-color: var(--green); background: var(--ok-bg); } .spell-word.is-bad { border-color: var(--red); background: var(--bad-bg); }
.spell-tiles { display: flex; gap: .3rem; justify-content: center; min-height: 2.6rem; margin-bottom: .75rem; flex-wrap: wrap; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.mcol { display: grid; gap: .6rem; align-content: start; }
.mitem { border: 2px solid var(--line); border-bottom-width: 4px; background: var(--surface); border-radius: var(--radius-sm); padding: .6rem; font-size: 1rem; font-weight: 700; cursor: pointer; min-height: 58px; transition: all .12s; }
.mitem-ar .ar { font-size: 1.45rem; font-weight: 400; }
.mitem.sel { border-color: var(--primary); background: color-mix(in srgb, var(--teal) 16%, var(--surface)); }
.mitem.matched { border-color: var(--green); background: var(--ok-bg); color: var(--ok-tx); opacity: .6; cursor: default; }
.mitem.wrong { border-color: var(--red); background: var(--bad-bg); animation: shake .35s; }
.flip { perspective: 1000px; height: 260px; cursor: pointer; margin: .5rem 0 1rem; outline: none; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: var(--radius); display: grid; place-content: center; text-align: center; gap: .3rem; padding: 1rem; border: 2px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.flip-back { transform: rotateY(180deg); background: linear-gradient(135deg, var(--deep), var(--teal)); color: #fff; border: 0; }
.flip-back .muted { color: #cfe7e1; } .flip-back .ar { font-size: 1.6rem; }
.flip:focus-visible .flip-face { outline: 3px solid var(--gold); }
.big-uz { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; }
.trace-head { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.trace { position: relative; margin: .5rem auto; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow); touch-action: none; }
.trace canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.trace-draw { cursor: crosshair; }

/* Nazariya */
.theory { padding: 1.4rem; } .theory-emoji { font-size: 2.4rem; }
.theory-html { font-size: 1.04rem; } .theory-html h3 { margin-top: 1rem; } .theory-html ul { padding-left: 1.2rem; }
.tbl { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; font-size: 1rem; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: .45rem .55rem; text-align: left; vertical-align: middle; }
.tbl th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; }
.letters-tbl .forms { font-size: 1.5rem; white-space: nowrap; }
.say { border: 0; background: color-mix(in srgb, var(--teal) 12%, transparent); color: var(--primary); font: inherit; font-weight: 800; border-radius: 8px; padding: .05rem .45rem; cursor: pointer; }
.say.ar { font-family: var(--font-ar); font-weight: 400; font-size: 1.3rem; }
.say.big-say { font-size: 2rem; }
.say::after { content: " 🔊"; font-size: .6em; font-family: var(--font); }
.say:hover { background: color-mix(in srgb, var(--teal) 25%, transparent); }
.tip { background: color-mix(in srgb, var(--gold) 14%, var(--surface)); border-left: 4px solid var(--gold); border-radius: 10px; padding: .8rem 1rem; margin-top: .75rem; }
.dialog p { margin: .3rem 0; }

/* ── Natijalar ── */
.result { max-width: 560px; margin: 1.5rem auto; text-align: center; padding: 2rem 1.25rem; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1.25rem 0; }
.res-stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: .8rem .4rem; display: grid; }
.res-stats b { font-size: 1.4rem; } .res-stats span { font-size: .8rem; color: var(--muted); }
.res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: 1.25rem; }
.mistakes { text-align: left; background: var(--bad-bg); border-radius: var(--radius-sm); padding: .8rem 1rem; }
.mistakes summary { font-weight: 800; cursor: pointer; color: var(--bad-tx); }
.mistakes ul { list-style: none; padding: 0; margin: .6rem 0; display: grid; gap: .4rem; }
.mistakes li { display: flex; justify-content: space-between; gap: 1rem; background: var(--surface); border-radius: 8px; padding: .45rem .7rem; align-items: center; }
.mistakes li b { color: var(--ok-tx); text-align: right; }
.lvl-big { display: inline-grid; place-items: center; width: 110px; height: 110px; border-radius: 28px; background: linear-gradient(135deg, var(--gold), var(--teal)); color: #fff; font-size: 2.6rem; font-weight: 900; margin-bottom: 1rem; }
.pl-bars { display: grid; gap: .5rem; margin: 1rem 0; }
.pl-bar { display: grid; grid-template-columns: 34px 1fr 40px; align-items: center; gap: .6rem; font-weight: 800; }

/* ── Alifbo ── */
.alpha-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.alpha-card { display: grid; justify-items: center; gap: 0; padding: .5rem .3rem; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--surface); cursor: pointer; transition: transform .1s, border-color .15s; position: relative; }
.alpha-card:hover { transform: translateY(-2px); border-color: var(--teal-2); }
.alpha-card.sel { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 30%, transparent); }
.alpha-card.traced::after { content: "✓"; position: absolute; top: 4px; left: 6px; color: var(--green); font-weight: 900; font-size: .8rem; }
.alpha-letter { font-size: 2.4rem; color: var(--deep); line-height: 1.5; }
[data-theme="dark"] .alpha-letter { color: var(--cream); }
.alpha-name { font-weight: 800; font-size: .85rem; }
.letter-detail { display: grid; gap: .75rem; }
.ld-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.ld-big { font-size: 5rem; line-height: 1.3; color: var(--teal); }
.forms-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.form-box { display: grid; justify-items: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem; }
.form-box .ar { font-size: 2.4rem; }
.pill-mini { display: inline-block; font-size: .75rem; background: var(--surface-2); border-radius: 999px; padding: .1rem .5rem; }

/* ── Takrorlash ── */
.review-hero { display: flex; align-items: center; gap: 1rem; } .review-hero p { margin: 0; }
.mode-card { text-align: left; cursor: pointer; font: inherit; display: grid; gap: .35rem; justify-items: start; transition: transform .1s, border-color .15s; }
.mode-card:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--teal-2); }
.mode-card:disabled { opacity: .6; cursor: not-allowed; }
.mode-ic { font-size: 2rem; }
.srs-card { text-align: center; padding: 2.5rem 1rem; display: grid; gap: 1rem; justify-items: center; margin-top: .5rem; }
.srs-answer { border-top: 2px dashed var(--line); padding-top: 1rem; width: 100%; }
.srs-actions { margin-top: 1rem; display: grid; }
.srs-grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.grade { flex-direction: column; gap: 0; padding: .7rem .3rem; white-space: normal; }
.grade small { font-weight: 600; font-size: .72rem; opacity: .8; }
.g1 { background: var(--bad-bg); color: var(--bad-tx) !important; }
.g3 { background: color-mix(in srgb, var(--gold) 20%, var(--surface)); }
.g5 { background: var(--ok-bg); color: var(--ok-tx) !important; }

/* ── Lug'at ── */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; flex-wrap: wrap; justify-self: start; }
.seg button { border: 0; background: transparent; padding: .5rem .8rem; border-radius: 9px; font-weight: 800; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.cat-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-s { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .3rem .75rem; font-weight: 700; font-size: .85rem; cursor: pointer; }
.chip-s.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.wrow { display: grid; grid-template-columns: auto minmax(110px, 1fr) 1.2fr auto auto; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.wrow:last-child { border-bottom: 0; }
.w-ar { display: grid; justify-items: end; } .w-ar .ar { font-size: 1.45rem; font-weight: 400; line-height: 1.6; text-align: right; }
.w-uz { font-size: .95rem; }
.root-h { font-size: 1.5rem; display: flex; gap: .5rem; align-items: baseline; }
.star { color: var(--gold); font-size: 1.4rem; } .star.on { color: var(--gold); }
.str { display: inline-flex; gap: 2px; } .str i { width: 6px; height: 14px; border-radius: 2px; background: var(--surface-2); } .str i.on { background: var(--green); }
@media (max-width: 560px) { .wrow { grid-template-columns: auto 1fr auto; } .w-uz { grid-column: 2; } .wrow .str { display: none; } }

/* ── Grammatika ── */
.gram summary { display: flex; align-items: center; gap: .6rem; cursor: pointer; flex-wrap: wrap; list-style: none; }
.gram summary::-webkit-details-marker { display: none; }
.gram summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .2s; }
.gram[open] summary::after { transform: rotate(180deg); }
.gram[open] summary { margin-bottom: .75rem; }
.gram .btn { margin-top: .75rem; }

/* ── Fonlar galereyasi ── */
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin: .5rem 0 1rem; }
.bg-tile { position: relative; height: 92px; border-radius: var(--radius-sm); border: 3px solid transparent; cursor: pointer; display: flex; align-items: flex-end; padding: .4rem; box-shadow: var(--shadow); overflow: hidden; }
.bg-tile span { background: rgba(0, 0, 0, .55); color: #fff; font-weight: 800; font-size: .8rem; border-radius: 8px; padding: .15rem .45rem; }
.bg-tile em { position: absolute; top: .35rem; right: .35rem; font-style: normal; font-size: .7rem; font-weight: 800; background: var(--gold); color: #2b1d02; border-radius: 6px; padding: 0 .35rem; }
.bg-tile.on { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 40%, transparent); }
.bg-tile.on::after { content: "✓"; position: absolute; top: .3rem; left: .45rem; color: #fff; font-weight: 900; text-shadow: 0 1px 3px #000; }

/* ── Sozlamalar ── */
.form { display: grid; gap: 1rem; }
.switch { display: flex; align-items: center; gap: .6rem; font-weight: 700; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--primary); }
input[type="range"] { accent-color: var(--primary); }

/* ── Admin ── */
.admin { display: grid; gap: 1rem; max-width: 980px; margin: 0 auto; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.admin-head h1 { margin: 0; }
.admin-tabs { display: flex; gap: .4rem; flex-wrap: wrap; }
.admin-tabs a { text-decoration: none; padding: .5rem .9rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 800; color: var(--text) !important; }
.admin-tabs a.on { background: var(--primary); color: #fff !important; border-color: var(--primary); }
.admin-body { display: grid; gap: 1rem; }
.ad-mod { margin-top: .75rem; } .ad-mod h4 { margin: 0 0 .4rem; }
.ad-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .45rem .5rem; border-radius: 10px; border: 1px solid var(--line); margin-bottom: .35rem; background: var(--surface); }
.ad-row .ar { font-size: 1.3rem; }
.ad-row.is-hidden { opacity: .5; }
.ad-actions { margin-left: auto; display: flex; gap: .25rem; }
.tag { font-size: .72rem; font-weight: 800; border-radius: 6px; padding: .05rem .45rem; background: var(--surface-2); color: var(--muted); }
.tag-custom { background: var(--ok-bg); color: var(--ok-tx); } .tag-edited { background: color-mix(in srgb, var(--gold) 25%, var(--surface)); color: #7a4a12; }
.preview { background: var(--surface-2); }
.ad-msg { color: var(--red); font-weight: 700; min-height: 1em; }
.admin-login .form { margin: 1rem 0; }

/* ── Toast va konfetti ── */
#toast { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: .5rem; width: min(92vw, 440px); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: .75rem 1rem; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow); animation: toastIn .25s ease; transition: opacity .35s, transform .35s; text-align: center; }
.toast.badge { background: linear-gradient(135deg, var(--gold), var(--rust)); color: #fff; }
.toast.bad { background: var(--red); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall 2.6s ease-in forwards; }
@keyframes fall { to { top: 105%; transform: rotate(720deg) translateX(40px); } }
@media (prefers-reduced-motion: reduce) {
  *:not(.timer-bar), *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
