/* ==========================================================================
   Run Your Class — design system
   Single source of truth. Templates should not define their own <style>.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Surfaces */
  --bg:            #ffffff;
  --bg-subtle:     #fafafa;
  --bg-sunken:     #f4f4f5;

  /* Ink */
  --ink:           #111111;
  --ink-2:         #5c5c5c;
  --ink-3:         #8e8e8e;

  /* Lines */
  --line:          #e4e4e4;
  --line-strong:   #cfcfcf;

  /* The single accent. Primary actions and links only. */
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-soft:   rgba(37, 99, 235, 0.09);

  /* Marks a student who has given a quotation. Deeper than pure `gold`, which
     at this border weight sat at about 1.4:1 against the white page. */
  --quoted:        #c8930b;

  /* Semantic — state only, never decoration */
  --success:       #15803d;
  --success-bg:    #f2fbf5;
  --danger:        #b91c1c;
  --danger-bg:     #fef4f4;
  --warning:       #a16207;
  --warning-bg:    #fefbf1;

  /* Type scale */
  --fs-1:    2.25rem;
  --fs-2:    1.625rem;
  --fs-3:    1.25rem;
  --fs-4:    1.0625rem;
  --fs-body: 1rem;
  --fs-sm:   0.875rem;
  --fs-xs:   0.8125rem;

  /* Space */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;

  /* Geometry — one radius, no shadows */
  --radius:    4px;
  --radius-lg: 6px;

  --content-width: 1100px;

  /* --- Bootstrap overrides, so utility classes inherit the system --- */
  --bs-body-font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--bg);
  --bs-border-color: var(--line);
  --bs-link-color: var(--accent);
  --bs-link-hover-color: var(--accent-hover);
  --bs-primary: var(--accent);
  --bs-border-radius:       var(--radius);
  --bs-border-radius-sm:    3px;
  --bs-border-radius-lg:    var(--radius-lg);
  --bs-border-radius-xl:    var(--radius-lg);
  --bs-border-radius-2xl:   var(--radius-lg);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

html {
  height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: var(--bs-body-font-family);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1 0 auto;
  display: block;
}

/* Type scale. Tight tracking at display sizes, normal at body sizes. */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--ink);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-top: 0;
}

h1, .h1 { font-size: var(--fs-1); }
h2, .h2 { font-size: var(--fs-2); }
h3, .h3 { font-size: var(--fs-3); }
h4, .h4 { font-size: var(--fs-4); }
h5, .h5 { font-size: var(--fs-body); }
h6, .h6 { font-size: var(--fs-sm); }

/* Bootstrap display-* classes appear throughout the templates. Fold them
   into the same scale rather than letting them run to 5rem. */
.display-1, .display-2, .display-3 { font-size: var(--fs-1); font-weight: 500; letter-spacing: -0.02em; }
.display-4, .display-5             { font-size: var(--fs-2); font-weight: 500; letter-spacing: -0.02em; }
.display-6                         { font-size: var(--fs-3); font-weight: 500; letter-spacing: -0.015em; }

.lead {
  font-size: var(--fs-4);
  font-weight: 400;
  color: var(--ink-2);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  opacity: 1;
  margin: var(--sp-6) 0;
}

::placeholder {
  color: var(--ink-3) !important;
  opacity: 1;
}

/* --------------------------------------------------------------------------
   3. Page shell
   -------------------------------------------------------------------------- */

.page {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--sp-7) var(--sp-5) var(--sp-8);
}

.page-wide {
  max-width: none;
  padding-left: var(--sp-6);
  padding-right: var(--sp-6);
}

.page-narrow {
  max-width: 560px;
}

/* Single-column form pages */
.page-form {
  max-width: 720px;
}

/* Title block: eyebrow / title / description / actions */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-bottom: var(--sp-5);
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--line);
}

.page-header h1,
.page-header .page-title {
  margin: 0;
}

.page-header .page-description {
  margin: var(--sp-2) 0 0;
  color: var(--ink-2);
  font-size: var(--fs-4);
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.section {
  margin-bottom: var(--sp-7);
}

.section-title {
  font-size: var(--fs-3);
  margin-bottom: var(--sp-4);
}

/* --------------------------------------------------------------------------
   4. Header / navigation
   -------------------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background-color: var(--bg);
}

.site-header .navbar,
.navbar {
  background-color: transparent !important;
  box-shadow: none;
  padding: var(--sp-4) 0;
}

.navbar-brand {
  font-size: var(--fs-4);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink) !important;
}

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

.navbar-nav .nav-link {
  color: var(--ink-2) !important;
  font-size: var(--fs-sm);
  font-weight: 400;
  padding: var(--sp-2) var(--sp-3) !important;
  border-bottom: none;
  transition: color 0.12s ease;
}

.navbar-nav .nav-link:hover {
  color: var(--ink) !important;
  text-decoration: none;
}

.navbar-nav .nav-link.active {
  color: var(--ink) !important;
  font-weight: 500;
  background-color: transparent !important;
  border-bottom: none;
}

.navbar-toggler {
  border: 1px solid var(--line);
  padding: var(--sp-1) var(--sp-2);
}

.navbar-toggler:focus {
  box-shadow: none;
}

/* Legacy masthead nav (pre-redesign markup) */
.nav-masthead .nav-link {
  color: var(--ink-2);
  border-bottom: none;
}

.nav-masthead .nav-link:hover,
.nav-masthead .nav-link:focus,
.nav-masthead .active {
  color: var(--ink);
  border-bottom-color: transparent;
}

/* --------------------------------------------------------------------------
   5. Footer
   -------------------------------------------------------------------------- */

.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background-color: var(--bg);
  padding: var(--sp-5) 0;
  margin-top: var(--sp-8);
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.site-footer a {
  color: var(--ink-2);
}

.site-footer a:hover {
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */

.btn {
  --bs-btn-box-shadow: none;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.4;
  padding: 0.5rem 0.875rem;
  border: 1px solid transparent;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:focus,
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-sm { font-size: var(--fs-xs); padding: 0.3125rem 0.625rem; }
.btn-lg { font-size: var(--fs-body); padding: 0.625rem 1.125rem; }

/* Primary — the accent. One per view, ideally. */
.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:active,
.btn-primary:focus {
  background-color: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  color: #fff !important;
}

/* Everything that was decorative colour collapses to a neutral outline.
   btn-success / btn-info / btn-warning / btn-secondary / btn-light / btn-dark
   all land here so existing markup reads as one system. */
.btn-secondary,
.btn-success,
.btn-info,
.btn-warning,
.btn-light,
.btn-dark,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-info,
.btn-outline-warning,
.btn-outline-dark,
.btn-outline-light {
  background-color: var(--bg);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-secondary:hover,
.btn-success:hover,
.btn-info:hover,
.btn-warning:hover,
.btn-light:hover,
.btn-dark:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover,
.btn-outline-info:hover,
.btn-outline-warning:hover,
.btn-outline-dark:hover,
.btn-outline-light:hover,
.btn-secondary:active,
.btn-success:active,
.btn-info:active,
.btn-warning:active,
.btn-light:active,
.btn-dark:active {
  background-color: var(--bg-sunken) !important;
  border-color: var(--line-strong) !important;
  color: var(--ink) !important;
}

.btn-outline-primary {
  background-color: transparent;
  border-color: var(--line-strong);
  color: var(--accent);
}

.btn-outline-primary:hover,
.btn-outline-primary:active {
  background-color: var(--accent-soft) !important;
  border-color: var(--accent) !important;
  color: var(--accent-hover) !important;
}

/* Destructive keeps its colour — this is signal, not decoration. */
.btn-danger {
  background-color: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover,
.btn-danger:active {
  background-color: #991b1b !important;
  border-color: #991b1b !important;
  color: #fff !important;
}

.btn-outline-danger {
  background-color: transparent;
  border-color: var(--line-strong);
  color: var(--danger);
}

.btn-outline-danger:hover,
.btn-outline-danger:active {
  background-color: var(--danger-bg) !important;
  border-color: var(--danger) !important;
  color: var(--danger) !important;
}

.btn-link {
  color: var(--accent);
  border-color: transparent;
  background: none;
  padding-left: 0;
  padding-right: 0;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.45;
}

/* --------------------------------------------------------------------------
   7. Cards, panels, lists
   -------------------------------------------------------------------------- */

.card {
  background-color: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none !important;
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--line);
  padding: var(--sp-4) var(--sp-5);
  font-weight: 500;
}

.card-header h1, .card-header h2, .card-header h3,
.card-header h4, .card-header h5, .card-header h6 {
  font-size: var(--fs-4);
  margin: 0;
}

/* Coloured card headers collapse into the neutral header treatment */
.card-header.bg-primary,
.card-header.bg-secondary,
.card-header.bg-info,
.card-header.bg-success,
.card-header.bg-warning,
.card-header.bg-dark,
.card-header.bg-light {
  background-color: transparent !important;
  color: var(--ink) !important;
}

.card-header .text-white {
  color: var(--ink) !important;
}

.card-body   { padding: var(--sp-5); }
.card-footer {
  background-color: transparent;
  border-top: 1px solid var(--line);
  padding: var(--sp-4) var(--sp-5);
}

.list-group {
  border-radius: var(--radius);
}

.list-group-item {
  background-color: var(--bg);
  border: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-4);
  color: var(--ink);
}

.list-group-item + .list-group-item {
  border-top-width: 0;
}

/* Bare rows — the roster / team list pattern used across the app */
.stack {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.stack > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line);
}

.stack-main {
  min-width: 0;
}

.stack-title {
  font-weight: 500;
}

/* Interpuncted metadata line. Values read as data, not as badges. */
.stack-meta {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  line-height: 1.5;
}

.stack-meta > span + span::before {
  content: "·";
  margin: 0 0.5em;
  color: var(--line-strong);
}

.stack-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

.stack-empty {
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.stack-description {
  margin: var(--sp-1) 0 var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  max-width: 60ch;
}

/* Rows carrying several stacked lines need room to breathe */
.stack > li:has(.stack-description),
.stack > li:has(.meter) {
  align-items: flex-start;
  padding: var(--sp-4) 0;
}

/* Horizontal bars for magnitude across named categories.
   Single hue, direct value labels, no legend — the heading names the series.
   Data-end rounded, baseline end square. */
.bars {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bars > li {
  display: grid;
  grid-template-columns: 8rem 1fr 3rem;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
}

.bar-label {
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.bar-track {
  display: block;
  height: 10px;
  border-left: 1px solid var(--line);
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  background-color: var(--accent);
  border-radius: 0 4px 4px 0;
}

.bar-value {
  font-size: var(--fs-sm);
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 575.98px) {
  .bars > li {
    grid-template-columns: 6rem 1fr 2.5rem;
  }
}

/* Wide tables scroll inside their own container */
.table-scroll {
  overflow-x: auto;
}

/* Part-to-whole across a few ordered buckets. Status hues carry severity; the
   legend names and counts each one so identity is never colour-alone.
   A 2px surface gap separates adjacent fills. */
.stacked-bar {
  display: flex;
  height: 10px;
  border-radius: var(--radius);
  overflow: hidden;
  background-color: var(--bg-sunken);
  max-width: 520px;
}

.stacked-seg {
  height: 100%;
  transition: width 0.2s ease;
}

.stacked-seg + .stacked-seg {
  border-left: 2px solid var(--bg);
}

.stacked-seg.is-low,
.swatch.is-low    { background-color: var(--success); }
.stacked-seg.is-medium,
.swatch.is-medium { background-color: var(--warning); }
.stacked-seg.is-high,
.swatch.is-high   { background-color: var(--danger); }

.swatch-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  list-style: none;
  padding: 0;
  margin: var(--sp-3) 0 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.swatch-legend li {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.swatch-value {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Severity in a table cell: a coloured dot plus the word, never colour alone */
.risk-flag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.risk-flag::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.risk-flag.is-low::before    { background-color: var(--success); }
.risk-flag.is-medium::before { background-color: var(--warning); }
.risk-flag.is-high::before   { background-color: var(--danger); }
.risk-flag.is-high           { color: var(--danger); }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.filter-row .btn.active {
  background-color: var(--ink) !important;
  border-color: var(--ink) !important;
  color: var(--bg) !important;
}

.section-subtitle {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-2);
  margin: var(--sp-4) 0 var(--sp-2);
}

.risk-headline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: 0;
}

.risk-score {
  font-size: var(--fs-2);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

.risk-score-max {
  font-size: var(--fs-sm);
  color: var(--ink-3);
}

.break-anywhere {
  overflow-wrap: anywhere;
}

/* Event log down a single hairline rule */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--sp-4);
  border-left: 1px solid var(--line);
}

.timeline-item {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  font-size: var(--fs-sm);
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--sp-4) - 4px);
  top: 1.05em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--line-strong);
}

.timeline-item.is-success::before { background-color: var(--success); }
.timeline-item.is-warning::before { background-color: var(--warning); }
.timeline-item.is-error::before   { background-color: var(--danger); }

.timeline-time {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 5rem;
}

.timeline-message {
  color: var(--ink-2);
}

/* Read-only view of submitted student text */
.response-view {
  white-space: pre-wrap;
  min-height: 200px;
  padding: var(--sp-4);
  background-color: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
}

/* Slim completion indicator */
.meter {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}

.meter-track {
  width: 140px;
  height: 3px;
  background-color: var(--bg-sunken);
  border-radius: 2px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background-color: var(--ink-3);
}

.meter-label {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Centred placeholder for empty collections */
.empty-state {
  padding: var(--sp-8) 0;
  max-width: 48ch;
}

.empty-state .section-title {
  margin-bottom: var(--sp-2);
}

.empty-state p {
  margin-bottom: var(--sp-4);
}

/* Key/value pairs. Labels quiet, values in ink. */
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sp-2) var(--sp-5);
  margin: 0;
  font-size: var(--fs-sm);
}

.facts dt {
  color: var(--ink-3);
  font-weight: 400;
}

.facts dd {
  margin: 0;
  color: var(--ink);
}

/* Wider label column, for definition-style prose rather than short values */
.facts-wide {
  grid-template-columns: 11rem 1fr;
  gap: var(--sp-3) var(--sp-5);
}

.facts-wide dt {
  color: var(--ink);
  font-weight: 500;
}

.facts-wide dd {
  color: var(--ink-2);
}

@media (max-width: 575.98px) {
  .facts,
  .facts-wide {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .facts dt,
  .facts-wide dt {
    margin-top: var(--sp-3);
  }
}

/* Numbered walkthrough */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  max-width: 60ch;
}

.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 var(--sp-4) var(--sp-6);
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  font-size: var(--fs-sm);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.steps-title {
  font-size: var(--fs-4);
  margin-bottom: var(--sp-1);
}

.steps p {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

/* Long-form body copy rendered from user input */
.prose {
  max-width: 68ch;
  color: var(--ink);
}

.prose p:last-child {
  margin-bottom: 0;
}

/* Secondary page navigation — quieter than the primary action row */
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-bottom: var(--sp-7);
  font-size: var(--fs-sm);
}

.subnav a {
  color: var(--ink-2);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}

.subnav a:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
  text-decoration: none;
}

/* Single-field add form sitting under a stack */
.inline-form {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  max-width: 420px;
}

.inline-form .form-control {
  flex: 1;
}

.inline-form .btn {
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   8. Forms
   -------------------------------------------------------------------------- */

.form-control,
.form-select {
  background-color: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: var(--fs-body);
  color: var(--ink);
  box-shadow: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

/* Selects need room for the caret Bootstrap draws as a background image;
   the shared padding rule above would otherwise run the text into it. */
.form-select {
  padding-right: 2.25rem;
}

.form-select-sm {
  padding: 0.3125rem 2rem 0.3125rem 0.625rem;
  font-size: var(--fs-sm);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.form-control-color {
  padding: 0.25rem;
  width: 3rem;
}

.form-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
  margin-bottom: var(--sp-2);
}

.form-text,
.form-check-label + .text-secondary {
  font-size: var(--fs-sm);
  color: var(--ink-3);
}

.form-check-input {
  border-color: var(--line-strong);
}

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

.form-check-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-group-text {
  background-color: var(--bg-subtle);
  border-color: var(--line-strong);
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

/* Django's built-in auth forms (password reset / change) render their widgets
   without a class, so give bare inputs inside a page form the same treatment
   rather than patching each form individually. */
.page form input:not([type]),
.page form input[type="text"],
.page form input[type="email"],
.page form input[type="password"],
.page form input[type="number"],
.page form input[type="url"],
.page form input[type="tel"],
.page form input[type="datetime-local"],
.page form input[type="date"],
.page form textarea,
.page form select {
  display: block;
  width: 100%;
  background-color: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: var(--fs-body);
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.page form input:focus-visible,
.page form textarea:focus-visible,
.page form select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* Checkboxes and radios must keep their intrinsic size */
.page form input[type="checkbox"],
.page form input[type="radio"] {
  display: inline-block;
  width: auto;
  padding: 0;
}

.page form input[type="color"] {
  width: 2rem;
  padding: 0.15rem;
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

.form-error {
  margin-top: var(--sp-1);
  font-size: var(--fs-sm);
  color: var(--danger);
}

/* Submit / cancel pair closing a form */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  padding-top: var(--sp-5);
  margin-top: var(--sp-6);
  border-top: 1px solid var(--line);
}

/* Boxed aside inside a form — supporting detail, not a card */
.callout {
  padding: var(--sp-4) var(--sp-5);
  background-color: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.callout-title {
  font-size: var(--fs-4);
  margin-bottom: var(--sp-3);
}

.callout-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: var(--sp-2);
}

.callout-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.callout-list li + li {
  margin-top: var(--sp-1);
}

/* Footer links under an auth form */
.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}

/* Centered auth forms */
.form-signin {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  padding: 0;
}

.form-signin .form-control {
  font-size: var(--fs-body);
  padding: 0.5rem 0.75rem;
}

/* Undo the old seam-joined email/password inputs */
.form-signin input[type="email"],
.form-signin input[type="password"] {
  margin-bottom: var(--sp-3);
  border-radius: var(--radius);
}

/* --------------------------------------------------------------------------
   9. Badges, alerts, tables
   -------------------------------------------------------------------------- */

/* Bootstrap's .badge sets white text and expects a bg-* class alongside it,
   so a bare <span class="badge"> was invisible. Neutral is the default here. */
.badge {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0;
  padding: 0.25em 0.5em;
  border-radius: var(--radius);
  background-color: var(--bg-sunken);
  color: var(--ink-2);
}

/* Decorative badge colours collapse to neutral */
.badge.bg-primary,
.badge.bg-secondary,
.badge.bg-info,
.badge.bg-success,
.badge.bg-warning,
.badge.bg-dark,
.badge.bg-light {
  background-color: var(--bg-sunken) !important;
  color: var(--ink-2) !important;
}

.badge.bg-danger {
  background-color: var(--danger-bg) !important;
  color: var(--danger) !important;
}

.alert {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--ink);
  background-color: var(--bg-subtle);
}

.alert-success { background-color: var(--success-bg); border-color: #cdeed8; color: var(--success); }
.alert-danger  { background-color: var(--danger-bg);  border-color: #f4d4d4; color: var(--danger); }
.alert-warning { background-color: var(--warning-bg); border-color: #f0e3c2; color: var(--warning); }
.alert-info    { background-color: var(--bg-subtle);  border-color: var(--line); color: var(--ink-2); }

.table {
  --bs-table-border-color: var(--line);
  font-size: var(--fs-sm);
  margin-bottom: 0;
}

.table > thead > tr > th {
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  padding: var(--sp-2) var(--sp-3);
}

.table > tbody > tr > td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   10. Modals, dropdowns, breadcrumbs, tooltips
   -------------------------------------------------------------------------- */

.modal-content {
  background-color: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.10);
}

.modal-header,
.modal-footer {
  border-color: var(--line);
  padding: var(--sp-4) var(--sp-5);
}

.modal-header .modal-title {
  font-size: var(--fs-4);
}

.modal-body {
  padding: var(--sp-5);
}

.modal-backdrop.show {
  opacity: 0.35;
}

.dropdown-menu {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  padding: var(--sp-1);
  font-size: var(--fs-sm);
}

.dropdown-item {
  border-radius: 3px;
  padding: var(--sp-2) var(--sp-3);
  color: var(--ink-2);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: var(--bg-sunken);
  color: var(--ink);
}

.accordion {
  --bs-accordion-border-color: var(--line);
  --bs-accordion-border-radius: var(--radius);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 3px var(--accent-soft);
  --bs-accordion-active-bg: var(--bg-subtle);
  --bs-accordion-active-color: var(--ink);
  max-width: 68ch;
}

.accordion-button {
  font-size: var(--fs-4);
  font-weight: 500;
  padding: var(--sp-3) var(--sp-4);
  box-shadow: none !important;
}

.accordion-body {
  padding: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.accordion-body ol,
.accordion-body ul {
  margin-bottom: var(--sp-3);
  padding-left: var(--sp-5);
}

.accordion-body li + li {
  margin-top: var(--sp-1);
}

.accordion-body > :last-child {
  margin-bottom: 0;
}

.breadcrumb {
  background-color: transparent;
  padding: 0;
  margin-bottom: var(--sp-4);
  font-size: var(--fs-sm);
}

.breadcrumb-item,
.breadcrumb-item.active {
  color: var(--ink-3);
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--line-strong);
}

.tooltip-inner {
  background-color: var(--ink);
  border-radius: var(--radius);
  font-size: var(--fs-xs);
  padding: var(--sp-1) var(--sp-2);
}

/* --------------------------------------------------------------------------
   11. Utility overrides
   -------------------------------------------------------------------------- */

.text-muted,
.text-secondary  { color: var(--ink-2) !important; }
.text-primary    { color: var(--accent) !important; }
.text-success    { color: var(--success) !important; }
.text-danger     { color: var(--danger) !important; }
.text-warning    { color: var(--warning) !important; }
.text-info       { color: var(--ink-2) !important; }

.bg-primary      { background-color: var(--accent) !important; }
.bg-light        { background-color: var(--bg-subtle) !important; }
.bg-dark         { background-color: var(--ink) !important; }

/* No decorative depth anywhere */
.shadow,
.shadow-sm,
.shadow-lg {
  box-shadow: none !important;
}

a.link          { color: var(--ink) !important; }
a.link:hover    { color: var(--ink-2) !important; }

/* --------------------------------------------------------------------------
   12. Legacy hero / wallpaper neutralisation
   The photo-background system is retired. These rules flatten the existing
   markup so pages read correctly before the templates are cleaned up.
   -------------------------------------------------------------------------- */

.hero,
.hero-home,
.hero-my-classes,
.hero-tracking,
.hero-class-detail,
.hero-tracker,
.hero-footer {
  background-image: none !important;
  background-color: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: none;
  box-shadow: none !important;
  min-height: 0;
  margin-top: 0;
}

.hero .container,
.hero .card,
.hero .list-group,
.hero .rounded,
.hero .form-control,
.hero .form-select,
.hero .breadcrumb,
.hero .nav-item,
.hero .col-md-8,
.hero .col-md-4,
.hero ul.list-unstyled li,
.hero .btn-group .btn,
.hero .nav-link,
.hero-tracker .border.rounded {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.hero .container {
  background-color: transparent !important;
  border: none !important;
  border-radius: 0;
  box-shadow: none !important;
  max-width: var(--content-width);
}

.hero .card,
.hero .list-group,
.hero-tracker .border.rounded {
  background-color: var(--bg) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
}

.hero .form-control,
.hero .form-select {
  background-color: var(--bg) !important;
  border: 1px solid var(--line-strong) !important;
}

.hero .breadcrumb,
.hero .nav-item,
.hero .col-md-8,
.hero .col-md-4,
.hero ul.list-unstyled li,
.circle-container {
  background-color: transparent;
  border-radius: 0;
}

.hero .col-md-8,
.hero .col-md-4 {
  padding: 0 calc(var(--bs-gutter-x, 1.5rem) * 0.5);
  margin-bottom: 0;
}

.hero h1, .hero h2, .hero h3,
.hero h4, .hero h5, .hero h6 {
  text-shadow: none;
}

.top-container {
  padding-top: 0 !important;
}

.tracking-container {
  min-height: 0;
}

/* --------------------------------------------------------------------------
   13. Discussion circles
   -------------------------------------------------------------------------- */

.circle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
  padding: 0;
}

/* Scoped — this used to override Bootstrap's global .row */
.circle-container .row {
  width: 100%;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin: 0;
}

.circle-container .row > .col {
  flex: 0 0 auto;
  width: auto;
  padding: 0;
}

.circle {
  cursor: pointer;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1.5px solid var(--line-strong);
  background-color: var(--bg);
  font-size: var(--fs-sm);
  line-height: 1.3;
  user-select: none;
  transition: transform 0.08s ease;
}

.circle:active {
  transform: scale(0.96);
}

/* A gold ring marks a student who has given a quotation. Thicker than the
   resting border so it still reads across a room at the lighter weight. */
.circle.is-quoted {
  border-color: var(--quoted);
  border-width: 3px;
}

.circle .student-name {
  font-weight: 500;
}

.contribution-count {
  font-size: var(--fs-3);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

.student-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
}

/* Swatch + label pair, sized to sit inline with buttons */
.color-field {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  margin: 0;
  cursor: pointer;
}

.color-field .form-control-color {
  width: 2rem;
  height: 2rem;
  padding: 0.15rem;
  margin: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

/* Plain-text session report */
.report {
  display: inline-block;
  text-align: left;
  margin: var(--sp-5) auto 0;
  padding: var(--sp-4);
  background-color: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  white-space: pre-wrap;
}

.arrows {
  display: flex;
  justify-content: center;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}

.arrows i {
  cursor: pointer;
  color: currentColor;
  opacity: 0.55;
  transition: opacity 0.12s ease;
}

.arrows i:hover {
  opacity: 1;
}

/* Behavior-points circles: larger, and the fill carries the meaning */
.behavior-circle {
  width: 116px;
  height: 116px;
  border-color: var(--line);
  padding: var(--sp-2);
}

.behavior-circle .student-name {
  font-size: var(--fs-xs);
  line-height: 1.2;
}

.behavior-circle .points-display {
  font-size: var(--fs-3);
  font-weight: 400;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   12a. Control bar and stat row
   -------------------------------------------------------------------------- */

/* Row of labelled selects sitting above a grid */
.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  padding-bottom: var(--sp-5);
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--line);
}

.control-field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.control-field .form-select {
  width: auto;
  font-size: var(--fs-sm);
}

/* Summary figures. Numbers carry the weight; labels stay quiet. */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-7);
  margin-bottom: var(--sp-6);
}

.stat-value {
  font-size: var(--fs-2);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: var(--fs-sm);
  color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   12b. Discussion overview heatmap
   Students down, sessions across, contribution count per cell. The fill is a
   sequential ramp because the value is an ordered magnitude; every step is
   named and bounded in the legend, so colour is never the only cue.
   -------------------------------------------------------------------------- */

.overview-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.overview-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

.overview-table th,
.overview-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: var(--sp-2) var(--sp-3);
  white-space: nowrap;
}

.overview-table thead th {
  background-color: var(--bg-subtle);
  font-weight: 500;
  font-size: var(--fs-xs);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
}

.overview-table thead th.student-col {
  left: 0;
  z-index: 3;
  text-align: left;
}

.overview-table td.student-name-cell {
  font-weight: 500;
  position: sticky;
  left: 0;
  background-color: var(--bg);
  z-index: 1;
  cursor: pointer;
}

.overview-table td.student-name-cell:hover {
  background-color: var(--bg-sunken);
}

/* Sequential ramp, light to dark. Text flips once the fill is dark enough. */
.cell-0     { background-color: var(--bg-subtle); color: var(--ink-3); }
.cell-low   { background-color: #dbeafe; color: #14345c; }
.cell-mid   { background-color: #93c5fd; color: #14345c; }
.cell-high  { background-color: #3b82f6; color: #ffffff; }
.cell-vhigh { background-color: #1d4ed8; color: #ffffff; }

/* Absent reads as a texture, not a colour, so it never joins the ramp */
.cell-absent {
  background: repeating-linear-gradient(45deg,
    var(--bg-subtle), var(--bg-subtle) 4px,
    var(--bg-sunken) 4px, var(--bg-sunken) 8px);
  color: var(--ink-3);
  text-align: center;
}

.cell-none {
  background-color: var(--bg);
  color: var(--line-strong);
  text-align: center;
}

.totals-col {
  background-color: var(--bg-sunken) !important;
  font-weight: 500;
}

.session-header {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* The column currently driving the sort */
.session-selected-header {
  background-color: var(--accent-soft) !important;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.session-selected-cell {
  border-left: 1px solid var(--accent) !important;
  border-right: 1px solid var(--accent) !important;
}

.overview-table td.cell-clickable {
  text-align: center;
  cursor: pointer;
}

.session-topic {
  font-size: var(--fs-xs);
}

/* Per-cell breakdown by contribution type */
.cell-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 1px var(--sp-2);
  justify-content: center;
  margin-top: 3px;
  padding-top: 2px;
  border-top: 1px solid currentColor;
  font-size: var(--fs-xs);
  white-space: normal;
  opacity: 0.8;
}

.cell-breakdown > span {
  white-space: nowrap;
}

.overview-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  align-items: center;
  margin-top: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.overview-legend .badge {
  margin-right: var(--sp-1);
}

/* --------------------------------------------------------------------------
   13a. Saved-discussion tracking rows
   -------------------------------------------------------------------------- */

.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--sp-5) var(--sp-6);
}

.student-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
}

.student-row-main {
  min-width: 0;
}

.student-row .student-name {
  font-size: var(--fs-4);
  font-weight: 500;
  margin-bottom: var(--sp-2);
}

.contribution-icons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.contribution-type {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}

.contribution-type i {
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.12s ease;
}

.contribution-badge {
  color: #fff !important;
  font-size: var(--fs-xs);
  cursor: pointer;
}

.student-flags {
  display: flex;
  gap: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.student-flags .form-check-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  margin: 0;
}

.student-flags .form-check-input {
  margin: 0;
  float: none;
}

/* Absentees stay visible but recede */
.student-row.is-dimmed {
  opacity: 0.45;
}

/* Scrollable checkbox list for picking leaders / note takers */
.picker-list {
  max-height: 180px;
  overflow-y: auto;
  margin-top: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
}

/* Running log of what happened during a session */
.activity-log {
  max-height: 220px;
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-4);
  background-color: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.activity-log p {
  margin: 0;
}

.activity-log p + p {
  margin-top: var(--sp-1);
}

/* --------------------------------------------------------------------------
   13b. Run-class screen
   -------------------------------------------------------------------------- */

.instruction-display {
  min-height: 200px;
  font-size: var(--fs-4);
  line-height: 1.7;
}

.instruction-display.cursor-pointer {
  cursor: pointer;
}

/* Instructions are projected to a room, so they stay large */
.instruction-line {
  font-size: var(--fs-1);
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: var(--sp-2);
}

.instruction-editor {
  resize: vertical;
  min-height: 200px;
  font-size: var(--fs-4);
  line-height: 1.7;
}

/* Countdown on the run-class sidebar — smaller than the standalone timer */
.run-timer {
  font-size: 3.25rem;
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: var(--sp-4);
  font-variant-numeric: tabular-nums;
}

.picked-student {
  font-size: var(--fs-2);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
}

/* --------------------------------------------------------------------------
   14. Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  padding: var(--sp-8) 0 0;
  background-color: var(--bg);
  border-right: 1px solid var(--line);
  box-shadow: none;
}

.sidebar-sticky {
  position: relative;
  top: 0;
  height: calc(100vh - 48px);
  padding-top: var(--sp-2);
  overflow-x: hidden;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .px-md-4 {
    padding-left: calc(2rem + 48px);
    padding-right: 2rem;
  }
}

/* --------------------------------------------------------------------------
   15. Timer
   -------------------------------------------------------------------------- */

.timer-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 220px);
  padding: var(--sp-6) var(--sp-5);
}

.timer-container {
  width: 100%;
  text-align: center;
}

.timer-container h3 { margin-bottom: var(--sp-5); }
.timer-container h4 { font-size: var(--fs-2); margin-bottom: var(--sp-5); }

.timer-input-card {
  max-width: 320px;
}

.timer-active-card {
  max-width: 900px;
}

.timer-container input {
  text-align: center;
  font-size: var(--fs-3);
}

.timer-display {
  font-size: clamp(5rem, 22vw, 15rem) !important;
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.timer-controls .btn {
  min-width: 110px;
}

.timer-status .badge {
  background-color: var(--bg-sunken);
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.keyboard-shortcuts kbd {
  background-color: var(--bg-sunken);
  color: var(--ink-2);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}

.timer-pulse {
  animation: timer-pulse 1s infinite;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* --------------------------------------------------------------------------
   15a. Print
   Pages a student may print as a receipt (assignment_submitted) drop the
   site chrome and any controls.
   -------------------------------------------------------------------------- */

@media print {
  .site-header,
  .site-footer,
  .no-print {
    display: none !important;
  }

  .page {
    padding: 0;
    max-width: none;
  }

  .callout,
  .card {
    border-color: #ccc;
    background-color: transparent;
  }

  a {
    color: var(--ink);
    text-decoration: none;
  }
}

/* --------------------------------------------------------------------------
   16. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
  :root {
    --fs-1: 1.75rem;
    --fs-2: 1.375rem;
    --fs-3: 1.125rem;
  }

  .page {
    padding: var(--sp-5) var(--sp-4) var(--sp-7);
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .circle {
    width: 76px;
    height: 76px;
  }
}
