/* Nahfaz — ilova uslubi (yangi dizayn: «Arab tili Ustoz — yangi dizayn.pdf»).
   Ranglar dizayndan olingan: qorong'i fon, firuza urg'u, yumshoq kartochkalar. Yorug' mavzu — shu tuzilmaning
   mos nusxasi (tizim mavzusiga qarab). Telegram mavzu ranglari ishlatilmaydi: dizayn hamma joyda bir xil bo'lsin. */

:root {
  color-scheme: light dark;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #eceff3;        /* ikonka qutisi, kichik tugma, belgi */
  --text: #0e1116;
  --hint: #66707c;
  --tint: rgba(110, 122, 138, 0.14);
  --line: #e1e5ea;
  --brand: 15 138 119;         /* firuza — asosiy rang (r g b) */
  --accent: rgb(var(--brand));
  --on-accent: #ffffff;
  --danger: #d9453a;
  --ok: #16a34a;
  --hero: #13463f;
  --hero-mark: #26554d;
  --radius: 20px;
  --font-ui: "Manrope", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ar: "Noto Naskh Arabic", "Amiri", "Scheherazade New", "Geeza Pro", "Traditional Arabic", "Segoe UI", serif;
  --top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --app-h: 100dvh;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #171c22;
    --surface-2: #1f232c;
    --text: #edf1f4;
    --hint: #8c96a2;
    --tint: rgba(140, 150, 165, 0.14);
    --line: #232a33;
    --brand: 52 194 168;       /* #34c2a8 */
    --on-accent: #08241f;
    --danger: #f0857a;
  }
}
/* bo'lim ranglari (r g b): kartochka ichidagi progress va chip uchun */
.c-sarf { --c: 52 194 168; }
.c-nahv { --c: 52 194 168; }
.c-lugat { --c: 52 194 168; }
.c-suhbat { --c: 52 194 168; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
svg { width: 1.25em; height: 1.25em; flex: none; } /* o'lchamsiz ikonkalar 0×0 bo'lib qolmasin; aniqlari pastda */
.num svg { width: 16px; height: 16px; }
.chev svg { width: 18px; height: 18px; }
.tools svg { width: 19px; height: 19px; }
.ar { font-family: var(--font-ar); }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- ekran ---------- */
#app { height: var(--app-h); max-width: 760px; margin: 0 auto; position: relative; }
.screen {
  height: 100%; display: flex; flex-direction: column; background: var(--bg);
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pad { padding: 12px 16px calc(24px + var(--bottom)); }

.topbar {
  display: flex; align-items: center; gap: 4px; padding: calc(8px + var(--top)) 12px 8px 12px;
  background: var(--bg); min-height: 60px;
}
.topbar .grow { flex: 1; min-width: 0; padding: 0 6px; }
.topbar .ttl { font-weight: 700; font-size: 18px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12.5px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .aside { color: var(--hint); font-size: 14px; font-variant-numeric: tabular-nums; padding-right: 8px; flex: none; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--text);
}
.icon-btn:active { background: var(--tint); }
.icon-btn svg { width: 22px; height: 22px; }
/* kvadrat ikonka tugmasi (profil kartasi: tahrirlash, nusxalash) */
.sq-btn { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text); }
.sq-btn:active { filter: brightness(.9); }
.sq-btn svg { width: 20px; height: 20px; }
/* ikonka qutisi: kartochka va qatorlarning chap tomonida */
.ibox { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--hint); }
.ibox svg { width: 21px; height: 21px; }
.ibox.danger { background: rgb(240 133 122 / .13); color: var(--danger); }
.ibox.brand { background: rgb(var(--brand) / .14); color: var(--accent); }

/* ---------- bosh sahifa ---------- */
.hello { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + var(--top)) 20px 6px; }
.hello p { margin: 0; color: var(--hint); font-size: 14px; }
.hello h1 { margin: 2px 0 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: rgb(var(--brand) / .18); color: var(--accent); overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.hero {
  margin: 16px 16px 6px; padding: 20px 20px 22px; border-radius: 26px; color: #fff; position: relative; overflow: hidden;
  background: var(--hero);
}
.hero .mark {
  position: absolute; right: 18px; top: -4px; font: 92px/1.3 var(--font-ar); color: var(--hero-mark); pointer-events: none;
}
.hero small { position: relative; display: block; font-size: 12.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #8ee0cf; }
.hero h2 { position: relative; margin: 6px 0 4px; font-size: 24px; line-height: 1.2; font-weight: 800; max-width: 88%; }
.hero p { position: relative; margin: 0 0 16px; font-size: 14.5px; color: rgb(255 255 255 / .82); }
.hero .btn { position: relative; border-radius: 16px; min-height: 48px; padding: 10px 22px; background: #34c2a8; color: #08241f; }
.hero .btn svg { width: 18px; height: 18px; }
.h-title { margin: 22px 20px 6px; font-size: 18px; font-weight: 700; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 8px 16px; }
.tile {
  text-align: left; background: var(--surface); border-radius: var(--radius); padding: 16px; min-height: 160px;
  display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); position: relative;
  transition: transform .12s ease;
}
.tile:active { transform: scale(.98); }
.tile .ibox { margin-bottom: 10px; }
.tile b { font-size: 17px; line-height: 1.2; font-weight: 700; }
.tile .meta { font-size: 13.5px; color: var(--hint); line-height: 1.3; }
.tile .bar { margin-top: auto; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.tile .bar i { display: block; height: 100%; min-width: 5px; background: var(--accent); border-radius: 3px; }
.strip { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 4px 16px 8px; }
.pill {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 18px; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
}
.pill .ibox { width: 32px; height: 32px; border-radius: 0; background: none; color: var(--hint); }
.pill small { display: block; font-size: 12.5px; color: var(--hint); line-height: 1.2; }
.pill b { display: block; font-size: 15px; line-height: 1.25; font-weight: 700; }
.foot { padding: 6px 24px 0; color: var(--hint); font-size: 12.5px; line-height: 1.5; text-align: center; }

/* ---------- tugmalar, maydonlar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px;
  border-radius: 16px; font-weight: 700; background: var(--accent); color: var(--on-accent);
}
.btn:active { filter: brightness(.92); }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: rgb(240 133 122 / .13); color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.field {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 12px 14px;
  font-size: 16px; min-height: 48px; resize: none;
}
.field::placeholder { color: var(--hint); }
.field:focus { outline: 2px solid rgb(var(--brand) / .5); border-color: transparent; }
.lbl { display: block; margin: 14px 2px 6px; font-size: 12.5px; color: var(--hint); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; margin: 8px 16px; }
.card .row + .row { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 14px; padding: 14px; width: 100%; text-align: left; font-weight: 600; }
.row .tx { flex: 1; min-width: 0; }
.row .sub { display: block; font-size: 13px; color: var(--hint); margin-top: 1px; font-weight: 500; }
.row:active { background: var(--tint); }
.row .chev { color: var(--hint); flex: none; display: grid; place-items: center; }
.row.danger { color: var(--danger); }
.h-sec { margin: 22px 22px 6px; font-size: 12.5px; color: var(--hint); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; display: flex; justify-content: space-between; gap: 12px; }
.h-sec .aside { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 13px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 4px; gap: 4px; margin: 8px 16px; }
.seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 6px; border-radius: 14px; font-size: 15px; font-weight: 700; color: var(--text); }
.seg button svg { width: 18px; height: 18px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.note { margin: 6px 22px; color: var(--hint); font-size: 13px; line-height: 1.5; }
/* almashtirgich (kunlik eslatma) */
.switch { width: 52px; height: 30px; border-radius: 15px; background: #2d3542; position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(22px); }
@media (prefers-color-scheme: light) { .switch:not(.on) { background: #c9d0d8; } }
/* profil kartasi */
.who { display: flex; align-items: center; gap: 12px; padding: 14px; }
.who .avatar { width: 56px; height: 56px; font-size: 22px; }
.who b { font-size: 19px; font-weight: 800; line-height: 1.2; }
.who .sub { font-size: 14px; }
.who .tx { min-width: 0; }
.who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offline-note { margin: 0 16px 12px; padding: 10px 12px; border-radius: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgb(217 119 6 / .12); border: 1px solid rgb(217 119 6 / .4); font-size: 13.5px; line-height: 1.4; }
.offline-note span { flex: 1 1 200px; }
.offline-note .btn { min-height: 36px; padding: 5px 12px; border-radius: 12px; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter.warn i { background: #d97706; }
.meter.full i { background: var(--danger); }

/* ---------- birinchi ochilish ekranlari (rozilik, hisob ochish) ---------- */
.gate { height: 100%; display: flex; flex-direction: column; padding: calc(56px + var(--top)) 24px calc(20px + var(--bottom)); gap: 12px; overflow-y: auto; animation: fade .18s ease-out; }
.gate .ibox { width: 76px; height: 76px; border-radius: 26px; background: var(--surface); border: 1px solid var(--line); color: var(--text); margin-bottom: 18px; }
.gate .ibox svg { width: 34px; height: 34px; }
.gate h2 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; }
.gate > p { margin: 0; color: var(--hint); font-size: 16px; line-height: 1.5; }
.gate .info { display: flex; gap: 14px; align-items: flex-start; margin-top: 12px; padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); font-size: 15px; line-height: 1.45; }
.gate .info svg { width: 22px; height: 22px; margin-top: 1px; color: var(--hint); }
.gate .grow { flex: 1; min-height: 12px; }
.gate .btn { width: 100%; }
.gate .link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; color: var(--accent); font-weight: 600; font-size: 15px; }
.gate .link svg { width: 17px; height: 17px; }
.gate .err { color: var(--danger); font-size: 13.5px; margin: 0; min-height: 1.2em; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: 100%; }
.messages { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.msg { max-width: 92%; border-radius: 18px; padding: 10px 14px; position: relative; word-wrap: break-word; }
.msg.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; white-space: pre-wrap; max-width: 86%; }
.msg.me img { display: block; max-width: 220px; max-height: 220px; border-radius: 10px; margin-bottom: 6px; }
.msg.act {
  align-self: center; background: var(--tint); color: var(--hint); font-size: 13px; padding: 5px 12px; border-radius: 999px;
  max-width: 96%; text-align: center;
}
.msg.err { align-self: stretch; max-width: 100%; background: rgba(220, 38, 38, .1); color: var(--text); border: 1px solid rgba(220, 38, 38, .35); font-size: 14.5px; }
.msg.err .btn { margin-top: 8px; min-height: 38px; padding: 6px 14px; }
.msg.note-msg { align-self: stretch; max-width: 100%; background: rgb(217 119 6 / .12); border: 1px solid rgb(217 119 6 / .4); font-size: 14.5px; }
.tools { display: flex; gap: 2px; margin: 6px -6px -4px; }
.tools button { padding: 4px 8px; border-radius: 8px; color: var(--hint); font-size: 15px; }
.tools button:active { background: var(--tint); }
.tools button[aria-pressed="true"] { color: var(--accent); }
/* An-Na'im: javob ostidagi kitob sahifasi tugmalari va to'liq ekranda ko'rish */
.pages { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.lbl-inline { font-size: 12.5px; color: var(--hint); }
.chip.sm { padding: 4px 10px; font-size: 13px; }
.page-view { display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(0, 0, 0, .9); }
.page-body { max-width: 100%; max-height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.page-body img { display: block; max-width: none; width: 100%; height: auto; background: #fff; border-radius: 6px; cursor: zoom-in; }
.page-body.zoom img { width: 230%; cursor: zoom-out; }   /* bosilganda yirik: siljitib o'qiladi */
.page-close { position: fixed; top: calc(8px + var(--top)); right: 10px; z-index: 1; background: rgba(0, 0, 0, .55); color: #fff; }
.book-inline { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.book-inline-page { border-radius: 12px; overflow: hidden; background: #fff; }
.book-inline-page img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.book-inline-page small { display: block; padding: 4px 10px; color: #667; background: #f1f1f1; font-size: 12px; }
.typing { display: inline-flex; gap: 5px; align-items: center; padding: 6px 2px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--hint); opacity: .5; animation: dot 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .18s; } .typing i:nth-child(3) { animation-delay: .36s; }
@keyframes dot { 0%, 80%, 100% { transform: scale(.7); opacity: .35; } 40% { transform: scale(1); opacity: .9; } }
.typing-note { font-size: 12.5px; color: var(--hint); margin-top: 2px; }
/* Javob oqim bilan kelayotganda: matn oxirida yonib-o'chadigan kursor */
.msg.live .fmt:empty::after, .msg.live .fmt > :last-child::after { content: "▍"; color: var(--hint); margin-inline-start: 2px; animation: pulse 1s steps(2) infinite; }
.intro { margin: auto 0; padding: 18px 8px; text-align: center; }
.intro .big { font-size: 46px; line-height: 1; }
.intro h2 { margin: 10px 0 6px; font-size: 20px; }
.intro p { margin: 0 auto 14px; color: var(--hint); max-width: 30em; font-size: 14.5px; }
.intro .actions { display: flex; flex-direction: column; gap: 8px; max-width: 320px; margin: 0 auto; }
.intro .examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 12px; scrollbar-width: none; flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; font-size: 14px; white-space: nowrap;
  background: rgb(var(--c, var(--brand)) / .13); color: var(--text); border: 1px solid rgb(var(--c, var(--brand)) / .3);
}
.chip:active { filter: brightness(.94); }
.chip[disabled] { opacity: .5; pointer-events: none; }
.composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px calc(8px + var(--bottom)); background: var(--surface);
  border-top: 1px solid var(--line); flex: none;
}
.composer .field { border-radius: 22px; padding: 10px 14px; min-height: 44px; max-height: 140px; line-height: 1.35; background: var(--bg); }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.send svg { width: 21px; height: 21px; }
.send[disabled] { opacity: .45; pointer-events: none; }
.attach { flex: none; }
.preview { display: flex; align-items: center; gap: 10px; padding: 8px 12px 0; background: var(--surface); }
.preview img { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; }
.preview span { flex: 1; font-size: 13px; color: var(--hint); }
.rec { display: flex; align-items: center; gap: 10px; flex: 1; padding: 0 8px; font-variant-numeric: tabular-nums; }
.rec .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Gemini javobi (formatlangan) ---------- */
.fmt { font-size: 15.5px; line-height: 1.55; overflow-wrap: anywhere; }
.fmt .line, .fmt .li, .fmt .h { margin: 0 0 4px; }
.fmt .gap { height: 8px; }
.fmt .h { font-weight: 700; margin-top: 8px; }
.fmt [dir="rtl"] { text-align: right; }
.fmt .li { display: flex; gap: 8px; align-items: baseline; }
.fmt .li .mk { flex: none; min-width: 1.05em; color: var(--hint); }
.fmt .li .tx { flex: 1; min-width: 0; }
.fmt .li.l1 { padding-inline-start: 16px; } .fmt .li.l2 { padding-inline-start: 32px; }
.fmt .ar { font-size: 1.34em; line-height: 1.8; unicode-bidi: isolate; }
.fmt strong { font-weight: 650; }
.fmt code { font: 0.92em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--tint); padding: .1em .38em; border-radius: 6px; }
.fmt pre.code { background: var(--tint); padding: 10px 12px; border-radius: 10px; overflow-x: auto; margin: 6px 0; white-space: pre; font: 13.5px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.spoiler { filter: blur(5px); cursor: pointer; background: var(--tint); border-radius: 6px; transition: filter .2s; user-select: none; -webkit-user-select: none; }
.spoiler.open { filter: none; background: none; user-select: text; -webkit-user-select: text; }
.title-fmt .ar { font-size: 1.22em; line-height: 1.6; }

/* ---------- pastki oyna (sheet) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 50; animation: ov .18s ease-out; }
@keyframes ov { from { opacity: 0; } }
.sheet {
  border: 1px solid var(--line); border-bottom: 0;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-width: 760px; margin: 0 auto; max-height: calc(var(--app-h) - 36px);
  background: var(--surface); border-radius: 26px 26px 0 0; display: flex; flex-direction: column;
  animation: up .22s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet header { display: flex; align-items: center; padding: 8px 8px 8px 20px; flex: none; }
.sheet header h3 { margin: 0; flex: 1; font-size: 18px; line-height: 1.25; }
.sheet .body { overflow-y: auto; padding: 0 16px calc(18px + var(--bottom)); overscroll-behavior: contain; }
.sheet .body .card { margin-left: 0; margin-right: 0; }
.lesson-unit { margin: 14px 4px 6px; font-size: 13px; color: var(--hint); font-weight: 600; line-height: 1.4; }
.num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; background: var(--tint); color: var(--hint); }
.num.done { background: rgb(22 163 74 / .16); color: var(--ok); }
.num.cur { background: var(--accent); color: var(--on-accent); }
.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.topic { padding: 12px; border-radius: 14px; background: var(--surface-2); text-align: left; font-size: 14px; line-height: 1.3; border: 2px solid transparent; }
.topic[aria-pressed="true"] { border-color: var(--accent); background: rgb(var(--brand) / .1); }
.opt { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 16px; background: var(--surface-2); width: 100%; text-align: left; margin-bottom: 8px; border: 2px solid transparent; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: rgb(var(--brand) / .1); }
.opt .n { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; flex: none; }
.opt b { display: block; }
.opt small { color: var(--hint); font-size: 13px; line-height: 1.35; display: block; }

/* ---------- boshqalar ---------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(84px + var(--bottom)); display: flex; justify-content: center; pointer-events: none; z-index: 80; padding: 0 16px; }
.toast { background: rgba(31, 35, 44, .96); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14.5px; max-width: 420px; text-align: center; animation: fade .18s ease-out; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.toast.bad { background: rgba(185, 28, 28, .96); }
.skeleton { background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.center { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 10px; }
.center .big { font-size: 56px; line-height: 1; }
.center .btn { min-width: 220px; }
.center h2 { margin: 0; font-size: 20px; }
.center p { margin: 0; color: var(--hint); max-width: 28em; }
.center code { background: var(--tint); padding: 3px 8px; border-radius: 8px; font-size: 15px; user-select: all; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px 12px; }
.stat b { display: block; font-size: 28px; line-height: 1.15; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: 13px; color: var(--hint); margin-top: 2px; }
.votes { display: flex; gap: 14px; color: var(--hint); font-weight: 600; font-variant-numeric: tabular-nums; }
.votes span { display: inline-flex; align-items: center; gap: 6px; }
.votes svg { width: 18px; height: 18px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding: 16px 16px 0; }
.chart .col { flex: 1; display: flex; align-items: flex-end; height: 100%; }
.chart .col i { display: block; width: 100%; border-radius: 4px; background: #3a424f; min-height: 4px; }
.chart .col.max i { background: var(--accent); }
.chart .col.zero i { opacity: .35; }
.chart-axis { display: flex; justify-content: space-between; padding: 8px 16px 14px; font-size: 13px; color: var(--hint); }
.grant { padding: 14px; }
.grant b { display: block; margin-bottom: 10px; }
.grant .form { display: flex; gap: 8px; }
.grant .form .field { flex: 1; min-width: 0; }
.grant .who-line { margin-top: 12px; font-size: 14px; color: var(--hint); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-id { background: var(--surface-2); color: var(--text); padding: 4px 10px; border-radius: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.empty-dash { margin: 8px 16px; padding: 18px; border: 1.5px dashed var(--line); border-radius: 18px; color: var(--hint); display: flex; align-items: center; justify-content: center; gap: 10px; }
.empty-dash svg { width: 18px; height: 18px; }
.fb { padding: 14px; }
.fb small { color: var(--hint); display: block; margin-bottom: 4px; }
.fb p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.fb-head { display: flex; align-items: center; gap: 12px; }
.fb-head .avatar { width: 40px; height: 40px; font-size: 15px; background: var(--surface-2); color: var(--hint); }
.fb-head .tx { flex: 1; min-width: 0; font-weight: 700; }
.fb-head .when { color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.fb-body { margin: 2px 0 0 52px; }
.fb-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.fb-actions .btn { min-height: 38px; padding: 6px 14px; border-radius: 12px; }
.word { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.word .ar { font-size: 22px; line-height: 1.7; }
.search { margin: 12px 16px 4px; }

/* Kartochka mashqi (interval takrorlash) */
.center .actions { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 320px; margin-top: 6px; }
.rv { padding: 8px 16px; display: flex; flex-direction: column; gap: 12px; }
.rv-progress { height: 4px; border-radius: 2px; background: var(--tint); overflow: hidden; }
.rv-progress i { display: block; height: 100%; background: rgb(217 119 6); border-radius: 2px; transition: width .25s ease-out; }
.rv-count { text-align: center; font-size: 13px; color: var(--hint); }
.rv-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 46vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px 18px; text-align: center; cursor: pointer; user-select: none;
}
.rv-word { font-size: 40px; line-height: 1.6; overflow-wrap: anywhere; }
.rv-back { border-top: 1px solid var(--line); padding-top: 18px; width: 100%; animation: fade .18s ease-out; }
.rv-mean { font-size: 22px; line-height: 1.4; overflow-wrap: anywhere; }
.rv-mean.muted { color: var(--hint); font-size: 16px; margin-bottom: 10px; }
.rv-grade { display: flex; gap: 8px; }
.rv-grade .btn { flex: 1; justify-content: center; }

/* ---------- Kutubxona (Tolibi ilm matnlari) ---------- */
.lib-intro { padding: 16px 16px 10px; }
.lib-intro .lib-ar { font-size: 26px; line-height: 1.5; color: var(--accent); }
.lib-intro b { display: block; font-size: 17px; margin-top: 2px; }
.lib-intro p { margin: 6px 0 0; font-size: 14px; line-height: 1.5; }
.lib-intro p.sub { color: var(--hint); font-size: 13px; }
.lib-intro .link { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--accent); font-weight: 600; font-size: 14px; }
.lib-intro .link svg { width: 16px; height: 16px; }
.row.book { align-items: flex-start; }
.row.book:active { background: none; }
.book-ar { display: block; font-size: 19px; line-height: 1.6; text-align: right; font-weight: 600; }
.book-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip.alt { --c: 217 119 6; }   /* izohli nusxa — boshqa rangda, yodlash nusxasidan ajralib tursin */
.reader { overflow-x: auto; background: var(--bg); }
.reader-pages { width: 100%; padding: 8px 8px calc(16px + var(--bottom)); display: flex; flex-direction: column; gap: 8px; }
.pg { position: relative; width: 100%; background: #fff; border-radius: 4px; box-shadow: 0 1px 3px rgb(0 0 0 / .18); overflow: hidden; }
.pg canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pg-n { position: absolute; inset: 0; display: grid; place-items: center; color: #b4bac2; font-size: 15px; font-weight: 600; }
.reader-status { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 24px; text-align: center; }
.reader-status p { margin: 0; color: var(--hint); max-width: 26em; }
.reader-status .big { font-size: 46px; line-height: 1; }
.reader-status .btn { min-width: 220px; }
.topbar .icon-btn[aria-pressed="true"] { color: var(--accent); }
