/* =============================================================
   PrepodovAI — Design System v2
   Light/dark themes, modern type, accessible components.
   ============================================================= */

:root {
  color-scheme: light;

  /* Slate-based palette: cool, restrained, content-first — matches the
     "AI-Native UI" style (chrome recedes, streaming text leads). Previous
     warm-sand palette was comfortable but competed with content density. */
  --bg: #f8fafc; /* slate-50 */
  --bg-elevated: #ffffff;
  --bg-muted: #f1f5f9; /* slate-100 */
  --bg-inverse: #020617; /* slate-950 */

  --surface: #ffffffee;
  --surface-strong: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.75);

  --ink: #020617; /* slate-950 — body text */
  --ink-muted: #334155; /* slate-700 */
  --ink-subtle: #475569; /* slate-600 */
  --ink-inverse: #f8fafc;

  --border: #e2e8f0; /* slate-200 */
  --border-strong: #cbd5e1; /* slate-300 */
  --border-focus: #0369a1; /* sky-700 */

  /* Accent: sky (professional, trustworthy for education) */
  --accent: #0369a1; /* sky-700 */
  --accent-hover: #075985; /* sky-800 */
  --accent-soft: #e0f2fe; /* sky-100 */
  --accent-ink: #0c4a6e; /* sky-900 */

  /* Warm signal for "needs attention" (pending submissions) */
  --warm: #c2410c; /* orange-700 */
  --warm-soft: #ffedd5; /* orange-100 */
  --warm-ink: #7c2d12; /* orange-900 */

  --danger: #b91c1c; /* red-700 */
  --danger-soft: #fee2e2; /* red-100 */
  --danger-ink: #7f1d1d; /* red-900 */

  --success: #047857; /* emerald-700 */
  --success-soft: #d1fae5; /* emerald-100 */
  --success-ink: #064e3b; /* emerald-900 */

  --info: #1d4ed8; /* blue-700 */
  --info-soft: #dbeafe; /* blue-100 */
  --info-ink: #1e3a8a; /* blue-900 */

  /* Softer shadow scale — HIG "deference": chrome recedes so content leads.
     Use subtle shadows for elevation, not heavy drop-shadows. */
  --shadow-xs: 0 1px 2px rgba(16, 22, 26, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 22, 26, 0.05), 0 1px 2px rgba(16, 22, 26, 0.03);
  --shadow-md: 0 4px 12px rgba(16, 22, 26, 0.06), 0 2px 4px rgba(16, 22, 26, 0.03);
  --shadow-lg: 0 16px 40px rgba(16, 22, 26, 0.08), 0 6px 12px rgba(16, 22, 26, 0.04);

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Typography: one system font family across the whole app; hierarchy via
     weight (700 for headings, 600 for labels, 500 for body, 400 for helpers)
     and size, not alternate font families. Mirrors HIG "clarity". */
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-body);
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, "Cascadia Mono", "Consolas", monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --container: 1180px;
  --container-narrow: 820px;

  /* Motion: one curve shared everywhere so the product feels physically
     coherent (HIG "depth"). Slightly under-damped spring approximation. */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --transition-fast: 150ms var(--ease-standard);
  --transition-base: 220ms var(--ease-standard);
}

[data-theme="dark"] {
  color-scheme: dark;

  /* Dark palette mirrors the slate primary. Deep slate-900 bg with
     slightly lifted cards; sky accent stays readable on dark. */
  --bg: #020617; /* slate-950 */
  --bg-elevated: #0f172a; /* slate-900 */
  --bg-muted: #1e293b; /* slate-800 */
  --bg-inverse: #f8fafc;

  --surface: #0f172aee;
  --surface-strong: #1e293b;
  --surface-glass: rgba(15, 23, 42, 0.8);

  --ink: #f1f5f9; /* slate-100 */
  --ink-muted: #cbd5e1; /* slate-300 */
  --ink-subtle: #94a3b8; /* slate-400 */
  --ink-inverse: #020617;

  --border: #334155; /* slate-700 */
  --border-strong: #475569; /* slate-600 */
  --border-focus: #38bdf8; /* sky-400 */

  --accent: #38bdf8; /* sky-400 — readable on dark */
  --accent-hover: #7dd3fc; /* sky-300 */
  --accent-soft: #082f49; /* sky-950 */
  --accent-ink: #bae6fd; /* sky-200 */

  --warm: #fb923c; /* orange-400 */
  --warm-soft: #431407; /* orange-950 */
  --warm-ink: #fed7aa; /* orange-200 */

  --danger: #f87171; /* red-400 */
  --danger-soft: #450a0a; /* red-950 */
  --danger-ink: #fecaca; /* red-200 */

  --success: #34d399; /* emerald-400 */
  --success-soft: #022c22; /* emerald-950 */
  --success-ink: #a7f3d0; /* emerald-200 */

  --info: #60a5fa; /* blue-400 */
  --info-soft: #172554; /* blue-950 */
  --info-ink: #bfdbfe; /* blue-200 */

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6), 0 6px 12px rgba(0, 0, 0, 0.4);
}

/* ---------- Base ---------- */

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

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  /* Subtle ambient gradients — sky + blue, barely visible — adds depth
     without chrome noise. Matches "AI-Native UI" ambient backdrop. */
  background:
    radial-gradient(circle at 15% 5%, rgba(3, 105, 161, 0.08), transparent 55%),
    radial-gradient(circle at 85% 20%, rgba(29, 78, 216, 0.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at 15% 5%, rgba(56, 189, 248, 0.12), transparent 55%),
    radial-gradient(circle at 85% 20%, rgba(96, 165, 250, 0.08), transparent 60%),
    var(--bg);
}

.bg {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.noise {
  position: fixed;
  inset: 0;
  opacity: 0.03;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

h1, h2, h3, h4, h5 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
}

/* Tighter, bigger hierarchy. h1 feels editorial (not timid); h2 anchors
   section cards; h3 labels sub-sections without shouting. */
h1 { font-size: clamp(30px, 4vw, 42px); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: clamp(22px, 2.4vw, 28px); font-weight: 700; }
h3 { font-size: 18px; font-weight: 600; }
h4 { font-size: 15px; font-weight: 600; }

p { margin: 0; line-height: 1.65; }

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

code, pre, .mono { font-family: var(--font-mono); font-size: 0.92em; }

/* Focus rings — AI-native: crisp, high-contrast, never "sharp blue" default.
   The offset + accent-tint ring reads as a premium polish detail. */

a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: inherit;
}

/* Anything that looks tappable must feel tappable. */
button,
summary,
[role="button"],
.chip,
.tab,
.submission-card__summary,
.recent-item,
select {
  cursor: pointer;
}

button:disabled,
button[aria-busy="true"] {
  cursor: not-allowed;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--ink-inverse);
  text-decoration: none;
  transform: translateY(-220%);
  transition: transform var(--transition-base);
  z-index: 50;
  font-weight: 600;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

/* ---------- Layout ---------- */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-16);
  position: relative;
  z-index: 1;
}

.runtime-shell {
  display: grid;
  gap: var(--space-5);
}

.runtime-shell--narrow {
  max-width: var(--container-narrow);
}

.stack {
  display: grid;
  gap: var(--space-3);
}

.stack--lg {
  gap: var(--space-5);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover { text-decoration: none; }

.brand__mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--warm)));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(15, 107, 94, 0.25);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pill--student {
  background: var(--warm-soft);
  color: var(--warm-ink);
}

/* ---------- Landing hero ---------- */

/* Landing hero: minimal single-column pattern (ui-ux-pro-max: Pattern →
   Minimal Single Column). Large typography, breathing room, single CTA. */
.hero {
  max-width: var(--container-narrow);
  margin: var(--space-16) auto var(--space-10);
  padding: var(--space-12) var(--space-8) var(--space-10);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  z-index: 1;
  text-align: center;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -60px -120px auto auto;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  filter: blur(20px);
}

.hero__actions,
.hero__stats {
  justify-content: center;
}

.hero__lead {
  margin-left: auto;
  margin-right: auto;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background: var(--warm-soft);
  color: var(--warm-ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-4);
}

.hero__badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warm);
}

.hero h1 {
  font-size: clamp(40px, 6vw, 64px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-weight: 800;
  margin-bottom: var(--space-5);
}

.hero__lead {
  font-size: 18px;
  color: var(--ink-muted);
  max-width: 640px;
}

.hero__actions {
  margin-top: var(--space-6);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.hero__stats {
  margin-top: var(--space-8);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}

.hero-stat__num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.hero-stat__label {
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 13px;
}

.features-grid {
  max-width: var(--container-narrow);
  margin: 0 auto var(--space-16);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
  padding: 0 var(--space-5);
}

.feature-card {
  padding: var(--space-6);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.feature-card__icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: var(--space-3);
}

.feature-card h3 {
  margin-bottom: var(--space-2);
}

.feature-card p {
  color: var(--ink-muted);
  font-size: 15px;
}

.roles-grid {
  max-width: var(--container-narrow);
  margin: 0 auto var(--space-16);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
  padding: 0 var(--space-5);
}

.role-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-8);
  background: linear-gradient(140deg, var(--surface-strong), color-mix(in srgb, var(--accent-soft) 40%, var(--surface-strong)));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.role-card--student {
  background: linear-gradient(140deg, var(--surface-strong), color-mix(in srgb, var(--warm-soft) 60%, var(--surface-strong)));
}

.role-card h2 {
  margin-bottom: var(--space-2);
}

.role-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-2);
  color: var(--ink-muted);
}

.role-card li {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
}

.role-card li::before {
  content: "✓";
  color: var(--accent);
  font-weight: 700;
}

.role-card .btn {
  align-self: flex-start;
}

/* ---------- Panels / Cards ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.panel--step {
  display: grid;
  gap: var(--space-5);
}

.panel--secondary {
  background: var(--bg-elevated);
}

.panel--secondary > summary,
.advanced-box > summary {
  cursor: pointer;
  font-weight: 700;
  padding: var(--space-2) 0;
}

.panel-block {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: grid;
  gap: var(--space-4);
}

.step-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: flex-start;
}

.step-head--compact { align-items: center; }

.step-head p { max-width: 560px; }

.step-kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: flex-start;
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

/* ---------- Tabs ---------- */

.tablist {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  scrollbar-width: none;
}

.tablist::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 0 auto;
  padding: 10px 16px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab:hover { color: var(--ink); background: color-mix(in srgb, var(--surface-strong) 70%, transparent); }

.tab[aria-selected="true"] {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.tab .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--warm);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.tab[aria-selected="true"] .tab-count {
  background: var(--accent);
}

.tab-panel { display: none; }
.tab-panel[data-active="true"] { display: grid; gap: var(--space-5); }

/* ---------- Status banner ---------- */

.status-banner {
  max-width: var(--container);
  margin: var(--space-4) auto 0;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 5;
}

.status-banner--idle { display: none; }

.status-banner--info {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 30%, transparent);
  color: var(--info-ink);
}
.status-banner--success {
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
  color: var(--success-ink);
}
.status-banner--error {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger-ink);
}

/* ---------- Toast stack ---------- */

.toast-stack {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  display: grid;
  gap: var(--space-2);
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  gap: var(--space-3);
  align-items: center;
  min-width: 260px;
  max-width: 380px;
  animation: slideIn 220ms cubic-bezier(0.3, 0.1, 0.2, 1);
}

.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--info { border-left-color: var(--info); }

.toast button {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.toast button:hover { background: var(--bg-muted); color: var(--ink); }

@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------- Forms ---------- */

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--ink);
}

.field-help,
.muted {
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.5;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}

.field-grid--compact {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.field-card {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: grid;
  gap: var(--space-2);
}

.field-card--plain {
  background: transparent;
  border: 0;
  padding: 0;
}

textarea,
input[type="file"],
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="tel"],
select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
textarea:hover, input:hover, select:hover { border-color: var(--border-strong); }

input::placeholder,
textarea::placeholder { color: var(--ink-subtle); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  /* subtle inner highlight — the sky button gains physical presence */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), var(--shadow-xs);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 28%, transparent);
  color: #fff;
  text-decoration: none;
}

.btn:active { transform: translateY(0); }

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
}

.btn--ghost:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn--subtle {
  background: var(--bg-muted);
  color: var(--ink);
  border-color: var(--border);
}

.btn--subtle:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn--accent {
  background: #8a4a00;
  border-color: #8a4a00;
  color: #fff;
}

.btn--accent:hover {
  background: #703b00;
  border-color: #703b00;
  color: #fff;
  box-shadow: 0 6px 14px color-mix(in srgb, #8a4a00 28%, transparent);
}

[data-theme="dark"] .btn--accent {
  background: var(--warm);
  border-color: var(--warm);
  color: #2a1800;
}

[data-theme="dark"] .btn--accent:hover {
  background: color-mix(in srgb, var(--warm) 88%, white);
  border-color: color-mix(in srgb, var(--warm) 88%, white);
  color: #2a1800;
}

.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn--danger:hover {
  background: color-mix(in srgb, var(--danger) 88%, black);
  border-color: color-mix(in srgb, var(--danger) 88%, black);
  color: #fff;
}

.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--icon { padding: 8px; min-width: 36px; min-height: 36px; }
.btn--block { width: 100%; }

.btn:disabled,
.btn[aria-busy="true"] {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none !important;
  box-shadow: none !important;
}

.btn[aria-busy="true"]::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 600ms linear infinite;
  margin-right: 4px;
}

@keyframes spin {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast);
  flex: 0 0 auto;
}

.icon-btn:hover {
  background: var(--bg-muted);
  color: var(--ink);
  border-color: var(--border-strong);
}

.icon-btn svg {
  display: block;
  pointer-events: none;
}

/* ---------- Inline actions / Rows ---------- */

.inline-actions,
.action-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.action-row--between { justify-content: space-between; }
.action-row--end { justify-content: flex-end; }

/* ---------- Badges / Chips ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-muted);
  color: var(--ink-muted);
  border: 1px solid transparent;
}

.badge--neutral { background: var(--bg-muted); color: var(--ink-muted); }
.badge--accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge--warm { background: var(--warm-soft); color: var(--warm-ink); }
.badge--success { background: var(--success-soft); color: var(--success-ink); }
.badge--danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge--info { background: var(--info-soft); color: var(--info-ink); }

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 1;
}

/* Give each badge variant a saturated dot so status reads across the room. */
.badge--warm::before { background: var(--warm); }
.badge--accent::before { background: var(--accent); }
.badge--success::before { background: var(--success); }
.badge--info::before { background: var(--info); }
.badge--danger::before { background: var(--danger); }

.badge--plain::before { display: none; }

/* ---------- Empty / Inline status ---------- */

.empty-state {
  padding: var(--space-6);
  border-radius: var(--radius-md);
  background: var(--bg-muted);
  border: 1px dashed var(--border-strong);
  color: var(--ink-muted);
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
}

.empty-state--error {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger-ink);
}

.empty-state h4 {
  color: var(--ink);
  margin-bottom: 6px;
}

.inline-status {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.5;
}

.inline-status--info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--info-ink); }
.inline-status--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success-ink); }
.inline-status--error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger-ink); }

.confirm-box {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--warm-soft);
  border: 1px solid color-mix(in srgb, var(--warm) 35%, transparent);
  color: var(--warm-ink);
}

.confirm-box__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- Advanced box ---------- */

.advanced-box {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--bg-elevated);
}

/* ---------- Tree (course structure) ---------- */

.tree { min-height: 70px; }

.tree-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-2);
}

.tree-list--nested {
  padding-left: var(--space-5);
  margin-top: var(--space-2);
  border-left: 2px solid var(--border);
}

.tree-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.tree-item--lesson {
  padding: 6px 12px;
  background: transparent;
  border: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  color: var(--ink-muted);
}

.tree-item--lesson strong { color: var(--ink); }

.tree-line {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.tree-line strong { font-size: 15px; }

/* ---------- Rubric builder ---------- */

.rubric { display: grid; gap: var(--space-3); }

.rubric-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--surface-strong);
}

.rubric-card__head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-3);
}

.rubric-grid,
.rubric-levels {
  display: grid;
  gap: var(--space-3);
}

.rubric-grid {
  grid-template-columns: minmax(0, 2fr) minmax(120px, 180px);
}

.rubric-levels {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: var(--space-3);
}

.rubric-field {
  display: grid;
  gap: 6px;
}

.rubric-field > span {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-muted);
}

/* ---------- Submission cards (grading queue) ---------- */

.submission-list,
.assignment-list,
.feedback-list,
.students-list {
  display: grid;
  gap: var(--space-3);
}

.submission-card,
.assignment-card,
.feedback-card,
.student-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  padding: var(--space-5);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.submission-card:hover,
.assignment-card:hover,
.feedback-card:hover,
.student-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.submission-card[data-active="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

/* Distinct left-border colour per pipeline state so a dense queue is
   scannable at three metres without reading status badges. */
.submission-card[data-status="submitted"] {
  border-left: 4px solid var(--warm);
}
.submission-card[data-status="draft_ready"] {
  border-left: 4px solid var(--info);
}
.submission-card[data-status="finalized"] {
  border-left: 4px solid var(--success);
  background: color-mix(in srgb, var(--success-soft) 35%, var(--surface-strong));
}
.submission-card[data-status="finalized"] .submission-card__title {
  opacity: 0.85;
}

.submission-card__summary,
.assignment-card__head,
.feedback-card__head,
.student-card__head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: flex-start;
  flex-wrap: wrap;
}

.submission-card__title,
.feedback-title,
.assignment-card h3,
.student-card__name {
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
}

.submission-card__meta {
  display: flex;
  gap: var(--space-2);
  color: var(--ink-muted);
  font-size: 13px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.submission-card__meta span::after {
  content: "·";
  margin-left: 8px;
  color: var(--ink-subtle);
}

.submission-card__meta span:last-child::after { display: none; }

.submission-card__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.submission-card__preview {
  margin: var(--space-3) 0 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.55;
  max-height: 84px;
  overflow: hidden;
  position: relative;
}

.submission-card__preview::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 24px;
  background: linear-gradient(transparent, var(--bg-muted));
  pointer-events: none;
}

.submission-card__body {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.submission-content,
.feedback-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  max-height: 420px;
  overflow-y: auto;
}

/* ---------- Grade selector (segmented) ---------- */

.grade-select {
  display: inline-flex;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-muted);
  padding: 3px;
  gap: 2px;
}

.grade-select__btn {
  padding: 6px 14px;
  border: 0;
  background: transparent;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-muted);
  border-radius: var(--radius-xs);
  cursor: pointer;
  min-width: 42px;
}

.grade-select__btn[aria-pressed="true"] {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.grade-select__btn:hover { color: var(--ink); }

/* ---------- Stats ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

.stat-card {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.stat-card__label {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-card__hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-subtle);
}

.stat-card--accent { background: linear-gradient(135deg, var(--accent-soft), var(--surface-strong)); border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }
.stat-card--accent .stat-card__value { color: var(--accent-ink); }
.stat-card--warm { background: linear-gradient(135deg, var(--warm-soft), var(--surface-strong)); border-color: color-mix(in srgb, var(--warm) 25%, var(--border)); }
.stat-card--warm .stat-card__value { color: var(--warm-ink); }

/* ---------- Dashboard recent list ---------- */

.recent-list { display: grid; gap: var(--space-2); }

.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  font-size: 13px;
}

.recent-item__main { display: grid; gap: 2px; min-width: 0; }
.recent-item__title { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item__meta { color: var(--ink-subtle); }

/* ---------- Keyboard hint ---------- */

.kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  box-shadow: 0 1px 0 var(--border);
  line-height: 1;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--ink-muted);
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--bg-muted);
  color: var(--ink);
}

.theme-toggle svg { width: 18px; height: 18px; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }

/* ---------- Modal overlay ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
  animation: fadeIn 160ms ease;
}

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  display: grid;
  gap: var(--space-4);
  animation: popIn 220ms cubic-bezier(0.3, 0.1, 0.2, 1);
}

.modal__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

.modal__close {
  background: transparent;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  color: var(--ink-muted);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.modal__close:hover { background: var(--bg-muted); color: var(--ink); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { transform: translateY(10px) scale(0.98); opacity: 0.5; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ---------- Filters bar ---------- */

.filter-bar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-muted);
  border: 1px solid var(--border);
}

.filter-bar input[type="search"] {
  flex: 1 1 200px;
  min-width: 180px;
}

.chip-group { display: flex; gap: 4px; flex-wrap: wrap; }

.chip {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface-strong);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast);
}

.chip:hover { border-color: var(--border-strong); color: var(--ink); }

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Course switcher ---------- */

.course-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
}

.course-switcher select {
  border: 0;
  background: transparent;
  padding: 5px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  max-width: 220px;
  cursor: pointer;
}

.course-switcher select:focus { outline: none; }

.course-switcher .icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 0;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
}

.course-switcher--student .icon-btn {
  background: var(--warm-soft);
  color: var(--warm-ink);
}

/* ---------- Auth panel ---------- */

.auth-panel { text-align: center; }
.auth-panel .step-head { justify-content: center; }
.auth-panel .step-head > div { max-width: 420px; margin: 0 auto; }
.auth-panel .stack,
.auth-panel form {
  text-align: left;
  max-width: 460px;
  margin: 0 auto;
}
.auth-panel .tablist { margin: 0 auto var(--space-5); max-width: 380px; }
.auth-panel .role-btn { min-width: 130px; padding: 8px 14px; }
.auth-panel h1 { font-size: clamp(28px, 4vw, 36px); }

.password-field {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.password-field input {
  flex: 1 1 auto;
}

.password-toggle {
  white-space: nowrap;
  padding: 10px 12px;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}

.dropzone:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
  border-color: var(--accent);
}

/* ---------- Dropzone ---------- */

.dropzone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--bg-muted);
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast);
  cursor: pointer;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone--active {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.01);
}

.dropzone__inner {
  text-align: center;
  color: var(--ink-muted);
  pointer-events: none;
}

.dropzone__title {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.dropzone__hint {
  font-size: 12px;
}

.dropzone .file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-info {
  margin-top: 8px;
  min-height: 24px;
}

.domain-select {
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
}

/* ---------- Markdown body ---------- */

.md-body {
  line-height: 1.65;
}
.md-body .md-p { margin: 0 0 10px; }
.md-body .md-p:last-child { margin-bottom: 0; }
.md-body .md-h {
  margin: 12px 0 6px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.md-body .md-ul {
  margin: 6px 0 10px;
  padding-left: 24px;
}
.md-body .md-li { margin: 2px 0; }
.md-body .md-num { margin: 4px 0; }
.md-body .md-num > span { color: var(--accent); font-weight: 700; margin-right: 4px; }
.md-body .md-code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--bg-muted);
  font-family: var(--font-mono);
  font-size: 0.92em;
}
.md-body .md-pre {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 13px;
  overflow-x: auto;
  white-space: pre;
}
.md-body strong { color: var(--ink); }

.feedback-body {
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  margin-top: 6px;
}

/* ---------- Chunk meta bar ---------- */

.chunk-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .step-head,
  .section-head,
  .submission-card__summary,
  .assignment-card__head,
  .feedback-card__head,
  .student-card__head,
  .confirm-box {
    flex-direction: column;
    align-items: stretch;
  }

  .rubric-grid,
  .rubric-levels { grid-template-columns: 1fr; }

  .topbar { padding: var(--space-3) var(--space-4); }
  .container { padding: var(--space-4) var(--space-4) var(--space-12); }
  .panel { padding: var(--space-4); }
}

@media (max-width: 600px) {
  .hero { margin: var(--space-5) var(--space-3); padding: var(--space-6) var(--space-5); }

  .hero h1 { font-size: 28px; }
  .hero__lead { font-size: 16px; }

  .inline-actions,
  .action-row,
  .confirm-box__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn, .btn--block { width: 100%; }

  .brand__mark { width: 24px; height: 24px; font-size: 12px; }

  .pill { font-size: 11px; padding: 5px 10px; }

  /* Narrow-screen grading ergonomics — keep buttons thumb-reachable. */
  .submission-card__actions {
    flex-wrap: wrap;
    gap: var(--space-2);
    width: 100%;
    justify-content: flex-start;
  }
  .grade-select {
    width: 100%;
    justify-content: space-between;
  }
  .grade-select__btn {
    flex: 1 1 auto;
  }
  /* Keyboard hints are useless on touch — hide them. */
  .kbd { display: none; }
}

/* ---------- AI-native micro-interactions ---------- */

/* Typing indicator: three dots that pulse while the model is generating.
   Used next to the "Сгенерировать черновик" button during inference. */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingDot 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typingDot {
  0%, 80%, 100% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Streaming text reveal: subtle fade-up on newly-rendered content so the
   AI-generated draft feels alive rather than plopped in. */
.stream-in {
  animation: streamIn 320ms var(--ease-standard) both;
}

@keyframes streamIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pulse: used on draft-in-progress cards or pending notifications. */
.pulse-accent {
  position: relative;
}

.pulse-accent::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent);
  animation: pulseRing 2s infinite;
  pointer-events: none;
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
  70% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .typing-dots span,
  .stream-in,
  .pulse-accent::before {
    animation: none;
  }
}

/* ---------- Skeleton loaders ---------- */

.skeleton {
  position: relative;
  background: linear-gradient(
    90deg,
    var(--bg-muted) 0%,
    color-mix(in srgb, var(--bg-muted) 60%, var(--surface-strong)) 50%,
    var(--bg-muted) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent;
  pointer-events: none;
  user-select: none;
}

.skeleton-row {
  height: 80px;
  margin-bottom: var(--space-2);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ---------- Filter chip count badge ---------- */

.chip .chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 0 6px;
  height: 18px;
  min-width: 18px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 15%, transparent);
  font-size: 11px;
  font-weight: 700;
}

.chip[aria-pressed="true"] .chip-count {
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
}

/* ---------- Course switcher pending pip ---------- */

.course-switcher__pending {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--warm);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  margin: 0 4px;
  min-width: 20px;
}

/* ---------- Auth hero mark ---------- */

.auth-hero-mark {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--warm)));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 34px;
  margin-bottom: var(--space-4);
  box-shadow: 0 16px 40px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ---------- Two-column auth panel (login page "why account" section) ---------- */

.auth-why {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.auth-why__item {
  display: grid;
  gap: 4px;
}

.auth-why__item .icon {
  font-size: 20px;
  color: var(--accent);
}

.auth-why__item h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.auth-why__item p {
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* ---------- Shortcut cheatsheet table ---------- */

.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.shortcut-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.shortcut-table td:first-child {
  width: 140px;
  white-space: nowrap;
}

.shortcut-table tr:last-child td {
  border-bottom: 0;
}

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

/* ---------- Utility ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-muted { color: var(--ink-muted); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* Legacy card class kept for index page */
.card {
  padding: var(--space-5);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.grid {
  max-width: var(--container-narrow);
  margin: 0 auto var(--space-12);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
  padding: 0 var(--space-5);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.stat {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
