/* Conductor tokens and components (soul.md 3c and 3d). No framework CSS.
   Orange is reserved for the problem and is not used on any student or teacher state. */

:root {
  --ink: #222A4C;
  --blue: #0066E3;
  --orange: #F2681C;
  --grey-1: #5F647C;
  --grey-2: #8E94A6;
  --grey-3: #BABEC9;
  --line: #E5E8ED;
  --ground: #FBFDFF;
  --white: #FFFFFF;
  /* Destructive actions only (SYS-536): things that delete or cannot be undone. 6.0:1 with white. */
  --destructive: #B42318;
  --destructive-hover: #912018;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --t: 200ms;
  --radius: 2px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 18px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
p { margin: 0; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }

.label {
  font: 500 18px/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--grey-1);
}
.label--blue { color: var(--blue); }
.num, .figures dd { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.small { font-size: 18px; }
.side__muted { color: var(--grey-1); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; font: 500 18px var(--mono); letter-spacing: 0.08em; }
/* SYS-737: the locked logo mark (app/templates/_brand.html), 24 px, flat, blue through color. */
.mark { flex: none; color: var(--blue); }
.draft-tag {
  position: fixed; right: 12px; bottom: 8px; margin: 0;
  font: 500 18px var(--mono); letter-spacing: 0.06em; color: var(--grey-1);
  border: 1px dashed var(--grey-3); padding: 2px 6px; background: var(--ground);
}

/* ---- controls: every control has hover, pressed, focus and disabled states ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--ink); border-radius: var(--radius);
  background: var(--white); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), border-color var(--t) var(--ease), transform var(--t) var(--ease);
}
.btn--primary { background: var(--ink); color: var(--white); }
.btn--primary:hover { background: #2E3868; }
.btn--secondary:hover { background: #F1F4F8; }
.btn--inverse { background: var(--white); color: var(--ink); border-color: var(--white); }
.btn--inverse:hover { background: #EEF1F6; }
/* Destructive (SYS-536): delete, revoke, remove, sign and close. Red fill, white text,
   44 px and 18 px at least on every page. Its focus ring is the shared one (focus.css,
   SYS-535): 2 px blue, 2 px off the button, so it shows against the page, not the red. */
.btn--destructive {
  background: var(--destructive); border-color: var(--destructive); color: var(--white);
  min-height: 44px; font-size: max(18px, 1rem); font-weight: 500;
}
.btn--destructive:hover { background: var(--destructive-hover); border-color: var(--destructive-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .btn-text:focus-visible, .starter:focus-visible, .select:focus-visible, .input:focus-visible,
.segmented input:focus-visible + span, .file-list button:focus-visible, .project-list button:focus-visible,
.code-card button:focus-visible, .reply-actions button:focus-visible, a:focus-visible, .linkbox__url:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
.btn:disabled, .btn[aria-disabled="true"] { background: var(--line); border-color: var(--line); color: var(--grey-2); cursor: not-allowed; transform: none; }
.btn--large { min-height: 48px; padding: 12px 24px; }
.btn--block { width: 100%; white-space: normal; text-wrap: balance; } /* a long label wraps evenly (Nectar, #55) */
.btn--icon { width: 44px; min-height: 44px; padding: 0; font-size: 20px; }
.btn-text {
  border: 0; background: none; padding: 2px 4px; cursor: pointer;
  font: 500 18px var(--mono); letter-spacing: 0.06em; color: var(--blue);
  transition: color var(--t) var(--ease);
}
.btn-text:hover { color: var(--ink); }
.btn-text:active { color: #00429A; }
.btn-text:disabled { color: var(--grey-3); cursor: not-allowed; }
.linklike { font-size: 18px; }
.input, .select {
  min-height: 40px; padding: 6px 10px; border: 1px solid var(--grey-1); border-radius: var(--radius); background: var(--white);
  transition: border-color var(--t) var(--ease);
}
.input:hover, .select:hover { border-color: var(--grey-1); }
.input:disabled, .select:disabled { background: var(--line); color: var(--grey-2); }
.input[aria-invalid="true"] { border-color: var(--ink); border-width: 2px; }
.field-error { font-size: 18px; margin-top: 6px; }

/* ---- corner ticks on emphasis boxes ---- */
.tick { position: absolute; width: 10px; height: 10px; border-color: var(--blue); border-style: solid; border-width: 0; pointer-events: none; }
.tick.tl { top: -5px; left: -5px; border-top-width: 2px; border-left-width: 2px; }
.tick.tr { top: -5px; right: -5px; border-top-width: 2px; border-right-width: 2px; }
.tick.bl { bottom: -5px; left: -5px; border-bottom-width: 2px; border-left-width: 2px; }
.tick.br { bottom: -5px; right: -5px; border-bottom-width: 2px; border-right-width: 2px; }

/* ---- state card: what happened, what to do, at most one action. Ink and grey only. ---- */
.state-card { position: relative; border: 1px solid var(--ink); background: var(--white); padding: 20px 22px; display: grid; gap: 6px; }
.state-card__what { font-size: 20px; font-weight: 500; }
.state-card__todo { color: var(--grey-1); }
.state-card .btn { justify-self: start; margin-top: 10px; }
.state-page { max-width: 560px; margin: 0 auto; padding: 48px 20px; display: grid; gap: 32px; }
.state-card--page { padding: 32px; }
.state-card--page .state-card__what { font-size: 28px; }
.state-card--inline { margin-bottom: 20px; }

/* ---- student first screen ---- */
.disclosure { max-width: 720px; margin: 0 auto; padding: 40px 24px 64px; display: grid; gap: 28px; }
.disclosure__head { display: grid; gap: 6px; }
.disclosure__class { font-size: 20px; }
.disclosure__body { display: grid; gap: 22px; }
.disclosure__block { display: grid; gap: 8px; }
.disclosure__block h1 { font-size: 30px; }
.disclosure__block h2 { font-size: 20px; }
.disclosure__adults, .disclosure__remove { font-weight: 500; }
.disclosure__actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 6px; }

/* ---- chat: laptop first, three columns; phone stacks ---- */
.page-chat { overflow: hidden; }
.chat-app { display: grid; grid-template-columns: 280px minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; }
.side { padding: 24px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.side--left { border-right: 1px solid var(--line); }
.side--right { border-left: 1px solid var(--line); }
.side__class { font-size: 18px; font-weight: 500; }
.side__project { font-size: 20px; }
.side__section { display: grid; gap: 8px; margin-top: 10px; }
.side__row { display: flex; justify-content: space-between; align-items: center; }
.side__foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 8px; }
.project-list, .file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.project-list button {
  width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; text-align: left;
  border: 1px solid transparent; background: none; cursor: pointer; border-radius: var(--radius);
  transition: background var(--t) var(--ease);
}
.project-list button:hover { background: #F1F4F8; }
.project-list button[aria-current="true"] { border-color: var(--line); background: var(--white); }
.project-list .count { font: 18px var(--mono); color: var(--grey-1); letter-spacing: 0.06em; }
.file-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; border-bottom: 1px solid var(--line); padding: 8px 0; }
.file-list .file-name { font: 18px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .file-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 2px; }
.file-list .file-size { font: 18px var(--mono); color: var(--grey-1); }
.file-list button { border: 0; background: none; color: var(--blue); cursor: pointer; font: 18px var(--mono); letter-spacing: 0.06em; padding: 4px 0; }
.file-list button:hover { color: var(--ink); }
.meter-card { border: 1px solid var(--line); background: var(--white); padding: 14px 16px; display: grid; gap: 6px; }
.meter-card__count { display: flex; align-items: baseline; gap: 8px; }
.meter-card__count .num { font-size: 34px; min-width: 2ch; text-align: right; }
.meter { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; }
.meter span { height: 6px; background: var(--line); transition: background var(--t) var(--ease); }
.meter span.used { background: var(--blue); }
.clear-confirm { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.clear-confirm span { grid-column: 1 / -1; font-size: 18px; }
.note-card { margin-top: auto; border: 1px solid var(--line); background: var(--white); padding: 14px 16px; display: grid; gap: 6px; }

/* overflow-y auto: if the bar and composer ever outgrow the screen (wide text spacing, a long
   language), the column scrolls instead of cutting them off (SYS-544, WCAG 1.4.12). */
.center { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; min-width: 0; min-height: 0; height: 100%; overflow-x: hidden; overflow-y: auto; }
.center__bar { display: flex; justify-content: space-between; align-items: center; padding: 14px 40px; border-bottom: 1px solid var(--line); }
.model-pill { display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--ink); padding: 6px 12px; font-weight: 500; }
.conn { display: flex; align-items: center; gap: 8px; color: var(--grey-1); font-size: 18px; }
.conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.conn[data-state="offline"] .conn__dot { background: var(--grey-3); }

/* The thread scrolls; nothing below it moves while text streams in. */
.thread { overflow-y: auto; padding: 28px 40px 16px; display: flex; flex-direction: column; gap: 22px; overscroll-behavior: contain; scrollbar-gutter: stable; }
.thread:focus { outline: none; }
.msg { max-width: 880px; width: 100%; margin: 0 auto; display: grid; gap: 8px; }
.msg__who { font: 500 18px var(--mono); letter-spacing: 0.06em; color: var(--blue); }
.msg--user .msg__who { color: var(--grey-1); text-align: right; }
.msg--user .msg__body { justify-self: end; max-width: 80%; background: var(--white); border: 1px solid var(--line); padding: 12px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg--ai .msg__body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; overflow-wrap: anywhere; }
.msg__body > * { min-width: 0; }
.msg--ai .msg__body p { white-space: pre-wrap; }
/* Fixed-height placeholder, shown at once on send. It grows with text, never shrinks. */
.reply-live { min-height: 7.5em; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply-live.is-waiting::after { content: "Claude is writing"; color: var(--grey-1); font: 18px var(--mono); letter-spacing: 0.06em; }
.reply-note { font: 18px var(--mono); color: var(--grey-1); letter-spacing: 0.06em; }
.reply-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.reply-actions button, .code-card button {
  border: 0; background: none; color: var(--grey-1); cursor: pointer; padding: 4px 2px; font-size: 18px;
  transition: color var(--t) var(--ease);
}
.reply-actions button:hover, .code-card button:hover { color: var(--ink); }
.reply-actions button:active, .code-card button:active { color: var(--blue); }
.code-card { border: 1px solid var(--ink); background: var(--white); min-width: 0; max-width: 100%; }
.code-card__bar { display: flex; align-items: center; gap: 16px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.code-card__name { flex: 1; font: 18px var(--mono); }
.code-card pre { margin: 0; padding: 14px 16px; max-height: 420px; overflow: auto; font: 16px/1.6 var(--mono); white-space: pre; }

.empty { max-width: 820px; width: 100%; margin: auto; display: grid; gap: 14px; padding: 24px 0; }
.empty__title { font-size: 44px; }
.empty__lead { color: var(--grey-1); }
.starters { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.starter {
  display: grid; gap: 6px; text-align: left; padding: 18px 20px; background: var(--white); border: 1px solid var(--line);
  cursor: pointer; border-radius: var(--radius); transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.starter:hover { border-color: var(--ink); }
.starter:active { background: #F1F4F8; }
.starter strong { font-weight: 500; font-size: 18px; }
.starter > span:last-child { color: var(--grey-1); }

.banner { margin: 0 40px 12px; background: var(--ink); color: var(--white); padding: 16px 20px; display: flex; align-items: center; gap: 16px; max-width: 880px; justify-self: center; width: calc(100% - 80px); }
.banner__text { flex: 1; display: grid; gap: 2px; }
.banner__what { font-weight: 500; }
.banner__todo { color: #D5D9E4; }

.composer { position: relative; margin: 0 40px; max-width: 880px; justify-self: center; width: calc(100% - 80px); border: 1px solid var(--ink); background: var(--white); padding: 12px 16px; display: grid; gap: 8px; }
.composer__controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.composer__label { color: var(--grey-1); font-size: 18px; }
.segmented { display: inline-flex; border: 1px solid var(--line); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 6px 14px; transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.segmented label:hover span { background: #F1F4F8; }
.segmented input:checked + span { background: var(--ink); color: var(--white); }
.composer__input { border: 0; resize: none; padding: 6px 0; min-height: 72px; max-height: 240px; line-height: 1.5; background: transparent; }
.composer:focus-within { box-shadow: 0 0 0 1px var(--blue); }
.composer__foot { display: flex; align-items: center; gap: 12px; }
.hint { flex: 1; font-size: 18px; color: var(--ink); min-height: 1.5em; }
.hint strong { font-weight: 500; }
.keys { color: var(--grey-1); font-size: 18px; }
.composer-line { text-align: center; color: var(--grey-1); font-size: 18px; padding: 10px 40px 14px; }

.preview { display: grid; gap: 6px; }
.preview__bar { display: flex; justify-content: space-between; align-items: center; }
.preview iframe { width: 100%; height: 420px; border: 1px solid var(--ink); background: var(--white); }

/* ---- teacher ---- */
.topbar { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center; padding: 16px 40px; border-bottom: 1px solid var(--line); }
.topbar__crumb { color: var(--grey-1); }
/* Long button text wraps rather than widening the page (SYS-544, 1.4.10). */
.teacher .btn { white-space: normal; }
.teacher select, .teacher .select { max-width: 100%; }
.teacher > *, .teacher__grid > * { min-width: 0; }
.teacher { max-width: 1040px; margin: 0 auto; padding: 36px 40px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; overflow-wrap: anywhere; }
.teacher__head { display: grid; gap: 6px; }
.teacher__head h1 { font-size: 36px; }
.teacher__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.panel { border: 1px solid var(--line); background: var(--white); padding: 18px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }
.panel__head { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.record { display: grid; gap: 16px; }
.figures { margin: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--white); }
.figures div { padding: 14px 16px; border-right: 1px solid var(--line); display: grid; gap: 4px; }
.figures div:last-child { border-right: 0; }
.figures dd { margin: 0; font-size: 22px; white-space: nowrap; }
.spendbar { display: grid; gap: 4px; }
.spendbar__track { height: 10px; background: var(--line); }
.spendbar__fill { height: 100%; background: var(--ink); transition: width var(--t) var(--ease); }
.spendbar__scale { display: flex; justify-content: space-between; font-size: 18px; color: var(--grey-1); }
.linkbox { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.linkbox__url { flex: 1; min-width: 280px; font: 18px var(--mono); padding: 8px 10px; border: 1px solid var(--grey-1); background: var(--ground); }
.linkbox__off { flex: 1; font-weight: 500; }
.roster { display: grid; gap: 8px; }
.roster__row { display: flex; gap: 10px; }
.roster__row .input { width: 120px; }
/* Close and outcome (SYS-509, frame EmKlE): 18px text, 44px targets. */
.close { font-size: 18px; }
.close .label { font-size: 18px; }
.close .btn, .close .input { min-height: 44px; font-size: 18px; }
.close .input { width: 100%; padding: 8px 12px; border: 1px solid var(--grey-1); border-radius: 0; background: var(--white); }
.close .input:hover { border-color: var(--grey-1); }
.close__lead { color: var(--grey-1); max-width: 720px; }
.close__grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: start; }
.close__hint { color: var(--grey-1); }
.close__value { font-size: 22px; }
.close__error { border-left: 2px solid var(--ink); padding: 8px 12px; background: var(--ground); }
.close__rows { margin: 0; }
.close__rows div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.close__rows dd { margin: 0; text-align: right; }
.outcome { gap: 10px; }
.outcome__actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
@media (max-width: 900px) { .close__grid { grid-template-columns: 1fr; } }

/* ---- smaller screens: phone must work, laptop is the target ---- */
@media (max-width: 1180px) {
  .chat-app { grid-template-columns: 240px minmax(0, 1fr); }
  .side--right { display: none; }
  .side--right.is-open { display: flex; position: fixed; inset: 0 0 0 auto; width: min(420px, 100%); background: var(--ground); z-index: 5; }
}
@media (max-width: 760px) {
  .page-chat { overflow: auto; }
  .chat-app { grid-template-columns: 1fr; grid-template-rows: auto 100dvh; height: auto; min-height: 100dvh; }
  .side--left { border-right: 0; border-bottom: 1px solid var(--line); }
  .side--left .side__section, .side--left .side__foot, .side--left .clear-row { display: none; }
  /* The thread keeps a floor on a phone, so a tall composer never squeezes it (and the
     starters in it) to nothing: the column scrolls instead (SYS-544, WCAG 2.4.11). */
  .center { height: 100dvh; grid-template-rows: auto minmax(min(12rem, 40dvh), 1fr) auto auto auto; }
  .center__bar, .thread { padding-left: 16px; padding-right: 16px; }
  .composer, .banner { margin: 0 12px 10px; width: calc(100% - 24px); }
  .starters { grid-template-columns: 1fr; }
  .empty__title { font-size: 32px; }
  .keys { display: none; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .teacher, .topbar { padding-left: 16px; padding-right: 16px; }
  .teacher__grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---- One confirm pattern for every destructive action (SYS-536): app/templates/_confirm.html
   and app/static/confirm.js. What happens, then Confirm and Back; focus starts on Back. */
.confirm-dialog {
  width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto;
  border: 1px solid var(--ink); border-radius: var(--radius); padding: 28px; color: var(--ink); background: var(--white);
  font-size: 18px; line-height: 1.5;
}
.confirm-dialog[open] { display: grid; gap: 16px; }
.confirm-dialog::backdrop { background: rgba(34, 42, 76, 0.45); }
.confirm-dialog h2 { font-size: 26px; font-weight: 500; margin: 0; }
.confirm-dialog p { margin: 0; }
.confirm-dialog__facts { margin: 0 0 16px; display: grid; gap: 8px; border-left: 3px solid var(--ink); padding: 4px 0 4px 14px; }
.confirm-dialog__facts dt { font: 500 18px var(--mono); letter-spacing: 0.04em; color: var(--grey-1); }
.confirm-dialog__facts dd { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.confirm-dialog__warn { font-weight: 500; }
.confirm-dialog__actions { display: flex; gap: 12px; flex-wrap: wrap; }
.confirm-dialog__actions .btn { min-height: 44px; font-size: max(18px, 1rem); }

