/* Study Plan tab on /account/calendar/ (docs/javascripts/study-plan.js).
   Uses the calendar page's colour tokens, so it follows its light/dark theme.
   Each course block sets --h (its calendar hue) and everything inside takes
   its accent from it. */

.sp-root {
  --h: 262;
  --r-lg: 18px;
  --r-md: 12px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  padding: 22px 22px 26px;
}

.sp-root,
.sp-root [style*="--h"] {
  --accent: hsl(var(--h) 78% 64%);
  --accent-soft: hsl(var(--h) 80% 60% / 0.14);
  --accent-line: hsl(var(--h) 70% 60% / 0.45);
}

.sp-muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.sp-muted b {
  color: var(--text);
}

.sp-eyebrow {
  font: 800 0.66rem/1.2 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.sp-empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  color: var(--muted);
  text-align: center;
  font-size: 0.88rem;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.sp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.sp-head h2 {
  margin: 6px 0 4px;
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}

.sp-head p {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: 0.86rem;
}

.sp-season {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--item-bg);
}

.sp-season button {
  border: 0;
  background: none;
  color: var(--dim);
  font: 800 0.7rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sp-season button:hover {
  color: var(--text);
}

.sp-season button[aria-selected="true"] {
  background: var(--brand);
  color: #0a0514;
}

.sp-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ── Rings ──────────────────────────────────────────────────────────── */
.sp-ring {
  --size: 46px;
  --p: 0;
  position: relative;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--hover) 0);
}

.sp-ring::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--surface);
}

.sp-ring > span {
  position: relative;
  font: 800 0.66rem/1 var(--mono);
  color: var(--text);
}

.sp-ring.sm {
  --size: 36px;
}

.sp-ring.sm::before {
  inset: 3px;
}

.sp-ring.sm > span {
  font-size: 0.58rem;
}

.sp-ring.lg {
  --size: 72px;
}

.sp-ring.lg::before {
  inset: 6px;
}

.sp-ring.lg > span {
  font-size: 0.95rem;
}

.sp-ring.done {
  background: var(--green);
}

.sp-ring.done > span::before {
  content: "";
  display: block;
  width: 12px;
  height: 7px;
  border-left: 2.5px solid var(--green);
  border-bottom: 2.5px solid var(--green);
  transform: translateY(-2px) rotate(-45deg);
}

.sp-ring.missing {
  background: var(--hover);
}

.sp-ring.missing > span {
  color: var(--muted);
}

/* ── Hero: next exam and the season's timeline ──────────────────────── */
.sp-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 14px;
}

.sp-next,
.sp-timeline {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--item-bg);
  min-width: 0;
}

.sp-next {
  border-color: var(--accent-line);
  background:
    radial-gradient(130% 140% at 0% 0%, var(--accent-soft), transparent 62%),
    var(--item-bg);
}

.sp-next-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 10px 0 16px;
}

.sp-next-course {
  font: 900 1.6rem/1.1 var(--mono);
  color: var(--text);
}

.sp-next-when {
  margin-top: 6px;
  color: var(--dim);
  font-size: 0.85rem;
}

.sp-countdown {
  text-align: right;
}

.sp-countdown b {
  display: block;
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.sp-countdown span {
  font: 800 0.64rem/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.sp-next-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.4;
}

.sp-next-foot span {
  color: var(--muted);
  font-size: 0.76rem;
}

.sp-tl {
  position: relative;
  height: 176px;
  margin: 6px 8px 0;
}

.sp-tl-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--hover));
}

.sp-tl-today {
  position: absolute;
  left: 0;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 22%, transparent);
}

.sp-tl-today span {
  position: absolute;
  top: 22px;
  left: -2px;
  font: 800 0.6rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.sp-tl-mark {
  position: absolute;
  top: 50%;
  width: 0;
}

.sp-tl-dot {
  position: absolute;
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line);
}

.sp-tl-label {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.25;
}

.sp-tl-mark.lane1 .sp-tl-label,
.sp-tl-mark.lane3 .sp-tl-label {
  bottom: auto;
  top: 14px;
}

.sp-tl-mark.lane2 .sp-tl-label {
  bottom: 50px;
}

.sp-tl-mark.lane3 .sp-tl-label {
  top: 50px;
}

/* A thin stem ties far-out labels to their dot. */
.sp-tl-mark.lane2::before,
.sp-tl-mark.lane3::before {
  content: "";
  position: absolute;
  left: -0.5px;
  width: 1px;
  height: 40px;
  background: var(--accent-line);
}

.sp-tl-mark.lane2::before {
  bottom: 8px;
}

.sp-tl-mark.lane3::before {
  top: 8px;
}

.sp-tl-mark.end .sp-tl-label {
  left: auto;
  right: -8px;
  transform: none;
  text-align: right;
}

.sp-tl-label b {
  display: block;
  font: 800 0.72rem/1.2 var(--mono);
  color: var(--accent);
}

.sp-tl-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── Course rail ────────────────────────────────────────────────────── */
.sp-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 10px;
}

.sp-course-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--item-bg);
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.sp-course-card:hover {
  border-color: var(--accent-line);
  transform: translateY(-1px);
}

.sp-course-card.selected {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, var(--accent-soft), transparent 70%),
    var(--item-bg);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.sp-course-card.done {
  opacity: 0.62;
}

.sp-course-card-hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  cursor: pointer;
}

.sp-course-card-hit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sp-course-card button,
.sp-course-card a {
  position: relative;
  z-index: 2;
}

.sp-card-body {
  min-width: 0;
  flex: 1 1 auto;
}

.sp-card-code {
  font: 900 0.98rem/1.2 var(--mono);
  color: var(--text);
}

.sp-course-card.selected .sp-card-code {
  color: var(--accent);
}

.sp-card-when {
  margin-top: 2px;
  font-size: 0.76rem;
  color: var(--dim);
}

.sp-card-when.muted {
  color: var(--muted);
}

.sp-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--muted);
}

.sp-days {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--hover);
  font: 800 0.68rem/1.3 var(--mono);
  color: var(--text);
}

.sp-days.soon {
  background: color-mix(in srgb, var(--red) 18%, transparent);
  color: var(--red);
}

.sp-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 8px;
}

.sp-tag {
  display: inline-block;
  margin-top: 6px;
  font: 800 0.64rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sp-tag.done {
  color: var(--green);
}

.sp-chip-btn,
.sp-link-btn {
  font: 800 0.68rem/1 var(--mono);
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
}

.sp-chip-btn {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.sp-chip-btn:hover {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

.sp-link-btn {
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--muted);
}

.sp-link-btn:hover {
  color: var(--text);
  text-decoration: underline;
}

.sp-note {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--r-md);
  font-size: 0.82rem;
  color: var(--dim);
  line-height: 1.5;
}

.sp-note.warn {
  border-left-color: var(--amber);
  color: var(--text);
}

/* ── Boxes ──────────────────────────────────────────────────────────── */
.sp-box {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--item-bg);
  min-width: 0;
}

.sp-box h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: var(--text);
}

.sp-box-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.sp-sub {
  margin: 18px 0 10px;
  font: 800 0.66rem/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.sp-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* ── Schedule ───────────────────────────────────────────────────────── */
.sp-planner {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 7%, transparent), transparent 70%),
    var(--item-bg);
}

.sp-planner .empty {
  color: var(--muted);
  font-size: 0.84rem;
  padding: 10px 0 0;
}

.sp-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.sp-job-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 8px;
}

.sp-job {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 0.8rem;
  color: var(--dim);
}

.sp-job b {
  font-family: var(--mono);
  color: var(--text);
}

.sp-ok {
  color: var(--green);
  font-weight: 800;
}

.sp-warn {
  color: var(--amber);
  font-weight: 800;
}

/* The day grid of the preview (not the .sp-days countdown chip). */
.sp-preview .sp-days {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  padding: 2px;
  border-radius: 0;
  background: none;
  font: inherit;
  color: inherit;
}

.sp-day {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.sp-day-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.sp-day-head b {
  color: var(--text);
}

.sp-sess {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 8px;
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--green) 9%, transparent);
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.35;
}

.sp-sess.review {
  background: color-mix(in srgb, var(--teal) 10%, transparent);
}

.sp-sess.final {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
}

.sp-sess-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sp-commit {
  margin-top: 4px;
}

/* ── Course workspace ───────────────────────────────────────────────── */
.sp-course {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.sp-course-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 160% at 100% 0%, var(--accent-soft), transparent 60%),
    var(--item-bg);
}

.sp-course-title {
  flex: 1 1 auto;
  min-width: 0;
}

.sp-course-head h3 {
  margin: 4px 0 2px;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  font-weight: 900;
  letter-spacing: -0.015em;
  color: var(--text);
}

.sp-work {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr);
  gap: 14px;
  align-items: start;
}

.sp-main,
.sp-aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* Stats */
.sp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.sp-stat {
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

.sp-stat b {
  display: block;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.sp-stat span {
  font-size: 0.7rem;
  color: var(--muted);
}

/* Most repeated: one grid so every bar starts at the same edge. */
.sp-rep {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 12px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.sp-rep li {
  display: contents;
}

.sp-rep-rank {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent-soft);
  font: 800 0.68rem/1 var(--mono);
  color: var(--accent);
}

.sp-rep li:first-child .sp-rep-rank {
  background: var(--accent);
  color: #0a0514;
}

.sp-rep-name {
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--text);
}

.sp-rep-bar {
  display: block;
  height: 5px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
}

.sp-rep-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), hsl(var(--h) 80% 74%));
}

.sp-rep-count {
  text-align: right;
  font-size: 0.66rem;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
}

.sp-rep-count b {
  font-size: 0.82rem;
  color: var(--text);
}

/* Grade table */
.sp-need-table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.sp-need-table th,
.sp-need-table td {
  padding: 8px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  color: var(--dim);
}

.sp-need-table thead th {
  border-top: 0;
  font: 800 0.6rem/1.3 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sp-need-table tbody th {
  width: 2.8em;
  font-weight: 900;
  color: var(--text);
}

.sp-need-table td b {
  display: block;
  color: inherit;
}

.sp-need-table td span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}

.sp-need-table td.secured,
.sp-need-table td.ok {
  color: var(--green);
}

.sp-need-table td.stretch {
  color: var(--amber);
}

.sp-need-table td.hard {
  color: var(--red);
}

.sp-need-table tr.gone th,
.sp-need-table td.gone {
  color: var(--muted);
  opacity: 0.55;
}

.sp-need-table tr.best th,
.sp-need-table tr.best td {
  background: var(--accent-soft);
}

/* Chapters */
.sp-chapters {
  display: flex;
  flex-direction: column;
  margin-top: 12px;
}

.sp-ch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-top: 1px solid var(--line);
}

.sp-ch:first-child {
  border-top: 0;
}

.sp-ch.out {
  opacity: 0.45;
}

.sp-ch-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.sp-ch-num {
  font: 800 0.62rem/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.sp-ch-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}

.sp-ch-meta {
  margin-top: 2px;
  font-size: 0.73rem;
  color: var(--muted);
}

.sp-check {
  position: relative;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.sp-check input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.sp-check span {
  display: block;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.sp-check input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
}

.sp-check input:checked + span::after {
  content: "";
  display: block;
  width: 9px;
  height: 5px;
  margin: 5px 0 0 4.5px;
  border-left: 2px solid #0a0514;
  border-bottom: 2px solid #0a0514;
  transform: rotate(-45deg);
}

.sp-check input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sp-chev {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
}

.sp-chev::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -6px 0 0 -4px;
  border-right: 2px solid var(--dim);
  border-bottom: 2px solid var(--dim);
  transform: rotate(45deg);
  transition: transform 0.15s;
}

.sp-chev[aria-expanded="true"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.sp-chev[aria-expanded="true"]::after {
  margin-top: -2px;
  border-color: var(--accent);
  transform: rotate(-135deg);
}

.sp-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 0 14px 48px;
}

.sp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--line);
}

.sp-item.l1 {
  box-shadow: inset 3px 0 0 var(--amber);
}

.sp-item.l2 {
  box-shadow: inset 3px 0 0 var(--green);
}

.sp-item-text {
  min-width: 0;
}

.sp-item-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.sp-item-name {
  margin-top: 6px;
  font-size: 0.86rem;
  font-weight: 750;
  color: var(--text);
  line-height: 1.35;
}

.sp-item-count {
  font-size: 0.7rem;
  color: var(--muted);
}

.sp-item-mem {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--item-bg);
  font-size: 0.76rem;
  color: var(--dim);
  line-height: 1.5;
}

.sp-tier,
.sp-kind {
  padding: 3px 7px;
  border-radius: 6px;
  font: 800 0.58rem/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sp-tier.core {
  background: color-mix(in srgb, var(--red) 16%, transparent);
  color: var(--red);
}

.sp-tier.high {
  background: color-mix(in srgb, var(--amber) 16%, transparent);
  color: var(--amber);
}

.sp-tier.review {
  background: var(--hover);
  color: var(--muted);
}

.sp-kind {
  background: var(--accent-soft);
  color: var(--accent);
}

.sp-level {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--item-bg);
}

.sp-level button {
  border: 0;
  background: none;
  color: var(--muted);
  font: 800 0.62rem/1 var(--mono);
  padding: 8px 11px;
  border-radius: 999px;
  cursor: pointer;
}

.sp-level button:hover {
  color: var(--text);
}

.sp-level button.l0[aria-pressed="true"] {
  background: var(--hover);
  color: var(--text);
}

.sp-level button.l1[aria-pressed="true"] {
  background: color-mix(in srgb, var(--amber) 24%, transparent);
  color: var(--amber);
}

.sp-level button.l2[aria-pressed="true"] {
  background: color-mix(in srgb, var(--green) 24%, transparent);
  color: var(--green);
}

.sp-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 6px;
}

.sp-links a {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font: 800 0.66rem/1 var(--mono);
  color: var(--accent);
  text-decoration: none;
}

.sp-links a:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* Memorize cards */
.sp-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 800 0.66rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  cursor: pointer;
}

.sp-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sp-switch span {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--hover);
  transition: background 0.15s;
}

.sp-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}

.sp-switch input:checked + span {
  background: var(--accent-soft);
}

.sp-switch input:checked + span::after {
  background: var(--accent);
  transform: translateX(14px);
}

.sp-switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sp-mem {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 8px;
}

.sp-flash {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 88px;
  padding: 12px 14px;
  border: 1px dashed var(--accent-line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sp-flash:hover {
  background: var(--accent-soft);
}

.sp-flash b {
  font-size: 0.82rem;
  line-height: 1.3;
}

.sp-flash span {
  font-size: 0.74rem;
  font-style: italic;
  color: var(--muted);
}

.sp-flash.flipped {
  border-style: solid;
  border-color: var(--line);
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 80%),
    var(--surface);
}

.sp-flash.flipped span {
  font-style: normal;
  color: var(--dim);
  line-height: 1.5;
}

/* Lists and weights */
.sp-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sp-list li {
  position: relative;
  padding-left: 16px;
  font-size: 0.8rem;
  color: var(--dim);
  line-height: 1.45;
}

.sp-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
}

.sp-weights {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 10px;
}

.sp-weight {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 38px;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--dim);
}

.sp-weight b {
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.sp-weight-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
}

.sp-weight-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* ── Smaller screens ────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .sp-work {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .sp-hero {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .sp-root {
    padding: 16px;
  }

  .sp-course-head {
    flex-wrap: wrap;
    padding: 18px;
  }

  .sp-items {
    padding-left: 0;
  }

  .sp-item {
    flex-direction: column;
    align-items: stretch;
  }

  .sp-level {
    align-self: flex-start;
  }

  .sp-ch {
    flex-wrap: wrap;
  }

  .sp-ch .sp-level {
    margin-left: 48px;
  }

  /* Too narrow to label; the course cards below list every date. */
  .sp-timeline {
    display: none;
  }
}

/* Exam scope line (from the course overview page) above the chapter list. */
.sp-scope {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  font-size: 0.8rem;
  color: var(--dim);
}

.sp-scope b {
  color: var(--text);
}

.sp-scope a {
  color: var(--accent);
}

/* ── Exam format ────────────────────────────────────────────────────── */
.sp-fmt {
  border-color: var(--accent-line);
  box-shadow: inset 4px 0 0 var(--accent);
}

.sp-fmt.unset {
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--item-bg);
}

.sp-fmt h3 {
  margin-top: 4px;
}

.sp-card-format {
  margin-top: 6px;
  font: 800 0.64rem/1.3 var(--mono);
  letter-spacing: 0.04em;
  color: var(--accent);
}

.sp-card-format.unset {
  color: var(--muted);
  font-weight: 700;
}

.sp-fmt-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.sp-fmt-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.sp-fmt-field > span,
.sp-fmt-field legend {
  padding: 0;
  font: 800 0.66rem/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sp-fmt-field legend {
  margin-bottom: 6px;
}

.sp-fmt-field textarea,
.sp-fmt-field input:not([type="checkbox"]),
.sp-fmt-field select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
}

.sp-fmt-field textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.45;
}

.sp-fmt-field textarea:focus,
.sp-fmt-field input:focus,
.sp-fmt-field select:focus {
  outline: none;
  border-color: var(--accent);
}

.sp-fmt-detect {
  min-height: 1em;
  font-size: 0.74rem;
  color: var(--accent);
}

.sp-fmt-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sp-fmt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sp-fmt-chip {
  position: relative;
  cursor: pointer;
}

.sp-fmt-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sp-fmt-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 14px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 17px;
  line-height: 1.25;
  background: var(--surface);
  color: var(--dim);
  font-size: 0.8rem;
  font-weight: 700;
}

.sp-fmt-chip:hover span {
  border-color: var(--accent-line);
}

.sp-fmt-chip input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.sp-fmt-chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sp-fmt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.sp-fmt-quote {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent-line);
  border-radius: 0 10px 10px 0;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.5;
}

.sp-fmt-topics {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--dim);
}

.sp-fmt-topics b {
  color: var(--text);
}

.sp-fmt .sp-note {
  margin-top: 12px;
}

.sp-fmt-prep {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 14px;
  margin-top: 16px;
}

.sp-fmt-type {
  min-width: 0;
}

.sp-fmt-type-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.sp-fmt-type h4 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--text);
}

.sp-fmt-type-head span {
  font: 700 0.68rem/1 var(--mono);
  color: var(--muted);
}

.sp-fmt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.sp-fmt-list .sp-item-name {
  margin: 0 0 6px;
}

.sp-fmt-list .sp-item-mem a {
  color: var(--accent);
  white-space: nowrap;
}

.sp-fmt-history {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--muted);
}

.sp-fmt-history summary {
  cursor: pointer;
  font-weight: 700;
}

.sp-fmt-history ul {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.55;
}

@media (max-width: 640px) {
  .sp-fmt-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .sp-fmt-row .sp-fmt-field:last-child {
    grid-column: 1 / -1;
  }
}

/* Drive to and from uni, used by the scheduler. */
.sp-commute {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--dim);
}

.sp-commute input {
  width: 72px;
  height: 32px;
  padding: 0 8px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  font: inherit;
}

.sp-commute input:focus {
  outline: none;
  border-color: var(--accent);
}

.sp-commute span {
  color: var(--muted);
}

.sp-day-campus {
  margin: -2px 0 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Usual leave-home / leave-uni times per weekday. */
.sp-uni {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--dim);
}

.sp-uni summary {
  cursor: pointer;
  font-weight: 750;
  color: var(--accent);
}

.sp-uni-grid {
  display: grid;
  grid-template-columns: 48px minmax(0, 150px) minmax(0, 150px) auto;
  gap: 8px 10px;
  align-items: center;
  justify-content: start;
  margin-top: 10px;
}

.sp-uni-grid > span {
  font: 800 0.64rem/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sp-uni-grid b {
  font: 800 0.78rem/1 var(--mono);
  color: var(--text);
}

.sp-uni-grid input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  font: inherit;
  color-scheme: light dark;
}

.sp-uni-grid input:focus {
  outline: none;
  border-color: var(--accent);
}

@media (max-width: 640px) {
  .sp-uni-grid {
    grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) auto;
  }
}

/* ── Remaining ──────────────────────────────────────────────────────── */
.sp-rem-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.sp-rem-summary > div {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--item-bg);
}

.sp-rem-summary b {
  display: block;
  font-size: clamp(1.3rem, 2.4vw, 1.8rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}

.sp-rem-summary span {
  font-size: 0.78rem;
  color: var(--muted);
}

.sp-rem-focus {
  border-color: var(--accent-line);
  background: linear-gradient(135deg, var(--accent-soft), transparent 65%), var(--item-bg);
}

.sp-rem-focus h3 {
  margin-top: 6px;
}

.sp-rem-focus-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.sp-rem-focus-list li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

.sp-rem-focus-list b {
  font-size: 0.92rem;
  color: var(--text);
}

.sp-rem-focus-list span {
  font-size: 0.78rem;
  color: var(--dim);
}

.sp-rem-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.sp-rem-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.sp-rem-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sp-rem-days {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.64rem;
  color: var(--muted);
}

.sp-rem-days b {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
}

.sp-rem-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.sp-rem-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
}

.sp-rem-kind {
  font: 800 0.6rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sp-rem-meta {
  font-size: 0.76rem;
  color: var(--muted);
}

.sp-rem-state {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--hover);
  font: 800 0.66rem/1.3 var(--mono);
  color: var(--dim);
  white-space: nowrap;
}

.sp-rem-row.soon .sp-rem-state {
  background: color-mix(in srgb, var(--amber) 16%, transparent);
  color: var(--amber);
}

.sp-rem-row.now .sp-rem-state {
  background: var(--accent-soft);
  color: var(--accent);
}

.sp-rem-row.late .sp-rem-state {
  background: color-mix(in srgb, var(--red) 16%, transparent);
  color: var(--red);
}

.sp-rem-weeks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.sp-rem-week {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  --tone: var(--green);
}

.sp-rem-week.free {
  --tone: var(--muted);
}

.sp-rem-week.busy {
  --tone: var(--amber);
}

.sp-rem-week.tight {
  --tone: var(--red);
}

.sp-rem-week-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.84rem;
  color: var(--text);
}

.sp-rem-pill {
  font: 800 0.62rem/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tone);
}

.sp-rem-load {
  height: 6px;
  margin-top: 10px;
  border-radius: 99px;
  background: var(--hover);
  overflow: hidden;
}

.sp-rem-load span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tone);
}

.sp-rem-week-meta {
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--muted);
}

.sp-rem-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.sp-rem-chip {
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.sp-rem-chip.due {
  background: var(--hover);
  color: var(--dim);
}

@media (max-width: 1100px) {
  .sp-rem-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .sp-rem-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sp-rem-row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }

  .sp-rem-state {
    grid-column: 2;
    justify-self: start;
  }

  .sp-rem-row .sp-link-btn {
    grid-column: 3;
    grid-row: 1;
  }
}
