/* Telegram mavzu ranglari (Telegram ichida avtomatik), tashqarida — zaxira qiymatlar */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f7);
  --text: var(--tg-theme-text-color, #0f172a);
  --hint: var(--tg-theme-hint-color, #8a94a6);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --sep: var(--tg-theme-section-separator-color, rgba(127, 127, 127, .18));
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --ok: #22a06b;
  --gold: #e0a100;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #17212b; --bg2: #0e1621; --text: #f5f5f5; --hint: #708499; --card: #17212b; --sep: rgba(255, 255, 255, .08);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); overscroll-behavior-y: contain; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: var(--text); }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg2); padding: 12px 16px 6px; }
.top-title { font-size: 22px; font-weight: 700; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view { padding: 4px 12px 16px; max-width: 760px; margin: 0 auto; }

/* Pastki menyu */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--bg); border-top: 1px solid var(--sep); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 4px 9px; font-size: 11px; color: var(--hint); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabs button .ic { font-size: 21px; line-height: 1.1; }
.tabs button.on { color: var(--btn); font-weight: 600; }

/* Kartochkalar va ro'yxatlar */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 10px 0; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.muted { color: var(--hint); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 12px; margin: 8px 0; box-shadow: var(--shadow); cursor: pointer; }
.list-item:active { transform: scale(.99); }
.swatch { width: 46px; height: 46px; border-radius: 12px; flex: none; display: grid; place-items: center; font-size: 20px; position: relative; overflow: hidden; }
.swatch::after { content: ""; position: absolute; left: 8px; bottom: 9px; width: 18px; height: 4px; border-radius: 3px; background: var(--acc, #fff); }
.title { font-weight: 600; font-size: 15px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--bg2); color: var(--hint); margin-right: 4px; font-weight: 600; }
.badge.gold { background: rgba(224, 161, 0, .15); color: var(--gold); }
.badge.ok { background: rgba(34, 160, 107, .14); color: var(--ok); }
.badge.red { background: rgba(229, 72, 77, .12); color: var(--danger); }

.seg { display: flex; background: var(--bg); border-radius: 11px; padding: 3px; gap: 2px; margin: 4px 0 8px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 10px; border-radius: 9px; font-size: 13px; color: var(--hint); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--btn); color: var(--btn-text); font-weight: 600; }

/* Tugmalar */
.btn { border: 0; border-radius: 12px; padding: 12px 14px; background: var(--btn); color: var(--btn-text); font-weight: 600; cursor: pointer; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.sec { background: var(--bg2); color: var(--text); }
.btn.ghost { background: transparent; color: var(--link); padding: 8px; }
.btn.danger { background: rgba(229, 72, 77, .12); color: var(--danger); }
.btn.sm { padding: 8px 10px; font-size: 13px; border-radius: 10px; width: auto; }
.btn:disabled { opacity: .5; }
.btn:active { opacity: .85; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.act { border: 0; background: var(--card); border-radius: 14px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; cursor: pointer; box-shadow: var(--shadow); }
.act .ic { font-size: 22px; }

/* Slayd ko'rinishlari */
.thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .thumbs { grid-template-columns: repeat(3, 1fr); } }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--bg); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); cursor: pointer; }
.thumb canvas { width: 100%; height: 100%; display: block; }
.thumb .n { position: absolute; left: 6px; top: 6px; font-size: 11px; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 6px; padding: 1px 6px; }
.skel { background: linear-gradient(90deg, var(--bg2) 25%, var(--sep) 50%, var(--bg2) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

.viewer { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; flex-direction: column; }
.viewer canvas { width: 100%; height: auto; max-height: 100%; object-fit: contain; }
.viewer .stage { flex: 1; display: grid; place-items: center; overflow: hidden; touch-action: pan-y; }
.viewer .bar { display: flex; align-items: center; justify-content: space-between; color: #fff; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
.viewer .bar button { background: rgba(255, 255, 255, .14); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-size: 16px; }

/* Bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fade .2s; }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: var(--bg); border-radius: 18px 18px 0 0; padding: 14px 14px calc(18px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
.sheet-body h3 { margin: 4px 0 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 10px; }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(20, 20, 20, .92); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: 14px; max-width: 90vw; text-align: center; }

/* Formalar */
.field { margin: 10px 0; }
.field label { display: block; font-size: 12px; color: var(--hint); margin: 0 0 4px 2px; }
.inp { width: 100%; border: 1px solid var(--sep); background: var(--bg2); border-radius: 10px; padding: 10px 12px; outline: none; resize: vertical; }
.inp:focus { border-color: var(--btn); }
textarea.inp { min-height: 64px; }
.multi .item { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0; }
.multi .item .inp { flex: 1; }
.x { border: 0; background: var(--bg2); border-radius: 9px; width: 34px; height: 34px; flex: none; cursor: pointer; color: var(--hint); }

/* Tahrirlovchi */
.slide-ed { background: var(--card); border-radius: var(--radius); margin: 10px 0; box-shadow: var(--shadow); overflow: hidden; }
.slide-ed .hd { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; }
.slide-ed .hd .num { width: 28px; height: 28px; border-radius: 8px; background: var(--bg2); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.slide-ed .handle { cursor: grab; padding: 4px 6px; color: var(--hint); font-size: 18px; touch-action: none; }
.slide-ed .bd { padding: 0 12px 12px; border-top: 1px solid var(--sep); }
.slide-ed.sortable-ghost { opacity: .4; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sticky-bottom { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 6; display: flex; gap: 8px; padding: 10px 12px; margin: 0 -12px; background: var(--bg2); border-top: 1px solid var(--sep); }
.sticky-bottom .btn { white-space: nowrap; font-size: 14px; padding-left: 8px; padding-right: 8px; }
.sticky-bottom #edSave { flex: 0 0 38%; }

/* Mashq */
.prompter { position: fixed; inset: 0; z-index: 30; background: #0b0b0f; color: #f5f5f5; display: flex; flex-direction: column; }
.prompter .txt { flex: 1; overflow: auto; padding: 30vh 22px 50vh; font-size: var(--pf, 28px); line-height: 1.5; font-weight: 500; scroll-behavior: auto; }
.prompter .txt h2 { color: #f5c542; font-size: .8em; margin: 1.4em 0 .4em; }
.prompter .ctl { display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #15151c; flex-wrap: wrap; }
.prompter .ctl button { background: #262633; color: #fff; border: 0; border-radius: 10px; padding: 10px 14px; font-size: 15px; }
.prompter .ctl .timer { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 700; margin-left: auto; }
.prompter .guide { position: absolute; left: 0; right: 0; top: 30vh; height: 2px; background: rgba(245, 197, 66, .35); pointer-events: none; }
.flash { perspective: 1200px; margin: 14px 0; }
.flash .inner { position: relative; min-height: 240px; transition: transform .45s; transform-style: preserve-3d; }
.flash.flip .inner { transform: rotateY(180deg); }
.flash .face { position: absolute; inset: 0; backface-visibility: hidden; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; justify-content: center; font-size: 18px; }
.flash .back { transform: rotateY(180deg); font-size: 15px; }
.progress { height: 6px; background: var(--bg2); border-radius: 3px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--btn); transition: width .3s; }

/* Hisob */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--card); border-radius: 14px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 22px; }
.tile span { font-size: 11px; color: var(--hint); }
.vip-card { background: linear-gradient(135deg, #2b1c55, #6b3fa0 60%, #e0a100); color: #fff; border-radius: 18px; padding: 16px; margin: 10px 0; box-shadow: var(--shadow); }
.vip-card .muted { color: rgba(255, 255, 255, .75); }
.buy { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--sep); cursor: pointer; }
.buy:last-child { border-bottom: 0; }
.price { font-weight: 700; white-space: nowrap; }
.copy { display: flex; gap: 6px; align-items: center; background: var(--bg2); border-radius: 10px; padding: 8px 10px; font-size: 13px; word-break: break-all; }

/* Dizaynlar */
.themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-card { background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); cursor: pointer; border: 2px solid transparent; }
.theme-card.on { border-color: var(--btn); }
.theme-card .pv { aspect-ratio: 16 / 9; position: relative; }
.theme-card .pv canvas { width: 100%; height: 100%; display: block; }
.theme-card .nm { padding: 8px 10px; font-size: 13px; font-weight: 600; }
.theme-card .nm small { display: block; font-weight: 400; color: var(--hint); font-size: 11px; }

/* Admin */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 20px; }
.kpi span { font-size: 12px; color: var(--hint); }
.chart { background: var(--card); border-radius: 14px; padding: 12px; margin: 10px 0; box-shadow: var(--shadow); }
.chart h4 { margin: 0 0 8px; font-size: 14px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 110px; }
.bars i { flex: 1; background: var(--btn); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; position: relative; }
.bars i:hover::after { content: attr(data-v); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 10px; background: var(--text); color: var(--bg); padding: 1px 4px; border-radius: 4px; white-space: nowrap; font-style: normal; }
.axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--hint); margin-top: 4px; }
.receipt { width: 100%; max-height: 320px; object-fit: contain; border-radius: 10px; background: var(--bg2); margin: 8px 0; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--sep); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(18px); }
.empty { text-align: center; padding: 40px 20px; color: var(--hint); }
.empty .big { font-size: 46px; }
.spin { width: 22px; height: 22px; border: 3px solid var(--sep); border-top-color: var(--btn); border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 30px; color: var(--hint); }

/* ---------- 3–4-bosqich: yaratish, imtihon, slaydma-slayd mashq ---------- */
.small { font-size: 12.5px; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--sep); background: var(--bg2); color: var(--text); border-radius: 99px; padding: 7px 13px; font: inherit; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--btn); color: var(--btn-text); border-color: var(--btn); font-weight: 600; }
.advice { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(34, 160, 107, .1); font-size: 13.5px; }
.toggle { padding: 8px 0; gap: 10px; }
.toggle > span:first-child { min-width: 0; }
.tstrip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.tsw { flex: 0 0 auto; width: 92px; border: 2px solid transparent; background: none; padding: 0; color: var(--text); font: inherit; cursor: pointer; scroll-snap-align: center; border-radius: 12px; }
.tsw .sw { display: block; height: 52px; border-radius: 10px; position: relative; border: 1px solid var(--sep); overflow: hidden; }
.tsw .sw i { position: absolute; left: 10px; bottom: 10px; width: 34px; height: 5px; border-radius: 3px; }
.tsw .sw.rnd { background: conic-gradient(#0d1e36, #22d3ee, #f59e0b, #7c3aed, #10b981, #0d1e36); }
.tsw .nm { display: block; font-size: 11.5px; padding: 4px 2px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tsw.on { border-color: var(--btn); }
.cost { margin: 10px 2px; font-size: 14px; }
.cost .ok { color: var(--ok); }
.cost .warn { color: var(--danger); font-weight: 600; }
.btn.gold { background: var(--gold); color: #1b1300; }
.active-job { border: 1px solid var(--btn); cursor: pointer; }
.prog { text-align: center; padding: 22px 16px; }
.prog-ic, .hero-ic { font-size: 46px; text-align: center; }
.prog h3 { margin: 8px 0 14px; }
.progress.lg { height: 12px; border-radius: 6px; margin-bottom: 8px; }
.pv-bar { border: 2px solid var(--btn); }
.pv-bar .row { margin-top: 6px; }

.exam-q { font-size: 17px; line-height: 1.45; margin-top: 10px; }
.grade-card { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.score { flex: none; width: 70px; height: 70px; border-radius: 50%; display: flex; align-items: baseline; justify-content: center; padding-top: 18px; box-sizing: border-box; background: var(--bg2); }
.score b { font-size: 26px; }
.score span { font-size: 12px; opacity: .7; }
.score.hi, .pill.hi { background: rgba(34, 160, 107, .16); color: var(--ok); }
.score.mid, .pill.mid { background: rgba(224, 161, 0, .16); color: var(--gold); }
.score.lo, .pill.lo { background: rgba(229, 72, 77, .14); color: var(--danger); }
.fb { border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.fb p { margin: 4px 0 0; }
.fb.ok { background: rgba(34, 160, 107, .1); }
.fb.miss { background: rgba(224, 161, 0, .12); }
.fb.tip { background: var(--card); }
details.card summary { cursor: pointer; font-weight: 600; }
details.card p { margin: 8px 0 0; white-space: pre-wrap; }
.pill { flex: none; min-width: 34px; height: 30px; border-radius: 15px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; background: var(--bg2); }
#eMic.rec { background: rgba(229, 72, 77, .14); color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.rehearse { position: fixed; inset: 0; z-index: 30; background: #0b0b0f; color: #f2f2f2; display: flex; flex-direction: column; }
.r-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-variant-numeric: tabular-nums; }
.r-top .r-pos { opacity: .7; }
.r-top .r-slide { font-weight: 700; font-size: 18px; }
.r-top .r-slide.near { color: #f5c542; }
.r-top .r-slide.over { color: #ff6b6b; }
.r-top .r-total { margin-left: auto; opacity: .8; font-size: 14px; }
.r-top button, .r-ctl button { background: #262633; color: #fff; border: 0; border-radius: 10px; padding: 8px 12px; font-size: 16px; }
.r-stage { flex: none; padding: 0 10px; touch-action: pan-y; }
.r-cv { aspect-ratio: 16 / 9; background: #1a1a22; border-radius: 8px; overflow: hidden; }
.r-cv canvas { width: 100%; height: auto; display: block; }
.r-notes { flex: 1; overflow: auto; padding: 12px 16px; }
.r-notes h3 { color: #f5c542; margin: 4px 0 8px; font-size: 16px; }
.r-notes p { font-size: 19px; line-height: 1.5; margin: 0 0 10px; }
.r-notes .r-big { font-size: 17px; }
.r-ctl { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #15151c; }
.r-ctl button { flex: 1; padding: 13px; font-size: 18px; }
.r-ctl button.main { flex: 2; background: #2f6fed; font-weight: 700; }
.r-row { padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, .07); font-size: 14px; }
.r-row .bar { height: 6px; background: #262633; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.r-row .bar i { display: block; height: 100%; }
.r-row .fast { color: #f5c542; } .r-row .bar i.fast { background: #f5c542; }
.r-row .slow { color: #ff6b6b; } .r-row .bar i.slow { background: #ff6b6b; }
.r-row .okk { color: #4ade80; } .r-row .bar i.okk { background: #4ade80; }

/* ---------- Pullik qismlar ---------- */
.buy > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.buy small { font-size: 12px; }
.buy .badge { display: inline-block; margin-left: 6px; vertical-align: middle; }
.shop h4 { margin: 16px 0 2px; }
.perks { list-style: none; padding: 0; margin: 6px 0 4px; font-size: 13.5px; }
.perks li { padding: 2px 0; }
.pend { border: 1px solid var(--gold); }
.upsell { border: 1px solid rgba(224, 161, 0, .5); background: linear-gradient(135deg, rgba(224, 161, 0, .10), transparent 60%), var(--card); }
.ok-t { color: var(--ok); }
.warn-t { color: var(--danger); font-weight: 600; }
