/* =====================================================================
   GSBE MBA — Raqamli Iqtisodiyot
   O'qishga mo'ljallangan, mobil-birinchi dizayn tizimi.

   Tamoyillar:
   - Matn markazda: chalg'ituvchi bezaklar, og'ir soyalar va ranglar yo'q
   - Uzoq o'qish uchun serif shrift, keng qator oralig'i, 68ch o'lcham
   - Uch mavzu: light / dark / darker  (html[data-theme])
   - Barcha bosiladigan element kamida 44px — telefon uchun qulay
   ===================================================================== */

/* ---------------------------------------------------------------
   1. Mavzu (theme) tokenlari
   --------------------------------------------------------------- */

:root,
:root[data-theme="light"] {
  --bg:          #FBFAF7;
  --bg-raised:   #FFFFFF;
  --bg-sunken:   #F2F0EB;
  --bg-hover:    #EDEAE3;

  --text:        #1F2124;
  --text-soft:   #55585D;
  --text-faint:  #8A8D92;

  --line:        #E2DFD7;
  --line-strong: #CFCBC1;

  --accent:      #2F5D62;
  --accent-text: #234A4E;
  --accent-bg:   #E8EFEF;
  --on-accent:   #FFFFFF;

  --ok:          #2E6B4F;
  --ok-bg:       #E6F0EA;
  --warn:        #8C5A22;
  --warn-bg:     #F5ECDF;
  --bad:         #93382F;
  --bad-bg:      #F5E6E4;

  --shadow:      0 1px 3px rgba(31, 33, 36, .06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:          #1A1C1F;
  --bg-raised:   #212429;
  --bg-sunken:   #16181B;
  --bg-hover:    #2A2E34;

  --text:        #E6E4DF;
  --text-soft:   #A8ABB0;
  --text-faint:  #7A7D82;

  --line:        #2E3238;
  --line-strong: #3D424A;

  --accent:      #7FB3B8;
  --accent-text: #9CC7CB;
  --accent-bg:   #22333650;
  --on-accent:   #14171A;

  --ok:          #7FBF9B;
  --ok-bg:       #1E2B24;
  --warn:        #D9A566;
  --warn-bg:     #2E2519;
  --bad:         #D98A80;
  --bad-bg:      #2E1E1C;

  --shadow:      0 1px 3px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

:root[data-theme="darker"] {
  --bg:          #0B0C0E;
  --bg-raised:   #121417;
  --bg-sunken:   #08090A;
  --bg-hover:    #1B1E22;

  --text:        #D9D7D2;
  --text-soft:   #93969B;
  --text-faint:  #64676B;

  --line:        #1E2126;
  --line-strong: #2C3037;

  --accent:      #6FA6AC;
  --accent-text: #8CBEC3;
  --accent-bg:   #14232640;
  --on-accent:   #08090A;

  --ok:          #6DB08C;
  --ok-bg:       #131E18;
  --warn:        #C79553;
  --warn-bg:     #221B11;
  --bad:         #C87C72;
  --bad-bg:      #221514;

  --shadow:      0 1px 3px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* Foydalanuvchi tanlamagan bo'lsa — tizim sozlamasiga ergashadi */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:          #1A1C1F;
    --bg-raised:   #212429;
    --bg-sunken:   #16181B;
    --bg-hover:    #2A2E34;
    --text:        #E6E4DF;
    --text-soft:   #A8ABB0;
    --text-faint:  #7A7D82;
    --line:        #2E3238;
    --line-strong: #3D424A;
    --accent:      #7FB3B8;
    --accent-text: #9CC7CB;
    --accent-bg:   #22333650;
    --on-accent:   #14171A;
    --ok:          #7FBF9B;
    --ok-bg:       #1E2B24;
    --warn:        #D9A566;
    --warn-bg:     #2E2519;
    --bad:         #D98A80;
    --bad-bg:      #2E1E1C;
    --shadow:      0 1px 3px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------
   2. Shriftlar va o'lchov
   --------------------------------------------------------------- */

:root {
  /* Interfeys uchun — aniq, ixcham */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, sans-serif;

  /* O'qish uchun — serif, uzoq matnda ko'z charchamaydi */
  --font-read: "Charter", "Bitstream Charter", "Iowan Old Style",
               "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --read-width: 68ch;
  --page-pad: 18px;

  /* Barmoq bilan bosish uchun minimal o'lcham */
  --tap: 52px;

  /* O'qish shrifti o'lchami — foydalanuvchi sozlashi mumkin */
  --read-size: 1.18rem;
  --read-lh: 1.78;
}

/* Shrift o'lchami darajalari (yuqori paneldagi A- / A+ tugmalari) */
:root[data-fs="s"] { --read-size: 1.05rem; --read-lh: 1.72; }
:root[data-fs="m"] { --read-size: 1.18rem; --read-lh: 1.78; }
:root[data-fs="l"] { --read-size: 1.34rem; --read-lh: 1.82; }
:root[data-fs="xl"] { --read-size: 1.5rem;  --read-lh: 1.86; }

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  margin: 0 0 .5em;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.011em;
  color: var(--text);
}
h1 { font-size: 1.55rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.06rem; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent-bg); color: var(--text); }

/* ---------------------------------------------------------------
   3. Sahifa karkasi
   --------------------------------------------------------------- */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Yuqori panel — mobil va desktopda bir xil, sodda */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--page-pad);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  font-weight: 650;
  font-size: .95rem;
  letter-spacing: -.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand small {
  display: block;
  font-weight: 400;
  font-size: .72rem;
  color: var(--text-faint);
  letter-spacing: 0;
}

.topbar-spacer { flex: 1; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-soft);
  font-size: .85rem;
  font-weight: 550;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.icon-btn:active { background: var(--bg-hover); }

/* Mavzu va shrift almashtirgichlari */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.seg button {
  min-width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { background: var(--bg-hover); color: var(--text); }
.seg button:active { background: var(--bg-hover); }
.seg button[aria-pressed="true"] {
  background: var(--accent-bg);
  color: var(--accent-text);
}
.seg button[disabled] { opacity: .32; cursor: default; }
.seg button[disabled]:hover { background: transparent; }

/* Telefonda uchta tugma o'rniga bitta almashtiruvchi */
.seg-theme { display: none; }
.theme-cycle { display: inline-flex; min-width: 62px; }

@media (min-width: 700px) {
  .seg-theme { display: inline-flex; }
  .theme-cycle { display: none; }
}

/* Yon menyu — faqat keng ekranda */
.layout {
  flex: 1;
  display: flex;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
}

.sidebar { display: none; }

.main {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 24px var(--page-pad) 96px;
}

/* Sahifa o'qish kengligi — matn haddan tashqari cho'zilmasin */
.main > * { max-width: var(--read-width); }
.main > .wide { max-width: none; }

/* Pastki navigatsiya — mobil */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .84rem;
  font-weight: 550;
  color: var(--text-faint);
  letter-spacing: -.01em;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.bottom-nav a:hover { text-decoration: none; color: var(--text-soft); }
.bottom-nav a:active { background: var(--bg-hover); }
.bottom-nav a.active { color: var(--accent-text); font-weight: 650; }
/* Faol bo'limni ustki chiziq bilan belgilaymiz */
.bottom-nav a.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

/* ---------------------------------------------------------------
   4. Sarlavha bloki
   --------------------------------------------------------------- */

.page-head { margin-bottom: 22px; }
.page-head h1 { margin-bottom: 6px; }
.page-head .lede {
  color: var(--text-soft);
  font-size: .95rem;
  margin: 0;
}

.eyebrow {
  font-size: .74rem;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}

/* ---------------------------------------------------------------
   5. Bloklar
   --------------------------------------------------------------- */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px;
}
.card + .card { margin-top: 12px; }

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.stat-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 680;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: .8rem;
  color: var(--text-soft);
  margin-top: 3px;
}

/* Progress */
.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width .35s ease;
}
.progress-fill.success { background: var(--ok); }
.progress-fill.warning { background: var(--warn); }

/* ---------------------------------------------------------------
   6. Tugmalar va formalar
   --------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 13px 22px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.005em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background .15s ease, border-color .15s ease, transform .08s ease;
}
.btn:hover { text-decoration: none; }
/* Bosilganda seziladigan javob */
.btn:active { transform: scale(.975); }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  background: var(--bg-raised);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-block { width: 100%; }
.btn-sm { min-height: 44px; padding: 10px 16px; font-size: .92rem; }

/* Telefonda tugmalar sukut bo'yicha to'liq kenglikda — nishonga tegish oson */
@media (max-width: 699px) {
  .btn { width: 100%; }
  .btn-sm { width: auto; }
  .flex.gap-2 > .btn,
  .flex.gap-2 > form,
  .flex.gap-2 > form > .btn { width: 100%; }
}

.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 16px; /* iOS zoom oldini oladi */
}
.form-input::placeholder { color: var(--text-faint); }
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* ---------------------------------------------------------------
   7. Belgilar (badge)
   --------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge-easy    { background: var(--ok-bg);   color: var(--ok); }
.badge-medium  { background: var(--warn-bg); color: var(--warn); }
.badge-hard    { background: var(--bad-bg);  color: var(--bad); }
.badge-neutral { background: var(--bg-sunken); color: var(--text-soft); border: 1px solid var(--line); }

/* ---------------------------------------------------------------
   8. Mavzular ro'yxati
   --------------------------------------------------------------- */

.topic-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.topic-row:last-child { border-bottom: 0; }

.topic-num {
  flex-shrink: 0;
  width: 30px;
  font-size: .82rem;
  font-weight: 650;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.topic-info { flex: 1; min-width: 0; }
.topic-info h3 {
  margin: 0 0 4px;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.35;
}
.topic-info h3 a { color: var(--text); }
.topic-info h3 a:hover { color: var(--accent-text); }

.topic-progress-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.topic-progress-line .progress-track { max-width: 180px; }
.topic-row .btn { flex-shrink: 0; margin-top: 2px; }

/* ---------------------------------------------------------------
   9. Dars — o'qish rejimi
   --------------------------------------------------------------- */

.lesson-header {
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.lesson-header h1 {
  font-family: var(--font-read);
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -.015em;
}
.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: .82rem;
  color: var(--text-faint);
  margin-top: 10px;
}

.lesson-layout { display: block; }

/* Dars matni — asosiy urg'u shu yerda */
.lesson-content {
  font-family: var(--font-read);
  font-size: var(--read-size);
  line-height: var(--read-lh);
  letter-spacing: .003em;
  color: var(--text);
  max-width: var(--read-width);
  overflow-wrap: break-word;
}
.lesson-content > *:first-child { margin-top: 0; }
.lesson-content p { margin: 0 0 1.15em; }
.lesson-content h2,
.lesson-content h3 {
  font-family: var(--font-read);
  margin: 1.9em 0 .6em;
  line-height: 1.3;
  letter-spacing: -.012em;
}
.lesson-content h2 { font-size: 1.34rem; }
.lesson-content h3 { font-size: 1.16rem; }
.lesson-content strong { font-weight: 650; }
.lesson-content ul,
.lesson-content ol { padding-left: 1.3em; margin: 0 0 1.15em; }
.lesson-content li { margin-bottom: .5em; }
.lesson-content li::marker { color: var(--text-faint); }

.lesson-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-family: var(--font-ui);
  font-size: .92rem;
  line-height: 1.5;
}
.lesson-content th,
.lesson-content td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.lesson-content th {
  background: var(--bg-sunken);
  font-weight: 600;
  font-size: .86rem;
}

/* Keng jadvallar telefonda gorizontal siljisin */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Dars ichidagi navigatsiya — telefonda yig'ilgan holda */
.lesson-nav {
  margin: 0 0 26px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.lesson-nav > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.lesson-nav > summary::-webkit-details-marker { display: none; }
.lesson-nav > summary::after {
  content: "";
  width: 8px; height: 8px;
  margin-left: auto;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .2s ease;
}
.lesson-nav[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.lesson-nav[open] > summary { border-bottom: 1px solid var(--line); }
.lesson-nav ol { list-style: none; margin: 0; padding: 10px 16px 14px; counter-reset: ln; }
.lesson-nav li { counter-increment: ln; }
.lesson-nav li a {
  display: flex;
  gap: 10px;
  min-height: 46px;
  align-items: center;
  padding: 6px 0;
  font-size: .95rem;
  color: var(--text-soft);
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
.lesson-nav li a::before {
  content: counter(ln);
  flex-shrink: 0;
  width: 20px;
  font-size: .78rem;
  font-weight: 650;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.lesson-nav li a:hover { color: var(--text); text-decoration: none; }
.lesson-nav li a.current { color: var(--accent-text); font-weight: 600; }
.lesson-nav li a.done::after {
  content: "o'qildi";
  font-size: .7rem;
  color: var(--ok);
  margin-left: auto;
}

/* Yon qutilar — matndan keyin, sokin */
.lesson-aside { margin-top: 34px; }
.aside-box {
  border-left: 3px solid var(--line-strong);
  padding: 2px 0 2px 16px;
  margin-bottom: 22px;
  font-size: .96rem;
  line-height: 1.65;
  color: var(--text-soft);
}
.aside-box h4 {
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 6px;
}
.aside-box p:last-child { margin-bottom: 0; }
.aside-box.remember { border-left-color: var(--accent); }
.aside-box.remember h4 { color: var(--accent-text); }
.aside-box.exam-hint { border-left-color: var(--warn); }
.aside-box.exam-hint h4 { color: var(--warn); }

.lesson-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.lesson-footer form { margin: 0; }

@media (max-width: 699px) {
  .lesson-footer { flex-direction: column; align-items: stretch; }
  .lesson-footer form { width: 100%; }
  .lesson-footer .flex.gap-2 { flex-direction: column; width: 100%; }
}

/* O'qish progressi — sahifa yuqorisidagi ingichka chiziq */
.read-progress {
  position: fixed;
  top: 0; left: 0;
  z-index: 40;
  height: 3px;
  width: 0;
  background: var(--accent);
  transition: width .1s linear;
  pointer-events: none;
}

/* Telefonda "Keyingi dars" doim barmoq yetadigan joyda turadi */
.reader-bar {
  position: fixed;
  left: 0; right: 0;
  /* Pastki navigatsiya balandligi + iPhone'dagi xavfsiz zona */
  bottom: calc(58px + env(safe-area-inset-bottom));
  z-index: 25;
  display: none;
  gap: 10px;
  padding: 10px var(--page-pad);
  background: color-mix(in srgb, var(--bg-raised) 94%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-top: 1px solid var(--line);
}
.reader-bar .btn { flex: 1; margin: 0; }
@media (max-width: 999px) {
  .reader-bar.is-active { display: flex; }
  /* Yopishqoq panel matnni to'sib qolmasligi uchun qo'shimcha joy */
  body.has-reader-bar .main { padding-bottom: 150px; }
}

/* ---------------------------------------------------------------
   10. Bilim kartalari
   --------------------------------------------------------------- */

.kcard-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

.kcard {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  cursor: pointer;
}
.kcard:hover { border-color: var(--line-strong); }
.kcard-code {
  font-size: .98rem;
  font-weight: 650;
  color: var(--accent-text);
  letter-spacing: -.005em;
}
.kcard-title { font-size: .88rem; color: var(--text-soft); margin-top: 3px; }
.kcard-explanation {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: .95rem;
  line-height: 1.65;
  color: var(--text-soft);
}
.kcard.open .kcard-explanation { display: block; }

/* ---------------------------------------------------------------
   11. Flashcard
   --------------------------------------------------------------- */

.flashcard-stage { max-width: 560px; margin: 0 auto; }
.flashcard {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 26px;
  font-family: var(--font-read);
  font-size: 1.25rem;
  line-height: 1.55;
  cursor: pointer;
}
.flashcard .fc-back { display: none; color: var(--accent-text); }
.flashcard.flipped .fc-front { display: none; }
.flashcard.flipped .fc-back { display: block; }
.flashcard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

/* ---------------------------------------------------------------
   12. Test / imtihon
   --------------------------------------------------------------- */

.question-block {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.question-block:first-of-type { padding-top: 6px; }

.question-num {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .76rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.question-text {
  font-family: var(--font-read);
  font-size: 1.12rem;
  line-height: 1.6;
  margin: 10px 0 16px;
  color: var(--text);
}

.option-label {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 15px 16px;
  margin-bottom: 10px;
  background: var(--bg-raised);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  font-size: 1.02rem;
  line-height: 1.5;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
}
.option-label:hover { border-color: var(--line-strong); }
.option-label:active { transform: scale(.99); }
.option-label input {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
}
.option-label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.option-label.correct   { border-color: var(--ok);  background: var(--ok-bg); }
.option-label.incorrect { border-color: var(--bad); background: var(--bad-bg); }

.exam-submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
  margin-top: 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------------
   13. Natija sahifasi
   --------------------------------------------------------------- */

.result-hero { text-align: center; padding: 28px 0 34px; }
.result-score {
  font-size: 3.4rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.result-score-label { color: var(--text-soft); font-size: .92rem; margin-top: 8px; }

.topic-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.topic-result-row:last-child { border-bottom: 0; }
.topic-result-row .name { flex: 1; font-size: .94rem; min-width: 0; }
.topic-result-row .pct {
  width: 52px;
  text-align: right;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------
   14. Kirish sahifasi
   --------------------------------------------------------------- */

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px var(--page-pad);
  background: var(--bg);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 {
  font-family: var(--font-read);
  font-size: 1.6rem;
  text-align: center;
  margin-bottom: 6px;
}
.auth-card .subtitle {
  text-align: center;
  color: var(--text-soft);
  font-size: .92rem;
  margin-bottom: 28px;
}
.auth-error {
  background: var(--bad-bg);
  color: var(--bad);
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: .9rem;
  margin-bottom: 16px;
}
.demo-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: .85rem;
  color: var(--text-faint);
  text-align: center;
}

/* ---------------------------------------------------------------
   15. Yordamchi sinflar
   --------------------------------------------------------------- */

.text-muted  { color: var(--text-soft); }
.text-small  { font-size: .875rem; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}
.gap-2 { gap: 12px; }
.box {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px;
}
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-faint);
  font-size: .95rem;
}

/* ---------------------------------------------------------------
   16. Kengroq ekranlar
   --------------------------------------------------------------- */

@media (min-width: 700px) {
  :root { --page-pad: 32px; }
  body { font-size: 17px; }
  h1 { font-size: 1.75rem; }
  .card-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .kcard-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .lesson-header h1 { font-size: 2rem; }
  .lesson-content { font-size: 1.2rem; }
}

@media (min-width: 1000px) {
  .bottom-nav { display: none; }
  .main { padding-bottom: 72px; }

  .sidebar {
    display: block;
    width: 216px;
    flex-shrink: 0;
    padding: 26px 12px 26px var(--page-pad);
    position: sticky;
    top: 57px;
    align-self: flex-start;
    max-height: calc(100vh - 57px);
    overflow-y: auto;
  }
  .nav-link {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 12px;
    margin-bottom: 2px;
    border-radius: var(--r-sm);
    font-size: .92rem;
    font-weight: 500;
    color: var(--text-soft);
  }
  .nav-link:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
  .nav-link.active {
    background: var(--accent-bg);
    color: var(--accent-text);
    font-weight: 600;
  }
  .sidebar-sep {
    height: 1px;
    background: var(--line);
    margin: 14px 12px;
  }

  /* Keng ekranda o'qish ustunini qolgan maydon markaziga joylaymiz */
  .main { padding-left: 28px; padding-right: var(--page-pad); }
  .main > * { margin-left: auto; margin-right: auto; }
}

/* ---------------------------------------------------------------
   17. Harakatni kamaytirish / chop etish
   --------------------------------------------------------------- */

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

@media print {
  .topbar, .bottom-nav, .sidebar, .lesson-nav,
  .lesson-footer, .exam-submit-bar { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .main { padding: 0; max-width: none; }
  .lesson-content { font-size: 12pt; }
}
