/* ═══════════════════════════════════════════════════════════
   ФИНАНСОВЫЙ КУРС — Dark Theme (Espanoverse-style)
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:           #0a0e1a;
  --bg-card:      #0d1220;
  --bg-card-2:    #111827;
  --bg-input:     #0d1220;
  --border:       rgba(30,41,59,0.8);
  --border-soft:  rgba(30,41,59,0.5);
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --text-dim:     #475569;
  --accent:       #3b82f6;
  --accent-hover: #60a5fa;
  --accent-dark:  #2563eb;
  --accent-glow:  rgba(59,130,246,0.15);
  --accent-glow2: rgba(59,130,246,0.08);
  --green:        #10b981;
  --green-bg:     rgba(16,185,129,0.1);
  --red:          #ef4444;
  --red-bg:       rgba(239,68,68,0.1);
  --amber:        #f59e0b;
  --amber-bg:     rgba(245,158,11,0.1);
  --sidebar-w:    260px;
  --radius:       14px;
  --radius-sm:    10px;
  --radius-pill:  999px;
  --shadow:       0 4px 24px rgba(0,0,0,0.6);
  --shadow-card:  0 1px 3px rgba(0,0,0,0.5), 0 8px 24px rgba(0,0,0,0.4);
  --transition:   0.18s ease;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── VIEWS ──────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* app-root hidden by default; auth.js overrides with inline style */
#app-root { display: none; }

/* ── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a4460; }

/* ══════════════════════════════════════════════════════════
   AUTH SCREEN
   ══════════════════════════════════════════════════════════ */
/* ── LANDING / СТРАНИЦА 0 ─────────────────────────────────────── */
.landing-screen {
  min-height: 100vh;
  background: var(--bg);
  padding: 48px 20px 80px;
}
.landing-inner { max-width: 720px; margin: 0 auto; }

.landing-hero { text-align: center; margin-bottom: 56px; }
.landing-logo {
  width: 60px; height: 60px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #ef4444 0%, var(--accent) 100%);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; color: #fff;
}
.landing-title { font-size: 2rem; font-weight: 800; color: var(--text); margin-bottom: 10px; }
.landing-tagline { color: var(--text-muted); font-size: 1.05rem; line-height: 1.5; max-width: 540px; margin: 0 auto 28px; }

.landing-cta-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.landing-btn {
  padding: 14px 26px; border-radius: var(--radius-pill); font-weight: 700; font-size: 0.95rem;
  border: 1.5px solid var(--border); background: var(--bg-card); color: var(--text);
  cursor: pointer; transition: var(--transition);
}
.landing-btn:hover { border-color: var(--accent); }
.landing-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.landing-btn.primary:hover { background: var(--accent-hover); }
.landing-btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }

.landing-section { margin: 0 auto 40px; padding: 28px; background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.landing-section h2 { font-size: 1.2rem; color: var(--text); margin-bottom: 12px; }
.landing-section p { color: var(--text-muted); line-height: 1.6; }
.landing-payment-note { font-size: 0.8rem; color: var(--text-dim); margin-top: 8px; }

.landing-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 640px) { .landing-steps { grid-template-columns: 1fr; } }
.landing-step { text-align: center; }
.landing-step-num {
  width: 34px; height: 34px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--accent-glow); color: var(--accent); font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.landing-step-title { font-weight: 700; color: var(--text); margin-bottom: 4px; }
.landing-step-text { font-size: 0.85rem; color: var(--text-muted); }

.landing-footer { text-align: center; }
.landing-link { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; font-size: 0.95rem; }
.landing-legal { margin-top: 18px; font-size: 0.78rem; color: var(--text-dim); }

/* ── ТАРИФЫ (pricing.html) ────────────────────────────────────── */
.pricing-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 720px) { .pricing-grid { grid-template-columns: repeat(2, 1fr); } }
.pricing-card {
  background: var(--bg-card-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 20px 14px; text-align: center;
}
.pricing-term { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }
.pricing-price { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.landing-link:hover { color: var(--accent-hover); }

.auth-back-link {
  align-self: flex-start; background: none; border: none; color: var(--text-muted);
  font-size: 0.85rem; cursor: pointer; padding: 0; margin-bottom: 4px;
}
.auth-back-link:hover { color: var(--accent); }

/* ── DEMO BANNER ──────────────────────────────────────────────── */
#demo-banner {
  background: var(--amber-bg); color: var(--amber); border-bottom: 1px solid var(--amber);
  padding: 10px 20px; font-size: 0.85rem; text-align: center;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
}
#demo-banner button {
  background: var(--amber); color: #1a1200; border: none; border-radius: var(--radius-pill);
  padding: 5px 14px; font-weight: 700; font-size: 0.8rem; cursor: pointer;
}

.auth-screen {
  display: none;   /* виден только когда JS явно включит (showLoginScreen,
                       ставит inline style="display:flex", он и победит) —
                       иначе на долю секунды виден вместе с лендингом до authInit() */
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-box {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #ef4444 0%, var(--accent) 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  color: white;
  margin-bottom: 4px;
}

.auth-box h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: -6px;
}

.auth-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.auth-input::placeholder { color: var(--text-dim); }
.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-btn {
  width: 100%;
  background: var(--accent);
  color: #000;
  font-weight: 800;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 24px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  letter-spacing: 0.01em;
}
.auth-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-link-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 11px 20px;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  width: 100%;
}
.auth-link-btn:hover { border-color: var(--accent); color: var(--accent); }

.auth-error {
  color: var(--red);
  font-size: 0.85rem;
  min-height: 16px;
  font-weight: 500;
}
.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
  margin: 2px 0 6px;
  text-align: left;
  cursor: pointer;
}
.auth-consent input { margin-top: 2px; flex-shrink: 0; }
.auth-success {
  color: var(--green);
  font-size: 0.85rem;
  min-height: 16px;
  font-weight: 500;
}

/* ── ЛИЧНЫЙ КАБИНЕТ ───────────────────────────────────────────── */
.account-wrap { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; padding: 0 4px 40px; }
.account-section { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 22px; }
.account-section h3 { font-size: 1.05rem; color: var(--text); margin-bottom: 14px; }
.account-section h4 { font-size: 0.9rem; color: var(--text); }
.account-section .auth-input { margin-bottom: 10px; }
.account-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 0.9rem; }
.account-row:last-child { border-bottom: none; }
.account-row span { color: var(--text-muted); }
.account-sub-placeholder { background: var(--amber-bg); border: 1px solid var(--amber); border-radius: var(--radius-sm); padding: 14px 16px; }
.account-sub-status { color: var(--amber); font-weight: 700; margin-bottom: 6px; }
.account-sub-placeholder p { color: var(--text-muted); font-size: 0.85rem; }
.account-empty { color: var(--text-dim); font-size: 0.85rem; margin-top: 6px; }

/* ── LAYOUT ───────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
@media (max-width: 1023px) { #sidebar { display: none; } }

#app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding-bottom: 24px;
}
@media (max-width: 1023px) {
  #app-main {
    margin-left: 0;
    padding-top: 56px;
    padding-bottom: 72px;
  }
}

/* ── SIDEBAR INTERNALS ─────────────────────────────────────── */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.sb-logo-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff;
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
  flex-shrink: 0;
}
.sb-logo-icon.sm { width: 32px; height: 32px; font-size: .75rem; border-radius: 10px; }
.sb-logo-title { font-weight: 700; font-size: .875rem; color: var(--text); }
.sb-logo-sub { font-size: .7rem; color: var(--text-dim); }

.sb-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sb-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}
.sb-nav-item:hover {
  color: var(--text);
  background: rgba(30,41,59,0.5);
}
.sb-nav-item.active {
  color: #60a5fa;
  background: rgba(59,130,246,0.1);
  border-color: rgba(59,130,246,0.2);
}
.sb-nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sb-bottom {
  padding: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sb-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 8px;
  transition: color var(--transition);
}
.sb-icon-btn:hover { color: var(--text); }

/* ── MOBILE TOP ───────────────────────────────────────────── */
#mob-top {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: rgba(13,18,32,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 40;
}
@media (max-width: 1023px) { #mob-top { display: flex; } }
.mob-top-left { display: flex; align-items: center; gap: 10px; }
.mob-top-title { font-weight: 600; font-size: .9rem; color: var(--text); }
.mob-top-right { display: flex; align-items: center; gap: 8px; }

/* ── MOBILE BOTTOM NAV ────────────────────────────────────── */
#mob-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(13,18,32,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-soft);
  z-index: 40;
  padding: 8px 0;
}
@media (max-width: 1023px) { #mob-nav { display: flex; justify-content: space-around; } }
.mob-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: .65rem;
  font-weight: 500;
  transition: color var(--transition);
}
.mob-nav-item span:first-child { font-size: 1.2rem; }
.mob-nav-item.active, .mob-nav-item:hover { color: #60a5fa; }

/* ── DASHBOARD TOP BAR (compact) ─────────────────────────── */
.dash-topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin: 28px 28px 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.dash-topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}
.dash-topbar-sub {
  font-size: .82rem;
  color: var(--text-muted);
}
@media (max-width: 600px) {
  .dash-topbar { margin: 16px 16px 0; padding-bottom: 12px; }
  .dash-topbar-title { font-size: 1.1rem; }
}

/* ── CONTINUE / BROWSE CTA ───────────────────────────────── */
.dash-cta-row {
  display: flex;
  gap: 12px;
  margin: 4px 28px 26px;
  flex-wrap: wrap;
}
.cta-primary,
.cta-secondary {
  flex: 1 1 0;
  min-width: 0;
  min-height: 166px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 30px 32px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
}
.cta-primary {
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 16px rgba(16,185,129,0.28);
}
.cta-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(16,185,129,0.38); }
.cta-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.cta-primary-icon, .cta-secondary-icon { font-size: 2.6rem; line-height: 1; flex-shrink: 0; }
.cta-primary-text, .cta-secondary-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cta-primary-label, .cta-secondary-label { font-size: 1.35rem; font-weight: 700; }
.cta-primary-sub, .cta-secondary-sub {
  font-size: .92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cta-primary-sub { opacity: .92; }
.cta-secondary {
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text);
}
.cta-secondary-sub { color: var(--text-muted); }
.cta-secondary:hover { transform: translateY(-1px); border-color: rgba(59,130,246,0.35); background: var(--bg-card-2); }
@media (max-width: 600px) {
  .dash-cta-row { margin: 4px 16px 22px; flex-direction: column; flex-wrap: nowrap; }
  .cta-primary, .cta-secondary { min-height: 140px; padding: 26px 24px; }
}

/* ── DASHBOARD STATS ──────────────────────────────────────── */
.dash-stats {
  margin: 20px 28px;
}
@media (max-width: 600px) {
  .dash-stats { margin: 16px 16px; }
}
.dash-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 16px;
  transition: border-color var(--transition);
}
.dash-stat:hover { border-color: rgba(59,130,246,0.3); }
.dash-stat-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.dash-stat-label-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.dash-stat-edit {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .8rem;
  opacity: .6;
  padding: 0;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  transition: opacity var(--transition);
}
.dash-stat-edit:hover { opacity: 1; }
.dash-stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.dash-stat-value-of { font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.dash-stat-sub { font-size: .72rem; color: var(--text-muted); }

/* ── TOPIC CARDS (dash) ───────────────────────────────────── */
.dash-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 4px 28px 12px;
}
.theme-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 28px 28px;
}
@media (max-width: 600px) {
  .theme-list { padding: 0 16px 16px; }
  .dash-section-title { margin: 4px 16px 12px; }
}

.theme-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.theme-item:hover {
  border-color: rgba(59,130,246,0.3);
  background: var(--bg-card-2);
}
.theme-item.locked {
  opacity: 0.5;
  cursor: not-allowed;
}
.theme-item-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  transition: transform var(--transition);
}
.theme-item:hover .theme-item-icon { transform: scale(1.08); }
.theme-item-info { flex: 1; min-width: 0; }
.theme-item-num {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 2px;
}
.theme-item-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.theme-item-sub { font-size: .8rem; color: var(--text-muted); }
.theme-item-arrow { color: var(--text-dim); font-size: 1.1rem; transition: color var(--transition); }
.theme-item:hover .theme-item-arrow { color: #60a5fa; }
.theme-item-badge {
  background: rgba(16,185,129,0.1);
  color: #10b981;
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: var(--radius-pill);
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 10px;
  white-space: nowrap;
}
.theme-item-soon {
  flex-shrink: 0;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* ── SECTION ACCORDION CARDS ──────────────────────────────── */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}
.section-card:hover { border-color: rgba(99,102,241,0.25); }
.section-card.open { border-color: rgba(59,130,246,0.3); }

.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  user-select: none;
}
@media (max-width: 600px) { .section-head { gap: 12px; padding: 14px 14px; } }

.section-icon-wrap {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
@media (max-width: 600px) { .section-icon-wrap { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 10px; } }

.section-meta { flex: 1; min-width: 0; }
.section-num {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.section-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.section-desc {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
@media (max-width: 480px) { .section-desc { display: none; } }

.section-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.section-badge {
  font-size: .72rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
}
.section-chevron {
  color: var(--text-dim);
  font-size: 1.3rem;
  transition: transform var(--transition);
  line-height: 1;
}
.section-card.open .section-chevron { transform: rotate(90deg); }

.section-body {
  display: none;
  border-top: 1px solid var(--border-soft);
  padding: 6px 0;
}
.section-card.open .section-body { display: block; }

/* ── SUBTOPIC ROWS ────────────────────────────────────────── */
.subtopic-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  transition: background var(--transition);
}
@media (max-width: 600px) { .subtopic-row { padding: 10px 14px; gap: 10px; } }
.subtopic-row.active {
  cursor: pointer;
}
.subtopic-row.active:hover {
  background: rgba(59,130,246,0.06);
}
.subtopic-row.locked {
  opacity: 0.5;
}
.sub-num {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 36px;
  flex-shrink: 0;
}
.sub-title {
  flex: 1;
  font-size: .875rem;
  color: var(--text);
  min-width: 0;
}
.subtopic-row.active .sub-title { color: var(--text); }
.sub-status {
  font-size: .72rem;
  font-weight: 600;
  color: #10b981;
  white-space: nowrap;
  flex-shrink: 0;
}
.sub-lock {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  padding: 2px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}

.user-badge {
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}
.db-dot {
  font-size: 0.7rem;
  cursor: default;
  user-select: none;
  opacity: 0.8;
}

/* ══════════════════════════════════════════════════════════
   CONTENT PAGES
   ══════════════════════════════════════════════════════════ */
#topic-landing {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* Hero — styles moved to bottom of file */

/* Aggregate progress */
.home-aggregate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}

.agg-stats {
  display: flex;
  gap: 32px;
  justify-content: center;
}

.agg-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.agg-num {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.agg-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.agg-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--bg-card-2);
  border-radius: 3px;
  overflow: hidden;
}

.agg-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent-hover));
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ── MATERIALS SECTION ───────────────────────────────────── */
.materials-section {
  margin-bottom: 40px;
}

.materials-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-left: 2px;
}

.materials-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 36px;
}

.mat-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-decoration: none;
  color: inherit;
  position: relative;
}
.mat-card:hover:not(.mat-disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-2px);
}
.mat-card.mat-disabled { cursor: default; opacity: 0.4; }

.mat-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-glow);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 4px;
}
.mat-title { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.mat-sub   { font-size: 0.76rem; color: var(--text-muted); }

.mat-soon {
  position: absolute;
  top: 10px; right: 12px;
  background: var(--bg-card-2);
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 20px;
}

/* ── TOPICS GRID ─────────────────────────────────────────── */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.topic-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.topic-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
  transform: translateY(-2px);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topic-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  /* color set via style attr */
  opacity: 0.9;
}

.card-titles { flex: 1; min-width: 0; }
.card-titles h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 2px;
}
.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Mini cube grid */
.mini-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
}
.mc {
  aspect-ratio: 1;
  border-radius: 2px;
}
.mc.unanswered { background: var(--border); }
.mc.correct    { background: var(--green); }
.mc.wrong      { background: var(--red); }
.mc.hint       { background: var(--amber); }

/* ══════════════════════════════════════════════════════════
   TOPIC PAGE
   ══════════════════════════════════════════════════════════ */
#topic-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.topic-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px;
  margin-bottom: 28px;
}

.tab-btn {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
  white-space: nowrap;
}
.tab-btn.active {
  background: var(--accent);
  color: #000;
  font-weight: 800;
}
.tab-btn:hover:not(.active) { color: var(--text); background: var(--bg-card-2); }

/* ── THEORY ──────────────────────────────────────────────── */
.theory-content {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  line-height: 1.8;
  color: var(--text);
}

.theory-content h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}
.theory-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
.theory-content h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin: 20px 0 8px;
}
.theory-content p {
  color: #c8d0dc;
  margin-bottom: 10px;
}
.theory-content ol, .theory-content ul {
  padding-left: 22px;
  color: #c8d0dc;
  margin-bottom: 10px;
}
.theory-content li { margin-bottom: 5px; }
.theory-content strong { color: var(--text); font-weight: 700; }
.theory-content em { color: var(--accent); font-style: italic; }
.theory-content code {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', monospace;
  font-size: 0.85em;
}
.theory-content blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-glow2);
  padding: 12px 18px;
  border-radius: 0 8px 8px 0;
  color: #c8d0dc;
  margin: 14px 0;
  font-style: italic;
}
.theory-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.formula {
  background: var(--bg-card-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 12px 20px;
  margin: 16px 0;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.98rem;
  color: var(--accent);
  font-weight: 600;
}

/* Markdown tables */
.md-table {
  border-collapse: collapse;
  width: 100%;
  margin: 18px 0;
  font-size: 0.88rem;
}
.md-table th, .md-table td {
  border: 1px solid var(--border);
  padding: 9px 14px;
  text-align: left;
  color: #c8d0dc;
}
.md-table thead th {
  background: var(--bg-card-2);
  font-weight: 700;
  color: var(--text);
}
.md-table tbody tr:hover { background: rgba(255,255,255,0.03); }

/* ── QUIZ ────────────────────────────────────────────────── */
.quiz-container { display: flex; flex-direction: column; gap: 20px; }

.question-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px;
  transition: border-color var(--transition);
}
.question-card.answered-correct { border-color: rgba(16,185,129,0.4); }
.question-card.answered-hint    { border-color: rgba(245,158,11,0.35); }
.question-card.answered-wrong   { border-color: rgba(239,68,68,0.35); }

.question-num {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.question-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 18px;
  line-height: 1.55;
}

.options { display: flex; flex-direction: column; gap: 9px; }

.option-btn {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card-2);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-glow2);
}
.option-btn:disabled { cursor: default; }

.opt-letter {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
  transition: all var(--transition);
  color: var(--text-muted);
}

.option-btn.correct {
  border-color: var(--green);
  background: var(--green-bg);
  color: #34d399;
}
.option-btn.correct .opt-letter { background: var(--green); color: #000; }

.option-btn.wrong {
  border-color: var(--red);
  background: var(--red-bg);
  color: #f87171;
}
.option-btn.wrong .opt-letter { background: var(--red); color: #fff; }

/* explanation */
.explanation {
  margin-top: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: rgba(245,158,11,0.07);
  border: 1px solid rgba(245,158,11,0.2);
  font-size: 0.88rem;
  color: #c8d0dc;
  display: none;
  line-height: 1.65;
}
.explanation.show { display: block; }
.explanation::before { content: '💡 '; }

.exp-correct { color: var(--green); font-weight: 700; margin-right: 6px; }
.exp-wrong   { color: var(--red);   font-weight: 700; margin-right: 6px; }

/* quiz result */
.quiz-result {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  text-align: center;
  display: none;
}
.quiz-result.show { display: block; }

.result-score {
  font-size: 3.5rem;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}
.result-score.good { color: var(--green); }
.result-score.ok   { color: var(--accent); }
.result-score.bad  { color: var(--red); }

.result-text { font-size: 1rem; color: var(--text-muted); margin-bottom: 28px; }

.restart-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 13px 30px;
  border-radius: var(--radius-pill);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.restart-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* gen button */
.gen-btn-wrap {
  text-align: center;
  padding: 24px 0 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.gen-btn {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 12px 28px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.gen-btn:hover { border-color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); }

.remaining-badge {
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

/* mode badge */
.mode-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 20px;
  margin-bottom: 14px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(245,158,11,0.25);
}

/* ── FINANCE QUIZ STATES ─────────────────────────────────── */
.question-card.answered-correct .question-num::after { content: ' ✓'; color: var(--green); }
.question-card.answered-wrong   .question-num::after { content: ' ✗'; color: var(--red); }
.question-card.answered-hint    .question-num::after { content: ' △'; color: var(--accent); }

/* AI buttons below question */
.single-ai-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.single-ai-btn {
  background: var(--bg-card-2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.single-ai-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow2);
}
.single-ai-btn.secondary {
  border-style: dashed;
}
.single-ai-btn.secondary:hover {
  border-style: solid;
}

/* AI-generated question block */
.ai-gen-stack {
  margin-top: 16px;
  margin-left: 20px;
  border-left: 3px solid rgba(245,158,11,0.3);
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ai-gen-question {
  background: rgba(245,158,11,0.04);
  border: 1.5px dashed rgba(245,158,11,0.25);
  border-radius: var(--radius);
  padding: 20px;
}
.ai-gen-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 12px;
  opacity: 0.8;
}

/* ── SINGLE MODE ─────────────────────────────────────────── */
.single-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.single-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.single-nav-btn {
  background: var(--bg-card-2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.single-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.single-progress {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}
.hint-btn {
  background: rgba(245,158,11,0.08);
  border: 1.5px solid rgba(245,158,11,0.3);
  color: var(--accent);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.hint-btn:hover { background: rgba(245,158,11,0.15); }

/* ── ANSWER ANALYSIS (explain mode) ─────────────────────── */
.progress-summary-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.psb-item {
  flex: 1;
  min-width: 90px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
}
.psb-num { font-size: 1.4rem; font-weight: 800; }
.psb-num.green { color: var(--green); }
.psb-num.red   { color: var(--red); }
.psb-num.gray  { color: var(--text-muted); }
.psb-lbl { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ══════════════════════════════════════════════════════════
   AI PANEL
   ══════════════════════════════════════════════════════════ */
.ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 54px;
  height: 54px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245,158,11,0.5);
  z-index: 300;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(245,158,11,0.65);
}

.ai-panel {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 360px;
  max-height: 520px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.97);
  transition: opacity 0.2s, transform 0.2s;
}
.ai-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ai-panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.ai-header-actions { display: flex; gap: 6px; }
.ai-header-actions button {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px; height: 28px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color var(--transition), color var(--transition);
}
.ai-header-actions button:hover { border-color: var(--accent); color: var(--accent); }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-welcome {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.ai-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.55;
  position: relative;
  /* Переносы строк — через white-space, а не <br> (см. formatText в ai.js):
     многострочные формулы $$...$$ от модели должны остаться одним текстовым
     узлом, иначе KaTeX не находит закрывающий $$ по ту сторону <br>. */
  white-space: pre-wrap;
}
.ai-msg.ai-msg-user::before,
.ai-msg.user::before {
  content: 'Вы';
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0,0,0,0.5);
  margin-bottom: 4px;
}
.ai-msg.ai-msg-assistant::before,
.ai-msg.assistant::before {
  content: 'ИИ';
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 4px;
}
.ai-msg.user, .ai-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  border-bottom-right-radius: 4px;
}
.ai-msg.assistant, .ai-msg-assistant {
  align-self: flex-start;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-msg.thinking, .ai-msg-typing {
  color: var(--text-muted);
  font-style: italic;
}
.ai-msg.error, .ai-msg-error {
  align-self: flex-start;
  background: var(--red-bg);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--red);
  font-size: 0.82rem;
}

.ai-input-row {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 0.85rem;
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  font-family: inherit;
  transition: border-color var(--transition);
}
.ai-textarea::placeholder { color: var(--text-dim); }
.ai-textarea:focus { border-color: var(--accent); }

.ai-send-btn {
  background: var(--accent);
  border: none;
  color: #000;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }

/* ══════════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow);
}
.modal-box h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
}

.modal-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card-2);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 18px;
}
.modal-tab {
  flex: 1;
  padding: 7px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.modal-tab.active { background: var(--accent); color: #000; }

.modal-tab-content { display: none; }
.modal-tab-content.active { display: block; }

.modal-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 6px;
  margin-top: 14px;
}
.modal-label:first-child { margin-top: 0; }

.modal-input, .model-select, .ai-context-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
}
.modal-input::placeholder, .ai-context-input::placeholder { color: var(--text-dim); }
.modal-input:focus, .model-select:focus, .ai-context-input:focus {
  border-color: var(--accent);
}
.model-select { cursor: pointer; }
.model-select option { background: var(--bg-card); color: var(--text); }

.ai-context-input { resize: vertical; min-height: 80px; }

.modal-save-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 11px 24px;
  border-radius: var(--radius-pill);
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 18px;
  transition: background var(--transition);
}
.modal-save-btn:hover { background: var(--accent-hover); }

.modal-status {
  font-size: 0.8rem;
  color: var(--green);
  margin-top: 8px;
}

/* ══════════════════════════════════════════════════════════
   PROGRESS PAGE (full page, was a modal)
   ══════════════════════════════════════════════════════════ */
#progress-page { padding-bottom: 40px; }
.prog-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}
@media (max-width: 600px) {
  .prog-wrap { padding: 14px 16px 60px; }
}

.prog-page-header { margin-bottom: 18px; }
.prog-page-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}
.prog-page-sub { font-size: .85rem; color: var(--text-muted); }

/* Hero: completion ring + KPI row */
.prog-hero-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 20px;
}
.prog-ring-card {
  position: relative;
  width: 120px; height: 120px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.prog-ring { width: 120px; height: 120px; }
.prog-ring-val {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -46%);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
}
.prog-ring-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, 60%);
  font-size: .62rem;
  color: var(--text-dim);
  white-space: nowrap;
  text-align: center;
}
@media (max-width: 600px) {
  .prog-hero-row { padding: 18px; gap: 16px; }
  .prog-ring-card, .prog-ring { width: 92px; height: 92px; }
  .prog-ring-val { font-size: 1.1rem; }
}

/* Generic content block (weak topics, heatmap, timeline) */
.prog-block {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.prog-block-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.prog-empty-note { font-size: .82rem; color: var(--text-muted); padding: 10px 2px 20px; }

/* Weak topics */
.prog-weak-block { border-color: rgba(239,68,68,0.25); }
.prog-weak-list { display: flex; flex-direction: column; gap: 8px; }
.prog-weak-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-card-2);
}
.prog-weak-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.prog-weak-info { flex: 1; min-width: 0; }
.prog-weak-title { font-size: .84rem; font-weight: 600; color: var(--text); }
.prog-weak-pct { display: block; margin-top: 2px; }

/* Activity heatmap */
.heat-grid {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.heat-cell {
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--bg-card-2);
  display: inline-block;
}
.heat-0 { background: var(--bg-card-2); }
.heat-1 { background: rgba(59,130,246,0.25); }
.heat-2 { background: rgba(59,130,246,0.48); }
.heat-3 { background: rgba(59,130,246,0.72); }
.heat-4 { background: rgba(59,130,246,0.96); }
.heat-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: .68rem;
  color: var(--text-dim);
}

/* Filter tabs + bulk expand/collapse toolbar */
.prog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.prog-bulk-row { display: flex; gap: 6px; flex-shrink: 0; }
.prog-bulk-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: .74rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}
.prog-bulk-btn:hover { color: var(--text); background: var(--bg-card-2); }

.prog-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.prog-filter-btn {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.prog-filter-btn:hover { border-color: rgba(59,130,246,0.35); color: var(--text); }
.prog-filter-btn.active {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.4);
  color: #60a5fa;
}

/* progress sections now reuse the home page's .section-card accordion
   (see SECTION ACCORDION CARDS below) for a consistent look between pages */
#prog-sections-wrap { display: flex; flex-direction: column; gap: 10px; }

.prog-num {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 28px;
}
.prog-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.prog-row:last-child { border-bottom: none; }
@media (max-width: 600px) { .prog-row { padding: 10px 14px; } }
.prog-row-locked {
  opacity: 0.45;
}
.prog-icon-locked { font-size: .9rem; }
.prog-soon {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  padding: 2px 8px;
  border-radius: 20px;
  flex-shrink: 0;
  white-space: nowrap;
}

.prog-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.prog-left { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.prog-left-text { display: flex; flex-direction: column; gap: 2px; }
.prog-title { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.prog-count { font-size: 0.74rem; color: var(--text-muted); }

.prog-right { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.prog-bar-row { display: flex; align-items: center; gap: 10px; }
.prog-bar-wrap {
  flex: 1;
  height: 5px;
  background: var(--bg-card-2);
  border-radius: 3px;
  overflow: hidden;
}
.prog-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent-hover));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.ans-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.ans-badge.good { background: var(--green-bg); color: var(--green); }
.ans-badge.ok   { background: var(--amber-bg); color: var(--amber); }
.ans-badge.bad  { background: var(--red-bg);   color: var(--red); }
.ans-badge.none { background: var(--bg-card-2); color: var(--text-dim); }

/* ── KPI summary row ──────────────────────────────────────── */
.prog-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  flex: 1;
  min-width: 220px;
}
@media (max-width: 480px) { .prog-kpi-row { grid-template-columns: repeat(2, 1fr); } }
.prog-kpi {
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
}
.prog-kpi-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}
.prog-kpi-label {
  font-size: .65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── full topic rows with 3 steps ─────────────────────────── */
.prog-row-compact {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.prog-row-compact:last-child { border-bottom: none; }
@media (max-width: 600px) { .prog-row-compact { padding: 10px 14px; } }

.prog-topic-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1 1 220px;
  min-width: 0;
}
.prog-topic-head > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.prog-mastered-badge {
  background: rgba(16,185,129,0.12);
  color: #10b981;
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 8px;
}
.prog-gen-badge {
  background: rgba(99,102,241,0.1);
  color: #818cf8;
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 8px;
}

/* three step rows inside each topic */
/* compact per-step status pill (icon distinguishes theory/quiz/control,
   color+text is a secondary signal — never the only one) */
.prog-pill-row { display: flex; gap: 6px; flex-shrink: 0; }
.ps-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  font-size: .74rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: default;
}
.ps-pill-icon { font-size: .8rem; line-height: 1; }
.ps-pill-good { background: var(--green-bg); color: var(--green); border-color: rgba(16,185,129,0.25); }
.ps-pill-ok   { background: var(--amber-bg); color: var(--amber); border-color: rgba(245,158,11,0.25); }
.ps-pill-bad  { background: var(--red-bg);   color: var(--red);   border-color: rgba(239,68,68,0.25); }
.ps-pill-none { background: var(--bg-card-2); color: var(--text-dim); }

.ps-no    { font-size: .73rem; color: var(--text-dim); }
.ps-good  { font-size: .73rem; font-weight: 600; color: #10b981; }
.ps-ok    { font-size: .73rem; font-weight: 600; color: #f59e0b; }
.ps-bad   { font-size: .73rem; font-weight: 600; color: #ef4444; }
.ps-date  { font-size: .68rem; color: var(--text-dim); }

/* ── activity timeline ────────────────────────────────────── */
.act-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-soft);
}
.act-item:last-child { border-bottom: none; }
.act-icon { font-size: .85rem; flex-shrink: 0; }
.act-label { flex: 1; font-size: .78rem; color: var(--text-muted); }
.act-time { font-size: .68rem; color: var(--text-dim); white-space: nowrap; }

.prog-row-actions { display: flex; gap: 6px; flex-wrap: wrap; flex-basis: 100%; }
.prog-btn {
  background: var(--bg-card-2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.prog-btn:hover { border-color: var(--accent); color: var(--accent); }
.prog-btn.warn  { border-color: rgba(239,68,68,0.4); color: var(--red); }
.prog-btn.warn:hover { background: var(--red-bg); }
.prog-btn.muted { opacity: 0.7; }

/* answer detail */
.ans-detail-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.ans-section-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 16px 0 8px;
}
.ans-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1.5px solid var(--border);
}
.ans-item.correct { border-color: rgba(16,185,129,0.3); background: var(--green-bg); }
.ans-item.wrong   { border-color: rgba(239,68,68,0.3);  background: var(--red-bg); }
.ans-q { font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.ans-given, .ans-correct { font-size: 0.8rem; color: var(--text-muted); }
.ans-correct { color: var(--green); margin-top: 3px; }

/* ══════════════════════════════════════════════════════════
   ADMIN PANEL
   ══════════════════════════════════════════════════════════ */
#admin-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 20px;
}
#admin-panel.open { display: flex; }

.admin-box, .admin-box-wide {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 680px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.admin-box-wide { max-width: 900px; }

.admin-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.admin-header h3 { font-size: 1rem; font-weight: 700; color: var(--text); }
.admin-close {
  background: var(--bg-card-2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}
.admin-close:hover { border-color: var(--red); color: var(--red); }

.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 18px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.admin-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: -1px;
}
.admin-tab.active { border-bottom-color: var(--accent); color: var(--accent); }
.admin-tab:hover:not(.active) { color: var(--text); }

.admin-body { overflow-y: auto; padding: 18px 24px; flex: 1; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.admin-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  vertical-align: middle;
}
.admin-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
}
.role-badge.admin   { background: var(--accent-glow); color: var(--accent); }
.role-badge.student { background: rgba(99,102,241,0.15); color: #818cf8; }

.admin-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.admin-actions button {
  background: var(--bg-card-2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.admin-actions button:hover { border-color: var(--accent); color: var(--accent); }

.admin-add-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}
.admin-add-row input, .admin-add-row select {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
}
.admin-add-row input::placeholder { color: var(--text-dim); }
.admin-add-row input:focus, .admin-add-row select:focus { border-color: var(--accent); }
.admin-add-row select option { background: var(--bg-card); }

.admin-add-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}
.admin-add-btn:hover { background: var(--accent-hover); }

#admin-add-error { font-size: 0.8rem; color: var(--red); margin-top: 6px; font-weight: 500; }

.admin-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.admin-empty {
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 12px 0;
}

.admin-progress-wrap { overflow-x: auto; }
.admin-progress-table .prog-cell {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 6px;
}
.admin-progress-table .prog-user-cell { font-size: 0.85rem; font-weight: 600; }
.prog-cell.good { color: var(--green); }
.prog-cell.ok   { color: var(--amber); }
.prog-cell.bad  { color: var(--red); }
.prog-cell.none { color: var(--text-dim); }

.admin-q-section { margin-bottom: 20px; }
.admin-q-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.admin-q-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.85rem;
  color: var(--text);
}
.admin-q-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 20px;
}
.admin-gen-qs-list { padding: 10px 0; }

/* ══════════════════════════════════════════════════════════
   READER VIEW
   ══════════════════════════════════════════════════════════ */
#reader-view.active {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.reader-toolbar {
  position: sticky;
  top: 0;
  background: rgba(10,14,26,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  z-index: 50;
}
@media (max-width: 1023px) { .reader-toolbar { top: 56px; } }

.reader-back {
  background: var(--bg-card-2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.reader-back:hover { border-color: var(--accent); color: var(--accent); }

.reader-title-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.reader-body {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 28px 80px;
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.reader-loading {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 60px 0;
  text-align: center;
}

.reader-frame {
  flex: 1;
  width: 100%;
  min-height: calc(100vh - 130px);
  border: none;
  display: none;
  background: var(--bg-card);
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .materials-grid { grid-template-columns: repeat(2, 1fr); }
  .theory-content { padding: 22px 18px; }
  .question-card  { padding: 20px 16px; }
  .auth-box { padding: 28px 22px; }
  .reader-body { padding: 24px 16px 60px; }
  .reader-toolbar { padding: 10px 16px; }
  .ai-panel { width: calc(100vw - 32px); right: 16px; }
  .prog-left { min-width: unset; }
}

/* keep the AI FAB / panel clear of the mobile bottom nav (#mob-nav, ~72px tall) */
@media (max-width: 1023px) {
  .ai-fab   { bottom: 88px; }
  .ai-panel { bottom: 156px; }
}

@media (max-width: 480px) {
  .materials-grid { grid-template-columns: 1fr 1fr; }
  .topics-grid    { grid-template-columns: 1fr; }
  .agg-stats      { gap: 20px; }
  .topic-tabs     { flex-wrap: wrap; }
}

/* card score / hint */
.card-score {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
}
.card-score.good { background: var(--green-bg);  color: var(--green); }
.card-score.ok   { background: var(--amber-bg);  color: var(--amber); }
.card-score.bad  { background: var(--red-bg);    color: var(--red); }
.card-hint { font-size: 0.76rem; color: var(--text-dim); }

/* agg-stat inline */
.agg-stat       { display: inline; }
.agg-sep        { color: var(--text-dim); margin: 0 6px; }
.agg-answered   { font-weight: 700; color: var(--text); }
.agg-pct        { font-weight: 700; color: var(--accent); }

/* ══════════════════════════════════════════════════════════
   LIGHT THEME
   ══════════════════════════════════════════════════════════ */
body.theme-light {
  --bg:           #f8fafc;
  --bg-card:      #ffffff;
  --bg-card-2:    #f1f5f9;
  --bg-input:     #f8fafc;
  --border:       #e2e8f0;
  --border-soft:  #edf2f7;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-dim:     #94a3b8;
  --shadow:       0 2px 12px rgba(0,0,0,0.07);
  --shadow-card:  0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

body.theme-light .reader-toolbar {
  background: rgba(248,250,252,0.95);
}

body.theme-light .ai-panel {
  background: #ffffff;
}

body.theme-light .ai-msg.assistant {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #0f172a;
}

body.theme-light .theory-content {
  color: #1e293b;
}
body.theme-light .theory-content p,
body.theme-light .theory-content ol,
body.theme-light .theory-content ul,
body.theme-light .theory-content li {
  color: #374151;
}
body.theme-light .theory-content h2 { color: #0f172a; }
body.theme-light .theory-content h3 { color: var(--accent-dark); }
body.theme-light .theory-content blockquote {
  background: #fef9ee;
  color: #92400e;
}
body.theme-light .md-table td { color: #374151; }
body.theme-light .md-table thead th { color: #0f172a; background: #f8fafc; }

body.theme-light .question-text { color: #0f172a; }
body.theme-light .option-btn { color: #374151; background: #f8fafc; }
body.theme-light .option-btn:hover:not(:disabled) { background: #fef9ee; }

body.theme-light .ai-welcome { color: #374151; }
body.theme-light .admin-table td { color: #1e293b; }

/* Sidebar + mobile nav have hardcoded dark rgba backgrounds — override for light */
body.theme-light #mob-top {
  background: rgba(255,255,255,0.97);
}
body.theme-light #mob-nav {
  background: rgba(255,255,255,0.97);
}
body.theme-light .sb-nav-item:hover {
  background: rgba(59,130,246,0.07);
  color: var(--text);
}
body.theme-light .cta-secondary:hover { border-color: rgba(37,99,235,0.3); }
body.theme-light .section-card:hover { border-color: rgba(99,102,241,0.2); }
body.theme-light .section-card.open { border-color: rgba(37,99,235,0.35); }
body.theme-light .subtopic-row.active:hover { background: rgba(37,99,235,0.05); }
body.theme-light .sub-lock { background: #f1f5f9; border-color: #e2e8f0; }

/* ══════════════════════════════════════════════════════════
   THEORY MATERIALS BUTTONS
   ══════════════════════════════════════════════════════════ */
.theory-materials {
  margin-top: 24px;
  padding: 20px 22px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
}
.theory-mat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.theory-mat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.theory-mat-btn {
  background: var(--bg-card-2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  font-family: inherit;
}
.theory-mat-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow2);
}
.theory-mat-btn.disabled, .theory-mat-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mat-soon-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 10px;
  color: var(--text-dim);
}

/* ══════════════════════════════════════════════════════════
   CONTROL TEST
   ══════════════════════════════════════════════════════════ */
.ctrl-header {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.ctrl-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.ctrl-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.ctrl-mastered-badge {
  display: inline-block;
  margin-top: 12px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.3);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}

/* ── Контроль: таймер ─────────────────────────────────────────── */
.ctrl-timer-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.ctrl-timer-label { font-size: 0.82rem; color: var(--text-dim); margin-right: 2px; }
.ctrl-timer-opt {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
  background: var(--bg-card-2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.ctrl-timer-opt:hover { border-color: var(--accent); }
.ctrl-timer-opt.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ctrl-timer-hint { font-size: 0.78rem; color: var(--text-dim); margin-left: 6px; }
.ctrl-timer {
  position: sticky;
  top: 8px;
  z-index: 5;
  margin-top: 12px;
  align-self: flex-start;
  background: var(--bg-card-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  font-size: 0.9rem;
  color: var(--text);
}
.ctrl-timer b { font-variant-numeric: tabular-nums; }
.ctrl-timer.urgent {
  border-color: #ef4444;
  color: #ef4444;
  animation: ctrlpulse 1s ease-in-out infinite;
}
@keyframes ctrlpulse { 50% { opacity: 0.55; } }

.ctrl-questions { display: flex; flex-direction: column; gap: 16px; }
.ctrl-card { }

.option-btn.ctrl-selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text);
}
.option-btn.ctrl-selected .opt-letter {
  background: var(--accent);
  color: #000;
}

.ctrl-submit-wrap {
  padding: 24px 0 8px;
  text-align: center;
}
.ctrl-submit-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 14px 32px;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  letter-spacing: 0.01em;
}
.ctrl-submit-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }

.ctrl-result {
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  border: 2px solid;
}
.ctrl-result-pass { border-color: var(--green); background: var(--green-bg); }
.ctrl-result-ok   { border-color: var(--accent); background: var(--accent-glow); }
.ctrl-result-fail { border-color: var(--red);   background: var(--red-bg); }

.ctrl-result-score {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 6px;
}
.ctrl-result-pass .ctrl-result-score { color: var(--green); }
.ctrl-result-ok   .ctrl-result-score { color: var(--accent); }
.ctrl-result-fail .ctrl-result-score { color: var(--red); }

.ctrl-result-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.ctrl-result-msg {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.ctrl-retry-btn {
  background: var(--bg-card-2);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}
.ctrl-retry-btn:hover { border-color: var(--accent); color: var(--accent); }

/* "Изучено" badge on home card */
.card-mastered-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(16,185,129,0.3);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

/* progress bar (non-finance quiz) */
.progress-bar-wrap {
  height: 4px;
  background: var(--bg-card-2);
  border-radius: 2px;
  margin-bottom: 20px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent-hover));
  border-radius: 2px;
  transition: width 0.4s ease;
}


/* ══════════════════════════════════════════════════════════
   TOPIC LANDING
   ══════════════════════════════════════════════════════════ */
/* ── PAGE BREADCRUMB ──────────────────────────────────────── */
.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px 0;
  flex-wrap: wrap;
}
@media (max-width: 600px) { .page-breadcrumb { padding: 12px 16px 0; gap: 8px; } }

.bc-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  white-space: nowrap;
}
.bc-back:hover {
  color: var(--accent);
  border-color: rgba(59,130,246,0.4);
  background: rgba(59,130,246,0.06);
}
.bc-trail {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.bc-crumb {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  transition: color var(--transition);
}
.bc-crumb:hover { color: var(--accent); }
.bc-crumb.bc-current {
  color: var(--text);
  font-weight: 600;
  max-width: 260px;
}
.bc-sep {
  color: var(--text-dim);
  font-size: .8rem;
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .bc-trail .bc-crumb:not(.bc-current) { display: none; }
  .bc-trail .bc-sep { display: none; }
}

.tl-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 0 60px;
}
.tl-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.tl-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}
.tl-titles { flex: 1; }
.tl-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 4px;
}
.tl-title {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 4px;
}
.tl-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════
   STEPS
   ══════════════════════════════════════════════════════════ */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.step-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  padding: 28px 0;
  border-bottom: 1px solid var(--border-soft);
  align-items: start;
}
.step-row:last-child { border-bottom: none; }
.step-left {
  padding-right: 24px;
  padding-top: 4px;
}
.step-num {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
  opacity: 0.9;
}
.step-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.step-right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.step-btn {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all var(--transition);
  font-family: inherit;
}
.step-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow2);
}
.step-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.step-btn.mastered {
  border-color: rgba(16,185,129,0.4);
  background: var(--green-bg);
  color: var(--green);
}

/* ── TOPIC LANDING PROGRESS BLOCK ───────────────────────── */
.tl-progress-block {
  margin-top: 32px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.tl-progress-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.tl-progress-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tl-prog-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 14px;
}
.tl-prog-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.tl-prog-bar-wrap {
  height: 6px;
  background: var(--bg-card-2);
  border-radius: 3px;
  overflow: hidden;
}
.tl-prog-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent-hover));
  border-radius: 3px;
  transition: width 0.5s ease;
}
.tl-prog-bar.green {
  background: linear-gradient(90deg, #059669, var(--green));
}
.tl-prog-stat {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.tl-prog-stat.good { color: var(--green); }
.tl-prog-stat.ok   { color: var(--accent); }
.tl-prog-stat.bad  { color: var(--red); }
.tl-prog-stat.dim  { color: var(--text-dim); font-weight: 500; }

@media (max-width: 600px) {
  .step-row { grid-template-columns: 1fr; gap: 14px; }
  .step-left { padding-right: 0; }
  .tl-title { font-size: 1.25rem; }
  .tl-icon { width: 48px; height: 48px; font-size: 1.4rem; }
}
