/* Page structure and shared components. */

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--space-4); }
main.container { padding-block: var(--space-5) var(--space-6); }

/* ---- App shell: staff get a sidebar, students and visitors a top bar ---- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.app-main { padding: var(--space-5) 2.75rem var(--space-6); min-width: 0; max-width: 90rem; width: 100%; }
.app-main.container--wide { max-width: none; padding-inline: var(--space-4); }

.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--color-text); text-decoration: none; }
.brand:hover { color: var(--color-text); }
.brand__mark {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 2.5px solid var(--color-accent); box-shadow: inset 0 0 0 3px var(--color-panel), inset 0 0 0 4px var(--color-accent);
}
.brand__name { font-family: var(--font-serif); font-size: 1.45rem; font-weight: 500; letter-spacing: -0.02em; line-height: 1; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.75rem; padding: 1.6rem 1.1rem;
  background: var(--color-panel); border-right: 1px solid var(--color-border);
}
.sidebar__bar > .brand { padding: 0 0.5rem; }
.sidebar__toggle { display: none; }
/* On wide screens the menu's wrapper doesn't exist for layout: its parts sit in the sidebar's column. */
.sidebar__menu { display: contents; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar__group { display: flex; flex-direction: column; gap: var(--space-1); }
.sidebar__heading { margin: 0 0 2px; padding: 0 0.65rem; font: 600 0.6875rem/1.2 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-muted); }
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: 0.55rem 0.65rem; border-radius: 9px; color: var(--color-subtle); font-size: 0.875rem; text-decoration: none;
}
.nav-link:hover { background: rgb(42 40 51 / 0.05); color: var(--color-text); }
.nav-link--active, .nav-link--active:hover { background: var(--color-accent-soft); color: var(--color-accent-text); font-weight: 600; }
.sidebar__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__code { font-size: 0.75rem; opacity: 0.8; }
.count-pill { font: 600 0.6875rem/1.3 var(--font-mono); background: var(--lemon-soft); color: var(--lemon-text); padding: 2px 7px; border-radius: var(--radius-pill); flex: none; }
.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2); }
.sidebar__user { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 0.5rem 0; border-top: 1px solid var(--color-border); flex-wrap: wrap; }
.sidebar__who { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.sidebar__who strong { font-size: 0.8125rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__who span { font-size: 0.75rem; color: var(--color-muted); }
.sidebar__user form { margin: 0; }
.link-button, button.link-button, input[type="submit"].link-button {
  background: none; border: 0; box-shadow: none; padding: 0; color: var(--color-muted); font-size: 0.75rem; font-weight: 500; text-decoration: underline; text-underline-offset: 3px;
}
.link-button:hover, button.link-button:hover { background: none; color: var(--color-text); }

.topbar { background: var(--color-panel); border-bottom: 1px solid var(--color-border); position: relative; z-index: 20; }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 4rem; flex-wrap: wrap; }
.topbar__left, .topbar__right { display: flex; align-items: center; gap: var(--space-4); }
.topbar__right { gap: 0.6rem; }
.topbar__right form { margin: 0; }
.topbar__nav { display: flex; gap: 6px; }
.topbar__nav .nav-link { padding: 0.45rem 0.75rem; border-radius: 8px; }
.topbar__user { font-size: 0.8125rem; color: var(--color-subtle); }
.topbar__link { color: var(--color-subtle); text-decoration: none; font-weight: 500; padding: 0.4rem 0.75rem; border-radius: 8px; }
.topbar__link:hover { background: rgb(42 40 51 / 0.05); color: var(--color-text); }

.avatar {
  display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; flex: none;
  background: var(--rose-soft); color: var(--rose-text); font-size: 0.8125rem; font-weight: 700;
}
.avatar--ta { background: var(--ta-bg); color: var(--ta-ink); }
.avatar--student { background: var(--mint-soft); color: var(--mint-text); }

@media (max-width: 960px) {
  /* The bar's row takes only its height; without this a short page stretches the bar to fill the screen. */
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; max-height: 100vh; gap: 0; padding: 0.6rem var(--space-3); border-right: 0; border-bottom: 1px solid var(--color-border); }
  .sidebar__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
  .sidebar__toggle { display: inline-flex; align-items: center; gap: 0.4rem; }
  .sidebar__menu { display: none; }
  .sidebar--open .sidebar__menu { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-3) 0 0.25rem; }
  .sidebar__footer { margin-top: 0; }
  .app-main { padding: var(--space-4) var(--space-3) var(--space-5); }
}

/* ---- Page header ---- */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4);
}
.page-header h1 { margin-bottom: 0; display: flex; align-items: center; gap: var(--space-2) var(--space-3); flex-wrap: wrap; }
.page-header p.muted { margin: 0 0 var(--space-1); font-size: 0.875rem; }
.page-header > .badge { align-self: center; }

.section-header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.section-header h2 { margin: 0; }

.actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }

.muted { color: var(--color-muted); }
.muted a { color: inherit; }
.hint { color: var(--color-muted); font-size: 0.8125rem; margin: var(--space-1) 0 0; }
.warning { color: var(--rose-text); font-weight: 600; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }

.dashboard-section, .course-section { margin-top: var(--space-5); }
.dashboard-section h2, .course-section h2 { margin-bottom: var(--space-3); }

/* ---- Cards ---- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.card > :last-child { margin-bottom: 0; }
.card + .card, .card + .course-section, .checklist { margin-top: var(--space-3); }
.card--inset { background: var(--color-surface-muted); box-shadow: none; border-radius: var(--radius); padding: var(--space-3); margin-bottom: var(--space-3); }
.empty-state { text-align: center; padding: var(--space-5) var(--space-4); }
.empty-state p { margin: 0 0 var(--space-2); }

/* ---- Course tones: each course keeps one pastel across pages ---- */
.tone-lilac { --tone-soft: var(--lilac-soft); --tone-ink: var(--lilac-text); --tone-bar: #b9aef0; }
.tone-sky   { --tone-soft: var(--sky-soft);   --tone-ink: var(--sky-text);   --tone-bar: #9cc4ec; }
.tone-mint  { --tone-soft: var(--mint-soft);  --tone-ink: var(--mint-text);  --tone-bar: #8fd3b4; }
.tone-peach { --tone-soft: var(--peach-soft); --tone-ink: var(--peach-text); --tone-bar: #f4b89a; }
.tone-lemon { --tone-soft: var(--lemon-soft); --tone-ink: var(--lemon-text); --tone-bar: #ecd27a; }
.tone-rose  { --tone-soft: var(--rose-soft);  --tone-ink: var(--rose-text);  --tone-bar: #f0a9c4; }
.code-tag { display: inline-block; font: 600 0.75rem/1.3 var(--font-mono); letter-spacing: 0.03em; padding: 0.25rem 0.55rem; border-radius: 6px; background: var(--tone-soft, var(--lilac-soft)); color: var(--tone-ink, var(--lilac-text)); }

/* ---- Course cards (dashboard) ---- */
.course-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
.course-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; border-radius: var(--radius-lg); box-shadow: none; transition: box-shadow 0.15s ease, transform 0.15s ease; }
.course-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.course-card__band { position: relative; height: 92px; padding: 1rem 1.1rem; background: var(--tone-soft); color: var(--tone-ink); display: flex; flex-direction: column; justify-content: space-between; }
.course-card__code { font: 600 0.75rem/1.2 var(--font-mono); letter-spacing: 0.04em; }
.course-card__area { font-size: 0.75rem; font-weight: 600; }
.course-card__stamp { position: absolute; right: 10px; top: 6px; }
.course-card__body { padding: 1.1rem; display: flex; flex-direction: column; gap: 0.85rem; flex: 1; }
.course-card__link { display: flex; flex-direction: column; gap: 0.2rem; text-decoration: none; color: inherit; }
.course-card__name { font-family: var(--font-serif); font-size: 1.375rem; line-height: 1.15; font-weight: 500; color: var(--color-text); }
.course-card__link:hover .course-card__name { color: var(--color-accent-text); }
.course-card__meta { font-size: 0.8125rem; color: var(--color-muted); }
.course-card__exam { display: flex; flex-direction: column; gap: 0.45rem; }
.course-card__exam-head { display: flex; justify-content: space-between; gap: var(--space-2); font-size: 0.8rem; }
.course-card__exam-head a { font-weight: 600; color: var(--color-text); text-decoration: none; }
.course-card__exam-head a:hover { color: var(--color-accent-text); text-decoration: underline; }
.course-card__legend { display: flex; flex-wrap: wrap; gap: 0.25rem 0.85rem; font-size: 0.75rem; color: var(--color-muted); }
.course-card__status { margin-top: auto; padding-top: 0.75rem; border-top: 1px dashed var(--color-border); font-size: 0.8125rem; font-weight: 600; color: var(--color-subtle); }
.course-card__status--ai { color: var(--ai-ink); }
.course-card__status--review { color: var(--lemon-text); }
.course-card__status--done { color: var(--mint-text); }
.course-card__exams { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; font-size: 0.8125rem; }
.course-card__exams a { color: var(--color-text); text-decoration: none; font-weight: 500; }
.course-card__exams a:hover { color: var(--color-accent-text); text-decoration: underline; }
.course-card__exams li { display: flex; justify-content: space-between; gap: 0 var(--space-2); align-items: center; flex-wrap: wrap; }
.review-waiting { flex-basis: 100%; font-size: 0.8125rem; color: var(--color-muted); }

/* Where the grading stands: verified (mint), in staff review (butter), AI only (striped lilac). */
.grading-bar { display: flex; height: 9px; border-radius: 6px; overflow: hidden; background: var(--color-track); }
.grading-bar__verified { background: var(--mint-bar); }
.grading-bar__review { background: var(--lemon-bar); }
.grading-bar__ai { background: repeating-linear-gradient(45deg, #b9aef0 0 3px, #e9e4fb 3px 6px); }

/* ---- Stat cards: AI drafts are dashed, human work is solid ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.9rem; margin-bottom: var(--space-4); }
.stat { padding: 1.1rem 1.25rem; border-radius: 14px; border: 1.5px solid var(--color-border); background: var(--color-surface); display: flex; flex-direction: column; gap: 0.35rem; text-decoration: none; }
.stat__label { font-size: 0.8125rem; font-weight: 600; }
.stat__value { font-family: var(--font-serif); font-size: 2.4rem; line-height: 1; color: var(--color-text); }
.stat--ai { border-style: dashed; border-color: var(--ai-border); background: #f4f1fd; }
.stat--ai .stat__label { color: var(--ai-ink); }
.stat--review { border-color: #f0e2a6; background: #fcf6dc; }
.stat--review .stat__label { color: var(--lemon-text); }
.stat--verified { border-color: #b8e3cf; background: #e6f6ee; }
.stat--verified .stat__label { color: var(--mint-text); }

/* ---- Badges ---- */
.badge {
  font-family: var(--font-sans); letter-spacing: 0;
  display: inline-flex; align-items: center; gap: 0.3em; white-space: nowrap;
  font-size: 0.75rem; font-weight: 600; line-height: 1.2; letter-spacing: 0.01em;
  border-radius: var(--radius-pill); padding: 0.28rem 0.65rem;
  background: var(--stone-soft); color: var(--stone-text); border: 0;
}
.badge--professor { background: var(--lilac-soft); color: var(--lilac-text); }
.badge--ta { background: var(--sky-soft); color: var(--sky-text); }
.badge--student { background: var(--stone-soft); color: var(--stone-text); }

.badge--draft { background: var(--stone-soft); color: var(--stone-text); }
.badge--published { background: var(--sky-soft); color: var(--sky-text); }
.badge--open { background: var(--mint-soft); color: var(--mint-text); }
.badge--closed { background: var(--peach-soft); color: var(--peach-text); }
.badge--grading { background: var(--lilac-soft); color: var(--lilac-text); }
.badge--in-review { background: var(--lemon-soft); color: var(--lemon-text); }
.badge--released { background: var(--mint-soft); color: var(--mint-text); }

.badge--correct { background: var(--mint-soft); color: var(--mint-text); }
.badge--warning, .badge--failed, .badge--flag { background: var(--rose-soft); color: var(--rose-text); }

.badge--run-queued, .badge--run-running { background: var(--lilac-soft); color: var(--lilac-text); }
.badge--run-completed { background: var(--mint-soft); color: var(--mint-text); }
.badge--run-failed { background: var(--rose-soft); color: var(--rose-text); }
.badge--run-cancelled { background: var(--stone-soft); color: var(--stone-text); }

/* ---- Flash and notices ---- */
.flash {
  border-radius: var(--radius); padding: 0.75rem var(--space-3); margin-bottom: var(--space-3);
  border: 1px solid transparent; font-weight: 500;
}
.flash--notice { background: var(--mint-soft); color: var(--mint-text); border-color: #c6ead7; }
.flash--alert { background: var(--rose-soft); color: var(--rose-text); border-color: #f7c9d3; }
.flash a { color: inherit; font-weight: 600; }
.error-list { margin: 0; padding-left: var(--space-3); }

.checklist { border-color: #f7d7b9; background: linear-gradient(0deg, var(--color-surface), var(--color-surface)) padding-box; }
.checklist h2 { font-size: 1rem; color: var(--peach-text); }
.checklist ul { margin: 0; padding-left: var(--space-4); display: grid; gap: var(--space-1); }

/* ---- Tables ---- */
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm);
}
.table th, .table td { text-align: left; padding: 0.8rem var(--space-3); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th {
  background: var(--color-surface-muted); color: var(--color-muted);
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.table tbody tr:hover td { background: var(--color-surface-muted); }
.table__actions { text-align: right; }
.table__actions form { display: inline; }

/* ---- Facts (definition lists) ---- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--space-3); margin: 0 0 var(--space-3); }
.facts > div { background: var(--color-surface-muted); border-radius: var(--radius); padding: 0.75rem var(--space-3); }
.facts dt { font-size: 0.75rem; color: var(--color-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.facts dd { margin: 2px 0 0; font-weight: 600; }

/* ---- Exams ---- */
.exam-list, .question-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.exam-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.exam-row__title { font-weight: 650; font-size: 1.0625rem; color: var(--color-text); text-decoration: none; }
.exam-row__title:hover { color: var(--color-accent-text); }
.exam-row__timing { margin: 2px 0 0; font-size: 0.8125rem; }

/* The exam's lifecycle as a stepper: dots joined by a line, mint up to the current step. */
.stepper { --dot: 1.6rem; list-style: none; display: flex; padding: 0; margin: 0 0 var(--space-4); }
.stepper__step { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; text-align: center; padding: 0 0.25rem; }
.stepper__step + .stepper__step::before {
  content: ""; position: absolute; top: calc(var(--dot) / 2 - 1px); right: calc(50% + var(--dot) / 2 + 4px); left: calc(-50% + var(--dot) / 2 + 4px);
  height: 2px; border-radius: 2px; background: var(--color-border);
}
.stepper__step--done + .stepper__step::before, .stepper__step--done::before { background: var(--mint-text); opacity: 0.45; }
.stepper__dot {
  width: var(--dot); height: var(--dot); flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--color-surface); border: 2px solid var(--color-border);
}
.stepper__dot svg { width: 0.95rem; height: 0.95rem; fill: none; stroke: var(--mint-text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.stepper__step--done .stepper__dot { background: var(--mint-soft); border-color: var(--mint-soft); }
.stepper__step--current .stepper__dot { border-color: var(--color-accent); background: var(--color-accent-soft); box-shadow: 0 0 0 4px rgb(88 71 217 / 0.12); }
.stepper__step--current .stepper__dot::after { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--color-accent); }
.stepper__title { font-size: 0.8125rem; font-weight: 550; color: var(--color-muted); }
.stepper__step--done .stepper__title { color: var(--color-text); }
.stepper__step--current .stepper__title { color: var(--color-accent-text); font-weight: 700; }
.stepper__date { font-size: 0.72rem; color: var(--color-muted); line-height: 1.3; }
.stepper__note { display: block; font-style: italic; }

/* People tables on phones: the email (and institution) moves under the name instead of its own column. */
.table__narrow-only { display: none; }

@media (max-width: 700px) {
  .table__wide-only { display: none; }
  .table__narrow-only { display: block; margin-top: 0.15rem; font-size: 0.75rem; color: var(--color-muted); overflow-wrap: anywhere; }
  /* The student top bar keeps one row on phones: the avatar stands for the name. */
  .topbar__user, .topbar .brand__institution { display: none; }
  .topbar__inner { flex-wrap: nowrap; gap: var(--space-2); padding-block: 0.5rem; }
  .topbar__left { gap: var(--space-2); }
  .stepper { flex-direction: column; gap: var(--space-2); }
  .stepper__step { flex-direction: row; align-items: center; text-align: left; gap: var(--space-2); padding: 0; }
  .stepper__step + .stepper__step::before { top: calc(-1 * var(--space-2) - 2px); bottom: auto; left: calc(var(--dot) / 2 - 1px); right: auto; width: 2px; height: calc(var(--space-2) + 4px); }
  .stepper__date { margin-left: auto; }
  .stepper__note { display: inline; }
}

.question { display: grid; gap: var(--space-2); }
.question[draggable="true"] { cursor: grab; }
.question.is-dragging { opacity: 0.5; }
.question__header { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.question__title { font-size: 1rem; margin: 0; }
.question__prompt { overflow-x: auto; font-size: 1rem; }
.question__rubric { margin: 0; font-size: 0.875rem; color: var(--color-muted); }
.question__actions { padding-top: var(--space-2); border-top: 1px dashed var(--color-border); }
.question__actions form { display: inline; }
.choice-list { margin: 0; padding-left: var(--space-4); display: grid; gap: var(--space-1); }
.choice--correct { font-weight: 600; color: var(--mint-text); }

.math-preview { border: 1px dashed var(--color-border-strong); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin-top: var(--space-2); background: var(--color-surface-muted); }
.math-preview[hidden] { display: none; }

/* ---- Taking an exam ---- */
.taking-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  background: rgb(247 248 249 / 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0; margin: calc(-1 * var(--space-3)) 0 var(--space-4);
}
.taking-header h1 { margin: 0; font-size: 1.375rem; }
.taking-header p { margin: 0; font-size: 0.8125rem; }
.taking-header__actions { display: flex; align-items: center; gap: var(--space-3); }
.completion-form { margin: 0; }
.timer {
  font-variant-numeric: tabular-nums; font-size: 1.125rem; font-weight: 700; margin: 0;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-pill);
  padding: 0.35rem 0.9rem; box-shadow: var(--shadow-sm);
}
.timer--warning { background: var(--rose-soft); color: var(--rose-text); border-color: #f7c9d3; }
.taking-footer { margin-top: var(--space-4); text-align: center; }

.answer-form { display: grid; gap: var(--space-2); }
.answer-form .trix-button-group--file-tools { display: none; }
.choice-options { gap: var(--space-2); }
.choice-option {
  padding: 0.6rem var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface); cursor: pointer; transition: border-color 0.12s, background 0.12s;
}
.choice-option:hover { border-color: var(--color-border-strong); background: var(--color-surface-muted); }
.choice-option:has(input:checked) { border-color: var(--color-accent); background: var(--color-accent-soft); }
.save-status { margin: 0; font-size: 0.8125rem; color: var(--color-muted); }
.save-status--error { color: var(--rose-text); font-weight: 600; }

.code-block { background: #f1f5fb; border: 1px solid #dde7f4; color: #2f3f5a; border-radius: var(--radius); padding: var(--space-3); overflow-x: auto; margin: 0; }
.submitted-answer { border-top: 1px solid var(--color-border); padding-top: var(--space-3); }
.start-exam { margin-top: var(--space-2); }

/* ---- Grading runs ---- */
.progress-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.progress-row progress { flex: 1; height: 0.6rem; border: 0; border-radius: var(--radius-pill); overflow: hidden; background: var(--color-accent-soft); accent-color: var(--color-accent); }
.progress-row progress::-webkit-progress-bar { background: var(--color-accent-soft); border-radius: var(--radius-pill); }
.progress-row progress::-webkit-progress-value { background: var(--color-accent); border-radius: var(--radius-pill); }
.progress-row progress::-moz-progress-bar { background: var(--color-accent); border-radius: var(--radius-pill); }
.run-summary { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding: var(--space-3) var(--space-4); }

/* ---- Misc pages ---- */
.auth { max-width: 26rem; margin: var(--space-5) auto; }
.auth h1 { text-align: center; }
.auth > p { text-align: center; color: var(--color-muted); margin-top: var(--space-3); }
.two-columns { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); align-items: start; }
.two-columns .card + .card { margin-top: 0; }
.key-status { margin: 0 0 var(--space-3); }
.remove-key { margin-top: var(--space-2); }
.prose p:last-child { margin-bottom: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Cards inside grids and lists are spaced by the grid gap, not by stacking margins. */
.course-grid > .card, .exam-list > .card, .question-list > .card { margin-top: 0; }
.badge--pending { background: var(--lemon-soft); color: var(--lemon-text); }
.exam-links { margin: var(--space-4) 0 0; gap: var(--space-3); }
.hint code { background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: 5px; padding: 0 0.3em; color: var(--color-text); }
.question__header { align-items: baseline; }
.card + p { margin-top: var(--space-3); }
/* Code must look exactly as typed: no ligatures turning == into a single glyph. */
code, pre, kbd, textarea.code, .code-lines { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* Library: filters, tag chips and the list of saved questions and rubrics. */
.library-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); margin: var(--space-3) 0; }
.library-filters .field { margin: 0; flex: 1 1 14rem; }
.library-filters .field:nth-of-type(2) { flex: 0 1 12rem; }
.library-filters .actions { margin: 0; }
.tag-cloud, .tag-list { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0 0 var(--space-3); }
.tag-list { margin: 0; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.65rem; border-radius: 999px;
  background: var(--sky-soft); color: var(--sky-text); font-size: 0.8125rem; font-weight: 550; text-decoration: none;
  border: 1px solid transparent;
}
a.tag-chip:hover { border-color: var(--sky-text); }
.tag-chip--active { background: var(--color-accent); color: var(--color-accent-contrast); }
.tag-chip__count { font-weight: 450; opacity: 0.75; }
.tag-chip--static { font-size: 0.75rem; }
.library-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.library-item { display: grid; gap: var(--space-2); }
.library-item .question__header, .library-item .actions { margin: 0; }
.library-item__prompt { max-height: 9rem; overflow: hidden; }
.library-item__meta { margin: 0; font-size: 0.875rem; }
.library-item__criteria { margin: 0; padding-left: 1.2rem; font-size: 0.9rem; }
.rubric-library-actions { margin: var(--space-3) 0; }

/* ---- The ink stamp (StampsHelper#ink_stamp) ---- */
.ink-stamp {
  display: inline-block; width: var(--stamp-size, 120px); height: var(--stamp-size, 120px); flex: none;
  transform: rotate(var(--stamp-rotate, -12deg)); mix-blend-mode: multiply; opacity: 0.9; pointer-events: none;
}
.ink-stamp svg { display: block; overflow: visible; }
.ink-stamp__label { font-family: var(--font-stamp); font-weight: 700; font-size: 11px; letter-spacing: 1.6px; text-anchor: middle; }
.ink-stamp__name { font-family: var(--font-stamp); font-weight: 700; font-size: 8.6px; letter-spacing: 0.8px; text-anchor: middle; }
.ink-stamp__date { font-family: var(--font-stamp); font-weight: 700; font-size: 7.6px; text-anchor: middle; }

/* ---- AI question drafts ---- */
.draft-layout { display: grid; grid-template-columns: minmax(16rem, 0.8fr) minmax(0, 1.6fr); gap: 1.5rem; align-items: start; }
.draft-layout > .card + .card { margin-top: 0; }
@media (max-width: 1000px) { .draft-layout { grid-template-columns: 1fr; } }
.draft-template { display: flex; flex-direction: column; gap: 0.75rem; position: sticky; top: 1.25rem; }
.draft-template .label-caps { margin: 0; }
.draft-template__title { font-family: var(--font-serif); font-weight: 500; font-size: 1.25rem; margin: 0; }
.draft-request { max-width: none; }
.draft-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.draft-proposal { gap: 1rem; }
.draft-proposal .fieldset { background: var(--color-surface); }
.draft-form { max-width: none; }
.draft-rationale { margin: 0; display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.9rem; line-height: 1.5; color: var(--color-body); }
.draft-rationale .voice { width: 1.6rem; height: 1.6rem; font-size: 0.6rem; }
.draft-waiting { min-height: 9rem; }
.draft-again summary { cursor: pointer; font-weight: 600; }
.draft-again[open] summary { margin-bottom: var(--space-3); }
.draft-meta { margin: 0; }
.library-item--draft { border: 1.5px dashed var(--ai-border); background: var(--ai-bg); }
.count-pill--ai { background: var(--ai-bg); color: var(--ai-ink); border: 1px dashed var(--ai-border); }

/* ---- Course skills ---- */
.skill-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.skill-list > .card { margin: 0; }
.skill-card { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.skill-card p { margin: 0; font-size: 0.875rem; line-height: 1.45; }
.skill-card__head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.skill-weight { display: inline-flex; gap: 3px; flex: none; }
.skill-weight span { width: 7px; height: 7px; border-radius: 50%; background: var(--color-track); }
.skill-weight span.is-on { background: var(--color-accent); opacity: 0.75; }
.skill-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; }
.draft-skills { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0; }

/* ---- Shared library ---- */
.shared-owner { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.8125rem; color: var(--color-muted); }
.shared-owner .voice { width: 1.6rem; height: 1.6rem; font-size: 0.6rem; }
.shared-owner strong { color: var(--color-text); font-weight: 600; }
.shared-hint { font-size: 0.8125rem; }
.shared-item { display: flex; flex-direction: column; gap: 0.75rem; }
.shared-item .label-caps { margin: 0.5rem 0 0; }
.library-filters .field:nth-of-type(3) { flex: 0 1 10rem; }

/* A question whose grades no longer match it: the key, points or rubric changed after grading. */
.regrade-note {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem;
  margin: 0.75rem 0; padding: 0.6rem 0.85rem; border-radius: 10px; background: var(--lemon-soft);
}
.regrade-note p { margin: 0; }
.regrade-note .warning { color: var(--lemon-text); font-weight: 600; }
.regrade-note .hint { display: block; margin-top: 0.15rem; }

/* A secondary action under the text of an auth card ("Send the link again"). */
.auth-card__action { margin-top: 0.9rem; }

/* Deleting something with everything in it (a course): folded away, and confirmed by typing its code. */
.danger-zone { margin-top: var(--space-4, 2rem); border-color: #f0b8c8; }
.danger-zone summary { cursor: pointer; font-weight: 600; color: var(--rose-text); }
.danger-zone[open] summary { margin-bottom: 0.6rem; }
.danger-zone .field { max-width: 22rem; }

/* A single search box with its button (the institution's people). */
.search-row { display: flex; gap: 0.5rem; align-items: center; max-width: 32rem; margin-bottom: var(--space-3); }
.search-row input[type=search] { flex: 1; }

/* The institution's name under the brand, once signed in. */
.brand__text { display: inline-flex; flex-direction: column; line-height: 1; }
.brand__institution { font-size: 0.7rem; color: var(--color-muted); margin-top: 0.2rem; letter-spacing: 0.01em; }

/* The administration area's sections (Institutions, People, Courses). */
.admin-tabs { display: flex; gap: 0.25rem; margin: 0 0 var(--space-4); border-bottom: 1px solid var(--color-border); }
.admin-tabs__tab { padding: 0.5rem 0.9rem; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--color-muted); text-decoration: none; font-weight: 500; }
.admin-tabs__tab:hover { color: var(--color-text); }
.admin-tabs__tab--active { color: var(--color-accent-text); border-bottom-color: var(--color-accent); }
.admin-standing { margin-top: var(--space-4); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.admin-standing p { margin: 0; }

/* The sharing menu on library cards: who the item reaches, and the ways to change it. */
.share-menu { position: relative; display: inline-block; }
.share-menu > summary { list-style: none; display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.share-menu > summary::-webkit-details-marker { display: none; }
.share-menu__list {
  position: absolute; z-index: 40; top: calc(100% + 0.35rem); left: 0; min-width: 17rem; padding: 0.35rem;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; box-shadow: 0 8px 24px rgb(42 40 51 / 0.12);
}
.share-menu__list form { margin: 0; }
.share-menu__item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; width: 100%; padding: 0.55rem 0.7rem;
  background: none; border: 0; border-radius: 8px; text-align: left; cursor: pointer; font: inherit; color: var(--color-text);
}
.share-menu__item:hover, .share-menu__item:focus-visible { background: var(--color-surface-muted); }
.share-menu__item strong { font-size: 0.85rem; font-weight: 600; }
.share-menu__item span { font-size: 0.75rem; color: var(--color-muted); }

/* Course grading costs: two small tables side by side, stacked on narrow screens. */
.cost-breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.table--compact td { padding-block: 0.45rem; }
.table--compact td:last-child { text-align: right; }
