/* ==========================================================================
   the_interactor — an attendance ledger.

   The subject is a session recording. Meet produces a transcript, a chat log and
   a sheet of who stayed how long; those three become marks in RollCall, which is
   the institution's record and is visible to students. Everything on this page
   exists to answer two questions before anything is written: who is drifting,
   and what exactly is about to be written.

   So the page is built as an instrument rather than a report. Colour is
   semantic and appears nowhere else: green is present, red is absent, amber is
   something a human must look at, indigo is "this is the write". Those four
   carry every meaning on the page and there is no fifth.

   Inter carries operational language; Plex Mono carries exact quantities,
   identifiers, and timestamps so columns remain aligned as values change. The
   shared Course Ops stylesheet owns that typography and the common chrome.

   The signature element is the term matrix, drawn as a strip chart rather than a
   grid of coloured cells. A heatmap answers "high or low" and throws the
   quantity away. Here each student is a hairline track and each session is a
   column in which speaking turns rise from a shared baseline, with the
   presence square set above it, sized by how long the student stayed. The point
   is to make a shape visible -- attended every week but stopped talking in week
   six -- without reading a single number.
   ========================================================================== */

/* ---------------------------------------------------------- domain layout */

:root {
  --spine: 208px;
  --aside: 348px;
  --cell-w: 50px;
  --cell-h: 38px;
  --name-col: minmax(150px, 220px);
  --detail: 330px;
}

/* ------------------------------------------------------------------- base */

html, body { height: 100%; }
body { overflow: hidden; }

h1, h2, h3 { margin: 0; font-weight: 600; }

button { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ shell */

.shell {
  display: grid;
  grid-template-columns: var(--spine) minmax(0, 1fr) var(--aside);
  grid-template-rows: 52px auto auto minmax(0, 1fr) 28px;
  grid-template-areas:
    'top   top      top'
    'pipe  pipe     pipe'
    'run   run      run'
    'spine main     aside'
    'foot  foot     foot';
  height: 100vh;
}

.btn[data-size='sm'] { min-height: 28px; padding: 4px 9px; font-size: 11px; }
.btn[data-variant='ghost'] { background: transparent; }

/* --------------------------------------------------------------- pipeline */

/* Four stages, left to right, with the numbers each one is actually holding.
   A stalled run should be obvious here rather than discovered by reading a
   command's output an hour later. */
.pipeline {
  grid-area: pipe;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
}

.stage {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 15px;
  border-right: 1px solid var(--rule-soft);
  /* Never compress below the figures: a stage squeezed until its labels collide
     reads as three unrelated words rather than as a step in a sequence. The
     strip scrolls instead. */
  flex: 1 0 auto;
  min-width: 214px;
  cursor: default;
}
.stage:last-child { border-right: 0; }

/* A dot, because a stage's state is a single fact and a word is four. */
.stage-dot {
  width: 7px; height: 7px; border-radius: 99px; flex: none;
  background: var(--ink-3);
}
.stage[data-state='ok'] .stage-dot { background: var(--ok); }
.stage[data-state='warn'] .stage-dot { background: var(--flag); }
.stage[data-state='blocked'] .stage-dot { background: var(--ink-3); box-shadow: 0 0 0 3px var(--flag-wash); }

.stage-body { min-width: 0; }
.stage-name {
  font-size: 12px; font-weight: 600; letter-spacing: -0.01em;
  display: flex; align-items: baseline; gap: 7px;
}
.stage-name .stage-detail {
  font-weight: 400; font-size: 11px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stage-metrics { display: flex; gap: 11px; margin-top: 1px; }
.stage-metric { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.stage-metric b { color: var(--ink); font-weight: 500; }
.stage[data-state='warn'] .stage-metric b { color: var(--flag); }

/* The connector: reads as a sequence, which is what it is. */
.stage + .stage { position: relative; }
.stage + .stage::before {
  content: '';
  position: absolute;
  left: -1px; top: 50%;
  width: 1px; height: 60%;
  transform: translateY(-50%);
  background: var(--rule);
}

/* ------------------------------------------------------------------ spine */

.spine {
  grid-area: spine;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.spine-label, .aside-label, .section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.spine-list { flex: 1; }

.cohort {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 6px 9px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.cohort:hover { background: var(--surface-2); }
.cohort[aria-current='true'] {
  background: var(--surface-2);
  border-color: var(--accent-line);
}

.cohort-course {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.cohort-name {
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.cohort-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 5px;
  font-size: 11px;
  color: var(--ink-3);
}
/* The dot belongs to the fact that follows it, so a wrap never strands it at
   the end of a line. */
.cohort-meta .sep { white-space: nowrap; }
.cohort-meta .sep::before {
  content: '· ';
  color: var(--ink-3);
  opacity: 0.7;
}

/* Delivery is a safety property, not decoration, so it is marked in words.
   "hand" reads faster than a colour a colour-blind reader cannot see. */
.delivery {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--rule);
  color: var(--ink-3);
}
.delivery[data-automation='true'] {
  border-color: var(--accent-line);
  color: var(--accent-ink);
}

.spine-foot { border-top: 1px solid var(--rule-soft); padding-top: 9px; margin-top: 9px; }
.spine-meta { font-size: 11px; color: var(--ink-3); }

/* ------------------------------------------------------------------- main */

.main {
  grid-area: main;
  overflow-y: auto;
  padding: 16px 18px 28px;
  outline: none;
}

.loading { color: var(--ink-3); padding: 40px 0; text-align: center; }

.empty {
  border: 1px dashed var(--rule);
  border-radius: var(--r);
  padding: 34px 26px;
  color: var(--ink-2);
  max-width: 620px;
}
.empty h2 { margin-bottom: 8px; }
.empty p { font-family: var(--sans); margin: 0 0 10px; }
.empty code {
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1px 5px;
}

.crumb {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.crumb h1 { font-size: 14px; letter-spacing: -0.01em; }
.crumb-meta { color: var(--ink-3); font-size: 11px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  font-size: 10.5px;
  color: var(--ink-3);
  margin: 12px 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule-soft);
}
.legend-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-swatch {
  width: 11px; height: 11px; border-radius: 2px;
  display: inline-block; flex: none;
}
.legend-bar {
  width: 9px; background: var(--ink-2); display: inline-block; flex: none; border-radius: 1px;
}

/* ------------------------------------------------------- the term matrix */

/* The matrix is a working table, not a chart floating in space. It carries the
   figures that make a row worth reading -- attendance, minutes, turns -- so a
   teacher can act on what they see without hovering anything. */
.matrix-panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: auto;
  /* The edge of the table is the edge of the panel, so a shadow there is a
     lie about where the data ends. The shadow belongs on the pinned block
     instead -- it says "the sessions continue under me", which is the thing
     a reader needs to know when a column is missing. */
  position: relative;
}

/* The pinned cells fill the gap to their right, or the sessions sliding
   under them show a sliver of themselves in it.

   The last of them also casts a rule, so the seam between "who this is" and
   "when they came" is visible rather than implied. It appears only once the
   table has actually scrolled -- a rule standing at the edge of a table that
   is not moving is a line with no meaning. */
.mx-pin { box-shadow: 2px 0 0 var(--surface); }

/* The last pinned cell fades what slides under it.

   A hard edge slices a date in half, and a half date reads as a broken one
   rather than as a column that is out of the way. The fade says the same
   thing and says it without lying about the data. */
.matrix-head .mx-chat::after {
  content: '';
  position: absolute;
  right: -20px;
  top: 0;
  bottom: 0;
  width: 20px;
  pointer-events: none;
  /* Solid across the gap so a date sliding under is hidden rather than
     sliced, then a short fade so the edge does not look cut. A column that
     is half under the frozen block still shows a little of itself -- every
     spreadsheet does this -- but it fades rather than stopping dead. */
  background: linear-gradient(to right, var(--surface) 0 11px, transparent 20px);
}

/* The identity block is pinned; the sessions scroll.

   A term is a dozen columns wide and a panel is not. The name and the four
   figures beside it are what a row *is* -- who this is, how often they came,
   how long they stayed -- and they are what a reader looks down while the
   sessions scroll past. So they stay put, and only the sessions move.

   The widths are fixed rather than proportional so the pin offsets can be
   exact. A sticky column needs to know where the one to its right begins. */
.matrix {
  --mx-name: 200px;
  --mx-att: 42px;
  --mx-time: 50px;
  --mx-turns: 36px;
  --mx-chat: 30px;
  --mx-gap: 2px;
  --pin-att: calc(var(--mx-name) + var(--mx-gap));
  --pin-time: calc(var(--pin-att) + var(--mx-att) + var(--mx-gap));
  --pin-turns: calc(var(--pin-time) + var(--mx-time) + var(--mx-gap));
  --pin-chat: calc(var(--pin-turns) + var(--mx-turns) + var(--mx-gap));

  display: grid;
  grid-template-columns:
    var(--mx-name) var(--mx-att) var(--mx-time) var(--mx-turns) var(--mx-chat)
    repeat(var(--cols), minmax(var(--cell-w), 1fr));
  gap: 0 var(--mx-gap);
  align-items: end;
  width: max-content;
  min-width: 100%;
}

/* One column for the whole term, when there are too many sessions to show
   one column each. */
.matrix--term {
  grid-template-columns:
    var(--mx-name) var(--mx-att) var(--mx-time) var(--mx-turns) var(--mx-chat)
    minmax(var(--mx-term), 1fr);
}

/* The pinned block. Opaque, so the sessions do not show through it, and
   above the cells they slide under. */
.mx-pin {
  position: sticky;
  background: var(--surface);
  z-index: 3;
}
.mx-name { left: 0; }
.matrix-name { left: 0; }
.mx-att { left: var(--pin-att); }
.mx-time { left: var(--pin-time); }
.mx-turns { left: var(--pin-turns); }
.mx-chat { left: var(--pin-chat); }

/* The header sits above the rows it heads, and its pinned cells above even
   that, so a row scrolled under the header is hidden by both. */
.matrix-head { z-index: 4; }
.matrix-head .mx-pin { z-index: 6; }

/* A row that is selected is washed, and the wash has to run through the
   pinned cells too or the highlight breaks at the first column. */
.mx-pin[data-picked='true'] { background: var(--accent-wash); }

/* Column headings for the figures, so the numbers mean something on sight. */
.mx-fig {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-align: right;
  padding: 0 6px 6px 0;
  border-bottom: 1px solid var(--rule-soft);
  white-space: nowrap;
}

.matrix-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}
/* One line per column, so a date sits directly over the marks it describes.

   The header used to be three lines -- date, time, count -- and the pinned
   labels sat in the middle of it. The dates then ran across the whole width
   while the marks below them were only the ones that had not scrolled away,
   so the header said one thing and the table said another. One line, and a
   date is above its own column. */
.mx-head-cell {
  display: flex;
  /* Aligned to the bottom of the header row, because the pinned labels sit
     there. A date one line above the label beside it is a date that does not
     line up with the marks under it. */
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 24px;
  padding: 0 2px 5px 2px;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  white-space: nowrap;
}
.mx-date { font-size: 10.5px; color: var(--ink); font-weight: 500; }
.mx-head-cell:hover .mx-date { color: var(--accent-ink); }
.mx-count { font-size: 11px; color: var(--ink-3); }

.matrix-name {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  height: var(--cell-h);
  /* The name sits on the same baseline as the bars rather than floating in the
     middle of its row. Centring it made each name look like it belonged to the
     marks below it. */
  padding: 0 8px 4px 8px;
  font-size: 12px;
  min-width: 0;
  border-left: 2px solid transparent;
  cursor: pointer;
}
.matrix-name .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.matrix-name .flag { color: var(--flag); font-size: 11px; flex: none; }

/* The figures. Right-aligned, tabular, dim by default -- the marks are the
   picture and these are the caption. */
.fig {
  font-size: 11px;
  color: var(--ink-2);
  text-align: right;
  padding: 0 6px 4px 0;
  height: var(--cell-h);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}
.fig[data-zero='true'] { color: var(--ink-3); opacity: 0.55; }

.matrix-name[aria-selected='true'] {
  background: var(--accent-wash);
  border-left-color: var(--accent);
}
.matrix-name:hover { background: var(--surface-2); }

/* One glyph per student per session: the speaking bar grows from the baseline,
   and the presence square caps it. Stacking them rather than setting the square
   in a corner is what makes the cell read as one mark instead of two things
   that happen to share a box. */
.cell {
  position: relative;
  height: var(--cell-h);
  width: 100%;
  display: block;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: default;
}

.cell::after {
  content: '';
  position: absolute;
  left: 3px; right: 3px; bottom: 6px;
  height: 1px;
  background: var(--rule);
}
.cell:hover::after, .cell:focus-visible::after { background: var(--ink-3); }

.stack {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 1.5px;
}

.cell .talk {
  width: 11px;
  height: var(--h, 0px);
  min-height: 1px;
  background: var(--ink-2);
  border-radius: 1px 1px 0 0;
  transition: height var(--t);
}
.cell .square {
  width: var(--sq, 6px);
  height: var(--sq, 6px);
  border-radius: 1.5px;
  background: var(--ok);
  opacity: 0.5;
  flex: none;
  transition: opacity var(--t-fast);
}
.cell:hover .square { opacity: 0.85; }

/* Chat turns: thinner and set beside the bar, never stacked, so the two
   measures never read as one quantity. */
.cell .chat {
  position: absolute;
  bottom: 7px;
  left: calc(50% + 9px);
  width: 4px;
  height: var(--hc, 0px);
  min-height: 0;
  background: var(--ink-3);
  opacity: 0.7;
  border-radius: 1px 1px 0 0;
}

/* Absent: a hollow tick on the baseline and nothing above it. The absence of
   height is the whole message, so this cell stays quiet. */
.cell[data-state='absent']::before {
  content: '';
  position: absolute;
  bottom: 3px; left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border: 1px solid var(--bad);
  border-radius: 50%;
  opacity: 0.55;
}

/* Attendance inferred from the transcript roster is the weaker kind, and the
   square says so rather than presenting it as equal evidence. */
.cell[data-source='transcript'] .square { background: var(--flag); }

.matrix-row-quiet .who { color: var(--ink-2); }

/* --------------------------------------------------------------- controls */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar .spacer { flex: 1; }

.filter {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 3px 10px;
  font-size: 11px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.filter:hover { border-color: var(--ink-3); }
.filter[aria-pressed='true'] {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}
.filter .n { color: var(--ink-3); margin-left: 5px; }
.filter[aria-pressed='true'] .n { color: var(--accent-ink); }

.search {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 4px 9px;
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  width: 170px;
}
.search::placeholder { color: var(--ink-3); }

select.sortby {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 4px 7px;
  font: inherit;
  font-size: 11px;
  color: var(--ink-2);
}

/* ------------------------------------------------------------ main layout */

.main-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--detail);
  gap: 16px;
  align-items: start;
}
.main-split > * { min-width: 0; }

.detail {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 13px 14px 15px;
  position: sticky;
  top: 0;
}
.detail h2 { font-size: 13px; margin-bottom: 2px; }
.detail .sub { font-size: 10.5px; color: var(--ink-3); margin-bottom: 11px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule-soft);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.stat {
  background: var(--surface);
  padding: 7px 9px;
}
.stat .v { font-size: 14px; font-weight: 500; line-height: 1.25; }
.stat .l { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.stat[data-tone='flag'] .v { color: var(--flag); }
.stat[data-tone='ok'] .v { color: var(--ok); }

/* Per-session figures inside the detail panel. Two shapes share this: a date
   row when a student is selected, and a name row when a session is. The first
   column carries different things, so they get different tracks -- one grid for
   both squeezed names into 52px and made the session list unreadable. */
.mini {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 34px 28px 34px;
  gap: 0 7px;
  align-items: center;
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.mini--person { grid-template-columns: minmax(0, 1fr) 46px 34px 28px 34px; }
.mini-head-row { padding-top: 0; border-bottom: 1px solid var(--rule-soft); }
.mini:last-child { border-bottom: 0; }
.mini .d { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .n { text-align: right; color: var(--ink-3); font-size: 10.5px; }
.mini[data-state='absent'] .d { color: var(--ink-3); }
.mini:hover { background: var(--surface-2); }

/* A session lists everyone, so it scrolls inside the card rather than running
   past the fold. */
.mini-scroll {
  max-height: 292px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.mini-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); border-bottom: 0; padding-bottom: 6px;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}

.bars { display: flex; align-items: flex-end; gap: 1.5px; height: 20px; }
.bars i {
  display: block; width: 5px; background: var(--ink-2);
  border-radius: 1px 1px 0 0; min-height: 1px;
}
.bars i[data-kind='chat'] { background: var(--ink-3); width: 3px; }

/* ------------------------------------------------------------------ aside */

.aside {
  grid-area: aside;
  background: var(--surface);
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  padding: 14px 15px 24px;
}
.aside-body > * + * { margin-top: 20px; }

.card { border-top: 1px solid var(--rule-soft); padding-top: 13px; }
.card:first-child { border-top: 0; padding-top: 0; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}
.card-head h2 { font-size: 12px; }
.card-head .n { color: var(--ink-3); font-size: 11px; }

/* A heading that opens and closes the card under it.

   The count stays outside the toggle so a shut card still says how much is
   in it -- a closed card that says nothing is the same as an empty one, and
   "five things need attention" is the reason to open it. */
.card-toggle {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 24px;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.card-toggle h2 { font-size: 12px; font-weight: 500; }
.card-toggle:hover h2 { color: var(--accent-ink); }
.card-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.caret {
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  color: var(--ink-3);
  flex: none;
  align-self: center;
  transition: transform var(--t-fast);
}
.caret[data-open='true'] { transform: rotate(90deg); }

/* A card that is shut takes no vertical room. */
.card-body[hidden] { display: none; }
.card-body { margin-top: 2px; }

.btn-tiny {
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 2px 8px;
  font-size: 10.5px;
  color: var(--ink-3);
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.btn-tiny:hover { color: var(--ink); border-color: var(--ink-3); }

/* The headline is the decision, written as the decision. */
.verdict {
  border: 1px solid var(--accent-line);
  background: var(--accent-wash);
  border-radius: var(--r);
  padding: 12px 13px;
}
.verdict h2 { font-size: 13px; color: var(--accent-ink); margin-bottom: 3px; }
.verdict p { margin: 0; font-size: 11px; color: var(--ink-2); font-family: var(--sans); }
.verdict[data-state='blocked'] {
  border-color: var(--flag-line);
  background: var(--flag-wash);
}
.verdict[data-state='blocked'] h2 { color: var(--flag); }

.rows { display: flex; flex-direction: column; gap: 1px; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--rule-soft);
}
.row:last-child { border-bottom: 0; }
.row .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .was { color: var(--ink-3); font-size: 10.5px; }
.row .arrow { color: var(--ink-3); }

/* A conflict is a sentence, not a label. Truncating it hides the one part
   that identifies the student it is about. */
.row--detail {
  display: block;
  padding: 6px 0 8px;
  border-bottom: 1px solid var(--rule-soft);
}
.row--detail .what { display: block; }
.row--detail .what .who { display: block; white-space: normal; }
.row--detail .tag { display: inline-block; margin-top: 4px; }

.tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag[data-state='present'] { color: var(--ok); border-color: var(--ok); }
.tag[data-state='absent'] { color: var(--bad); border-color: var(--bad); }
.tag[data-state='held'] { color: var(--flag); border-color: var(--flag-line); }

.note {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-2);
  border-left: 2px solid var(--rule);
  padding-left: 9px;
  margin: 8px 0 0;
}
.note[data-kind='conflict'] { border-left-color: var(--flag); }

/* ------------------------------------------------------------------ footer */

.footbar > span { overflow: hidden; text-overflow: ellipsis; }
.foot-warmup { margin-left: auto; color: var(--flag); flex: none; }

/* -------------------------------------------------------------------- tip */

.tip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: 280px;
}
.tip b { font-weight: 600; }
.tip .k { color: var(--ink-3); }

/* ------------------------------------------------------------ narrow view */

@media (max-width: 1400px) {
  .main-split { grid-template-columns: minmax(0, 1fr); }
  .detail { position: static; }
}

@media (max-width: 900px) {
  .stage-grid { grid-template-columns: minmax(0, 1fr); }
  .stage-grid > .panel--wide { grid-column: auto; }
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: var(--spine) minmax(0, 1fr);
    grid-template-areas:
      'top   top'
      'pipe  pipe'
      'spine main'
      'foot  foot';
  }
  .aside { display: none; }
  .stage-detail { display: none; }
}

@media (max-width: 720px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) 28px;
    grid-template-areas:
      'top'
      'pipe'
      'spine'
      'main'
      'foot';
  }
  .spine { border-right: 0; border-bottom: 1px solid var(--rule); max-height: 148px; }
  .cohort { display: inline-block; width: auto; margin-right: 6px; }
  .cohort-course { display: none; }
  .spine-list { white-space: nowrap; overflow-x: auto; }
  .main { padding: 12px 12px 20px; }
  .stage-metrics { display: none; }
  .matrix-name .flag { display: none; }
  .footbar { gap: 12px; }
  .foot-warmup { display: none; }
}

/* ------------------------------------------------------- running work */

/* A stage the page started. Visible above everything else, because the first
   question after pressing a button is "did it work and what did it say". */
.runbar {
  grid-area: run;
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 15px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
}
.runbar[hidden] { display: none; }
.runbar-dot {
  width: 7px; height: 7px; border-radius: 99px; flex: none;
  background: var(--ink-3);
}
.runbar-dot[data-status='running'] { background: var(--flag); animation: pulse 1.1s ease-in-out infinite; }
.runbar-dot[data-status='ok'] { background: var(--ok); }
.runbar-dot[data-status='failed'] { background: var(--bad); }
.runbar-spacer { flex: 1; }
.runbar-time { color: var(--ink-3); }

@keyframes pulse { 50% { opacity: 0.25; } }

/* --------------------------------------------------------- stage pages */

.stage-page { max-width: 1080px; }
/* A plain two-column grid with the panels placed in it directly.

   The earlier shape -- a 1.7fr column beside a 1fr column, each a flex stack --
   produced ragged panel bottoms, three columns on one page and two on the next,
   and a 1080px island of content in a much wider area. Every stage page now has
   the same shape: panels tile across two equal columns, each row's panels are
   stretched to the same height, and a panel that needs the width says so.
*/
.stage-page { max-width: none; }
.stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  margin-top: 16px;
}
.stage-grid > .panel { min-width: 0; }
/* A row that holds one panel should span, not leave a hole beside it. */
.stage-grid > .panel--wide { grid-column: 1 / -1; }

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

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 12px 14px 14px;
  min-width: 0;
  /* Two panels in a row share a height, so their rules line up across the page
     instead of ending wherever their content stopped. */
  display: flex;
  flex-direction: column;
}
.panel > .rows, .panel > .kv { flex: 1 1 auto; }
.panel-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.kv { display: flex; flex-direction: column; }
.kv-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 12px;
}
.kv-row:last-child { border-bottom: 0; }
.kv-k {
  color: var(--ink-3);
  flex: 0 1 auto;
  min-width: 0;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Values must not wrap into a column of three words. A key/value table that
   wraps reads as prose, and the eye stops being able to compare across rows. */
.kv-v {
  color: var(--ink);
  flex: 1 1 auto;
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}
.run-hint { font-size: 11px; max-width: 52ch; }

/* The one live control on the page. Disabled state is the interlock made
   visible: you can see it is off, not wonder why it is missing. */
.btn-push {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: var(--accent-ink);
  font-weight: 500;
}
.btn-push:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-push:disabled,
.btn-push[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--surface-2);
  border-color: var(--rule);
  color: var(--ink-3);
}
.btn-push[disabled]:hover { background: var(--surface-2); }

.btn-danger {
  background: var(--bad-wash);
  border-color: var(--bad);
  color: var(--bad);
  font-weight: 500;
}
.btn-danger:hover { background: var(--bad); color: #fff; }

/* The button and its confirmation travel as one block, so an answer is always
   drawn directly beneath the control that asked for it. Stacked rather than
   inline because in the narrow aside the two would not fit on one line, and a
   confirm row that wraps mid-sentence is worse than one that starts below. */
.push-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.push-control--sm {
  flex-direction: column;
  /* Sized to its words, so the button reads as the thing you press rather
     than as a second banner under the verdict. The confirmation is now a modal
     overlay, so no inline layout rules are needed here. */
  align-items: flex-start;
  gap: 7px;
}

/* The confirmation is a modal overlay, not an inline panel. */
.confirm-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 100;
  overscroll-behavior: contain;
  animation: confirm-fade-in 120ms ease-out;
}

@keyframes confirm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.confirm-modal {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  max-width: 420px;
  width: min(92vw, 420px);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  text-align: left;
  overflow: hidden;
  animation: confirm-scale-in 140ms ease-out;
}

@keyframes confirm-scale-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.confirm-modal-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--rule);
}

.confirm-modal-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.confirm-modal-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.confirm-modal-body {
  padding: 14px 18px;
}

.confirm-modal-message {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink);
}
.confirm-modal-when {
  margin: 6px 0 0;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.confirm-modal-body p + p { margin-top: 8px; }

.confirm-modal-warning {
  margin: 0;
  font-size: 12px;
  color: var(--ink-2);
}

.confirm-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 18px 14px;
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
}

.confirm-modal-actions .btn {
  min-width: 120px;
}

.confirm {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  flex: 1 1 260px;
}
/* In the aside the row owns the full width, so the text gets a line of its own
   and the two buttons sit together under it. */
.push-control--sm .confirm {
  flex: 1 1 100%;
  gap: 6px;
}
.blocked-note {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--flag);
  border-left: 2px solid var(--flag);
  padding-left: 9px;
}

.output { margin-top: 14px; }
.output-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--ink-3);
  margin-bottom: 5px;
}
.output pre {
  margin: 0;
  padding: 11px 13px;
  background: var(--desk);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  max-height: 340px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Stages are buttons, so they need button reset and a visible open state. */
.stage {
  font: inherit;
  color: inherit;
  text-align: left;
  border-top: 0; border-bottom: 0; border-left: 0;
  background: transparent;
  position: relative;
}
.stage[aria-current='true'] { background: var(--surface-2); }
.stage[aria-current='true']::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--accent);
}
.stage:hover { background: var(--surface-2); }
.stage-when { margin-left: auto; white-space: nowrap; }

.verdict-actions { margin-top: 10px; }
.btn-sm { padding: 4px 9px; font-size: 11px; }

/* One reconciled session: when it ran, where the attendance came from, what it
   produced. Three facts on one line, because they are one fact each. */
.sess {
  display: grid;
  grid-template-columns: minmax(0, auto) auto minmax(0, 1fr);
  align-items: baseline;
  gap: 9px;
  padding: 5px 0;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 12px;
}
.sess:last-child { border-bottom: 0; }
.sess-when { color: var(--ink-2); white-space: nowrap; }
.sess .tag { font-size: 11px; padding: 0 5px; }
.sess-what { color: var(--ink-3); text-align: right; }

/* ------------------------------------------------------------- the term strip

   A term viewed whole. One column per student, one mark per session, so the
   table's width grows by four pixels a session instead of fifty. A gap in the
   strip is a session someone missed, which is exactly the thing a teacher
   scanning down the column is looking for.

   The strip is not a replacement for the per-session cells -- those carry the
   speaking and chat detail -- it is the way to see the shape of a term at a
   glance when there are too many sessions to lay out side by side. */

.term-strip {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
  height: var(--cell-h);
  padding: 0 4px 7px 4px;
  overflow: hidden;
}
.term-mark {
  width: 4px;
  flex: none;
  height: 3px;
  border-radius: 1px;
  background: var(--ink-3);
  opacity: 0.35;
  align-self: flex-end;
}
.term-mark[data-state='present'] {
  height: var(--sq, 4px);
  background: var(--ok);
  opacity: 0.65;
}
.term-mark[data-state='absent'] {
  height: 2px;
  background: var(--bad);
  opacity: 0.5;
  border-radius: 99px;
}
.term-strip .term-head {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  width: 100%;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.35;
  padding: 0 4px 6px 4px;
  border-bottom: 1px solid var(--rule-soft);
  white-space: nowrap;
}
.term-strip .term-head b { color: var(--ink-2); font-weight: 500; }

/* A two-way switch, for a choice that is really a choice. */
.segmented {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
}
.seg {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--rule);
  padding: 4px 11px;
  font: inherit;
  font-size: 11px;
  color: var(--ink-3);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.seg:last-child { border-right: 0; }
.seg:hover { color: var(--ink); }
.seg[aria-pressed='true'] {
  background: var(--accent-wash);
  color: var(--accent-ink);
}

/* Search and sort are one control to the reader, so they wrap as one. */
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* A list that grows with the term. The count above it says how many there
   are, so a scrolled list never hides anything without saying so. */
.rows--scroll {
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* When the sessions run past the panel, the right edge fades out. Overlay
   scrollbars are invisible until you scroll, and a column sliced through the
   middle looks like a rendering fault rather than more data. */
.matrix-wrap { position: relative; }
.matrix-wrap::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--surface));
  opacity: 0;
  transition: opacity var(--t-fast);
}
.matrix-wrap[data-more='right']::after,
.matrix-wrap[data-more='both']::after { opacity: 1; }
.matrix-wrap[data-more='left']::before,
.matrix-wrap[data-more='both']::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  bottom: 1px;
  width: 28px;
  pointer-events: none;
  z-index: 7;
  background: linear-gradient(to right, var(--surface), transparent);
  opacity: 1;
}

/* ------------------------------------------------------ the RollCall card

   The verdict, the control that acts on it, and the sessions it would act
   on. Three things, and they were stacked with no rhythm between them: the
   button read as a section heading because it was a full-width bordered box,
   and the session rows were a flex line whose three figures lined up with
   nothing. */

/* The control sits inside the verdict, so its left edge is the verdict's left
   edge. Every line in the card starts in the same place. */
.verdict-actions {
  margin-top: 13px;
  display: flex;
  justify-content: flex-start;
}
.verdict-actions .btn-push { width: auto; }

/* The sessions are a table of three columns, so the eye can run down them. */
.rc-sessions { margin-top: 12px; }
.rc-session {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 4px 10px;
  padding: 5px 0;
}
.rc-when {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.rc-when b { font-weight: 500; color: var(--ink-2); font-size: 12px; }
.rc-time { color: var(--ink-3); font-size: 10.5px; }
.rc-count {
  color: var(--ink-3);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rc-count-sep { margin: 0 3px; opacity: 0.7; }
.rc-what { justify-self: end; }

/* A row with marks to send is a control, not a status line. The tag says
   "Write N" because "N to write" is a fact and this is an action. */
button.rc-session,
button.rc-push {
  width: 100%;
  background: transparent;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--r-sm);
}
button.rc-session {
  padding: 5px 6px;
  margin: 0 -6px;
}
button.rc-session:hover,
button.rc-push:hover {
  background: var(--surface-2);
}
button.rc-session:focus-visible,
button.rc-push:focus-visible {
  outline: 1px solid var(--accent-line);
  outline-offset: 1px;
}
button.rc-session[data-asked='true'],
button.rc-push[data-asked='true'] {
  background: var(--accent-wash);
}
.rc-hint {
  margin: 8px 0 0;
  font-family: var(--sans);
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--ink-3);
}
