/* Next Level brand: logo yellow + logo navy. Yellow is a FILL (buttons, bars, marks)
   carrying navy text; where yellow would be text on white it becomes --gold-text,
   because #E6AE17 on white is unreadable at body sizes. */
:root {
  --yellow: #e6ae17;
  --navy: #11203c;
  --bg: #ffffff;
  --side: #f5f6f8;
  --ink: #11203c;
  --muted: #5e6779;
  --line: #e3e6ec;
  --accent: #e6ae17;
  --accent-ink: #11203c;
  --accent-soft: #fcf2d4;
  --gold-text: #8a6300;
  --ok: #17885f;
  --ok-soft: #e2f3eb;
  --bad: #c53a2f;
  --bad-soft: #fbe9e7;
  --locked: #a4abb8;
  --card: #ffffff;
  --r: 10px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Montserrat", var(--font);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1628; --side: #111e35; --ink: #eef1f6; --muted: #9aa3b4; --line: #22304b;
    --accent-soft: #2c2715; --gold-text: #f0c445; --ok: #3cc492; --ok-soft: #14301f;
    --bad: #ff7a6e; --bad-soft: #3a1d1b; --locked: #56627a; --card: #111e35;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1628; --side: #111e35; --ink: #eef1f6; --muted: #9aa3b4; --line: #22304b;
  --accent-soft: #2c2715; --gold-text: #f0c445; --ok: #3cc492; --ok-soft: #14301f;
  --bad: #ff7a6e; --bad-soft: #3a1d1b; --locked: #56627a; --card: #111e35;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* logo: the light file on light surfaces, the white-"level" file on dark ones */
.logo { display: block; height: 58px; width: auto; max-width: 100%; object-fit: contain; }
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; text-decoration: none; font-weight: 500;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #f0bb26; border-color: #f0bb26; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg);
}
textarea.input { height: auto; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.flash { padding: 10px 14px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-size: 14px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }
.shell > div { min-width: 0; }
.side {
  background: var(--side); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 22px 16px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; text-decoration: none; }
.course-progress { margin: 22px 8px 8px; }
.course-progress .bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.course-progress .bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.course-progress small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }

.module { margin-top: 18px; }
.module-head {
  display: flex; align-items: baseline; gap: 8px; padding: 6px 8px; color: var(--muted); font-size: 13px;
}
.module-head b { color: var(--ink); font-weight: 600; font-size: 14px; }
.module.soon .module-head b { color: var(--locked); }
.module.soon .module-head svg { margin-left: auto; color: var(--locked); }
.lessons { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 2px; }
.lesson-link {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 8px; border-radius: 8px; text-decoration: none; font-size: 14px; line-height: 1.3;
}
.lesson-link:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.lesson-link.current { background: var(--card); box-shadow: inset 3px 0 0 var(--accent), 0 0 0 1px var(--line); }
.lesson-link .num { font-weight: 600; margin-right: 4px; }
.lesson-link .dur { color: var(--muted); font-size: 12px; }
.lesson-link.locked { color: var(--locked); cursor: default; }
.lesson-link.locked:hover { background: none; }
.state { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.state.passed { background: var(--accent); color: var(--navy); }
.state.open { border: 1.5px solid var(--accent); color: var(--gold-text); }
.state.locked { color: var(--locked); }
.ring { --p: 0; background: conic-gradient(var(--accent) calc(var(--p) * 1%), transparent 0); }

.side-lang {
  margin-top: auto; padding: 16px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  color: var(--muted); font-size: 13px;
}
.side-foot { padding: 12px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: var(--yellow);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.side-foot .who { min-width: 0; flex: 1; font-size: 13px; line-height: 1.3; }
.side-foot .who span { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.topbar { display: none; }
.main { min-width: 0; padding: 28px 40px 80px; }
.main-inner { max-width: 1040px; margin: 0 auto; }

/* ---------------------------------------------------------- lesson */
.lesson-head { display: flex; align-items: flex-end; gap: 18px; margin-bottom: 20px; }
/* the logo's NEXT is a bold geometric sans in yellow: the lesson number speaks the same way */
.lesson-no {
  font-family: var(--display); font-size: 60px; line-height: .8; font-weight: 700; letter-spacing: -.03em;
  color: var(--accent); font-variant-numeric: lining-nums;
}
.lesson-head h1 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -.02em; }
.lesson-head p { margin: 4px 0 0; color: var(--muted); }
.lesson-nav { margin-left: auto; display: flex; gap: 6px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 26px 0 20px; overflow-x: auto; }
.tab {
  border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }
.tab .pill { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--accent-soft); color: var(--gold-text); font-weight: 600; }
.tab .pill.ok { background: var(--ok-soft); color: var(--ok); }
.panel[hidden] { display: none; }

.desc { max-width: 68ch; white-space: pre-line; }

.chapters { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.chapter {
  display: grid; grid-template-columns: 112px 56px 1fr; gap: 14px; align-items: center;
  padding: 6px; border-radius: 10px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%;
}
.chapter:hover { background: var(--side); }
.chapter.active { background: var(--accent-soft); }
.chapter .thumb { width: 112px; aspect-ratio: 16/9; border-radius: 6px; background: var(--side) no-repeat; overflow: hidden; }
.chapter time { color: var(--gold-text); font-weight: 600; font-size: 14px; }

.files { display: grid; gap: 8px; max-width: 640px; }
.file {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; text-decoration: none;
}
.file:hover { border-color: var(--muted); }
.file .ext {
  width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font-size: 11px;
  font-weight: 700; background: var(--navy); color: var(--yellow); text-transform: uppercase;
}
.file .ext.pdf { background: var(--bad-soft); color: var(--bad); }
.file small { display: block; color: var(--muted); }
.file svg { margin-left: auto; color: var(--muted); }

.empty { color: var(--muted); padding: 24px 0; }

/* quiz */
.quiz { max-width: 680px; }
.quiz-gate { display: flex; gap: 16px; align-items: center; padding: 18px; border-radius: 12px; background: var(--side); }
.quiz-gate .meter { flex: 1; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.quiz-gate .meter i { display: block; height: 100%; background: var(--accent); }
.q { padding: 18px 0; border-bottom: 1px solid var(--line); }
.q:last-of-type { border-bottom: 0; }
.q-title { display: flex; gap: 12px; font-weight: 600; margin-bottom: 12px; }
.q-title span { color: var(--muted); font-weight: 500; min-width: 1.5em; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-radius: 8px;
  border: 1px solid var(--line); margin: 6px 0 0 calc(1.5em + 12px); cursor: pointer;
}
.opt:hover { border-color: var(--muted); }
.opt input { margin: 4px 0 0; accent-color: var(--navy); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.q.wrong .opt:has(input:checked) { border-color: var(--bad); background: var(--bad-soft); }
.q.right .opt:has(input:checked) { border-color: var(--ok); background: var(--ok-soft); }
.quiz-foot { display: flex; align-items: center; gap: 16px; margin-top: 18px; }
.result { padding: 18px; border-radius: 12px; display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.result.ok { background: var(--ok-soft); }
.result.bad { background: var(--bad-soft); }
.result .score { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.result.ok .score { color: var(--ok); }
.result.bad .score { color: var(--bad); }
.result .btn { margin-left: auto; }

/* ask */
.ask { max-width: 680px; display: grid; gap: 12px; }
.ask-form { display: grid; gap: 10px; }
.ask-form .row { display: flex; gap: 10px; align-items: center; }
.thread { display: grid; gap: 10px; margin-top: 18px; }
.msg { padding: 12px 14px; border-radius: 10px; background: var(--side); }
.msg .a { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.msg small { color: var(--muted); font-size: 12px; }
.msg .wait { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------------------------------------------------------- session-ended overlay */
.ended {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(8px); display: grid; place-items: center; z-index: 100; padding: 16px;
}
.ended[hidden] { display: none; }
.ended .box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; max-width: 380px; text-align: center; }
.ended h2 { margin: 12px 0 6px; font-size: 20px; }
.ended p { margin: 0 0 18px; color: var(--muted); }

/* ---------------------------------------------------------- auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
/* generated still life (tools/brand_art.py); the fill colour is the image's own yellow so a
   cover-crop never shows a seam */
.auth-art {
  background: #e6a811 url("/static/brand/login-art.jpg?v=2") center bottom / cover no-repeat;
  padding: 40px 48px; overflow: hidden;
}
.auth-art .logo { width: 132px; height: auto; }
.auth-form { display: grid; place-items: center; padding: 32px 16px; position: relative; }
/* the switch is a <form> too: undo the login form's grid/width */
.auth-form form.auth-lang { position: absolute; top: 20px; right: 24px; display: inline-flex; width: auto; max-width: none; gap: 2px; }
.auth-form form, .auth-form .card { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.auth-form h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.02em; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.tg-btn { background: #2aabee; border-color: #2aabee; color: #fff; }
.tg-wait { font-size: 13px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------- mobile */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw); z-index: 50; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 0 100vmax transparent;
  }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(8, 14, 28, .5); }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40;
    background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px; min-height: 52px;
  }
  .topbar .t { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 16px 16px 64px; }
  .lesson-head { gap: 12px; flex-wrap: wrap; }
  .lesson-no { font-size: 44px; }
  .lesson-head h1 { font-size: 20px; }
  .lesson-nav { width: 100%; margin-left: 0; }
  .lesson-nav .btn { flex: 1; }
  .chapter { grid-template-columns: 88px 48px 1fr; gap: 10px; }
  .chapter .thumb { width: 88px; }
  .opt { margin-left: 0; }
  /* four tabs fit one row at 375 in both languages (Russian labels are longer) */
  .tabs { gap: 0; }
  .tab {
    padding: 8px 6px; font-size: 14px; gap: 4px; line-height: 1.2;
    white-space: normal; text-align: center; justify-content: center; flex: 1 1 auto;
  }
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-art { padding: 18px 20px; min-height: 260px; background-position: center 58%; }
  .auth-art .logo { width: 104px; }
  .auth-form { padding-top: 64px; }
  .auth-form form.auth-lang { top: 16px; right: 16px; }
}
@media (max-width: 360px) {
  .tab { padding: 8px 4px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------------------------------------------------------- language switch (UZ | RU) */
.lang-switch { display: inline-flex; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); gap: 2px; }
.lang-switch button {
  border: 0; background: none; height: 26px; min-width: 34px; padding: 0 8px; border-radius: 6px; cursor: pointer;
  font: 600 12px/1 var(--font); color: var(--muted); letter-spacing: .02em;
}
.lang-switch button:hover { color: var(--ink); }
.lang-switch button[aria-pressed="true"] { background: var(--navy); color: #fff; }
