/* ==========================================================================
   Monday design system
   Light and dark themes share one accent: the Monday blue gradient
   (powder #BBCFF4 → electric #2B60E5 → navy #153893 → midnight #020B29).
   Every colour is a token, so themes and future brand changes happen here only.
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F6F6F3;
  --surface-3: #EDEDEA;
  --line: #E4E4E1;
  --line-strong: #D4D4D0;
  --text: #0E0E0E;
  --text-2: #3D3D3D;
  --muted: #5E5E5E;

  --accent: #1F4FE0;          /* links, progress, focus */
  --accent-strong: #0A1A5C;   /* headbars, active tags */
  --accent-bright: #4C86FF;   /* big numerals on dark hero */
  --accent-soft: #E8F1FB;     /* tinted surfaces */
  --accent-ink: #0A1A5C;      /* text on accent-soft */
  --on-accent: #FFFFFF;
  --hero: #0A1A5C;
  --hero-text: #FFFFFF;
  --hero-muted: #A9C9F2;

  --btn-bg: #153893;          /* primary buttons: plain dark blue */
  --btn-text: #FFFFFF;
  --nav-active-bg: #153893;
  --nav-active-text: #FFFFFF;

  --ok: #157347;
  --ok-soft: #E7F6EE;
  --bad: #C93A3A;
  --bad-soft: #FCE6E6;
  --warn: #9A6A00;
  --warn-soft: #FDF6DD;

  /* question difficulty levels and the "marked for review" flag */
  --lvl-1: #2F9E5B;  --lvl-1-soft: #E7F6EC;
  --lvl-2: #D99A0B;  --lvl-2-soft: #FFF4DB;
  --lvl-3: #D64545;  --lvl-3-soft: #FDE7E7;
  --mark: #E8A400;   --mark-line: #C98A00;

  --shadow: 0 1px 2px rgba(14, 14, 14, .04), 0 8px 24px rgba(14, 14, 14, .05);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0D0D0D;
  --surface: #141414;
  --surface-2: #1B1B1B;
  --surface-3: #242424;
  --line: #262626;
  --line-strong: #363636;
  --text: #F2F2F2;
  --text-2: #C8C8C8;
  --muted: #9A9A9A;

  --accent: #5B8CFF;
  --accent-strong: #262626;
  --accent-bright: #7FA3F3;
  --accent-soft: #1F1F1F;
  --accent-ink: #E0E0E0;
  --on-accent: #FFFFFF;
  --hero: #141414;
  --hero-text: #F2F2F2;
  --hero-muted: #9A9A9A;

  --btn-bg: #2456D9;
  --btn-text: #FFFFFF;
  --nav-active-bg: #1F1F1F;
  --nav-active-text: #F2F2F2;

  --ok: #5CF07F;
  --ok-soft: #0E2A1A;
  --bad: #FF7A7A;
  --bad-soft: #2A0F0F;
  --warn: #F2C94C;
  --warn-soft: #2A2410;

  --lvl-1-soft: rgba(47, 158, 91, .18);
  --lvl-2-soft: rgba(217, 154, 11, .18);
  --lvl-3-soft: rgba(214, 69, 69, .18);

  --shadow: none;
  color-scheme: dark;
}

/* Carbon-black dark-mode inputs, secondary buttons & tables (legible AA contrast, zero blue-gray) */
[data-theme="dark"] :is(.input, .select, .textarea, .search) {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text);
}
[data-theme="dark"] :is(.input, .textarea)::placeholder,
[data-theme="dark"] .search input::placeholder {
  color: var(--muted);
  opacity: 1;
}
[data-theme="dark"] .select option {
  background: #141414;
  color: #F2F2F2;
}
[data-theme="dark"] .btn--secondary {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text);
}
[data-theme="dark"] .btn--secondary:hover {
  background: var(--surface-3);
  border-color: #4A4A4A;
  filter: none;
}
[data-theme="dark"] thead th {
  background: var(--surface-2);
  color: var(--muted);
}

/* Session-mode colours: same pastel cards in both themes, text stays dark. */
:root {
  --mode-green: #4CB782;  --mode-green-soft: #E7F6EE;  --mode-green-line: #4CB782;
  --mode-yellow: #F2C94C; --mode-yellow-soft: #FDF6DD; --mode-yellow-line: #F2E2A6;
  --mode-orange: #F2994A; --mode-orange-soft: #FDEEDF; --mode-orange-line: #F6CFA9;
  --mode-red: #EB5757;    --mode-red-soft: #FCE6E6;    --mode-red-line: #F3B9B9;
  --mode-purple: #9B6BDF; --mode-purple-soft: #F1EAFB; --mode-purple-line: #D4C1F2;

  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Unbounded", "Onest", system-ui, sans-serif;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 24px;
  --rail: 96px;
  --topbar: 72px;
}

/* -------------------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar, 72px) + env(safe-area-inset-top, 0px) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ic { display: inline-flex; width: var(--ic, 20px); height: var(--ic, 20px); flex: none; }
.ic svg { width: 100%; height: 100%; }

.display { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.03em; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
/* numbers keep their natural width: equal-width digits leave a wide gap around this font's narrow 1 ("1 2"). Only a running
   timer needs them, so its digits don't jitter */
.num { font-variant-numeric: normal; }
[data-qtimer] { font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------------------- layout */

.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh; align-self: start;
  border-right: 1px solid var(--line);
  padding: 20px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg); z-index: 20; overflow-y: auto;
}
.rail__logo { font-family: var(--font-display); font-weight: 800; font-size: 22px; color: var(--text); text-decoration: none; margin-bottom: 18px; }
.rail__item {
  width: 76px; padding: 10px 0; border-radius: var(--r);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--text-2); text-decoration: none; text-align: center;
}
.rail__item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.rail__item.is-active { background: var(--nav-active-bg); color: var(--nav-active-text); }
.rail__sep { width: 40px; height: 1px; background: var(--line); margin: 8px 0; }
.rail__badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10px; display: inline-flex; align-items: center; justify-content: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15;
  height: var(--topbar); padding: 0 48px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
}
.topbar__context { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.topbar__tools { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: var(--bw, 1px) solid var(--line);
  background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none; position: relative;
}
.icon-btn:hover { border-color: var(--line-strong); }
.icon-btn .dot-badge { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--accent-strong); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; text-decoration: none;
}
.avatar--sm { width: 30px; height: 30px; font-size: 11px; background: var(--accent-soft); color: var(--accent-ink); }
.avatar--lg { width: 72px; height: 72px; font-size: 24px; }
.avatar.has-img { padding: 0; overflow: hidden; background: var(--surface-3); }
.avatar.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.page { padding: 36px 48px 72px; max-width: 1180px; width: 100%; margin-inline: auto; display: flex; flex-direction: column; gap: 28px; }
.page--narrow { max-width: 820px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.page-head__text { display: flex; flex-direction: column; gap: 8px; }
.page-head__text p { color: var(--text-2); font-size: 16px; }
.section { display: flex; flex-direction: column; gap: 16px; }
.section__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.spacer { flex: 1; }

/* -------------------------------------------------------------------------- surfaces */

.card {
  background: var(--surface); border: var(--bw, 1px) solid var(--line); border-radius: var(--r-lg);
  padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0;
}
.card--tight { padding: 18px; gap: 12px; }
.card--flush { padding: 0; gap: 0; overflow: hidden; }
.card--accent { border: 2px solid var(--accent); }
.card--inverse { background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg); }
.card--inverse .muted, .card--inverse .text-2 { color: color-mix(in srgb, var(--btn-text) 70%, transparent); }
.card--soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.card__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.hero {
  background: var(--hero); color: var(--hero-text); border-radius: var(--r-xl);
  padding: 36px 40px; display: flex; flex-wrap: wrap; gap: 32px; justify-content: space-between; align-items: flex-end;
  overflow: hidden;
}
.hero .eyebrow, .hero .hero-muted { color: var(--hero-muted); }
.hero__count { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.hero__number { font-family: var(--font-display); font-size: 112px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; color: var(--accent-bright); }
.hero__unit { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.hero__stats { display: flex; gap: 28px; }
.hero__stat-value { font-size: 32px; font-weight: 800; }
.hero .btn--primary { background: #FFFFFF; color: #0E0E0E; }

.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }

.empty {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); padding: 40px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--text-2);
}
.empty h3 { color: var(--text); }

/* -------------------------------------------------------------------------- buttons, chips, tags */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent;
  font: 700 15px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn--primary { background: var(--btn-bg); color: var(--btn-text); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn--accent { background: var(--accent); color: var(--on-accent); }
.btn--danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn--ghost { background: transparent; color: var(--text); padding: 0 12px; }
.btn--lg { min-height: 52px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: 13px; border-radius: 10px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: var(--bw, 1px) solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 600 14px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.chip:hover { text-decoration: none; border-color: var(--text); }
.chip.is-active { background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg); }
.chip__count { font-size: 12px; opacity: .7; }
.chips__sep { width: 1px; align-self: stretch; background: var(--line); margin: 4px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 700; background: var(--accent-strong); color: #FFFFFF; white-space: nowrap;
}
.tag--soft { background: var(--accent-soft); color: var(--accent-ink); }
.tag--line { background: transparent; color: var(--text); border: var(--bw, 1px) solid var(--line-strong); }
.tag--ink { background: var(--btn-bg); color: var(--btn-text); }
.tag--ok { background: var(--ok-soft); color: var(--ok); }
.tag--bad { background: var(--bad-soft); color: var(--bad); }
.tag--warn { background: var(--warn-soft); color: var(--warn); }
/* 6 Exam categories with the Pinterest palette */
.tag--exam-ORT  { background: #A0E0C8 !important; color: #0F382A !important; }
.tag--exam-ENT  { background: #74BFBA !important; color: #0A3230 !important; }
.tag--exam-EGE  { background: #4F8C9E !important; color: #FFFFFF !important; }
.tag--exam-OGE  { background: #31557E !important; color: #FFFFFF !important; }
.tag--exam-SAT  { background: #1B255D !important; color: #FFFFFF !important; }
.tag--exam-CSCA { background: #120B3C !important; color: #FFFFFF !important; }
.tag--exam-OLYMP { background: #F2C14E !important; color: #3A2A00 !important; }
.tag--exam-CALC1 { background: #BFE7D6 !important; color: #0B3B2B !important; }

.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state--new { color: var(--accent-ink); background: var(--accent-soft); }
.state--in_progress { color: var(--warn); background: var(--warn-soft); }
.state--submitted { color: var(--accent-ink); background: var(--accent-soft); }
.state--checked { color: var(--ok); background: var(--ok-soft); }
.state--overdue { color: var(--bad); background: var(--bad-soft); }
.state--draft { color: var(--muted); background: var(--surface-2); }
.state--published { color: var(--ok); background: var(--ok-soft); }
.state--archived { color: var(--muted); background: var(--surface-2); }
.state--pending { color: var(--warn); background: var(--warn-soft); }

.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }

/* -------------------------------------------------------------------------- progress */

.bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
[data-theme="dark"] .bar { background: #FFFFFF; }
.bar > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar--lg { height: 10px; border-radius: 5px; }
.split-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; }
.split-bar > span { min-width: 4px; }

.skill-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-sizing: border-box; border: 2px solid var(--text); position: relative; overflow: hidden; }
.skill-dot--mastered { background: var(--text); }
.skill-dot--progress::after { content: ""; position: absolute; inset: 0 50% 0 0; background: var(--text); }
.skill-dot--new { background: transparent; }
.skill-dot--outside { border: 2px dashed var(--muted); }

/* -------------------------------------------------------------------------- mode cards */

.modes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.mode-card {
  border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 10px;
  color: #0E0E0E; text-decoration: none; border: 1px solid; min-height: 150px; position: relative;
  font: inherit; text-align: left; cursor: pointer; width: 100%;
}
.mode-card:hover { text-decoration: none; transform: translateY(-1px); }
.mode-card__dot { width: 28px; height: 28px; border-radius: 50%; }
.mode-card__name { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.mode-card__desc { font-size: 13px; color: #3D3D3D; }
.mode-card.is-recommended { border-width: 2px; }
.mode-card.is-soon { cursor: default; }
.mode-card.is-soon .mode-card__name, .mode-card.is-soon .mode-card__desc, .mode-card.is-soon .mode-card__dot { opacity: .5; }
.mode-card .tag { position: absolute; top: 18px; right: 18px; background: #0E0E0E; color: #fff; }
.mode--green  { background: var(--mode-green-soft);  border-color: var(--mode-green-line); }
.mode--yellow { background: var(--mode-yellow-soft); border-color: var(--mode-yellow-line); }
.mode--orange { background: var(--mode-orange-soft); border-color: var(--mode-orange-line); }
.mode--red    { background: var(--mode-red-soft);    border-color: var(--mode-red-line); }
.mode--purple { background: var(--mode-purple-soft); border-color: var(--mode-purple-line); }
.bg-green { background: var(--mode-green); color: #0E0E0E; } .bg-yellow { background: var(--mode-yellow); }
.bg-orange { background: var(--mode-orange); } .bg-red { background: var(--mode-red); } .bg-purple { background: var(--mode-purple); }

/* -------------------------------------------------------------------------- work cards (collections) */

.work-card { gap: 14px; padding: 20px; }
.work-card__title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.work-card__desc { font-size: 14px; color: var(--text-2); line-height: 1.45; }
.work-card__meta { margin-top: auto; display: flex; gap: 14px; font-size: 13px; font-weight: 600; color: var(--text-2); flex-wrap: wrap; }
.meta-item { display: inline-flex; align-items: center; gap: 6px; --ic: 16px; }
.author { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }

/* -------------------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > label, .label { font-size: 14px; font-weight: 600; }
.field__hint { font-size: 13px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 0 14px; border: var(--bw, 1px) solid var(--line-strong); border-radius: 12px;
  background: var(--surface); color: var(--text); font: 500 15px var(--font);
}
.textarea { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input--mono { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.search {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px;
  border: var(--bw, 1px) solid var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--muted); --ic: 20px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 500 16px var(--font); color: var(--text); }
.search--sm { min-height: 44px; border-width: 1px; border-color: var(--line-strong); }
fieldset { border: var(--bw, 1px) solid var(--line); border-radius: var(--r-lg); padding: 24px; margin: 0; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
legend { padding: 0 8px; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.check-chip { position: relative; }
.check-chip input { position: absolute; opacity: 0; pointer-events: none; }
.check-chip span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: var(--bw, 1px) solid var(--line-strong); font-weight: 600; font-size: 14px; cursor: pointer; }
.check-chip input:checked + span { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); }
.check-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.check-chip--sm span { min-height: 30px; padding: 0 10px; font-size: 12px; }
.input--sm { min-height: 38px; font-size: 14px; padding: 0 12px; }
.icon-btn--sm { width: 32px; height: 32px; border-radius: 9px; }
.card--dashed { border-style: dashed; border-color: var(--line-strong); background: transparent; }

/* -------------------------------------------------------------------------- abilities map editor */

.tree-topic h2 { font-size: 22px; }
.tree-card { gap: 12px; }
.tree-card.is-archived, .tree-node.is-archived { opacity: .55; }
.tree-nodes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tree-node { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.tree-node:first-child { border-top: 0; padding-top: 0; }
.tree-node__name { font-weight: 600; }
.tree-add { display: flex; gap: 8px; margin-top: auto; }
.tree-add .input { flex: 1; min-width: 0; }
.tree-edit { position: relative; }
.tree-edit > summary { list-style: none; width: 32px; height: 32px; border-radius: 9px; border: var(--bw, 1px) solid var(--line); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); }
.tree-edit > summary::-webkit-details-marker { display: none; }
.tree-edit[open] > summary { border-color: var(--accent); color: var(--accent); }
.tree-edit__panel { position: absolute; right: 0; top: 38px; z-index: 30; width: 300px; background: var(--surface); border: var(--bw, 1px) solid var(--line-strong); border-radius: var(--r); padding: 16px; box-shadow: 0 12px 32px rgba(0, 0, 0, .14); }

/* -------------------------------------------------------------------------- publish page grid */

.segmented { display: inline-flex; border: var(--bw, 1px) solid var(--line-strong); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented a { padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--text-2); text-decoration: none; }
.segmented a.is-active { background: var(--nav-active-bg); color: var(--nav-active-text); }

.pub-section h2 { font-size: 22px; }
.pub-card { gap: 12px; }
.pub-card__meta { font-size: 13px; color: var(--muted); }
.pub-works { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.pub-work { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px 0; border-top: 1px solid var(--line); align-items: center; }
.pub-work:first-child { border-top: 0; padding-top: 0; }
.pub-work__title { font-weight: 700; color: inherit; text-decoration: none; }
.pub-work__title:hover { color: var(--accent); }
.pub-work__info { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); }
.pub-card__foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }

/* -------------------------------------------------------------------------- question editor */

.mat-list { display: flex; flex-direction: column; gap: 12px; }
.mat-block { border: var(--bw, 1px) solid var(--line-strong); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.mat-block__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mat-block .grid-2 { gap: 10px; }
.word-count { font-size: 12px; color: var(--muted); text-align: right; padding: 4px 10px 6px; }
.word-count.is-over { color: var(--bad); font-weight: 700; }
.tree-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tree-pick .field__new { margin-top: 6px; }
.preview-card .q-layout { gap: 14px; }
.preview-card .q-layout--split { grid-template-columns: minmax(0, 1fr); }
.preview-card .q-text { font-size: 16px; }
.preview-card .q-columns__body { font-size: 15px; padding: 12px 8px; min-height: 0; }
.preview-card .q-passage { padding: 12px; }
.preview-card .q-passage__text { font-size: 14px; }
.preview-card .option__box { min-height: 42px; font-size: 14px; padding: 8px 12px; }
.preview-card .options { gap: 8px; }

/* -------------------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; border: var(--bw, 1px) solid var(--line); border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table th a { color: inherit; text-decoration: none; }
.table th a.is-active { color: var(--text); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .t-strong { font-weight: 700; }
.table .bar { min-width: 90px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 700; letter-spacing: .04em; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); border: var(--bw, 1px) solid var(--line); }

/* list rows (journal, homework) */
.list { border: var(--bw, 1px) solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.list__row { padding: 18px 22px; display: grid; gap: 16px; align-items: center; border-bottom: 1px solid var(--line); }
[data-theme="dark"] .list__row { border-bottom-color: var(--line); }
.list__row:last-child { border-bottom: 0; }
.list__title { font-weight: 700; font-size: 16px; }

/* -------------------------------------------------------------------------- questions */

.q-card { border: var(--bw, 1px) solid var(--line); border-radius: var(--r-xl); padding: 28px; display: flex; flex-direction: column; gap: 22px; }
/* One layout for every question (sessions, tests, homework, results, preview).
   --split: material (picture, passage, columns) left · question + answers right.
   --single: one centred column — question on top, answers underneath. */
.q-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.q-layout--split { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
.q-layout--single { max-width: 760px; width: 100%; margin-inline: auto; }
.q-material { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.q-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.q-layout--split .q-main { position: sticky; top: 96px; }
.q-main__meta { gap: 8px; }
.q-mat-heading { font-size: 17px; font-weight: 800; margin: 0; }
.q-passage { background: var(--surface-2); border: var(--bw, 1px) solid var(--line); border-radius: 16px; padding: 18px 20px; }
.q-passage__title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.q-passage__text { font-size: 16px; line-height: 1.7; white-space: pre-line; }
.q-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: var(--bw, 1px) solid var(--line-strong); border-radius: 16px; overflow: hidden; }
.q-columns__col + .q-columns__col { border-left: 1px solid var(--line-strong); }
.q-columns__title { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 13px; padding: 10px 16px; }
.q-columns__body { padding: 22px 16px; font-size: 20px; font-weight: 600; text-align: center; min-height: 72px; display: flex; align-items: center; justify-content: center; }
.answer-input { max-width: 340px; width: 100%; }
.tag--xs { font-size: 11px; padding: 2px 8px; min-height: 0; }
.tree-sub { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.tree-sub__name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.q-figure { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.q-figure__frame { border-radius: 16px; background: #F6FAFE; border: var(--bw, 1px) solid var(--line); padding: 16px; display: flex; align-items: center; justify-content: center; }
.q-figure img { width: 100%; height: auto; max-height: 420px; object-fit: contain; cursor: zoom-in; }
.q-text { font-size: 20px; font-weight: 600; line-height: 1.45; white-space: pre-line; }
.q-num { font-size: 13px; font-weight: 700; color: var(--muted); }
/* Answer options, SAT style: one full-width row each, circled letter on the left. */
.options { display: flex; flex-direction: column; gap: 14px; }
.option-row { display: flex; align-items: center; gap: 12px; position: relative; }
.option { position: relative; flex: 1 1 auto; min-width: 0; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option__box {
  min-height: 64px; padding: 12px 20px; border-radius: 12px; border: 1.5px solid color-mix(in srgb, var(--text) 55%, transparent); background: var(--surface);
  display: flex; align-items: center; gap: 18px; font-size: 18px; font-weight: 500; cursor: pointer; height: 100%; position: relative; transition: border-color .12s, background .12s;
}
.option__box:hover { border-color: var(--text); }
.option__letter { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--text); display: grid; place-items: center; font-size: 14px; font-weight: 800; color: var(--text); }
/* long formulas can be swiped sideways, but a tall fraction must not grow a scrollbar beside it */
.option__text { min-width: 0; overflow-x: auto; overflow-y: hidden; padding-block: .3em; scrollbar-width: none; }
.option__text::-webkit-scrollbar { display: none; }
.option__note { margin-left: auto; font-size: 13px; font-weight: 700; }
.option input:checked + .option__box { border: 2.5px solid var(--accent); background: var(--accent-soft); color: var(--text); }
.option input:checked + .option__box .option__letter { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.option input:focus-visible + .option__box { outline: 2px solid var(--accent); outline-offset: 2px; }
.option input:disabled + .option__box { cursor: default; }
.option__box.is-correct, .option input:checked + .option__box.is-correct { border: 2.5px solid var(--ok); background: var(--ok-soft); color: var(--text); }
.option__box.is-correct .option__letter, .option input:checked + .option__box.is-correct .option__letter { background: var(--ok); border-color: var(--ok); color: #FFFFFF; }
.option__box.is-wrong, .option input:checked + .option__box.is-wrong { border: 2.5px solid var(--bad); background: var(--bad-soft); color: var(--text); }
.option__box.is-wrong .option__letter, .option input:checked + .option__box.is-wrong .option__letter { background: var(--bad); border-color: var(--bad); color: #FFFFFF; }
.option__box.is-correct .option__note { color: var(--ok); }
.option__box.is-wrong .option__note { color: var(--bad); }
/* eliminate: each option has a strike button beside it where the page asks for it (.has-strike) */
.option__strike { display: none; flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--text); background: var(--surface); color: var(--text); font: 800 13px var(--font); cursor: pointer; place-items: center; position: relative; padding: 0; }
.option__strike::after { content: ""; position: absolute; left: 3px; right: 3px; top: 50%; height: 2px; background: currentColor; transform: rotate(-35deg); }
.has-strike .option__strike { display: grid; }
.option-row.is-crossed .option__strike { background: var(--text); color: var(--surface); }
.option-row.is-crossed .option__strike::after { display: none; }
.option-row.is-crossed .option__box { opacity: .5; }
.option-row.is-crossed .option__box::after { content: ""; position: absolute; left: 10px; right: 10px; top: 50%; height: 2px; background: var(--text); }
.explain { border: var(--bw, 1px) solid var(--line); border-radius: var(--r-xl); padding: 24px 28px; display: flex; flex-direction: column; gap: 12px; }
.explain__text { font-size: 17px; line-height: 1.65; white-space: pre-line; }
.feedback { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.feedback--ok { color: var(--ok); }
.feedback--bad { color: var(--bad); }

.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; }
.timer.is-low { color: var(--bad); }

.session-bar {
  background: var(--accent-strong); color: #FFFFFF; padding: 12px 32px; min-height: 68px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 15;
}
.session-bar .icon-btn { background: transparent; color: #FFFFFF; border-color: rgba(255, 255, 255, .3); }
.session-bar .avatar { background: #FFFFFF; color: var(--accent-strong); }
.steps { display: flex; gap: 6px; flex: 1 1 200px; max-width: 340px; }
.steps span { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .25); }
.steps span.is-done { background: var(--mode-green); }
.steps span.is-wrong { background: var(--mode-red); }
.steps span.is-current { background: #FFFFFF; }

/* -------------------------------------------------------------------------- flashes */

.flashes { display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.flash--success { background: var(--ok-soft); color: var(--ok); }
.flash--error { background: var(--bad-soft); color: var(--bad); }
.flash--info { background: var(--accent-soft); color: var(--accent-ink); }

/* -------------------------------------------------------------------------- auth / welcome */

.welcome { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.welcome__art {
  position: relative; overflow: hidden; color: #FFFFFF; padding: 48px;
  background: #0A1A5C; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
}
[data-theme="dark"] .welcome__art { background: #141414; }
.welcome__art svg.orbit { position: absolute; right: -150px; top: 30px; width: 470px; height: 470px; }
.welcome__brand { position: relative; font-family: var(--font-display); font-weight: 800; font-size: 28px; }
.welcome__copy { position: relative; display: flex; flex-direction: column; gap: 20px; max-width: 500px; margin-top: auto; }
.welcome__copy h1 { font-family: var(--font-display); font-size: 52px; line-height: 1.05; }
.welcome__copy p { font-size: 18px; font-weight: 300; color: #D9E6FA; }
.welcome__panel { padding: 40px 48px; display: flex; flex-direction: column; gap: 28px; }
.welcome__form { width: 100%; max-width: 420px; align-self: center; display: flex; flex-direction: column; gap: 20px; flex: 1; justify-content: center; }
.tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--surface-2); border-radius: 14px; padding: 4px; border: var(--bw, 1px) solid var(--line); }
.tabs a { min-height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--text-2); text-decoration: none; }
.tabs a.is-active { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
[data-theme="dark"] .tabs a.is-active { background: #FFFFFF; color: #000000; }
.mode-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.mode-pills span { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; color: #0E0E0E; }

.exam-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.exam-option { position: relative; }
.exam-option input { position: absolute; opacity: 0; pointer-events: none; }
.exam-option span {
  display: flex; flex-direction: column; gap: 6px; padding: 22px; border-radius: 18px; border: var(--bw, 1px) solid var(--line);
  cursor: pointer; height: 100%;
}
.exam-option b { font-family: var(--font-display); font-size: 28px; font-weight: 800; }
.exam-option small { font-size: 14px; color: var(--muted); }
.exam-option input:checked + span { background: var(--accent-strong); border-color: var(--accent-strong); color: #FFFFFF; }
.exam-option input:checked + span small { color: #D6D6D2; }
.exam-option input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* -------------------------------------------------------------------------- misc components */

.leader { list-style: none; margin: 0; padding: 0; }
.leader li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.leader li:last-child { border-bottom: 0; }
.leader__place { width: 32px; font-weight: 800; color: var(--accent); }
.leader__me { background: var(--btn-bg); color: var(--btn-text); border-radius: 12px; padding: 12px 14px !important; border: 0 !important; margin-top: 8px; }
.leader__me .leader__place { color: inherit; }

.copy-field { display: flex; gap: 8px; align-items: stretch; }
.copy-field .input { flex: 1; }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

.pick-list { max-height: 560px; overflow-y: auto; border: var(--bw, 1px) solid var(--line); border-radius: var(--r-lg); }
.pick-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); align-items: start; }
.pick-row:last-child { border-bottom: 0; }
.pick-row__text { font-size: 14px; line-height: 1.45; }
.order-list { list-style: none; margin: 0; padding: 0; counter-reset: q; display: flex; flex-direction: column; gap: 8px; }
.order-list li { counter-increment: q; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: var(--bw, 1px) solid var(--line); border-radius: 12px; font-size: 14px; background: var(--surface); }
.order-list li::before { content: counter(q); font-weight: 800; color: var(--muted); }
.order-list .tools { display: flex; gap: 4px; }
.order-list .tools button { width: 30px; height: 30px; border-radius: 8px; border: var(--bw, 1px) solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }

.preview-card { border: var(--bw, 1px) solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.preview-card__bar { background: var(--accent); color: #FFFFFF; padding: 12px 18px; font-size: 13px; font-weight: 700; }
.preview-card__body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }

.dropzone { min-height: 120px; border: 1.5px dashed var(--line-strong); border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 16px; cursor: pointer; }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dropzone img { max-height: 180px; width: auto; border-radius: 8px; background: #fff; }

body.is-lightbox-open { overflow: hidden; overscroll-behavior: none; }
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .82);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .16s ease, visibility .16s ease;
  overscroll-behavior: none;
}
.lightbox.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
.lightbox__card {
  width: min(70vw, calc(70vh * var(--lb-aspect, 1.6)));
  width: min(70vw, calc(70dvh * var(--lb-aspect, 1.6)));
  max-height: 90vh; max-height: 90dvh;
  background: var(--surface, #FFFFFF); border: 1px solid var(--line, rgba(0,0,0,.1));
  border-radius: 16px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .42);
  transform: scale(.96); transition: transform .16s ease;
  overscroll-behavior: contain;
}
.lightbox.is-open .lightbox__card { transform: scale(1); }
.lightbox.is-fit .lightbox__card {
  width: min(95vw, calc(95vh * var(--lb-aspect, 1.6)));
  width: min(95vw, calc(95dvh * var(--lb-aspect, 1.6)));
  max-height: 95vh; max-height: 95dvh;
}
@media (max-width: 1024px) and (orientation: portrait), (max-width: 639px) {
  .lightbox__card {
    width: min(92vw, calc(92vh * var(--lb-aspect, 1.6)));
    width: min(92vw, calc(92dvh * var(--lb-aspect, 1.6)));
  }
}
.lightbox__bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.lightbox__zoom { font-size: 13px; font-weight: 700; color: var(--muted); min-width: 46px; font-variant-numeric: tabular-nums; }
.lightbox__tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lightbox__btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 16px; font-weight: 700; }
.lightbox__btn.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.lightbox__stage {
  position: relative; overflow: hidden; border-radius: 12px; background: #FFFFFF;
  width: 100%; aspect-ratio: var(--lb-aspect, 1.6); max-height: calc(90dvh - 88px);
  display: flex; align-items: center; justify-content: center;
  touch-action: none; overscroll-behavior: contain; user-select: none; -webkit-user-select: none;
}
.lightbox.is-fit .lightbox__stage { max-height: calc(95dvh - 88px); }
.lightbox__stage.is-zoomed { cursor: grab; }
.lightbox__stage.is-dragging { cursor: grabbing; }
.lightbox__stage img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  transform-origin: center center; will-change: transform; pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .lightbox, .lightbox__card { transition: none; }
}
[data-motion="reduce"] .lightbox, [data-motion="reduce"] .lightbox__card { transition: none; }

details.disclosure summary { cursor: pointer; font-weight: 700; color: var(--accent); list-style: none; }
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure[open] summary { margin-bottom: 10px; }

.katex { font-size: 1.05em; }

/* -------------------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page { padding: 28px 28px 64px; }
  .topbar { padding: 0 28px; }
}

@media (max-width: 900px) and (orientation: portrait), (max-width: 760px) {
  .q-layout--split { grid-template-columns: minmax(0, 1fr); }
  .q-layout--split .q-main { position: static; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .tree-pick { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 30px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 30;
    flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line);
    overflow-x: auto; justify-content: flex-start; gap: 2px;
  }
  .rail__logo, .rail__sep, .rail .spacer { display: none; }
  .rail__item { width: auto; min-width: 0; padding: 6px 2px; font-size: 9.5px; flex: 1 1 0; --ic: 20px; }
  .rail__item .ic { width: 20px; height: 20px; }
  .main { padding-bottom: 76px; }
  .topbar { padding: 0 16px; height: 60px; }
  .topbar__context { font-size: 11px; }
  .page { padding: 20px 16px 40px; gap: 22px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2, .span-all { grid-column: auto; }
  .grid[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  fieldset[style*="sticky"], aside[style*="sticky"], form.card[style*="sticky"] { position: static !important; }
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 24px; gap: 20px; }
  .hero__number { font-size: 72px; }
  .hero__unit { font-size: 20px; }
  .q-layout--split { grid-template-columns: minmax(0, 1fr); }
  .q-layout--split .q-main { position: static; }
  .q-columns__body { font-size: 17px; padding: 16px 10px; }
  .exam-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welcome { grid-template-columns: minmax(0, 1fr); }
  .welcome__art { min-height: 360px; padding: 28px; }
  .welcome__art svg.orbit { width: 200px; height: 200px; right: -60px; top: -40px; }
  .welcome__art { min-height: 0; gap: 20px; }
  .welcome__copy { margin-top: 24px; }
  .welcome__copy h1 { font-size: 34px; }
  .welcome__panel { padding: 28px 16px; }
  .session-bar { padding: 10px 16px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .list__row { grid-template-columns: minmax(0, 1fr) !important; gap: 8px; }
  .card { padding: 18px; }
  fieldset { padding: 18px; }
}

/* Phone turned sideways: figure left, question and answers right (as designed). */
@media (orientation: landscape) and (max-height: 520px) {
  .q-layout--split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
  .q-layout--split .q-main { position: static; }
  .q-layout--split .options { gap: 8px; }
  .q-layout--split .option__box { min-height: 46px; font-size: 16px; padding: 8px 12px; }
  .q-figure img { max-height: 240px; }
  .q-card { padding: 14px; gap: 12px; }
  .page { padding: 12px 24px; gap: 12px; }
  .session-bar { min-height: 52px; padding: 6px 24px; }
}

.rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 760px) {
  .has-figure-question .rotate-hint { display: flex; }
}

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

/* theme toggle shows the icon of the theme you will switch to */
[data-theme="light"] [data-theme-icon="dark"],
[data-theme="dark"] [data-theme-icon="light"] { display: none; }
[data-theme-icon] { display: inline-flex; }
[hidden] { display: none !important; }

/* selects: our own chevron, with room on the right (the native arrow sat on the edge) */
.select {
  -webkit-appearance: none; appearance: none; padding-right: 44px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237C8698' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 18px 18px;
}
.select:hover { border-color: var(--text); }
.select:focus { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232456D9' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }

/* homework: why the hand-in button is disabled */
.submit-hint { color: var(--bad); font-weight: 600; margin: 8px 0 0; }

/* free-input answers: entry directions (drawer) and the line under the input */
.entry-help { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.entry-help .link-btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; }
.entry-preview { color: var(--text-2, inherit); }
.entry-preview .math { font-size: 18px; margin-left: 6px; color: var(--text); }
.entry-rules ul { margin: 0 0 16px; padding-left: 18px; display: grid; gap: 6px; font-size: 14px; line-height: 1.45; }
.entry-table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: center; }
.entry-table th, .entry-table td { border: var(--bw, 1px) solid var(--line); padding: 8px 6px; vertical-align: middle; line-height: 1.6; }
.entry-table th { font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); }
.entry-table td:first-child { font-size: 17px; }
.entry-table td.bad { color: var(--bad); }
form[data-sat-entry] .answer-input .field__hint { display: none; }   /* SAT tests: the rules live in "Как вводить ответ" */

/* written answers (part 2): photo of the solution, criteria */
.written-box { border: 1.5px dashed var(--line-strong); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.file-btn { cursor: pointer; }
.written-thumb { max-width: 100%; max-height: 220px; object-fit: contain; border-radius: 10px; border: var(--bw, 1px) solid var(--line); background: #fff; cursor: zoom-in; align-self: flex-start; }
.assess { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: var(--bw, 1px) solid var(--line); }
.rubric { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.45; }
.rubric li label, .rubric li { display: flex; gap: 8px; align-items: flex-start; }
.rubric li b { min-width: 16px; }
.rubric li.is-on { font-weight: 600; color: var(--accent-ink); }
.entry-h { font-size: 15px; margin: 4px 0 6px; }
.entry-table--left td:last-child { text-align: left; font-size: 13px; line-height: 1.45; }
.entry-table--left td:first-child { font-size: 14px; font-weight: 700; }

/* ------------------------------------------------------------ deploy safety: banners, save pill, resume card */
.ds-banner-host { position: sticky; top: 0; z-index: 90; padding: 8px 14px 0; background: transparent; pointer-events: none; }
.ds-banner {
  pointer-events: auto;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: var(--bw, 1px) solid var(--line);
  border-left: 4px solid var(--accent);
  box-shadow: 0 6px 20px rgba(15, 23, 42, .08);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}
.ds-banner--warn { border-left-color: var(--accent); background: var(--accent-soft); }
.ds-banner--ok { border-left-color: var(--ok, #16a34a); }
.ds-banner__body { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.ds-banner__dot { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); flex-shrink: 0; }
.ds-banner--ok .ds-banner__dot { background: var(--ok, #16a34a); }
.ds-banner__text { min-width: 0; overflow-wrap: anywhere; }
.ds-banner.is-collapsed .ds-banner__text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-banner__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ds-banner__btn { min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; }

.ds-save-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  padding: 4px 10px;
  border-radius: 999px;
  border: var(--bw, 1px) solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}
.ds-save-pill[data-state="offline"] { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }
.ds-save-pill[data-state="saving"] { color: var(--text); }

.ds-resume {
  margin-bottom: 20px;
  padding: 20px 24px;
  border-radius: 18px;
  background: var(--surface);
  border: var(--bw, 1px) solid var(--line);
  border-left: 4px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ds-resume__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ds-resume__title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.015em; line-height: 1.3; color: var(--text); }
.ds-resume__list { display: flex; flex-direction: column; gap: 10px; }
.ds-resume__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  border: var(--bw, 1px) solid var(--line);
  background: var(--bg);
  flex-wrap: wrap;
}
.ds-resume__meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.ds-resume__name { font-weight: 700; color: var(--text); font-size: 16px; line-height: 1.35; }
.ds-resume__sub { font-size: 14.5px; line-height: 1.45; color: var(--text-2); }
.ds-resume__btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ds-resume__btn { min-height: 44px; min-width: 44px; padding: 0 16px; font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.ds-oob-note { margin-bottom: 14px; }

@media (max-width: 640px) {
  .ds-banner { flex-direction: column; align-items: stretch; }
  .ds-banner__actions { justify-content: flex-end; }
  .ds-resume__item { flex-direction: column; align-items: stretch; }
  .ds-resume__btns { justify-content: flex-start; }
}
