/* UNISHKA Learning — student site styles.
   Dark interface with one warm accent. No frameworks, no external files:
   the font (Inter, SIL Open Font License) is served from this site. */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.260c81a4759b.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-ext-wght-normal.1ad231aac0a8.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root, [data-theme="dark"] {
  --bg: #111111;
  --shell: #161616;
  --panel: #1e1e1e;
  --panel-2: #262626;
  --panel-3: #2f2f2f;
  --line: #2c2c2c;
  --line-strong: #3a3a3a;
  --input-hover: #4a4a4a;
  --text: #f3f4f6;
  --text-2: #d4d7dd;
  --muted: #a3a8b2;
  --accent: #5b9dff;
  --accent-hover: #7cb1ff;
  --accent-ink: #06101f;
  --accent-soft: rgba(91, 157, 255, 0.15);
  --accent-text: #8bbcff;
  --hero: #13213d;
  --hero-2: #0d1729;
  --hero-text: #f3f4f6;
  --hero-hello: #d5def0;
  --hero-muted: #b9c7e3;
  --hero-border: rgba(91, 157, 255, 0.18);
  --hero-glow: rgba(91, 157, 255, 0.20);
  --hero-track: rgba(255, 255, 255, 0.14);
  --card: #f6f7fb;
  --card-ink: #0f172a;
  --card-num: #1d4ed8;
  --card-2: var(--accent);
  --card-2-ink: #06101f;
  --topbar-bg: rgba(17, 17, 17, 0.82);
  --page-glow: rgba(91, 157, 255, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --shadow-menu: 0 20px 50px rgba(0, 0, 0, 0.5);
  --tag-opened: rgba(255, 255, 255, 0.07);
  --selection: rgba(91, 157, 255, 0.35);
  --ok: #7ee2a8;
  --ok-soft: rgba(126, 226, 168, 0.12);
  --ok-border: rgba(126, 226, 168, 0.3);
  --warn: #fbbf5a;
  --warn-soft: rgba(251, 191, 90, 0.13);
  --warn-border: rgba(251, 191, 90, 0.25);
  --err: #ff8f8f;
  --err-soft: rgba(255, 120, 120, 0.12);
  --err-border: rgba(255, 143, 143, 0.3);
  --focus: #9cc4ff;
  --brand-text: #f3f4f6;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f4f6f9;
  --shell: #ffffff;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --panel-3: #e3e7ed;
  --line: #e2e6ec;
  --line-strong: #cfd5de;
  --input-hover: #aab3c0;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #5b6475;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --accent-text: #1d4ed8;
  --hero: #e9f0ff;
  --hero-2: #dce7ff;
  --hero-text: #0f172a;
  --hero-hello: #334155;
  --hero-muted: #3b4a6b;
  --hero-border: rgba(37, 99, 235, 0.16);
  --hero-glow: rgba(37, 99, 235, 0.12);
  --hero-track: rgba(15, 23, 42, 0.12);
  --card: #ffffff;
  --card-ink: #0f172a;
  --card-num: #1d4ed8;
  --card-2: #2563eb;
  --card-2-ink: #ffffff;
  --topbar-bg: rgba(244, 246, 249, 0.85);
  --page-glow: rgba(37, 99, 235, 0.10);
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
  --shadow-menu: 0 18px 44px rgba(15, 23, 42, 0.16);
  --tag-opened: #eef1f5;
  --selection: rgba(37, 99, 235, 0.22);
  --ok: #166534;
  --ok-soft: rgba(34, 197, 94, 0.14);
  --ok-border: rgba(22, 101, 52, 0.25);
  --warn: #92400e;
  --warn-soft: rgba(245, 158, 11, 0.15);
  --warn-border: rgba(146, 64, 14, 0.25);
  --err: #b91c1c;
  --err-soft: rgba(239, 68, 68, 0.12);
  --err-border: rgba(185, 28, 28, 0.25);
  --focus: #2563eb;
  --brand-text: #0a4a6e;
  color-scheme: light;
}
:root {
  --r-xl: 26px;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sidebar: 252px;
  interpolate-size: allow-keywords;
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
a { color: var(--accent-text); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: color .15s var(--ease); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--selection); }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.02em; font-weight: 650; margin: 0 0 .6em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 1.6vw, 2.4rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--panel-2); padding: .1em .35em; border-radius: 5px; }
.small { font-size: .8rem; color: var(--muted); }
.break { word-break: break-all; }
.help { color: var(--muted); font-size: .92rem; margin: .25rem 0 1rem; }
.eyebrow { color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .02em; margin: 0 0 .35rem; }
.icon { flex: none; vertical-align: middle; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem; border-radius: var(--r-sm); z-index: 50; font-weight: 600; }
.skip-link:focus { left: 8px; }

/* ---------- Smooth page changes (browsers that support it) ---------- */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: sidebar; }
.topbar { view-transition-name: topbar; }
.page { view-transition-name: page; }
::view-transition-old(page) { animation: 120ms var(--ease) both fade-out; }
::view-transition-new(page) { animation: 260ms var(--ease) both rise-in; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
/* Switching light/dark: a plain cross-fade of the whole page. */
html.theme-switching::view-transition-old(*) { animation: 280ms ease both fade-out; }
html.theme-switching::view-transition-new(*) { animation: 280ms ease both fade-in; }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 64rem) { .shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); } }

.sidebar { display: none; }
@media (min-width: 64rem) {
  .sidebar {
    display: flex; flex-direction: column; gap: 1.5rem;
    position: sticky; top: 0; height: 100vh; padding: 1.5rem 1rem;
    background: var(--shell); border-right: 1px solid var(--line);
  }
}
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; padding: .25rem .5rem; }
.brand:hover { color: var(--text); }
.brand-logo { width: 36px; height: 36px; flex: none; }
.brand-text { font-weight: 800; font-size: 1.12rem; letter-spacing: .02em; color: var(--brand-text); line-height: 1; }
.brand-sub { display: block; color: var(--muted); font-size: .7rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }

.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.nav-link {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  padding: .62rem .8rem; border-radius: var(--r-md);
  color: var(--muted); text-decoration: none; font-size: .95rem; font-weight: 500;
  transition: background-color .18s var(--ease), color .18s var(--ease);
}
.nav-link:hover { background: var(--panel); color: var(--text); }
.nav-link.is-active { background: var(--panel-2); color: var(--text); }
.nav-link.is-active .icon { color: var(--accent); }
.nav-button { background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.side-nav { flex: 1; }
.side-foot { display: grid; gap: .5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.side-foot form { margin: 0; }

.user-chip { display: inline-flex; align-items: center; gap: .6rem; padding: .3rem .8rem .3rem .3rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: .88rem; color: var(--text-2); max-width: 100%; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-size: .72rem; font-weight: 700; flex: none; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main-col { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem; min-height: 64px;
  padding: .6rem 16px; background: var(--topbar-bg);
  backdrop-filter: saturate(140%) blur(14px); -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 64rem) { .topbar { padding: .6rem 2rem; } }
.topbar-title { flex: 1; min-width: 0; }
.topbar-eyebrow { color: var(--muted); font-size: .9rem; font-weight: 500; }
.brand-mobile { padding-left: 0; }
.brand-mobile .brand-sub { display: none; }
@media (min-width: 64rem) { .brand-mobile, .mobile-menu { display: none !important; } }
.user-chip-top { display: none; }
@media (min-width: 64rem) { .user-chip-top { display: inline-flex; } }

.mobile-menu { position: relative; }
.mobile-menu summary { list-style: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md); background: var(--panel); border: 1px solid var(--line); color: var(--text); cursor: pointer; }
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(280px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  padding: .5rem; box-shadow: var(--shadow-menu); animation: appear .18s var(--ease);
}
.mobile-menu-panel form { margin: .25rem 0 0; border-top: 1px solid var(--line); padding-top: .25rem; }

.page { width: 100%; max-width: 1240px; padding: 1.5rem 16px 3rem; flex: 1; outline: none; }
@media (min-width: 64rem) { .page { padding: 2rem 2rem 4rem; } }
.site-footer { display: flex; gap: 1.25rem; flex-wrap: wrap; padding: 1.25rem 16px 2rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
@media (min-width: 64rem) { .site-footer { padding: 1.25rem 2rem 2rem; } }
.site-footer a { color: var(--muted); }

/* Pages for visitors who aren't logged in */
.plain-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 2rem 16px 0;
  background: radial-gradient(1200px 500px at 50% -10%, var(--page-glow), transparent 60%), var(--bg); }
.plain-wrap .page { max-width: 46rem; padding-left: 0; padding-right: 0; }
.plain-wrap .site-footer { border-top: 0; justify-content: center; width: 100%; }
.brand-plain { margin-bottom: 1rem; gap: .8rem; }
.brand-plain .brand-logo { width: 52px; height: 52px; }
.brand-plain .brand-text { font-size: 1.5rem; }
.page.auth { display: grid; place-items: start center; padding-top: 4vh; }
.auth-card { width: min(100%, 26rem); padding: 2rem; }
.auth-card h1 { font-size: 1.9rem; margin-bottom: .3rem; }
.has-shell .page.auth { max-width: none; }

/* ---------- Building blocks ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 1.5rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .65rem 1.2rem; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-size: .95rem; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease), transform .12s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-block { width: 100%; }

.tag { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--panel-3); color: var(--text-2); white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-completed { background: var(--accent-soft); color: var(--accent-text); }
.tag-updated { background: var(--warn-soft); color: var(--warn); }
.tag-opened { background: var(--tag-opened); color: var(--text-2); }
.tag-not_started { background: transparent; color: var(--muted); border: 1px solid var(--line-strong); }

progress { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border: 0; border-radius: 999px; background: var(--panel-3); overflow: hidden; color: var(--accent); }
progress::-webkit-progress-bar { background: var(--panel-3); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width .6s var(--ease); }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

.messages { display: grid; gap: .5rem; margin-bottom: 1.25rem; }
.message { margin: 0; padding: .75rem 1rem; border-radius: var(--r-md); background: var(--panel-2); border: 1px solid var(--line-strong); animation: appear .3s var(--ease); }
.message-success { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); }
.message-error { background: var(--err-soft); border-color: var(--err-border); color: var(--err); }
.message-warning, .message-info { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.preview-banner, .notice { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem 1rem; border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.preview-banner { margin: 0 0 1.25rem; }
.preview-banner .icon, .notice .icon { margin-top: 3px; }

/* Forms */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; color: var(--text-2); }
.field input[type=text], .field input[type=password], .field input:not([type]), .field input[type=file], .field select, .field textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); padding: .7rem .9rem; min-height: 48px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field input:hover, .field textarea:hover { border-color: var(--input-hover); }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field input[type=file] { padding: .6rem; }
.field input[type=file]::file-selector-button { font: inherit; font-weight: 600; border: 0; border-radius: 999px; padding: .4rem .9rem; margin-right: .8rem; background: var(--panel-3); color: var(--text); cursor: pointer; }
.field.has-error input { border-color: var(--err); }
.field ul { padding-left: 1.2rem; margin: .4rem 0 0; color: var(--muted); font-size: .85rem; }
.field .help { margin-bottom: 0; }
.error { color: var(--err); font-size: .9rem; margin: .35rem 0 0; }
.form-errors { color: var(--err); background: var(--err-soft); border-radius: var(--r-md); padding: .6rem 1rem; margin-bottom: 1rem; }
.form-errors p { margin: 0; }

/* Collapsible boxes: opened and closed smoothly by static/js/site.js */
summary { cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }

/* ---------- Dashboard (study map) ---------- */
.hero {
  display: grid; gap: 1.5rem; align-items: center; overflow: hidden;
  border-radius: var(--r-xl); padding: 1.75rem; margin-bottom: 1.5rem;
  background: radial-gradient(700px 300px at 0% 0%, var(--hero-glow), transparent 60%), linear-gradient(135deg, var(--hero), var(--hero-2));
  border: 1px solid var(--hero-border); color: var(--hero-text);
}
@media (min-width: 56rem) { .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); padding: 2.25rem; } }
.hero-compact { grid-template-columns: 1fr !important; }
.hero-hello { color: var(--hero-hello); margin: 0 0 .4rem; font-weight: 500; }
.hero-title { font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.9rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1.05; margin: 0 0 .75rem; }
.hero-course { color: var(--hero-muted); margin: 0 0 1rem; font-size: .95rem; }
.hero-progress { display: flex; align-items: center; gap: .8rem; max-width: 22rem; margin-bottom: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-progress progress { background: var(--hero-track); }
.hero-progress progress::-webkit-progress-bar { background: var(--hero-track); }

.hero-cards { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: .9rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .25rem; scrollbar-width: none; }
.hero-cards::-webkit-scrollbar { display: none; }
.next-card {
  position: relative; display: flex; flex-direction: column; min-height: 210px; padding: 1rem 1rem 0;
  border-radius: var(--r-lg); text-decoration: none; overflow: hidden; scroll-snap-align: start;
  background: var(--card); color: var(--card-ink); border: 1px solid var(--line);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.next-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); color: var(--card-ink); }
.next-card-2 { background: var(--card-2); color: var(--card-2-ink); border-color: transparent; }
.next-card-2:hover, .next-card-2 .next-art { color: var(--card-2-ink); }
.next-num { color: var(--card-num); font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums; }
.next-card-2 .next-num { color: var(--card-2-ink); }
.next-title { font-size: 1.15rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin-top: .45rem; }
.next-module { font-size: .78rem; opacity: .75; margin-top: .4rem; }
.next-art { margin-top: auto; width: calc(100% + 2rem); margin-left: -1rem; height: 90px; color: var(--card-ink); opacity: .85; }

.dash-grid { display: grid; gap: 1.5rem; }
@media (min-width: 72rem) { .dash-grid { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.dash-main { display: grid; gap: 1.25rem; min-width: 0; }
.dash-side { display: grid; gap: 1.25rem; }
@media (min-width: 72rem) { .dash-side { position: sticky; top: 84px; } }

.module-panel { padding: 1.5rem 1.5rem 1rem; scroll-margin-top: 84px; }
.module-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem 2rem; flex-wrap: wrap; margin-bottom: .75rem; }
.module-head h2 { margin: 0; font-size: 1.35rem; }
.module-progress { display: flex; align-items: center; gap: .7rem; width: min(100%, 200px); font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-2); }
.group-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1.1rem 0 .3rem; }
.group-title-sub { text-transform: none; letter-spacing: 0; font-size: .9rem; }
.lesson-rows { list-style: none; margin: 0; padding: 0; }
.group-item { list-style: none; }
.lesson-row + .lesson-row { border-top: 1px solid var(--line); }
.row-link {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: .9rem;
  padding: .7rem .6rem; margin: 0 -.6rem; border-radius: var(--r-md);
  color: var(--text); text-decoration: none; transition: background-color .18s var(--ease);
}
a.row-link:hover { background: var(--panel-2); color: var(--text); }
@media (min-width: 48rem) { .row-link { grid-template-columns: 44px minmax(0, 1.1fr) minmax(0, 1fr) auto; } }
.row-icon { position: relative; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line-strong); color: var(--muted); font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; transition: border-color .2s var(--ease); }
.status-opened .row-icon { border-color: var(--accent); color: var(--text); background: conic-gradient(var(--accent-soft) 0 50%, transparent 50% 100%); }
.status-completed .row-icon { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.status-updated .row-icon { border-color: var(--warn); color: var(--warn); }
.status-soon .row-icon { border-style: dashed; }
.row-badge { position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); border: 2px solid var(--panel); }
.row-badge-updated { background: var(--warn); }
.row-main { display: grid; min-width: 0; }
.row-title { font-weight: 600; line-height: 1.3; }
.row-status { font-size: .8rem; color: var(--muted); }
.status-completed .row-status { color: var(--accent-text); }
.status-updated .row-status { color: var(--warn); }
.status-soon .row-title { color: var(--muted); }
.row-points { display: none; font-size: .82rem; color: var(--muted); line-height: 1.4; }
@media (min-width: 48rem) { .row-points { display: block; } }
.row-go { color: var(--muted); opacity: 0; transform: translateX(-4px); transition: opacity .18s var(--ease), transform .18s var(--ease); }
a.row-link:hover .row-go, a.row-link:focus-visible .row-go { opacity: 1; transform: none; color: var(--accent); }
.status-soon .row-link { grid-template-columns: 44px minmax(0, 1fr); }
@media (min-width: 48rem) { .status-soon .row-link { grid-template-columns: 44px minmax(0, 1.1fr) minmax(0, 1fr) 18px; } }

.side-panel { padding: 1.25rem; border-radius: var(--r-lg); }
.side-title { font-size: 1rem; margin-bottom: .75rem; }
.module-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.module-mini a { display: grid; gap: .35rem; padding: .55rem .6rem; margin: 0 -.6rem; border-radius: var(--r-md); color: var(--text); text-decoration: none; transition: background-color .18s var(--ease); }
.module-mini a:hover { background: var(--panel-2); color: var(--text); }
.mini-top { display: flex; justify-content: space-between; gap: .75rem; font-size: .86rem; }
.mini-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.module-mini progress { height: 4px; }
.recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.recent-card { display: grid; gap: .3rem; padding: .85rem 1rem; border-radius: var(--r-md); background: var(--panel-2); color: var(--text); text-decoration: none; transition: background-color .18s var(--ease), transform .18s var(--ease); }
.recent-card:hover { background: var(--panel-3); color: var(--text); transform: translateY(-1px); }
.recent-title { font-weight: 600; font-size: .92rem; line-height: 1.3; }
.recent-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .78rem; color: var(--muted); flex-wrap: wrap; }
.empty-state { max-width: 40rem; }

/* ---------- Lesson page ---------- */
.breadcrumb a { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); text-decoration: none; font-size: .9rem; max-width: 100%; }
.breadcrumb a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb a:hover { color: var(--text); }
.lesson-hero { max-width: 48rem; margin-bottom: 1.75rem; }
.lesson-hero h1 { font-size: clamp(1.9rem, 1.3rem + 2vw, 2.8rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1.08; margin-bottom: .8rem; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; color: var(--muted); font-size: .88rem; margin: 0 0 1rem; }
.lesson-layout { display: grid; gap: 1.5rem; }
@media (min-width: 64rem) {
  .lesson-layout { grid-template-columns: minmax(0, 46rem) minmax(240px, 300px); justify-content: space-between; align-items: start; }
  .lesson-side { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: thin; }
}
@media (max-width: 63.99rem) { .lesson-side { order: -1; } }
.lesson-content { min-width: 0; }
.lesson-content > :first-child { margin-top: 0; }

.lesson-body { font-size: 1.075rem; line-height: 1.75; color: var(--text-2); }
.lesson-body strong { color: var(--text); font-weight: 650; }
.lesson-body h2.block { font-size: 1.5rem; color: var(--text); margin: 2.5rem 0 .8rem; scroll-margin-top: 84px; }
.lesson-body h3.block { font-size: 1.15rem; color: var(--text); margin: 1.75rem 0 .5rem; scroll-margin-top: 84px; }
.lesson-body p.block { margin: 0 0 1.15rem; }
.key-point { margin: 1.5rem 0; padding: 1.1rem 1.25rem 1.1rem 1.5rem; border-radius: var(--r-lg); background: linear-gradient(135deg, var(--hero), var(--hero-2)); border: 1px solid var(--hero-border); color: var(--hero-text); font-weight: 500; position: relative; }
.key-point::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.key-point p, .example p { margin: 0; }
.example { margin: 1.5rem 0; padding: 1.1rem 1.25rem; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); }
.example .example-label { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-text); margin-bottom: .4rem; }
.block-list { margin: 0 0 1.15rem; }
.block-list p { margin: 0 0 .5rem; }
.block-list ul, .block-list ol { padding-left: 1.3rem; margin: 0; }
.block-list li { margin-bottom: .4rem; }
.block-list li::marker { color: var(--accent); }
.block-table, .block-figure, .block-image { margin: 1.75rem 0; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
.block-table table, .table-wrap table { border-collapse: collapse; width: 100%; font-size: .92rem; line-height: 1.5; }
.block-table caption { caption-side: top; text-align: left; padding: .8rem 1rem .2rem; font-size: .85rem; color: var(--muted); }
.block-table th, .block-table td { text-align: left; vertical-align: top; padding: .7rem 1rem; border-bottom: 1px solid var(--line); min-width: 9rem; }
.block-table thead th { color: var(--text); font-weight: 650; background: var(--panel-2); }
.block-table tbody tr:last-child td { border-bottom: 0; }
.figure-drawing { background: #fff; border-radius: var(--r-lg); padding: .75rem; overflow: hidden; }
.figure-drawing svg { display: block; width: 100%; height: auto; max-height: 80vh; }
.block-image img { display: block; max-width: 100%; height: auto; border-radius: var(--r-lg); }
figcaption { color: var(--muted); font-size: .88rem; line-height: 1.5; margin-top: .7rem; }

.check-yourself { margin: 1.75rem 0; border-radius: var(--r-lg); }
.check-yourself h2 { font-size: 1.15rem; margin-bottom: .3rem; }
.check-before { background: transparent; border-style: dashed; }
.cy-list { padding-left: 1.3rem; margin: .5rem 0 0; }
.cy-list li::marker { color: var(--accent); font-weight: 700; }
.cy-item { margin-bottom: 1rem; }
.cy-item:last-child { margin-bottom: 0; }
.cy-question { margin: 0 0 .3rem; font-weight: 600; color: var(--text); }
.cy-answer summary { list-style: none; display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; color: var(--accent-text); font-weight: 600; font-size: .92rem; }
.cy-answer summary::-webkit-details-marker { display: none; }
.cy-answer summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .2s var(--ease); margin-right: .2rem; }
.cy-answer[open] summary::before { transform: rotate(45deg); }
.cy-answer-text { background: var(--panel-2); border-radius: var(--r-md); padding: .8rem 1rem; color: var(--text-2); line-height: 1.65; }

.side-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: .4rem 1.1rem; margin-bottom: .9rem; }
.side-box summary { list-style: none; display: flex; align-items: center; gap: .55rem; min-height: 46px; font-weight: 650; }
.side-box summary::-webkit-details-marker { display: none; }
.side-box summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s var(--ease); }
.side-box[open] summary::after { transform: rotate(-135deg); }
.side-box summary .icon { color: var(--accent); }
.toc { list-style: none; padding: 0 0 .6rem; margin: 0; counter-reset: toc; font-size: .9rem; }
.toc li { counter-increment: toc; }
.toc a { display: flex; gap: .6rem; padding: .35rem .5rem; margin: 0 -.5rem; border-radius: var(--r-sm); color: var(--text-2); text-decoration: none; line-height: 1.4; transition: background-color .15s var(--ease), color .15s var(--ease); }
.toc a::before { content: counter(toc, decimal-leading-zero); color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; padding-top: .1rem; }
.toc a:hover { background: var(--panel-2); color: var(--text); }
.glossary dl { margin: 0 0 .8rem; font-size: .88rem; }
.glossary dt { font-weight: 650; color: var(--text); margin-top: .8rem; }
.glossary dt:first-child { margin-top: 0; }
.glossary dd { margin: .15rem 0 0; color: var(--muted); line-height: 1.5; }

.sources { margin-top: 2.5rem; }
.sources h2 { font-size: 1.15rem; }
.sources ol { padding-left: 1.4rem; font-size: .9rem; color: var(--muted); }
.sources li { margin-bottom: .4rem; overflow-wrap: anywhere; }

.complete-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem; margin: 2.5rem 0 1rem; padding: 1.25rem 1.5rem; border-radius: var(--r-lg); background: linear-gradient(135deg, var(--hero), var(--hero-2)); border: 1px solid var(--hero-border); color: var(--hero-text); }
.complete-box p { margin: 0; }
.complete-box .help { margin: 0; color: var(--hero-muted); }
.complete-title { font-weight: 650; font-size: 1.05rem; }
.complete-box .done { display: flex; align-items: center; gap: .7rem; font-weight: 600; }
.done-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.complete-form { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.pager-link { display: grid; gap: .25rem; padding: 1rem 1.2rem; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--text); transition: border-color .2s var(--ease), transform .2s var(--ease); }
.pager-link:hover { border-color: var(--accent); color: var(--text); transform: translateY(-2px); }
.pager-next { text-align: right; grid-column: 2; justify-items: end; }
.pager-label { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pager-title { font-weight: 600; line-height: 1.3; }
@media (max-width: 40rem) { .pager { grid-template-columns: 1fr; } .pager-next { grid-column: 1; } }

/* ---------- Staff pages ---------- */
.tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.tile { display: grid; gap: .4rem; align-content: start; height: 100%; border-radius: var(--r-lg); color: var(--text); text-decoration: none; transition: border-color .2s var(--ease), transform .2s var(--ease); }
a.tile:hover { border-color: var(--accent); color: var(--text); transform: translateY(-2px); }
.tile .icon { color: var(--accent); }
.tile span { color: var(--muted); font-size: .9rem; }
.tile-soon { opacity: .55; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.title-row h1 { margin: 0; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 1.5rem; }
.table-wrap th, .table-wrap td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap thead th { background: var(--panel-2); font-size: .82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.table-wrap tbody tr:last-child > * { border-bottom: 0; }
.status { display: inline-flex; padding: .18rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.status-imported { background: var(--ok-soft); color: var(--ok); }
.status-unchanged { background: var(--panel-3); color: var(--muted); }
.status-failed { background: var(--err-soft); color: var(--err); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem 1.5rem; margin: 0 0 1.5rem; }
.facts dt { color: var(--muted); font-weight: 500; }
.facts dd { margin: 0; }
@media (max-width: 40rem) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: .5rem; } }
.error-box { white-space: pre-wrap; background: var(--err-soft); color: var(--err); padding: 1rem; border-radius: var(--r-md); overflow-x: auto; }

/* Privacy notice and other text pages */
.prose { max-width: 48rem; line-height: 1.7; color: var(--text-2); }
.prose h1, .prose h2 { color: var(--text); }
.prose h2 { margin-top: 2rem; font-size: 1.2rem; }
.prose li { margin-bottom: .5rem; }
.prose strong { color: var(--text); }
.lesson-meta.prose-date { margin-bottom: 1.5rem; }

/* ---------- Motion preferences and print ---------- */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  :root { --bg: #fff; --panel: #fff; --text: #000; --text-2: #111; --muted: #444; }
  .sidebar, .topbar, .site-footer, .lesson-side, .complete-box, .pager, .cy-answer summary { display: none !important; }
  .shell { display: block; }
}

/* Small fixes */
.status { white-space: nowrap; }
.table-wrap td:first-child a { white-space: nowrap; }
.table-wrap code { background: transparent; padding: 0; color: var(--muted); }
@media (max-width: 40rem) { .next-card { min-height: 170px; } .next-art { height: 70px; } }

/* Light / dark switch */
.theme-form { margin: 0; }
.theme-toggle > span { display: inline-flex; align-items: center; gap: .75rem; }
[data-theme="light"] .show-in-dark, :root:not([data-theme="light"]) .show-in-light { display: none !important; }
.site-footer .theme-form .nav-link { padding: 0; color: var(--muted); font-size: .85rem; gap: .4rem; }
.site-footer .theme-form .nav-link:hover { background: none; color: var(--text); }
.site-footer .theme-toggle > span { gap: .4rem; }
.site-footer .theme-toggle .icon { width: 16px; height: 16px; }
[data-theme="light"] .figure-drawing { border: 1px solid var(--line); }
[data-theme="light"] .next-card-1, [data-theme="light"] .next-card-3 { border-color: var(--hero-border); }

/* Mark as complete: saving and done states (driven by static/js/site.js) */
.complete-box .btn[disabled] { cursor: progress; }
.complete-box.is-saving .btn:not(.is-busy) { opacity: .45; transition: opacity .2s var(--ease); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; flex: none; }
.just-completed .done-icon { animation: pop .55s cubic-bezier(.2, 1.5, .4, 1) both; }
.just-completed .done > span:last-child { animation: slide-in .45s .12s var(--ease) both; }
.just-completed > .btn { animation: slide-in .45s .22s var(--ease) both; }
.just-completed .done-icon::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); animation: ring .8s .15s var(--ease) both; pointer-events: none; }
.done-icon { position: relative; }
.tag.just-changed { animation: pop .45s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 65% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(2.2); opacity: 0; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
.sources + .pager, .check-yourself + .pager { margin-top: 2rem; }

/* Sources next to paragraphs: numbered markers with a card on hover, focus or tap */
.cites { white-space: nowrap; margin-left: .15rem; }
.cite { position: relative; display: inline-block; vertical-align: super; line-height: 1; font-size: 1rem; }
.cite-num {
  display: inline-grid; place-items: center; min-width: 1.3rem; height: 1.3rem; padding: 0 .3rem; margin-left: 2px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent-text);
  font-size: .68rem; font-weight: 700; font-variant-numeric: tabular-nums; text-decoration: none;
  transition: background-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.cite-num:hover, .cite.is-open .cite-num, .cite-num:focus-visible { background: var(--accent); color: var(--accent-ink); }
.cite-card {
  position: absolute; z-index: 30; left: 50%; top: calc(100% + 10px);
  display: none; gap: .35rem; width: min(21rem, calc(100vw - 32px)); padding: .85rem 1rem;
  background: var(--panel); color: var(--text-2); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-menu); font-size: .86rem; font-weight: 400; line-height: 1.45; white-space: normal; text-align: left;
  opacity: 0; transform: translateX(calc(-50% + var(--shift, 0px))) translateY(4px);
  /* Hidden cards use display: none so they never widen the page on phones. */
  transition: opacity .16s var(--ease) .1s, transform .16s var(--ease) .1s, display .26s allow-discrete;
}
.cite-card::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; } /* keeps the card open while the pointer moves onto it */
.cite.cite-up .cite-card { top: auto; bottom: calc(100% + 10px); }
.cite.cite-up .cite-card::before { top: auto; bottom: -12px; }
.cite:hover .cite-card, .cite:focus-within .cite-card, .cite.is-open .cite-card {
  display: grid; opacity: 1; transform: translateX(calc(-50% + var(--shift, 0px)));
  transition: opacity .16s var(--ease), transform .16s var(--ease), display .16s allow-discrete;
}
@starting-style {
  .cite:hover .cite-card, .cite:focus-within .cite-card, .cite.is-open .cite-card {
    opacity: 0; transform: translateX(calc(-50% + var(--shift, 0px))) translateY(4px);
  }
}
.cite-site { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cite-title { font-weight: 650; color: var(--text); }
.cite-claim { color: var(--muted); padding-left: .6rem; border-left: 2px solid var(--accent-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cite-link { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; color: var(--accent-text); text-decoration: none; margin-top: .15rem; justify-self: start; }
.cite-link:hover { text-decoration: underline; }
.key-point .cite-num { background: var(--panel); }
.source-site { color: var(--muted); font-size: .8rem; }
.sources li:target { background: var(--accent-soft); border-radius: var(--r-sm); }
.sources li { scroll-margin-top: 90px; transition: background-color .4s var(--ease); }
.table-sources { font-size: .82rem; }

/* ---------- Questions ---------- */
.nav-badge { margin-left: auto; min-width: 1.4rem; height: 1.4rem; padding: 0 .4rem; border-radius: 999px; display: inline-grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.page-head { margin-bottom: 1.5rem; max-width: 48rem; }
.page-head h1 { margin-bottom: .4rem; }
.page-head .help { margin: 0; }
.q-grid { display: grid; gap: 1.5rem; }
@media (min-width: 64rem) { .q-grid { grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); align-items: start; } .q-side { position: sticky; top: 84px; } }
.q-main { min-width: 0; display: grid; gap: 1.5rem; align-content: start; }
.ask-panel h2, .ask-panel h1, .reply-panel h2 { font-size: 1.15rem; margin-bottom: 1rem; }
.field select { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: .65rem .9rem; min-height: 48px; }
.field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field textarea { resize: vertical; line-height: 1.55; }
.field input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); vertical-align: middle; }
.form-actions { display: flex; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; }
.form-actions .help { margin: 0; }
.q-list-section h2 { font-size: 1.15rem; }
.q-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.q-card { display: grid; gap: .45rem; padding: 1rem 1.25rem; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; transition: border-color .18s var(--ease), transform .18s var(--ease); }
.q-card:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.q-card.has-new { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.q-card-top { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.q-when { color: var(--muted); font-size: .8rem; }
.q-text { line-height: 1.5; }
.q-meta { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .82rem; flex-wrap: wrap; }
.tag-new { background: var(--accent); color: var(--accent-ink); }
.empty-note { color: var(--muted); margin: 0; }
.faq-list { display: grid; gap: .25rem; }
.faq { border-top: 1px solid var(--line); }
.faq:first-child { border-top: 0; }
.faq summary { list-style: none; padding: .7rem 0; font-weight: 600; font-size: .92rem; display: flex; gap: .6rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; flex: none; margin: .4rem 0 0 auto; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s var(--ease); }
.faq[open] summary::after { transform: rotate(-135deg); }
.faq-answer { color: var(--text-2); font-size: .9rem; line-height: 1.6; padding-bottom: .8rem; }
.faq-lesson { display: flex; align-items: center; gap: .35rem; margin: .5rem 0 0; font-size: .82rem; }

.thread { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: 1rem; max-width: 48rem; }
.msg { padding: 1rem 1.25rem; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); animation: appear .3s var(--ease) both; }
.msg-staff { background: linear-gradient(135deg, var(--hero), var(--hero-2)); border-color: var(--hero-border); color: var(--hero-text); }
.msg-new { box-shadow: 0 0 0 3px var(--accent-soft); }
.msg-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.msg-head .avatar { width: 28px; height: 28px; font-size: .68rem; }
.msg-when { color: var(--muted); font-size: .8rem; }
.msg-staff .msg-when { color: var(--hero-muted); }
.msg-body { line-height: 1.65; overflow-wrap: anywhere; }
.msg-actions { display: flex; align-items: flex-start; gap: 1rem; margin-top: .6rem; font-size: .85rem; flex-wrap: wrap; }
.link-quiet { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; list-style: none; }
.link-quiet::-webkit-details-marker { display: none; }
.link-quiet:hover { color: var(--text); }
.confirm-box { margin-top: .6rem; padding: .8rem 1rem; border-radius: var(--r-md); background: var(--err-soft); border: 1px solid var(--err-border); display: grid; gap: .6rem; justify-items: start; }
.confirm-box p { margin: 0; color: var(--err); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.reply-panel { max-width: 48rem; }
.status-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.faq-publish summary { list-style: none; display: flex; align-items: center; gap: .5rem; margin: 0; }
.faq-publish summary::-webkit-details-marker { display: none; }
.faq-publish[open] summary { margin-bottom: .5rem; }
.faq-publish summary .icon { color: var(--accent); }

/* Inbox */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.segmented { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.seg { border: 0; background: none; color: var(--muted); font: inherit; font-size: .88rem; font-weight: 600; padding: .45rem .9rem; border-radius: 999px; cursor: pointer; transition: background-color .15s var(--ease), color .15s var(--ease); }
.seg:hover { color: var(--text); }
.seg.is-on { background: var(--panel-3); color: var(--text); }
.filter { display: grid; gap: .25rem; font-size: .8rem; color: var(--muted); font-weight: 600; }
.filter select { font: inherit; font-size: .9rem; color: var(--text); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: .45rem .7rem; min-height: 40px; max-width: 18rem; }
.inbox-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.inbox-row { display: grid; gap: .6rem 1rem; padding: .9rem 1.1rem; border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; transition: border-color .18s var(--ease), background-color .18s var(--ease); }
.inbox-row:hover { border-color: var(--accent); color: var(--text); }
@media (min-width: 56rem) { .inbox-row { grid-template-columns: 210px minmax(0, 1fr) auto; align-items: center; } }
.inbox-who { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.inbox-who > span:last-child { display: grid; min-width: 0; }
.inbox-cohort { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-text { display: grid; gap: .25rem; min-width: 0; }
.inbox-state { display: flex; gap: .6rem; align-items: center; justify-content: space-between; }
@media (min-width: 56rem) { .inbox-state { flex-direction: column; align-items: flex-end; } }

/* ---------- Ask a question: the message box ---------- */
.ask { border-radius: var(--r-xl); padding: 1.5rem; background: radial-gradient(600px 220px at 0% 0%, var(--hero-glow), transparent 65%), linear-gradient(135deg, var(--hero), var(--hero-2)); border: 1px solid var(--hero-border); color: var(--hero-text); }
.ask-head { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: 1.1rem; }
.ask-head h2 { margin: 0 0 .25rem; font-size: 1.3rem; }
.ask-head p { margin: 0; color: var(--hero-muted); font-size: .88rem; }
.ask-head p .icon { vertical-align: -2px; margin-right: .2rem; }
.ask-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; box-shadow: 0 8px 24px var(--accent-soft); }

.composer {
  border-radius: var(--r-lg); background: var(--panel); border: 1px solid var(--line-strong);
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px rgba(0,0,0,.18);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
  color: var(--text);
}
.composer:hover { border-color: var(--input-hover); }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), 0 10px 30px rgba(0,0,0,.18); }
.composer.has-error { border-color: var(--err); }
.composer-top { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .75rem .9rem 0; }
.chip-select { position: relative; display: inline-flex; align-items: center; gap: .45rem; max-width: 100%; padding: 0 2rem 0 .8rem; min-height: 38px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: .88rem; font-weight: 600; cursor: pointer; transition: background-color .15s var(--ease); }
.chip-select:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.chip-select:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip-select select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: inherit; font: inherit; padding: .4rem 0; max-width: min(22rem, 60vw); text-overflow: ellipsis; cursor: pointer; outline: none; }
.chip-select select option, .chip-select select optgroup { color: var(--text); background: var(--panel); }
.chip-caret { position: absolute; right: .85rem; top: 50%; width: 7px; height: 7px; margin-top: -5px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); pointer-events: none; }
.composer textarea {
  display: block; width: 100%; min-height: 120px; resize: none; border: 0; outline: none; background: transparent;
  color: var(--text); font: inherit; font-size: 1.02rem; line-height: 1.6; padding: .9rem 1.1rem .5rem;
}
.composer textarea::placeholder { color: var(--muted); opacity: .85; }
.composer-foot { display: flex; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; padding: .6rem .7rem .7rem 1.1rem; border-top: 1px solid var(--line); }
.composer-hint { color: var(--muted); font-size: .78rem; margin-right: auto; }
.composer-hint kbd { font: inherit; font-size: .72rem; padding: .05rem .35rem; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--panel-2); }
.composer-count { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.composer-count.is-near { color: var(--err); font-weight: 600; }
.composer-send { transition: background-color .18s var(--ease), transform .12s var(--ease), opacity .18s var(--ease); }
.composer:not(.has-text) .composer-send { opacity: .72; }
.composer.has-text .composer-send { opacity: 1; }
.composer-send.is-sending { opacity: .7; cursor: progress; }
.composer-error { margin: .5rem .25rem 0; }
.reply-panel { max-width: 48rem; }
.reply-title { font-size: 1.1rem; margin: 0 0 .75rem; }
@media (max-width: 40rem) {
  .ask { padding: 1.1rem; }
  .composer-hint { display: none; }
  .composer-send { width: 100%; }
}

/* ---------- Edit / delete actions and the confirmation dialog ---------- */
.msg-actions { display: flex; align-items: center; gap: .4rem; margin-top: .75rem; }
.act { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .7rem; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--muted); font: inherit; font-size: .84rem; font-weight: 500; text-decoration: none; cursor: pointer; list-style: none; transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease); }
.act::-webkit-details-marker { display: none; }
.act:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.act-danger:hover { background: var(--err-soft); color: var(--err); border-color: var(--err-border); }
.confirm { display: inline-block; }
.confirm[open] { display: block; flex-basis: 100%; }
.confirm > .confirm-panel { margin-top: .6rem; } /* only without JavaScript */
.confirm > .confirm-panel [data-confirm-cancel] { display: none; }
.danger-zone { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.confirm-panel { display: grid; justify-items: start; gap: .5rem; padding: 1.5rem; border-radius: var(--r-xl); background: var(--panel); border: 1px solid var(--line-strong); color: var(--text); }
.confirm-icon { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--err-soft); color: var(--err); margin-bottom: .25rem; }
.confirm-title { font-size: 1.2rem; margin: 0; }
.confirm-text { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.55; }
.confirm-preview { margin: .35rem 0 0; width: 100%; padding: .7rem .9rem; border-radius: var(--r-md); background: var(--panel-2); border-left: 3px solid var(--line-strong); color: var(--text-2); font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.confirm-actions { display: flex; justify-content: flex-end; gap: .6rem; width: 100%; margin-top: .75rem; flex-wrap: wrap; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

dialog.modal { padding: 0; border: 0; background: transparent; width: min(27rem, calc(100vw - 32px)); max-width: none; overflow: visible; color: var(--text); }
dialog.modal .confirm-panel { box-shadow: 0 30px 80px rgba(0,0,0,.45); }
dialog.modal::backdrop { background: rgba(5, 8, 15, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog.modal[open] { animation: modal-in .22s cubic-bezier(.2, 1.1, .4, 1) both; }
dialog.modal[open]::backdrop { animation: backdrop-in .22s var(--ease) both; }
dialog.modal.is-closing { animation: modal-out .16s ease-in both; }
dialog.modal.is-closing::backdrop { animation: backdrop-out .16s ease-in both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(4px) scale(.97); } }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes backdrop-out { to { opacity: 0; } }
@media (max-width: 30rem) { .confirm-actions .btn { flex: 1; } }

/* ---------- In this lesson (headings list in the side column) ---------- */
.in-lesson .toc { counter-reset: toc; padding-bottom: .3rem; }
.in-lesson .toc li { counter-increment: none; }
.in-lesson .toc .toc-level-2 { counter-increment: toc; }
.in-lesson .toc a { position: relative; border-radius: var(--r-sm); }
.in-lesson .toc .toc-level-3 a { padding-left: 2.1rem; font-size: .85rem; color: var(--muted); }
.in-lesson .toc .toc-level-3 a::before { content: ""; }
.in-lesson .toc a.is-current { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.in-lesson .toc a.is-current::before { color: var(--accent-text); }
.in-lesson .toc a.is-current::after { content: ""; position: absolute; left: -1.1rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.toc-extra { list-style: none; margin: 0 0 .7rem; padding: .5rem 0 0; border-top: 1px solid var(--line); font-size: .86rem; }
.toc-extra a { display: flex; align-items: center; gap: .5rem; padding: .3rem .5rem; margin: 0 -.5rem; border-radius: var(--r-sm); color: var(--muted); text-decoration: none; transition: background-color .15s var(--ease), color .15s var(--ease); }
.toc-extra a:hover { background: var(--panel-2); color: var(--text); }
.toc-extra a.is-current { background: var(--accent-soft); color: var(--accent-text); }
/* The heading you jumped to flashes briefly. */
.lesson-body .block:target, .check-yourself:target, #cy-after:target, .sources:target { animation: target-flash 1.6s var(--ease); border-radius: var(--r-sm); }
@keyframes target-flash { 0%, 30% { background: var(--accent-soft); box-shadow: 0 0 0 8px var(--accent-soft); } 100% { background: transparent; box-shadow: 0 0 0 8px transparent; } }

/* ---------- Phase 4: cohorts, accounts, progress ---------- */
.button-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }
code.mono { background: transparent; padding: 0; }
code.pw { font-size: 1rem; color: var(--text); background: var(--panel-2); padding: .2rem .5rem; border-radius: 6px; }
.tag-running { background: var(--ok-soft); color: var(--ok); }
.tag-ended { background: var(--panel-3); color: var(--muted); }
.tag-inactive { background: var(--err-soft); color: var(--err); }
.tag-upcoming { background: var(--accent-soft); color: var(--accent-text); }
.tag-due { background: var(--warn-soft); color: var(--warn); }
.cohort-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.cohort-card { display: grid; gap: .35rem; height: 100%; border-radius: var(--r-lg); color: var(--text); text-decoration: none; transition: border-color .2s var(--ease), transform .2s var(--ease); }
.cohort-card:hover { border-color: var(--accent); color: var(--text); transform: translateY(-2px); }
.cohort-card-top { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .3rem; }
.cohort-name { font-size: 1.15rem; letter-spacing: -.01em; }
.cohort-org, .cohort-dates { color: var(--muted); font-size: .88rem; }
.cohort-stats { display: flex; gap: 1.25rem; margin-top: .5rem; padding-top: .7rem; border-top: 1px solid var(--line); font-size: .88rem; color: var(--muted); }
.cohort-stats strong { color: var(--text); font-size: 1.05rem; }
.form-panel { max-width: 40rem; }
.form-panel h1 { margin-bottom: .3rem; }
.grid-form { margin-top: 1.25rem; }
.field input[type=date], .field input[type=number], .field input[type=email] { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: .7rem .9rem; min-height: 48px; color-scheme: inherit; }
.field input[type=date]:focus, .field input[type=number]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field:has(input[type=checkbox]) { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; }
.field:has(input[type=checkbox]) label { order: 2; margin: 0; font-weight: 500; }
.field:has(input[type=checkbox]) input { order: 1; }
.field:has(input[type=checkbox]) .help, .field:has(input[type=checkbox]) .error { order: 3; flex-basis: 100%; }
.username-preview { min-height: 1.4em; margin: -.25rem 0 1rem; padding: .6rem .8rem; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-text); font-family: ui-monospace, Menlo, monospace; font-size: .88rem; }
.username-preview:empty { display: none; }
.notice-strong { margin-bottom: 1.25rem; }
.cohort-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.cohort-head h1 { margin-bottom: .4rem; }
.cohort-head .lesson-meta { margin: 0; }
.stat-tiles { list-style: none; margin: 0 0 1.75rem; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.stat { display: grid; gap: .35rem; align-content: start; border-radius: var(--r-lg); padding: 1.1rem 1.25rem; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.stat-link { font-size: .85rem; display: inline-flex; gap: .3rem; align-items: center; }
.progress-table th, .progress-table td { vertical-align: middle; white-space: nowrap; }
.progress-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.progress-table thead th.num { text-align: right; }
.student-cell { display: inline-flex; align-items: center; gap: .6rem; }
.student-cell > span:last-child { display: grid; gap: .1rem; }
.student-cell .avatar { width: 28px; height: 28px; font-size: .66rem; }
.progress-table tr.is-inactive > * { opacity: .6; }
.pct { display: inline-flex; align-items: center; gap: .5rem; min-width: 8.5rem; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .88rem; }
.pct progress { width: 5rem; }
.pct-chip { display: inline-block; min-width: 3.2rem; padding: .15rem .45rem; border-radius: 6px; font-size: .82rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.pct-chip[data-level="none"] { color: var(--muted); }
.pct-chip[data-level="some"] { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text-2); }
.pct-chip[data-level="half"] { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
.pct-chip[data-level="full"] { background: var(--accent); color: var(--accent-ink); }
.row-actions { display: flex; gap: .25rem; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }
.confirm-icon-neutral { background: var(--accent-soft); color: var(--accent-text); }
.danger-panel { margin-top: 2rem; border-radius: var(--r-lg); }
.danger-panel h2 { font-size: 1.15rem; }
.manage-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.manage-grid h3 { font-size: 1rem; margin-bottom: .3rem; }
.manage-grid .help { min-height: 3em; }
.delete-page { max-width: 34rem; }
.delete-list { margin: 0; padding-left: 1.2rem; color: var(--text-2); }
.delete-page .grid-form { width: 100%; margin-top: .5rem; }

/* Password slips: hidden on screen, printed one per student */
.slips { display: none; }
@media print {
  @page { margin: 12mm; }
  body.password-page .no-print, body.password-page .messages { display: none !important; }
  body.password-page .main-col, body.password-page .page { display: block; padding: 0; max-width: none; }
  body.password-page { background: #fff; color: #000; }
  .slips { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; }
  .slip { break-inside: avoid; border: 1px dashed #888; border-radius: 4mm; padding: 6mm; font-size: 10.5pt; color: #000; background: #fff; }
  .slip-logo { height: 11mm; width: auto; display: block; margin-bottom: 3mm; }
  .slip-course { margin: 0 0 3mm; font-weight: 600; }
  .slip dl { display: grid; grid-template-columns: auto 1fr; gap: 1.5mm 4mm; margin: 0 0 3mm; }
  .slip dt { color: #555; }
  .slip dd { margin: 0; word-break: break-all; }
  .slip dd.mono { font-size: 13pt; font-weight: 700; letter-spacing: .04em; }
  .slip-note { margin: 0; font-size: 9pt; color: #444; }
}

/* Keep the row actions visible when the module columns scroll sideways */
.progress-table .actions-cell { position: sticky; right: 0; background: var(--panel); box-shadow: -12px 0 12px -10px rgb(0 0 0 / .45); padding-left: .5rem; }
.progress-table thead .actions-cell { background: var(--panel-2); }

/* Staging banner */
.env-banner { position: sticky; top: 0; z-index: 60; padding: .35rem 1rem; text-align: center; font-size: .82rem; font-weight: 600; background: #fbbf5a; color: #1a1300; }
.backup-ok { display: flex; align-items: center; gap: .4rem; margin: -.5rem 0 1rem; color: var(--muted); font-size: .88rem; }
