:root {
  --bg: #0B0D10;
  --bg-elev: #101319;
  --surface: #141820;
  --surface-2: #1A202B;
  --surface-3: #202836;
  --line: #232A36;
  --line-strong: #323C4E;
  --text: #F3F5F8;
  --muted: #98A2B3;
  --dim: #667085;
  --accent: #38BDF8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --ready: #34D399;
  --ready-soft: rgba(52, 211, 153, 0.14);
  --progress: #FBBF24;
  --progress-soft: rgba(251, 191, 36, 0.14);
  --wrong: #F87171;
  --wrong-soft: rgba(248, 113, 113, 0.14);
  --soon: #475467;
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 60px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Space Grotesk", "Inter", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

[hidden] { display: none !important; }

/* Custom subtle scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #262E3C; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #364154; }

/* =========================================================================
   TOP COMMAND BAR (100% WIDTH)
   ========================================================================= */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70;
  height: var(--topbar-h);
  width: 100%;
  padding: 0 20px;
  display: grid;
  grid-template-columns: auto minmax(200px, 460px) auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(11, 13, 16, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar-toggle-btn { flex-shrink: 0; }
.sidebar-toggle-btn.collapsed {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); background: var(--surface-2); }

.brand-home {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  padding: 2px 4px;
  color: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.brand-home:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand-mark { display: block; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.brand-name {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text);
}
.brand-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

.subjects-bar {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  margin-left: 6px;
}
.subjects-bar button {
  padding: 5px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.subjects-bar button:hover { color: var(--text); }
.subjects-bar button[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--text);
}

.topbar-center { width: 100%; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s;
}
.search-box:focus-within {
  border-color: var(--accent);
  background: var(--bg-elev);
}
.search-icon { color: var(--dim); flex-shrink: 0; }
.search-box input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
}
.search-box input::placeholder { color: var(--dim); }
.kbd-hint, kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  line-height: 1.2;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}
.streak-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
}
.streak-pill.active {
  border-color: rgba(52, 211, 153, 0.45);
  background: var(--ready-soft);
}
.streak-pill.active .streak-dot {
  background: var(--ready);
  box-shadow: 0 0 8px var(--ready);
}
.streak-label { color: var(--muted); font-size: 11px; }

.account { display: flex; align-items: center; gap: 8px; }
.account-pill {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-pill.guest { color: var(--muted); }

/* Buttons */
.btn-primary, .btn-outline, .text-btn {
  font-family: var(--sans);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-primary:hover { background: #FFFFFF; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-primary kbd {
  background: rgba(11, 13, 16, 0.14);
  border-color: rgba(11, 13, 16, 0.22);
  color: var(--bg);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}
.btn-outline:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; }
.btn-full { width: 100%; height: 42px; }

.text-btn {
  background: transparent;
  border: 0;
  padding: 2px 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}
.text-btn:hover { text-decoration: underline; }

/* =========================================================================
   FULL-SCREEN WORKSPACE GRID
   ========================================================================= */
.workspace {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 300px;
  min-height: 100vh;
  padding-top: var(--topbar-h);
  width: 100%;
}

.workspace.trainer-mode {
  grid-template-columns: 272px minmax(0, 1fr);
}
.workspace.trainer-mode .inspector { display: none; }

.workspace.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr) 300px;
}
.workspace.sidebar-collapsed .sidebar { display: none; }
.workspace.trainer-mode.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

/* =========================================================================
   LEFT SIDEBAR
   ========================================================================= */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 18px 16px 24px;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-caption {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}

.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item[aria-current="page"] {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
.nav-badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--surface);
  color: var(--muted);
}
.nav-badge.accent { background: var(--accent-soft); color: var(--accent); }
.nav-badge.warn { background: var(--progress-soft); color: var(--progress); }

.sidebar-block {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.block-head .nav-caption { margin-bottom: 0; }
.map-legend-mini {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* 27-cell Exam Matrix */
.exam-matrix {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}
.matrix-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform .1s, border-color .15s, background .15s;
}
.matrix-cell:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}
.matrix-cell.mastered {
  background: var(--ready-soft);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--ready);
}
.matrix-cell.learning {
  background: var(--progress-soft);
  border-color: rgba(251, 191, 36, 0.45);
  color: var(--progress);
}
.matrix-cell.weak {
  background: var(--wrong-soft);
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--wrong);
}
.matrix-cell.due {
  background: rgba(167, 139, 250, 0.16);
  border-color: rgba(167, 139, 250, 0.55);
  color: #C4B5FD;
}
.matrix-cell.soon {
  background: transparent;
  border-color: #1B202A;
  color: var(--soon);
  cursor: default;
}
.matrix-cell.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--dim);
}
.matrix-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  display: inline-block;
}
.dot.mastered { background: var(--ready); }
.dot.due { background: #A78BFA; }
.dot.learning { background: var(--progress); }
.dot.weak { background: var(--wrong); }
.dot.ready { background: var(--surface-3); border: 1px solid var(--line-strong); }
.dot.soon { background: #1B202A; }

/* Quick launch mode buttons */
.quick-modes { display: grid; gap: 6px; }
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mode-btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.mode-btn strong { font-size: 12.5px; font-weight: 600; }
.mode-btn span { font-size: 11px; color: var(--dim); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
}
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--dim);
}

/* =========================================================================
   CENTER STAGE
   ========================================================================= */
.stage {
  min-width: 0;
  padding: 22px 26px 42px;
}

/* KPI Row */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}
.kpi-ring-card {
  flex-direction: row;
  align-items: center;
  gap: 14px;
}
.kpi-ring-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}
.kpi-ring { transform: rotate(-90deg); display: block; }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 5; }
.ring-fill {
  fill: none;
  stroke: var(--ready);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset .4s ease;
}
.kpi-ring-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.kpi-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.kpi-sub { font-size: 11.5px; color: var(--dim); }
.kpi-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
}
.kpi-chip.ready { background: var(--ready-soft); color: var(--ready); }
.kpi-bar {
  height: 4px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.kpi-bar i {
  display: block;
  height: 100%;
  background: var(--text);
  border-radius: 99px;
  transition: width .35s ease;
}
.kpi-bar i.cyan { background: var(--accent); }
.kpi-bar i.green { background: var(--ready); }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.pill:hover { color: var(--text); border-color: var(--line-strong); }
.pill[aria-selected="true"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.pill-count {
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0.75;
}

.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.select-control {
  height: 34px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 12.5px;
  cursor: pointer;
}
.select-control:focus { outline: none; border-color: var(--accent); }

.view-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.view-toggle button {
  width: 32px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
}
.view-toggle button:hover { color: var(--text); }
.view-toggle button[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--text);
}

.catalog-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  margin-bottom: 14px;
}

/* Multi-column Task Catalog Cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
  align-items: start;
}
.cards-grid.list-mode {
  grid-template-columns: 1fr;
  gap: 8px;
}

.num-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.num-card.available:hover {
  border-color: var(--line-strong);
}
.num-card.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.2);
}
.num-card.soon { opacity: 0.52; }
.num-card.pulse {
  animation: cardPulse 0.9s ease;
}
@keyframes cardPulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.6); border-color: var(--accent); }
  100% { box-shadow: 0 0 0 12px rgba(56, 189, 248, 0); }
}

.num-card-main {
  padding: 15px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.num-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.num-badge {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
}

.state-pill {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid currentColor;
}
.state-pill.ready { color: var(--ready); background: var(--ready-soft); border-color: rgba(52, 211, 153, 0.35); }
.state-pill.in_progress { color: var(--progress); background: var(--progress-soft); border-color: rgba(251, 191, 36, 0.35); }
.state-pill.coming_soon { color: var(--soon); border-color: var(--line); }

.num-title {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.num-sub {
  font-size: 12px;
  color: var(--dim);
}

.num-meter-wrap { display: flex; flex-direction: column; gap: 5px; }
.num-meter-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.num-meter {
  height: 5px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.num-meter i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
}
.num-meter i.mastered { background: var(--ready); }
.num-meter i.weak { background: var(--wrong); }
.num-meter i.due { background: #A78BFA; }

/* Daily plan card & external-study trainer helpers */
.kpi-plan-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}
.kpi-plan-text {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.plan-cta-btn {
  align-self: flex-start;
  height: 28px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.plan-cta-btn:hover { background: rgba(56, 189, 248, 0.22); }

.assisted-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.assisted-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}
.answer-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.timer-box.muted-timer .timer-value,
.timer-box.muted-timer .timer-dot,
.timer-box.muted-timer #btn-timer-toggle {
  display: none;
}
.timer-box.muted-timer {
  padding: 0 6px;
  opacity: 0.72;
}
.verdict.info {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.35);
}
.verdict.info h2 { color: var(--accent); }

.verdict-help-banner {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.verdict-help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Hints card & Guide modal */
.hints-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hints-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.hint-item {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.hint-item strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 3px;
}

.modal-wide {
  max-width: 640px;
  width: calc(100vw - 32px);
  max-height: 86vh;
  overflow-y: auto;
}
.guide-title-text {
  margin-left: 8px;
  font-size: 15px;
}
.guide-body {
  display: grid;
  gap: 14px;
  margin-top: 12px;
  font-size: 13.5px;
  line-height: 1.55;
}
.guide-section h3 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.guide-section p { margin: 0; color: var(--text); }
.guide-section ul, .guide-section ol {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
  color: var(--text);
}
.guide-code-wrap {
  position: relative;
}
.guide-code {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  color: var(--text);
}
.guide-pitfalls li { color: #FCA5A5; }

/* Exam mode bar & Hub / Results Blank */
.exam-mode-bar {
  background: var(--surface);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.exam-mode-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.exam-mode-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.exam-pill {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
}
.exam-mode-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.exam-countdown {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
}
.exam-countdown.urgent {
  color: var(--wrong);
  border-color: rgba(248, 113, 113, 0.5);
}
.exam-nav-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.exam-nav-btn {
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.exam-nav-btn:hover { border-color: var(--line-strong); color: var(--text); }
.exam-nav-btn.filled {
  background: var(--ready-soft);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--ready);
}
.exam-nav-btn.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  color: var(--text);
}

.screen-exam {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.exam-launch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.exam-launch-card {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.exam-launch-card h2 { margin: 2px 0 0; font-size: 17px; }
.exam-launch-card p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.exam-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin-top: 4px;
}
.exam-check-row .select-control {
  flex: 1 1 200px;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exam-check-row .btn-primary { flex-shrink: 0; }

.exam-history-section h2 {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 10px;
}
.exam-history-list {
  display: grid;
  gap: 8px;
}
.exam-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.exam-history-meta { display: flex; flex-direction: column; gap: 2px; }
.exam-history-meta strong { font-size: 13.5px; }
.exam-history-meta span { font-size: 12px; color: var(--dim); }

.exam-score-hero {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.exam-score-badge {
  min-width: 112px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid rgba(56, 189, 248, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.exam-score-badge strong {
  font-family: var(--mono);
  font-size: 36px;
  line-height: 1;
  color: var(--accent);
}
.exam-score-badge span {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
}
.exam-score-meta h1 { margin: 0 0 6px; font-size: 20px; }
.exam-score-meta p { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.exam-res-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.exam-blank-list {
  display: grid;
  gap: 8px;
}
.blank-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.blank-item.ok { border-left: 3px solid var(--ready); }
.blank-item.no { border-left: 3px solid var(--wrong); }
.blank-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.blank-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.blank-answers {
  font-family: var(--mono);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.blank-answers code {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
}
.blank-explain {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  white-space: pre-wrap;
}
.blank-tools {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-mini-btn {
  height: 32px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.card-mini-btn:hover { border-color: var(--line-strong); color: var(--text); }

.num-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}
.card-solve-btn {
  flex: 1 1 112px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.card-solve-btn:hover { background: var(--text); color: var(--bg); }

.card-expand-btn {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
  cursor: pointer;
}
.card-expand-btn:hover { color: var(--text); border-color: var(--line-strong); }

.archetypes-drawer {
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  display: grid;
}
.archetype-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid #1A1F29;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.archetype-item:last-child { border-bottom: 0; }
.archetype-item:hover { background: var(--surface-2); color: var(--text); }
.archetype-item .arch-pct {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface);
}
.archetype-item.mastered .arch-pct { color: var(--ready); background: var(--ready-soft); }
.archetype-item.weak .arch-pct { color: var(--wrong); background: var(--wrong-soft); }
.archetype-item.learning .arch-pct { color: var(--progress); background: var(--progress-soft); }

/* =========================================================================
   WEAK SPOTS SCREEN
   ========================================================================= */
.section-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.section-hero h1 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 20px;
}
.section-hero p { margin: 0; color: var(--muted); font-size: 13px; }

.weak-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.weak-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.weak-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.weak-card-title { font-size: 13.5px; font-weight: 500; line-height: 1.4; }

/* =========================================================================
   FULL-SCREEN TWO-COLUMN TASK TRAINER
   ========================================================================= */
.trainer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.trainer-bar-left, .trainer-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.task-num-badge {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}
.trainer-crumb { display: flex; flex-direction: column; line-height: 1.25; }
.trainer-crumb strong { font-size: 14px; }
.trainer-crumb span { font-size: 12px; color: var(--muted); }

.timer-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px 0 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12.5px;
}
.timer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ready);
}
.timer-dot.paused { background: var(--progress); }
.timer-toggle {
  border: 0;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 10px;
  cursor: pointer;
}
.timer-toggle:hover { color: var(--text); }

.font-controls {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.font-controls button {
  height: 32px;
  padding: 0 9px;
  border: 0;
  background: var(--bg-elev);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.font-controls button:hover { background: var(--surface-2); color: var(--text); }
.font-controls button + button { border-left: 1px solid var(--line); }

.trainer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(330px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.problem-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px;
}
.problem-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.problem-tag {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}
.problem-diff {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--progress);
  letter-spacing: 0.12em;
}

.statement {
  font-family: var(--mono);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: var(--statement-size, 14px);
  line-height: 1.75;
  color: var(--text);
  overflow-x: auto;
}

.problem-visuals {
  margin-top: 18px;
  display: grid;
  gap: 16px;
}
.problem-visuals.with-graph {
  grid-template-columns: minmax(290px, 1.15fr) minmax(240px, 1fr);
  align-items: start;
}

.graph-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.graph-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.graph-svg {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}
.graph-edge {
  stroke: #4B576B;
  stroke-width: 2.2;
  transition: stroke .12s, stroke-width .12s;
}
.graph-edge.hi {
  stroke: var(--accent);
  stroke-width: 3;
}
.graph-node { cursor: pointer; }
.graph-node circle.node-bg {
  fill: var(--surface-2);
  stroke: #56647B;
  stroke-width: 2;
  transition: fill .12s, stroke .12s;
}
.graph-node:hover circle.node-bg,
.graph-node.selected circle.node-bg {
  fill: #172738;
  stroke: var(--accent);
  stroke-width: 2.6;
}
.graph-node.pinned circle.node-bg {
  stroke: var(--accent);
}
.graph-node text.node-label {
  fill: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.graph-pin-bg {
  fill: var(--accent);
  stroke: var(--bg-elev);
  stroke-width: 2;
}
.graph-pin-text {
  fill: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.graph-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}
.graph-picker button {
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.graph-picker button:hover { border-color: var(--accent); background: var(--surface-2); }
.graph-picker button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.graph-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--dim);
}

.table-wrap { overflow-x: auto; }
.table-wrap table {
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
.table-wrap caption {
  text-align: left;
  color: var(--muted);
  font-size: 11.5px;
  padding-bottom: 8px;
}
.table-wrap th, .table-wrap td {
  border: 1px solid var(--line-strong);
  padding: 7px 10px;
  text-align: center;
}
.table-wrap th { color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table-wrap th.col-header-pickable { cursor: pointer; transition: background .12s, color .12s; }
.table-wrap th.col-header-pickable:hover { background: var(--surface-3); color: var(--text); }
.table-wrap th.col-header-pickable.selected {
  background: var(--accent-soft);
  color: var(--accent);
}
.table-wrap th.col-header-pickable.pinned { color: var(--accent); }
.table-wrap td:first-child, .table-wrap th:first-child { text-align: center; font-weight: 600; }
.table-wrap tr.row-marked td { opacity: 0.45; }
.table-wrap td.row-header-cell { cursor: pointer; color: var(--muted); background: var(--surface-2); }
.table-wrap td.row-header-cell:hover { color: var(--text); }
.table-pin-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}

@media (max-width: 1280px) {
  .problem-visuals.with-graph { grid-template-columns: 1fr; }
}

.options {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.options li button {
  width: 100%;
  text-align: left;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.options li button:hover { border-color: var(--line-strong); background: var(--surface-3); }
.options li button.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.files-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.file {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12.5px;
}
.file:hover { border-color: var(--accent); background: var(--surface-3); }
.file-ext {
  font-size: 10px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Right side of trainer */
.trainer-side {
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.side-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.side-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.kind-badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text);
}

input[type=text], input[type=password], textarea {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 14.5px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--dim); }

.answer-actions { margin-top: 10px; }
.post-actions { display: grid; gap: 8px; margin-top: 14px; }

.verdict {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev);
}
.verdict.ok { border-color: rgba(52, 211, 153, 0.55); background: rgba(52, 211, 153, 0.06); }
.verdict.no { border-color: rgba(248, 113, 113, 0.55); background: rgba(248, 113, 113, 0.06); }
.verdict h2 {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.verdict.ok h2 { color: var(--ready); }
.verdict.no h2 { color: var(--wrong); }
.verdict .line { font-size: 13px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.verdict code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 13px;
}
.verdict .explain {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
}
.verdict .mastery {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}
.verdict-bar {
  margin-top: 6px;
  height: 5px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.verdict-bar i {
  display: block;
  height: 100%;
  background: var(--ready);
  transition: width .4s ease;
}

/* Scratchpad */
.scratchpad-tools { display: flex; align-items: center; gap: 10px; }
.scratchpad-stat { font-family: var(--mono); font-size: 11px; color: var(--dim); font-weight: 400; }
#scratchpad {
  resize: vertical;
  min-height: 110px;
  font-size: 12.5px;
  line-height: 1.55;
}

/* Siblings list */
.siblings-list { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
.sibling-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--bg-elev);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.sibling-btn:hover { background: var(--surface-2); color: var(--text); }
.sibling-btn.current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.sibling-pct { font-family: var(--mono); font-size: 11px; }

/* =========================================================================
   RIGHT CONTEXTUAL INSPECTOR
   ========================================================================= */
.inspector {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 20px 18px 28px;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.inspector-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
}
.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.inspector-head h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.inspector-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
}

.focus-list, .activity-list { display: grid; gap: 8px; }
.focus-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.focus-item:hover { border-color: var(--accent); background: var(--surface-2); }
.focus-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
}
.focus-topic { font-size: 12px; color: var(--muted); line-height: 1.35; }

.activity-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.activity-item:hover { border-color: var(--line); background: var(--surface-2); }
.act-dot { width: 8px; height: 8px; border-radius: 50%; }
.act-dot.ok { background: var(--ready); }
.act-dot.no { background: var(--wrong); }
.act-body { min-width: 0; }
.act-title {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.act-meta { font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
.act-time { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.muted-note { font-size: 12px; color: var(--dim); padding: 6px 0; }

/* =========================================================================
   EMPTY / ERROR / MODAL / TOAST
   ========================================================================= */
.screen-center {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-card {
  max-width: 440px;
  text-align: center;
  padding: 36px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  background: var(--ready-soft);
  color: var(--ready);
}
.empty-icon.warn { background: var(--wrong-soft); color: var(--wrong); }
.empty-card h2 { margin: 0 0 8px; font-family: var(--display); font-size: 20px; }
.empty-card p { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}
.modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-tabs { display: flex; gap: 6px; }
.modal-tabs button {
  padding: 7px 14px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.modal-tabs button[aria-selected="true"] {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}
.modal-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-note { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; line-height: 1.5; }
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 6px;
}
.modal-error {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: var(--wrong-soft);
  color: var(--wrong);
  font-size: 12.5px;
}

/* Mandatory Telegram auth gate */
.modal-backdrop.auth-gate {
  background: rgba(8, 10, 14, 0.94);
  backdrop-filter: blur(10px);
}
.auth-modal-card {
  max-width: 440px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.auth-title {
  margin: 0;
  font-family: var(--display);
  font-size: 19px;
  letter-spacing: -0.01em;
}
.auth-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--dim);
}

/* Telegram deep-link auth inside modal */
.btn-tg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: var(--radius-sm);
  background: rgba(38, 165, 228, 0.16);
  color: #E0F2FE;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-tg:hover {
  background: rgba(38, 165, 228, 0.26);
  border-color: rgba(56, 189, 248, 0.75);
}
.btn-tg:disabled { opacity: 0.5; cursor: default; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  font-size: 11.5px;
  color: var(--dim);
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.tg-wait-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tg-wait-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.tg-wait-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}
.tg-wait-hint {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.tg-wait-fallbacks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tg-wait-fallbacks .btn-outline { flex: 1 1 140px; }
.tg-wait-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toastIn .2s ease;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.5); }
.toast.err { border-color: rgba(248, 113, 113, 0.5); color: var(--wrong); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================= */
@media (max-width: 1360px) {
  .workspace {
    grid-template-columns: 256px minmax(0, 1fr);
  }
  .workspace.sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
  .inspector {
    position: static;
    height: auto;
    grid-column: 2;
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .workspace.sidebar-collapsed .inspector {
    grid-column: 1;
  }
}

@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trainer-layout { grid-template-columns: 1fr; }
  .trainer-side { position: static; }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    padding: 0 12px;
    gap: 10px;
  }
  .topbar-center { display: none; }
  .streak-label, .top-cta span { display: none; }
  .subjects-bar { margin-left: 0; }
  .subjects-bar button { padding: 4px 8px; font-size: 11.5px; }

  .workspace, .workspace.trainer-mode, .workspace.sidebar-collapsed, .workspace.trainer-mode.sidebar-collapsed {
    grid-template-columns: 1fr;
  }
  .workspace.sidebar-collapsed .sidebar {
    display: flex;
  }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: 286px;
    z-index: 65;
    transform: translateX(-105%);
    transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 60;
  }
  .stage { padding: 16px 14px 32px; }
  .inspector { grid-column: 1; grid-template-columns: 1fr; padding: 16px 14px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: 1fr; }
}

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