/* =========================================================
   MetaKomp — yagona uslublar fayli
   Barcha sahifalar shu faylga ulanadi (avval har sahifada
   CSS takrorlangan, styles.css esa umuman ulanmagan edi).
   ========================================================= */

:root {
  --ink: #16213a;
  --ink-soft: #33405a;
  --muted: #5a6578;
  --lapis: #1f3b73;
  --lapis-deep: #13284f;
  --lapis-tint: #e8edf7;
  --turq: #12807f;
  --turq-tint: #e3f3f2;
  --saffron: #c98a12;
  --saffron-tint: #fbf1dc;
  --paper: #f3f5f7;
  --surface: #ffffff;
  --line: #d9dfe7;
  --line-soft: #e8ecf1;
  --success: #13795b;
  --success-tint: #e2f4ec;
  --danger: #b42318;
  --danger-tint: #fdecea;

  --font-ui: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: "Literata", Georgia, "Times New Roman", serif;
  --font-code: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(19, 40, 79, .06), 0 2px 8px rgba(19, 40, 79, .05);
  --shadow-2: 0 12px 32px rgba(19, 40, 79, .14);

  /* Girih naqshi — butun identitetning asosiy belgisi */
  --girih: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='1'%3E%3Cpath d='M62 40 40 62 18 40 40 18Z'/%3E%3Cpath d='M55.6 55.6H24.4V24.4H55.6Z'/%3E%3Cpath d='M62 40H80M0 40H18M40 0V18M40 62V80'/%3E%3Cpath d='M0 8 8 0M72 0 80 8M80 72 72 80M8 80 0 72'/%3E%3Ccircle cx='40' cy='40' r='6'/%3E%3C/g%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg, canvas { max-width: 100%; display: block; }
a { color: var(--lapis); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #5b8def; outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--lapis-deep);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar::after {
  content: "";
  display: block;
  height: 6px;
  background: var(--lapis) var(--girih) 0 0 / 24px 24px;
  opacity: .9;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -.01em;
  flex-shrink: 0;
}
.brand-mark { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 400; font-size: .72rem; opacity: .7; letter-spacing: 0; margin-top: -2px; }
.nav { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.nav a {
  color: rgba(255,255,255,.78);
  text-decoration: none;
  font-size: .92rem;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  white-space: nowrap;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.14); }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  margin-left: 8px; padding-left: 16px;
  border-left: 1px solid rgba(255,255,255,.18);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--saffron); color: var(--lapis-deep);
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}
.btn-logout {
  background: none; border: 1px solid rgba(255,255,255,.3); color: #fff;
  padding: 6px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: .85rem;
}
.btn-logout:hover { background: rgba(255,255,255,.1); }
.nav-toggle {
  display: none; margin-left: auto; background: none; border: 0; color: #fff;
  width: 40px; height: 40px; border-radius: var(--r-sm); cursor: pointer; font-size: 1.2rem;
}

@media (max-width: 1020px) {
  .nav-toggle { display: grid; place-items: center; }
  .nav {
    display: none;
    position: absolute; left: 0; right: 0; top: 66px;
    flex-direction: column; align-items: stretch;
    background: var(--lapis-deep); padding: 8px 16px 16px; gap: 2px;
    box-shadow: var(--shadow-2);
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px; }
  .user-chip { margin: 8px 0 0; padding: 12px 0 0; border-left: 0; border-top: 1px solid rgba(255,255,255,.18); }
  .user-chip .btn-logout { margin-left: auto; }
}

/* ---------- Layout ---------- */
main { flex: 1; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 32px 16px 64px; }
.wrap-narrow { max-width: 860px; }
.page-head { margin-bottom: 28px; }
.page-head h1 {
  font-family: var(--font-read);
  font-weight: 600;
  font-size: clamp(1.7rem, 3.2vw, 2.3rem);
  line-height: 1.15;
  letter-spacing: -.01em;
}
.page-head p { color: var(--muted); margin-top: 6px; max-width: 64ch; }
h2.section-title {
  font-family: var(--font-read);
  font-weight: 600;
  font-size: 1.35rem;
  margin: 36px 0 14px;
}
.footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
}
.footer .wrap { padding-top: 20px; padding-bottom: 24px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 24px;
}
.panel + .panel { margin-top: 16px; }
.panel h2, .panel h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--lapis);
  color: #fff;
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--lapis-deep); }
.btn:disabled, .btn[aria-disabled="true"] { background: #a8b1c0; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--lapis); border-color: var(--line); }
.btn-ghost:hover { background: var(--lapis-tint); border-color: #c5d0e4; }
.btn-gold { background: var(--saffron); color: #1d1503; }
.btn-gold:hover { background: #b37a0e; }
.btn-turq { background: var(--turq); }
.btn-turq:hover { background: #0d6766; }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.input, .select, .textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #c9d1dc;
  border-radius: var(--r-sm);
  background: #fff;
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
.select { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6578' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center; padding-right: 36px; }
.textarea { min-height: 120px; resize: vertical; }
.textarea.code { font-family: var(--font-code); font-size: .85rem; min-height: 220px; tab-size: 4; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--lapis); box-shadow: 0 0 0 3px rgba(31,59,115,.15); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.alert { padding: 12px 14px; border-radius: var(--r-sm); font-size: .9rem; margin-bottom: 16px; }
.alert-error { background: var(--danger-tint); color: var(--danger); border: 1px solid #f5c2bd; }
.alert-ok { background: var(--success-tint); color: var(--success); border: 1px solid #b7e3cf; }
.alert-info { background: var(--lapis-tint); color: var(--lapis-deep); border: 1px solid #cdd8ec; }
.alert-warn { background: var(--saffron-tint); color: #7a5208; border: 1px solid #f0d9a6; }

/* ---------- Chips & progress ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  background: var(--line-soft); color: var(--ink-soft);
  white-space: nowrap;
}
.chip-done { background: var(--success-tint); color: var(--success); }
.chip-open { background: var(--lapis-tint); color: var(--lapis); }
.chip-lock { background: #eef0f3; color: #7b8494; }
.chip-gold { background: var(--saffron-tint); color: #8a5d07; }
.chip-fail { background: var(--danger-tint); color: var(--danger); }

.bar { height: 6px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--turq); border-radius: 99px; transition: width .4s ease; }
.bar.gold > span { background: var(--saffron); }

/* ---------- Toast ---------- */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: .92rem; animation: toast-in .25s ease; }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.loading { padding: 40px 0; text-align: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--lapis); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center; padding: 48px 20px;
  border: 1px dashed #c4ccd8; border-radius: var(--r-md); background: var(--surface);
}
.empty h3 { font-size: 1.1rem; margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 16px; max-width: 48ch; margin-left: auto; margin-right: auto; }

/* =========================================================
   AUTH (index.html)
   ========================================================= */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}
.auth-art {
  position: relative;
  background: var(--lapis-deep);
  color: #fff;
  padding: 48px clamp(24px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.auth-art::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--girih) 0 0 / 80px 80px;
  opacity: .08;
}
.auth-art::after {
  content: "";
  position: absolute;
  width: 520px; height: 520px; right: -180px; bottom: -200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(18,128,127,.55), rgba(18,128,127,0) 70%);
}
.auth-art > * { position: relative; z-index: 1; }
.auth-art .brand { font-size: 1.25rem; }
.auth-art .brand-mark { width: 38px; height: 38px; }
.auth-pitch { margin-top: auto; padding: 48px 0; max-width: 34rem; }
.auth-pitch h1 {
  font-family: var(--font-read);
  font-weight: 600;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -.015em;
}
.auth-pitch p { margin-top: 18px; color: rgba(255,255,255,.78); font-size: 1.05rem; max-width: 46ch; }
.auth-facts { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 32px; }
.auth-facts b { display: block; font-family: var(--font-read); font-size: 1.9rem; font-weight: 600; color: #f1c35e; line-height: 1; }
.auth-facts span { font-size: .85rem; color: rgba(255,255,255,.7); }
.auth-unis { border-top: 1px solid rgba(255,255,255,.16); padding-top: 20px; }
.auth-unis p { font-size: .82rem; color: rgba(255,255,255,.6); margin-bottom: 10px; }
.auth-unis ul { list-style: none; display: grid; gap: 6px; }
.auth-unis li { display: flex; gap: 10px; align-items: center; font-size: .92rem; }
.auth-unis li i { color: #f1c35e; width: 16px; }

.auth-side { display: flex; align-items: center; justify-content: center; padding: 40px 16px; background: var(--paper); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card h2 { font-family: var(--font-read); font-weight: 600; font-size: 1.6rem; margin-bottom: 4px; }
.auth-card > p { color: var(--muted); margin-bottom: 24px; }
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: #e6eaf0; border-radius: var(--r-md); margin-bottom: 24px;
}
.tab {
  flex: 1; padding: 9px 12px; border: 0; background: transparent;
  border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: .92rem;
}
.tab[aria-selected="true"] { background: #fff; color: var(--lapis-deep); box-shadow: var(--shadow-1); }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: .82rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.link-btn { background: none; border: 0; color: var(--lapis); cursor: pointer; font-size: .875rem; text-decoration: underline; padding: 0; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; width: 34px; height: 34px; cursor: pointer; color: var(--muted); border-radius: 4px; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 16px 32px; }
  .auth-pitch { padding: 28px 0 24px; }
  .auth-facts { gap: 20px; }
}

/* =========================================================
   HOME / DASHBOARD
   ========================================================= */
.hello {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 8px;
}
.hello-main h1 { font-family: var(--font-read); font-weight: 600; font-size: clamp(1.7rem, 3.4vw, 2.4rem); line-height: 1.12; }
.hello-main p { color: var(--muted); margin-top: 8px; max-width: 58ch; }
.hello-main .btn-row { margin-top: 20px; }
.progress-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 20px; display: flex; gap: 18px; align-items: center;
}
.ring { width: 92px; height: 92px; flex-shrink: 0; }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: var(--line-soft); }
.ring .val { stroke: var(--turq); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .6s ease; }
.ring text { font-family: var(--font-ui); font-weight: 700; font-size: 20px; fill: var(--ink); }
.progress-card dl { display: grid; grid-template-columns: auto auto; gap: 2px 14px; font-size: .88rem; }
.progress-card dt { color: var(--muted); }
.progress-card dd { font-weight: 600; text-align: right; }
@media (max-width: 820px) { .hello { grid-template-columns: 1fr; } }

.course-banner {
  margin-top: 24px;
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 16px 20px; border-radius: var(--r-md);
  background: var(--saffron-tint); border: 1px solid #efd59c;
}
.course-banner p { flex: 1; min-width: 220px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 32px 0 8px; }
.toolbar .input { max-width: 300px; }
.seg { display: inline-flex; background: #e6eaf0; padding: 3px; border-radius: 8px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--lapis-deep); box-shadow: var(--shadow-1); }

.level { margin-top: 28px; }
.level-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.level-head h2 { font-family: var(--font-read); font-weight: 600; font-size: 1.3rem; }
.level-head span { color: var(--muted); font-size: .9rem; }

.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
@media (max-width: 360px) { .modules { grid-template-columns: 1fr; } }
.mcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  position: relative;
}
.mcard.is-locked { background: #f8f9fb; }
.mcard.is-locked .mcard-title, .mcard.is-locked .mcard-desc { color: #7b8494; }
.mcard.is-done { border-color: #a9dbc6; }
.mcard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mnum {
  font-family: var(--font-read); font-weight: 600; font-size: 1.05rem;
  width: 40px; height: 40px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--lapis-tint); color: var(--lapis);
}
.mcard.is-done .mnum { background: var(--success-tint); color: var(--success); }
.mcard.is-locked .mnum { background: #eceff3; color: #8a93a2; }
.mcard-title { font-size: 1.08rem; font-weight: 700; line-height: 1.3; }
.mcard-desc { font-size: .9rem; color: var(--muted); flex: 1; }
.mcard-meta { display: flex; gap: 14px; font-size: .82rem; color: var(--muted); flex-wrap: wrap; }
.mcard-meta i { margin-right: 4px; opacity: .8; }
.mcard .bar { margin-top: 4px; }
.mcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.mcard-foot .small { color: var(--muted); }

/* =========================================================
   COURSE PAGE
   ========================================================= */
.course-hero {
  background: var(--lapis-deep);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.course-hero::before {
  content: ""; position: absolute; inset: 0;
  background: var(--girih) 0 0 / 64px 64px; opacity: .06;
}
.course-hero .wrap { position: relative; padding-top: 28px; padding-bottom: 28px; }
.crumbs { font-size: .85rem; color: rgba(255,255,255,.7); margin-bottom: 12px; }
.crumbs a { color: rgba(255,255,255,.85); }
.course-hero h1 { font-family: var(--font-read); font-weight: 600; font-size: clamp(1.6rem, 3.2vw, 2.3rem); line-height: 1.15; }
.course-hero p.lead { margin-top: 8px; color: rgba(255,255,255,.8); max-width: 66ch; }
.course-hero .meta { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 16px; font-size: .88rem; color: rgba(255,255,255,.85); }
.course-hero .meta i { color: #f1c35e; margin-right: 6px; }

.ctabs { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 66px; z-index: 20; }
.ctabs .wrap { padding-top: 0; padding-bottom: 0; display: flex; gap: 4px; overflow-x: auto; }
.ctab {
  border: 0; background: none; padding: 14px 14px 12px; cursor: pointer;
  font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-size: .95rem;
}
.ctab[aria-selected="true"] { color: var(--lapis-deep); border-bottom-color: var(--saffron); }
.ctab:disabled { color: #a3abb8; cursor: not-allowed; }

.course-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 32px; align-items: start; }
@media (max-width: 900px) { .course-layout { grid-template-columns: minmax(0, 1fr); } }
.lesson-nav { position: sticky; top: 130px; }
@media (max-width: 900px) { .lesson-nav { position: static; } }
.lesson-nav h3 { font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.lesson-nav ol { list-style: none; display: grid; gap: 4px; }
.lesson-nav button {
  width: 100%; text-align: left; border: 1px solid transparent; background: none;
  padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer;
  display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start;
}
.lesson-nav button:hover { background: #e9edf3; }
.lesson-nav button[aria-current="true"] { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-1); }
.lesson-nav .ln-n {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid #c3cbd7;
  display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--muted);
}
.lesson-nav .done .ln-n { background: var(--turq); border-color: var(--turq); color: #fff; }
.lesson-nav .ln-t { font-size: .92rem; font-weight: 600; line-height: 1.3; }
.lesson-nav .ln-d { font-size: .78rem; color: var(--muted); font-weight: 400; display: block; }
.lesson-nav .side-box { margin-top: 16px; padding: 14px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); font-size: .85rem; }

/* Reader */
.reader { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: clamp(20px, 4vw, 44px); }
.reader-head { margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.reader-head .small { color: var(--muted); }
.reader-head h2 { font-family: var(--font-read); font-weight: 600; font-size: clamp(1.4rem, 2.6vw, 1.85rem); line-height: 1.2; margin-top: 4px; }
.prose { font-family: var(--font-read); font-size: 1.06rem; line-height: 1.75; color: #1f2a40; max-width: 70ch; }
.prose > * + * { margin-top: 1em; }
.prose h3 { font-family: var(--font-ui); font-size: 1.12rem; font-weight: 700; margin-top: 1.8em; color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .35em; }
.prose code { font-family: var(--font-code); font-size: .86em; background: #eef1f6; padding: .1em .35em; border-radius: 4px; }
.prose table { border-collapse: collapse; font-family: var(--font-ui); font-size: .92rem; width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: #f2f4f8; }
.table-scroll { overflow-x: auto; }

.callout {
  font-family: var(--font-ui); font-size: .95rem; line-height: 1.6;
  border-left: 4px solid var(--turq); background: var(--turq-tint);
  padding: 12px 16px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.callout b { display: block; margin-bottom: 2px; }
.callout.warn { border-color: var(--saffron); background: var(--saffron-tint); }
.callout.teach { border-color: var(--lapis); background: var(--lapis-tint); }

/* Code blocks */
.code {
  font-family: var(--font-ui);
  border: 1px solid #263553; border-radius: var(--r-md); overflow: hidden;
  background: #0f1b33; max-width: 100%;
}
.code-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 14px; background: #17264a; color: #aab6cf; font-size: .78rem; }
.code-bar .lang { margin-right: auto; }
.code-bar button { background: none; border: 1px solid #33466f; color: #d6deef; border-radius: 5px; padding: 4px 10px; cursor: pointer; font-size: .78rem; }
.code-bar button:hover { background: #22345d; }
.code-bar button.run { background: var(--turq); border-color: var(--turq); color: #fff; }
.code-bar button.run:hover { background: #0d6766; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-family: var(--font-code); font-size: .86rem; line-height: 1.6; color: #e6ecf8; background: transparent !important; }
.code pre code { font-family: inherit; background: none; padding: 0; font-size: inherit; color: inherit; }
.code textarea { display: block; width: 100%; border: 0; background: #0b1529; color: #e6ecf8; font-family: var(--font-code); font-size: .86rem; line-height: 1.6; padding: 14px 16px; resize: vertical; min-height: 140px; tab-size: 4; }
.code textarea:focus { outline: 2px solid #5b8def; outline-offset: -2px; }
.code-out { border-top: 1px solid #263553; background: #08111f; color: #c9f2d9; font-family: var(--font-code); font-size: .82rem; padding: 10px 16px; white-space: pre-wrap; max-height: 260px; overflow: auto; }
.code-out.err { color: #ffb4a8; }
.code-out .lbl { color: #7f8ca6; display: block; margin-bottom: 4px; font-family: var(--font-ui); font-size: .75rem; }

.keypoints { margin-top: 32px; padding: 20px; border-radius: var(--r-md); background: #f6f8fb; border: 1px solid var(--line-soft); }
.keypoints h3 { font-size: 1rem; margin-bottom: 10px; }
.keypoints ul { padding-left: 1.2em; display: grid; gap: 6px; font-size: .95rem; }
.tasks { margin-top: 24px; }
.tasks h3 { font-size: 1rem; margin-bottom: 10px; }
.tasks ol { list-style: none; counter-reset: t; display: grid; gap: 10px; }
.tasks li { counter-increment: t; display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: .95rem; }
.tasks li::before { content: counter(t); width: 26px; height: 26px; border-radius: 6px; background: var(--saffron-tint); color: #8a5d07; display: grid; place-items: center; font-weight: 700; font-size: .82rem; }
.tasks .lvl { font-size: .75rem; font-weight: 600; color: var(--muted); display: block; margin-top: 4px; }
.reader-foot { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line-soft); display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }

.video { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--r-md); overflow: hidden; margin: 8px 0 24px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-link { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-md); margin: 8px 0 24px; font-size: .92rem; background: #fafbfc; }
.video-link i { color: #c4302b; font-size: 1.4rem; }

/* Overview */
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 900px) { .overview-grid { grid-template-columns: minmax(0, 1fr); } }
.goal-list { list-style: none; display: grid; gap: 10px; }
.goal-list li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; font-size: .95rem; }
.goal-list i { color: var(--turq); margin-top: 4px; }
.comp-list { display: grid; gap: 10px; }
.comp { padding: 12px 14px; border-radius: var(--r-sm); background: var(--lapis-tint); }
.comp b { display: block; font-size: .92rem; color: var(--lapis-deep); }
.comp span { font-size: .85rem; color: var(--ink-soft); }
.steps { list-style: none; display: grid; gap: 0; }
.steps li { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); align-items: center; font-size: .95rem; }
.steps li:last-child { border-bottom: 0; }
.steps .ln-n { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #c3cbd7; display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--muted); }
.steps .done .ln-n { background: var(--turq); border-color: var(--turq); color: #fff; }

/* Quiz */
.quiz { max-width: 760px; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; margin-bottom: 14px; }
.q legend, .q .q-text { font-weight: 600; margin-bottom: 12px; font-size: 1rem; display: block; float: left; width: 100%; }
.q fieldset { border: 0; }
.q .q-code { clear: both; margin-bottom: 12px; }
.opts { display: grid; gap: 8px; clear: both; }
.opt {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; font-size: .95rem;
}
.opt:hover { border-color: #a9b6cc; background: #f8fafc; }
.opt input { margin-top: 4px; accent-color: var(--lapis); }
.opt code { font-family: var(--font-code); font-size: .88em; background: #eef1f6; padding: 0 .3em; border-radius: 3px; }
.opt:has(input:checked) { border-color: var(--lapis); background: var(--lapis-tint); }
.opt.right { border-color: #8fd0b4; background: var(--success-tint); }
.opt.wrong { border-color: #f0a59c; background: var(--danger-tint); }
.q .explain { margin-top: 12px; font-size: .9rem; padding: 10px 12px; border-radius: var(--r-sm); background: #f4f6fa; color: var(--ink-soft); }
.result-box { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; padding: 24px; border-radius: var(--r-md); margin-bottom: 20px; border: 1px solid; }
.result-box.pass { background: var(--success-tint); border-color: #a9dbc6; }
.result-box.fail { background: var(--danger-tint); border-color: #f2b8b0; }
.result-score { font-family: var(--font-read); font-size: 3rem; font-weight: 600; line-height: 1; }
.result-box.pass .result-score { color: var(--success); }
.result-box.fail .result-score { color: var(--danger); }
.reflect { margin-top: 20px; }
.reflect ol { padding-left: 1.2em; display: grid; gap: 6px; }

/* =========================================================
   TABLES (assessment)
   ========================================================= */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.stat b { display: block; font-family: var(--font-read); font-size: 1.8rem; font-weight: 600; line-height: 1.1; }
.stat span { font-size: .85rem; color: var(--muted); }
.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 640px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: .82rem; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f8f9fb; }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .score-cell { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.tbl .score-cell .bar { flex: 1; }
.tbl .num { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 42px; }

/* =========================================================
   CERTIFICATES
   ========================================================= */
.cert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
@media (max-width: 380px) { .cert-grid { grid-template-columns: 1fr; } }
.cert-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; display: flex; flex-direction: column; }
.cert-card.is-course { border-color: #e6c77f; }
.cert-thumb { background: #e9edf3; aspect-ratio: 297 / 210; cursor: zoom-in; }
.cert-thumb canvas, .cert-thumb img { width: 100%; height: 100%; object-fit: contain; }
.cert-body { padding: 16px; display: grid; gap: 6px; }
.cert-body h3 { font-size: 1rem; }
.cert-code { font-family: var(--font-code); font-size: .82rem; color: var(--ink-soft); background: #f1f4f8; padding: 2px 8px; border-radius: 4px; justify-self: start; }
.cert-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; }

.modal { position: fixed; inset: 0; background: rgba(10, 18, 36, .72); display: grid; place-items: center; z-index: 200; padding: 16px; }
.modal-box { background: #fff; border-radius: var(--r-md); max-width: 1100px; width: 100%; max-height: 92vh; overflow: auto; }
.modal-box canvas, .modal-box img { width: 100%; height: auto; }
.modal-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }

.explainer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 28px; }
@media (max-width: 820px) { .explainer { grid-template-columns: 1fr; } }
.explainer div { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); font-size: .9rem; }
.explainer b { display: block; margin-bottom: 4px; }

/* Verify */
.verify-form { display: flex; gap: 10px; flex-wrap: wrap; }
.verify-form .input { flex: 1; min-width: 220px; font-family: var(--font-code); text-transform: uppercase; letter-spacing: .04em; }
.verdict { margin-top: 20px; padding: 20px; border-radius: var(--r-md); border: 1px solid; }
.verdict.ok { background: var(--success-tint); border-color: #a9dbc6; }
.verdict.bad { background: var(--danger-tint); border-color: #f2b8b0; }
.verdict h2 { font-size: 1.15rem; margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.verdict dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .95rem; }
.verdict dt { color: var(--muted); }
.verdict dd { font-weight: 600; }

/* =========================================================
   RESOURCES
   ========================================================= */
.res-group { margin-top: 28px; }
.res-group h2 { font-family: var(--font-read); font-weight: 600; font-size: 1.25rem; margin-bottom: 4px; }
.res-group > p { color: var(--muted); font-size: .92rem; margin-bottom: 14px; }
.res-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
@media (max-width: 340px) { .res-list { grid-template-columns: 1fr; } }
.res {
  display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start;
  padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  text-decoration: none; color: inherit;
}
.res:hover { border-color: #a9b6cc; }
.res .ic { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; background: var(--lapis-tint); color: var(--lapis); }
.res b { display: block; font-size: .98rem; }
.res span { font-size: .86rem; color: var(--muted); display: block; margin-top: 2px; }
.res em { font-style: normal; font-size: .75rem; font-weight: 600; color: var(--turq); display: block; margin-top: 6px; }

/* =========================================================
   PEER REVIEW
   ========================================================= */
.sub-list { display: grid; gap: 12px; }
.sub { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; }
.sub-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: start; }
.sub-head h3 { font-size: 1rem; }
.sub-head .small { color: var(--muted); }
.sub details { margin-top: 12px; }
.sub summary { cursor: pointer; font-weight: 600; color: var(--lapis); font-size: .92rem; }
.rubric { display: grid; gap: 10px; margin-top: 14px; }
.rubric-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--r-sm); }
.rubric-row b { font-size: .92rem; display: block; }
.rubric-row span { font-size: .8rem; color: var(--muted); }
.stars { display: inline-flex; gap: 2px; }
.stars input { position: absolute; opacity: 0; width: 0; }
.stars label { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--muted); }
.stars input:checked + label { background: var(--lapis); border-color: var(--lapis); color: #fff; }
.stars input:focus-visible + label { outline: 3px solid #5b8def; outline-offset: 1px; }
@media (max-width: 520px) { .rubric-row { grid-template-columns: 1fr; } }
.review { padding: 12px 14px; border-left: 3px solid var(--turq); background: #f6f9f9; border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: .92rem; }
.review + .review { margin-top: 8px; }

/* =========================================================
   ACCOUNT
   ========================================================= */
.acct { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .acct { grid-template-columns: minmax(0, 1fr); } }
.id-card { background: var(--lapis-deep); color: #fff; border-radius: var(--r-md); padding: 24px; position: relative; overflow: hidden; }
.id-card::before { content: ""; position: absolute; inset: 0; background: var(--girih) 0 0 / 56px 56px; opacity: .07; }
.id-card > * { position: relative; }
.id-card .avatar { width: 64px; height: 64px; font-size: 1.5rem; margin-bottom: 14px; }
.id-card h2 { font-family: var(--font-read); font-weight: 600; font-size: 1.35rem; line-height: 1.2; }
.id-card p { color: rgba(255,255,255,.75); font-size: .9rem; word-break: break-all; }
.id-card dl { margin-top: 18px; display: grid; gap: 10px; font-size: .9rem; }
.id-card dt { color: rgba(255,255,255,.6); font-size: .78rem; }
.id-card dd { font-weight: 600; }

/* ---------- Kod ranglari (Prism tokenlari) ---------- */
.code .token.comment { color: #7f8ca6; font-style: italic; }
.code .token.string, .code .token.triple-quoted-string { color: #a5e0a0; }
.code .token.keyword, .code .token.boolean { color: #f3b664; }
.code .token.builtin, .code .token.function { color: #8cc8ff; }
.code .token.number { color: #f5a3c7; }
.code .token.operator, .code .token.punctuation { color: #c2cbe0; }
.code .token.decorator, .code .token.class-name { color: #7ee0d6; }
.code .token.interpolation { color: #e6ecf8; }

/* ---------- Chop etish (dars materialini PDF sifatida saqlash) ---------- */
@media print {
  .topbar, .ctabs, .lesson-nav, .footer, .reader-foot, .code-bar, .video, .video-link, .toast-host { display: none !important; }
  body { background: #fff; }
  .course-hero { background: #fff; color: #000; }
  .course-hero::before { display: none; }
  .course-hero p.lead, .course-hero .meta, .crumbs { color: #333; }
  .course-layout { display: block; }
  .reader { border: 0; padding: 0; }
  .code { background: #f5f5f5; border-color: #ccc; break-inside: avoid; }
  .code pre { color: #111; white-space: pre-wrap; }
  .code .token { color: #111 !important; }
  .callout, .keypoints, .tasks li { break-inside: avoid; }
}
