:root {
  --bg: #eef3fb;
  --bg-2: #e4ecf8;
  --ink: #0f172a;
  --muted: #64748b;
  --card: #ffffff;
  --line: #d7e2f0;
  --line-strong: #b8c9e0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #dbeafe;
  --accent-muted: #eff6ff;
  --warn: #c2410c;
  --warn-soft: #ffedd5;
  --danger-soft: #fee2e2;
  --info: #0369a1;
  --info-soft: #e0f2fe;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(37, 99, 235, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ease: #2563eb;
  --ease-soft: #dbeafe;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 0% 0%, #dce8ff 0, transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, #e8f0ff 0, transparent 50%),
    linear-gradient(180deg, #f5f8fd, var(--bg));
  font: 15px/1.55 var(--font);
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6,
.brand strong,
.panel-title,
.card h3,
.card-body h4,
.mod-head h3,
.mod-head h4,
.sched-side h3 {
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Header ── */
.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}
.brand strong {
  display: block;
  font-size: 22px;
  line-height: 1.15;
  color: var(--ink);
}
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button,
.tabs a.tab-link {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font: 500 14px/1.2 var(--font);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tabs button:hover,
.tabs a.tab-link:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.tabs button.active,
.tabs a.tab-link.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.tabs a.tab-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

main {
  padding: 24px clamp(16px, 4vw, 48px) 64px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Form controls (unified) ── */
input[type="search"],
input[type="text"],
input[type="number"],
select,
textarea,
.field {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font: 500 14px/1.35 var(--font);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="search"]:focus,
input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 6px;
}

.search-panel { margin-bottom: 22px; }
.search { display: grid; gap: 8px; }
.search > span,
.field-label,
.strength-lab,
.filter-row-lab {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.search input {
  font-size: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
}
.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
  line-height: 1.45;
}

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.filters button,
.filters .chip {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  font: 600 12px/1.2 var(--font);
  color: var(--ink);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.filters.levels button { border-radius: 999px; padding: 5px 12px; }
.filters.letters button { min-width: 28px; padding: 4px 8px; }
.filters.dense { gap: 4px; }
.filters.dense .chip { padding: 4px 8px; font-size: 11px; border-radius: 6px; }
.filters button:hover,
.filters .chip:hover { border-color: var(--line-strong); }
.filters button.active,
.filters .chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.ctrl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.sort-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sort-box select { width: auto; min-width: 140px; padding: 6px 28px 6px 10px; font-size: 13px; }

.fold {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.fold > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 14px;
  font: 600 13px/1.2 var(--font);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 11px;
  transition: transform 0.15s ease;
}
.fold[open] > summary::before { transform: rotate(90deg); }
.fold-hint { color: var(--muted); font-weight: 500; }
.fold .filters { margin: 0; padding: 0 12px 12px; }
.fold .metric-rows { padding: 0 12px 12px; display: grid; gap: 6px; }
.filter-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 8px;
  align-items: center;
}
.filter-row .filters { padding: 0; }

.active-bar {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.clear-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font: 600 12px/1.2 var(--font);
  color: var(--muted);
  transition: border-color 0.12s, color 0.12s;
}
.clear-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Cards & results ── */
.results { display: grid; gap: 10px; }
.panel { display: grid; gap: 10px; margin-bottom: 8px; }
.panel-title { margin: 0; font-size: 20px; }
.group-list { display: grid; gap: 10px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.card.open {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.card-head {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 16px 18px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.card-head:hover { background: var(--accent-muted); }
.card h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.card-body {
  border-top: 1px solid var(--line);
  padding: 16px 18px 20px;
  background: #f8fafc;
}
.card-body .block { margin-top: 16px; }
.card-body h4 { margin: 0 0 8px; font-size: 15px; font-weight: 700; }

.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 9px;
  font: 500 12px/1.4 var(--font);
  background: var(--bg-2);
  color: var(--ink);
}
.pill.ok { background: var(--accent-soft); color: var(--accent-hover); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.neutral { background: #e2e8f0; color: #475569; }

.sub { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  background: #f8fafc;
}
td.wrap { white-space: normal; }

.text-link, .chip-link, .block-link {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-align: left;
  padding: 0;
  text-decoration: none;
}
.text-link:hover, .block-link:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
.chip-link {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 3px 10px;
  margin: 0 4px 6px 0;
  color: var(--ink);
  font-size: 13px;
}
.chip-link:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: 0; }
.link-stack { display: grid; gap: 6px; }
.block-link { padding: 4px 0; }
.empty {
  color: var(--muted);
  padding: 32px 16px;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  font-size: 14px;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px 16px;
  color: var(--muted);
  font-size: 14px;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  padding: 16px clamp(16px, 4vw, 48px) 32px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}

/* ── Plans & schedule toolbar ── */
.plan-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}
.plan-pick { display: grid; gap: 8px; }
.plan-pick select { border-radius: var(--radius-md); }
.strength {
  display: grid;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.strength-scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.strength-scale span:first-child { color: var(--accent); font-weight: 700; }
.strength-scale span:last-child { color: #dc2626; font-weight: 700; }
#strengthVal { font-weight: 600; color: var(--ink); text-align: center; flex: 1; }

.plan-meta {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

/* ── Plan modules ── */
.mod {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-lg);
  margin: 8px 0;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.mod.elective {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #f0f7ff, var(--card));
}
.mod-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}
.mod-head h3, .mod-head h4 { margin: 0; }
.mod-head h3 { font-size: 17px; }
.mod-head h4 { font-size: 15px; }
.mod-kids {
  margin-top: 10px;
  padding-left: 10px;
  border-left: 2px solid var(--accent-soft);
}

.disc {
  display: grid;
  gap: 4px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
.disc:last-child { border-bottom: 0; }
.disc.best { border-radius: var(--radius-md); padding: 8px 10px; margin: 4px 0; border-bottom: 0; }
.disc.best.g1 { background: #dbeafe; }
.disc.best.g2 { background: #e0f2fe; }
.disc.best.g3 { background: #fef9c3; }
.disc.best.g4 { background: #ffedd5; }
.disc.best.g5 { background: #fee2e2; }
.disc-name { font-weight: 600; font-size: 14px; }
.disc-rank {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.disc-rank.g1 { color: #1d4ed8; }
.disc-rank.g2 { color: #0369a1; }
.disc-rank.g3 { color: #854d0e; }
.disc-rank.g4 { color: #c2410c; }
.disc-rank.g5 { color: #b91c1c; }
.disc-rank.muted { color: var(--muted); font-weight: 600; }

.track-rec { border-radius: var(--radius-md); padding: 6px 8px; margin: 6px 0; }
.track-rec.g1 { background: #dbeafe; }
.track-rec.g2 { background: #e0f2fe; }
.track-rec.g3 { background: #fef9c3; }
.track-rec.g4 { background: #ffedd5; }
.track-rec.g5 { background: #fee2e2; }

.disc-check.suggested { border-radius: var(--radius-md); padding: 6px 8px; border-bottom: 0; }
.disc-check.suggested.g1 { background: #dbeafe; }
.disc-check.suggested.g2 { background: #e0f2fe; }
.disc-check.suggested.g3 { background: #fef9c3; }
.disc-check.suggested.g4 { background: #ffedd5; }
.disc-check.suggested.g5 { background: #fee2e2; }

.rule-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font: 700 10px/1.4 var(--font);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--info-soft);
  color: var(--info);
}
.rule-chip.req { background: #e2e8f0; color: var(--muted); }
.rule-chip.opt { background: var(--accent-soft); color: var(--accent-hover); }
.rule-chip.g1 { background: #dbeafe; color: #1d4ed8; }
.rule-chip.g2 { background: #e0f2fe; color: #0369a1; }
.rule-chip.g3 { background: #fef9c3; color: #854d0e; }
.rule-chip.g4 { background: #ffedd5; color: #c2410c; }
.rule-chip.g5 { background: #fee2e2; color: #b91c1c; }
.pill.band-g1 { background: #dbeafe; color: #1d4ed8; }
.pill.band-g2 { background: #e0f2fe; color: #0369a1; }
.pill.band-g3 { background: #fef9c3; color: #854d0e; }
.pill.band-g4 { background: #ffedd5; color: #c2410c; }
.pill.band-g5 { background: #fee2e2; color: #b91c1c; }

/* ── Schedule layout ── */
.sched-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.sched-side {
  position: sticky;
  top: 88px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  max-height: calc(100vh - 110px);
  overflow: auto;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.sched-side h3 { margin: 0 0 4px; font-size: 16px; }
#discFilter { margin-top: 8px; font-size: 13px; padding: 8px 12px; }

.stream-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: 650 12px/1.3 var(--font);
  cursor: pointer;
}
.stream-toggle:hover { text-decoration: underline; }
.stream-panel {
  margin-top: 8px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid var(--line);
}
.stream-opt {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--line);
}
.stream-opt:hover { border-color: #93c5fd; }
.stream-opt.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.stream-opt input { margin-top: 3px; }
.stream-opt-body { min-width: 0; display: grid; gap: 3px; }
.stream-opt-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.stream-opt-line {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.disc-pick { display: grid; gap: 8px; margin-top: 8px; min-width: 0; }
.disc-mod {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #f8fafc;
  padding: 8px 8px 6px;
  min-width: 0;
  overflow: hidden;
}
.disc-mod.elective {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #f0f7ff, #f8fafc);
}
.disc-mod.suggested {
  border-color: #93c5fd;
  background: #eff6ff;
}
.disc-mod.partial { border-style: dashed; }
.disc-mod-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  margin-bottom: 6px;
}
.disc-mod-head:not(:has(.track-box)) {
  grid-template-columns: 1fr;
}
.disc-mod-title h4,
.disc-mod-title h5 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.disc-mod-title { min-width: 0; }
.disc-mod-title h5 { font-size: 12px; font-weight: 650; color: var(--muted); }
.disc-mod-title .meta { margin-top: 4px; }
.disc-mod-kids {
  display: grid;
  gap: 4px;
  padding-left: 8px;
  border-left: 2px solid var(--accent-soft);
  margin-left: 4px;
  min-width: 0;
}
.disc-mod .disc-mod {
  background: var(--card);
  margin-top: 4px;
}
.track-box { padding-top: 2px; }
.picked-box {
  background: var(--accent-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin: 8px 0;
  max-height: 220px;
  overflow: auto;
}
.picked-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 13px;
}
.picked-head strong { font-weight: 700; color: var(--ink); }
.picked-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--ink);
}
.picked-list li { margin: 4px 0; line-height: 1.35; }
.pref-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.pref-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font: 600 13px/1.2 var(--font);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.pref-btn:hover { border-color: var(--accent); color: var(--accent); }
.pref-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.picked-only {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 8px;
  cursor: pointer;
  user-select: none;
}

.disc-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.disc-check.suggested { overflow: hidden; }
.disc-check-box { display: flex; padding-top: 2px; }
.disc-check-body { min-width: 0; max-width: 100%; overflow: hidden; }
.disc-check .disc-name {
  display: block;
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.disc-check .stats-pills { display: inline-flex; gap: 4px; flex-wrap: wrap; text-decoration: none; color: inherit; }
.disc-check .stats-pills:hover .pill { filter: brightness(0.96); }
.disc-check .teach-line { margin-top: 4px; overflow-wrap: anywhere; word-break: break-word; }
.disc-check.locked { opacity: 0.88; }
.disc-check .meta { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; align-items: center; }

.missing-box {
  background: var(--warn-soft);
  border: 1px solid #fdba74;
  color: var(--warn);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 12px;
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.variant-list { margin: 8px 0 16px; }
.variant-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.variant-arrow,
.week-arrow {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.12s, background 0.12s;
}
.variant-arrow {
  width: 38px;
  height: 38px;
  font-size: 16px;
  border-radius: var(--radius-md);
}
.variant-arrow:hover:not(:disabled),
.week-arrow:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-muted);
}
.variant-arrow:disabled,
.week-arrow:disabled { opacity: 0.35; cursor: default; }
.variant-select {
  flex: 1;
  min-width: 200px;
  font-size: 13px;
}
.variant-num-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.variant-num {
  width: 4.5rem;
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  font: 600 14px/1 var(--font);
  color: var(--ink);
  text-align: center;
  -moz-appearance: textfield;
}
.variant-num::-webkit-outer-spin-button,
.variant-num::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.variant-num:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.variant-meta { margin-top: 6px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.variant-pos { color: var(--muted); font-size: 12px; white-space: nowrap; font-weight: 500; }

.week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.week-nav.muted { color: var(--muted); font-size: 13px; }
.week-arrow { width: 34px; height: 32px; font-size: 15px; }
.week-select { flex: 1; min-width: 160px; padding: 6px 28px 6px 10px; font-size: 13px; }
.week-pos { color: var(--muted); font-size: 12px; white-space: nowrap; font-weight: 500; }

/* ── Timeline ── */
.disc-tl {
  margin: 0 0 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px 8px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.disc-tl-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--muted);
  letter-spacing: 0.01em;
}
/* Одна общая сетка: подписи и треки не считают ширину по отдельности. */
.disc-tl-grid {
  display: grid;
  grid-template-columns: minmax(140px, 280px) minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 5px;
  align-items: center;
  min-width: calc(140px + 10px + var(--weeks) * 12px);
}
.disc-tl-axis,
.disc-tl-lane {
  display: contents;
}
.disc-tl-axis-label {
  min-width: 0;
}
.disc-tl-axis-weeks,
.disc-tl-track {
  display: grid;
  grid-template-columns: repeat(var(--weeks), minmax(0, 1fr));
  gap: 0;
  width: 100%;
  min-width: 0;
}
.disc-tl-wk {
  appearance: none;
  -webkit-appearance: none;
  font: 500 10px/1 var(--font);
  text-align: center;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  border-radius: 4px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.disc-tl-wk.cur { color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.disc-tl-lane-active .disc-tl-label { font-weight: 600; color: var(--ink); }
.disc-tl-label {
  font-size: 11px;
  line-height: 1.25;
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
}
.disc-tl-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.disc-tl-span {
  flex: 0 1 auto;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.disc-tl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; align-self: center; }
.disc-tl-track-wrap {
  position: relative;
  min-width: 0;
  min-height: 10px;
  display: flex;
  align-items: center;
  width: 100%;
}
.disc-tl-rail {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1.5px dashed rgba(100, 116, 139, 0.45);
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 0;
}
.disc-tl-lane-active .disc-tl-rail {
  border-top-color: rgba(37, 99, 235, 0.35);
}
.disc-tl-track {
  position: relative;
  z-index: 1;
  height: 10px;
  background: transparent;
  align-items: center;
}
.disc-tl-bar {
  appearance: none;
  -webkit-appearance: none;
  height: 10px;
  width: 100%;
  background: var(--tl-c);
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  min-width: 0;
  box-sizing: border-box;
  opacity: 0.55;
}
.disc-tl-lane-active .disc-tl-bar { opacity: 1; }
.disc-tl-bar.run-start { border-radius: 5px 0 0 5px; }
.disc-tl-bar.run-end { border-radius: 0 5px 5px 0; }
.disc-tl-bar.run-start.run-end { border-radius: 5px; }
.disc-tl-bar.cur { box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.4); }
.disc-tl-skip {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  height: 10px;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  min-width: 0;
  box-sizing: border-box;
}
.disc-tl-skip.cur {
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.25);
  border-radius: 2px;
}

.semester-timeline {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--card);
}
.semester-timeline h4 { margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.sem-week { margin: 6px 0; border-top: 1px solid var(--line); padding-top: 4px; }
.sem-week:first-of-type { border-top: 0; padding-top: 0; }
.sem-week summary { cursor: pointer; font-weight: 600; font-size: 13px; padding: 4px 0; }
.sem-week-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.sem-week-list li { margin: 4px 0; line-height: 1.35; }

.variant-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font: 500 13px/1.2 var(--font);
  transition: background 0.12s, border-color 0.12s;
}
.variant-btn:hover { border-color: var(--accent); }
.variant-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Timetable grid ── */
.tt {
  display: grid;
  grid-template-columns: 64px repeat(6, 1fr);
  gap: 2px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  align-items: start;
}
.tt-head, .tt-time, .tt-cell {
  background: var(--card);
  padding: 6px;
  min-height: 44px;
  box-sizing: border-box;
}
.tt-head {
  font-weight: 700;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tt-time {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  align-self: stretch;
  padding-top: 8px;
}
.tt-cell {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 4px;
  align-self: stretch;
}
.tt-item {
  border-radius: 6px;
  padding: 4px 6px;
  margin: 0;
  font-size: 11px;
  text-align: left;
}
.tt-item.req { background: #e2e8f0; }
.tt-item.opt { background: var(--accent-soft); }
.tt-item.online { box-shadow: inset 3px 0 0 var(--accent); }
.tt-name { font-weight: 600; }
.tt-meta { color: var(--muted); word-break: break-word; font-size: 10px; }
.tt-legend { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; font-size: 12px; }
.tt-list { padding-left: 18px; font-size: 13px; }
.tt-list li { margin: 4px 0; }

@media (max-width: 720px) {
  .top { flex-direction: column; align-items: stretch; }
  .brand strong { font-size: 20px; }
  .filter-row { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 900px) {
  .sched-layout { grid-template-columns: 1fr; }
  .sched-side { position: static; max-height: none; }
  .sched-side { position: static; max-height: none; }
}
