:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #15181f;
  --muted: #5d6472;
  --line: #e4e2db;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #d9f0ec;
  --accent: #b45309;
  --accent-soft: #fdf0d8;
  --ok: #15803d;
  --ok-soft: #dcf3e3;
  --bad: #b91c1c;
  --bad-soft: #fbe0e0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 31, 0.06), 0 6px 20px rgba(20, 24, 31, 0.06);
}
/* Sayt har doim qorong'i ko'rinishda (logo qora fonga mos) */
:root {
  color-scheme: dark;
    --bg: #0b0d11;
    --surface: #151920;
    --ink: #eef0f4;
    --muted: #9aa3b2;
    --line: #2a303b;
    --brand: #2dd4bf;
    --brand-ink: #06201d;
    --brand-soft: #12312d;
    --accent: #fbbf24;
    --accent-soft: #3a2d0f;
    --ok: #4ade80;
    --ok-soft: #12301d;
    --bad: #f87171;
    --bad-soft: #3a1717;
    --shadow: none;
  
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 12px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.ko { font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* Joylashuv */
.shell { max-width: 640px; margin: 0 auto; padding: 0 16px 96px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  padding: calc(env(safe-area-inset-top) + 12px) 0 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-dot { width: 28px; height: 28px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; font-size: 14px; overflow: hidden; }
.main { padding-top: 6px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
}
.bottom-nav .inner { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; border-radius: 12px; text-decoration: none; color: var(--muted);
  font-size: 0.7rem; font-weight: 600;
}
.nav-item.active { color: var(--brand); background: var(--brand-soft); }

/* Kartalar va bloklar */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.tight { padding: 12px 14px; }
.hero { background: var(--brand); color: var(--brand-ink); border-radius: 20px; padding: 20px; }
.hero h1, .hero h2 { color: inherit; }
.hero .muted { color: inherit; opacity: 0.85; }
.banner { border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.banner.trial { background: var(--accent-soft); color: var(--accent); }
.banner.expired { background: var(--bad-soft); color: var(--bad); }
.banner.active, .banner.admin { background: var(--ok-soft); color: var(--ok); }
.banner b { font-weight: 700; }

.chip { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.chip.free { background: var(--ok-soft); color: var(--ok); }
.chip.premium { background: var(--accent-soft); color: var(--accent); }
.chip.mock { background: var(--bad-soft); color: var(--bad); }
.chip.pending { background: var(--accent-soft); color: var(--accent); }
.chip.approved { background: var(--ok-soft); color: var(--ok); }
.chip.rejected { background: var(--bad-soft); color: var(--bad); }

/* Tugmalar */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 700; padding: 12px 16px; border-radius: 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; min-height: 46px;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 8px 12px; min-height: 36px; font-size: 0.9rem; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn:focus-visible, .nav-item:focus-visible, .tab:focus-visible, .option:focus-visible, .list-item:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px;
}

/* Tablar */
.tabs { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.tab { flex: 1; appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.tab.active { background: var(--brand); color: var(--brand-ink); }

/* Ro'yxat */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  text-decoration: none; color: inherit; cursor: pointer; width: 100%; text-align: left; font: inherit;
}
.list-item.disabled { opacity: 0.6; cursor: default; }
.badge-circle { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; background: var(--brand-soft); color: var(--brand); }
.badge-circle.done { background: var(--ok-soft); color: var(--ok); }
.badge-circle.locked { background: var(--line); color: var(--muted); }
.badge-circle.premium { background: var(--accent-soft); color: var(--accent); }
.section-title { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 22px 0 8px; }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width 0.3s; }
.hero .progress { background: rgba(255, 255, 255, 0.25); }
.hero .progress > span { background: var(--brand-ink); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; text-decoration: none; color: inherit; }
.tile .ico { width: 38px; height: 38px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }

/* Formalar */
label.field { display: block; }
label.field > span { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 46px;
}
textarea { min-height: 120px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 20px; min-height: 20px; height: 20px; }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 12px; font-size: 0.9rem; }
.form-ok { background: var(--ok-soft); color: var(--ok); padding: 10px 12px; border-radius: 12px; font-size: 0.9rem; }

/* Test */
.q-text { font-size: 1.15rem; font-weight: 700; white-space: pre-wrap; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; font: inherit; width: 100%;
  background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; color: var(--ink);
}
.option .mark { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 800; }
.option.selected { border-color: var(--brand); background: var(--brand-soft); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.explain { background: var(--accent-soft); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: 0.95rem; white-space: pre-wrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.timer.low { color: var(--bad); }
.score-big { font-size: 3rem; font-weight: 800; line-height: 1; }
.dots { display: flex; flex-wrap: wrap; gap: 6px; }
.dot { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; color: var(--ink); }
.dot.answered { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.dot.current { outline: 2px solid var(--brand); }

/* Kartochkalar (flashcard) */
.flash { min-height: 240px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 10px; padding: 24px; }
.flash .front { font-size: 2.4rem; font-weight: 800; }
.flash .back { font-size: 1.4rem; font-weight: 700; color: var(--brand); }
.rate-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate-btn { flex-direction: column; gap: 0; padding: 8px 4px; font-size: 0.9rem; }
.rate-btn small { font-weight: 500; opacity: 0.75; }

/* Dars */
.video-wrap { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.prose { white-space: pre-wrap; word-wrap: break-word; }
.paywall { text-align: center; }
.paywall-icon { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }

/* Narxlar */
.plan { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.plan .price { font-size: 1.15rem; font-weight: 800; white-space: nowrap; }
.plan.selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.card-number { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; word-break: break-all; }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 6px; }

/* Admin */
.table-like { display: flex; flex-direction: column; gap: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 0.92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.receipt-img { max-width: 100%; max-height: 70vh; border-radius: 10px; display: block; margin: 0 auto; }

/* Modal, toast, yuklanish */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); color: var(--ink); border-radius: 18px; padding: 18px; max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; }
#toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 64px); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: 520px; box-shadow: var(--shadow); }
.toast.error { background: var(--bad); color: #fff; }
.toast.success { background: var(--ok); color: #fff; }
.loading { display: grid; place-items: center; padding: 60px 0; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.demo-bar { background: var(--accent-soft); color: var(--accent); font-size: 0.8rem; font-weight: 600; text-align: center; padding: 6px 10px; }

/* Kirish sahifasi */
.auth-wrap { max-width: 460px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 28px) 16px 40px; }
.auth-wrap .logo { width: 56px; height: 56px; border-radius: 18px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 28px; font-weight: 800; margin-bottom: 14px; }
.perks { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.perks li::before { content: "✓"; color: var(--brand); font-weight: 800; margin-right: 8px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Darajalar (TOPIK I/II, KIIP bosqichlari) */
.levels { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.levels::-webkit-scrollbar { display: none; }
.level-chip { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.level-chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.tile.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 12px; }
.article-body { white-space: pre-wrap; word-wrap: break-word; line-height: 1.65; }

/* HANAVON logotipi */
.brand-dot { background: transparent !important; width: 34px; height: 34px; border-radius: 0; }
.brand-dot picture, .brand-dot img { display: block; }
.auth-wrap .logo { width: 220px; height: 220px; background: transparent !important; border-radius: 0; margin: 0 auto 8px; }

.logo-stack { position: relative; }
.logo-stack .logo-red { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.logo-stack .logo-ink { position: absolute; inset: 0; background: var(--ink); -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; }

/* Kitoblar */
.book-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 560px) { .book-grid { grid-template-columns: repeat(3, 1fr); } }
.book { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; }
.book-wrap { position: relative; }
.book-cover { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: block; }
.book-cover.ph { display: grid; place-items: center; padding: 12px; text-align: center; font-weight: 700; background: var(--brand-soft); color: var(--brand); }
.book-chip { position: absolute; top: 8px; right: 8px; }
.book-title { font-weight: 700; font-size: 14px; line-height: 1.3; }
.book-big { max-width: 240px; margin: 0 auto; width: 100%; }
