/* Trailpost staff pages (teacher + school admin), shared shell.
   PROVISIONAL (M9 U8/U8a): Simon hasn't mocked these screens in the current
   system yet. Built inside it: tokens, fonts, rail + main layout, pills,
   focus rings and states copied from DESIGN.md / wiki/DESIGN-UI-COMPONENTS.md
   and the student app (index.html). Replace with his mocks when they land. */
:root {
  --paper:      #FBF7F0;
  --paper-2:    #F3EEE5;
  --card:       #FFFFFF;
  --line:       #E2DBCF;
  --grey-300:   #CFC7BA;
  --grey-600:   #625B51;
  --grey-700:   #4A453E;
  --ink:        #1C1916;
  --on-ink:     #FBF7F0;
  --orange:       #F4600C;
  --orange-hover: #FF7A2F;
  --orange-soft:  #FDE6D6;
  --yellow:       #F6D55C;
  --yellow-soft:  #FBEBB0;
  --ok:         #2F7D4F;
  --ok-soft:    #E3EFE7;
  --ok-text:    #215A38;
  --danger:     #B3261E;
  --danger-soft: #F7E7E4;
  --font-sans:  "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans); font-size: 16px; line-height: 1.6;
  color: var(--ink); background: var(--paper); overflow: hidden;
}
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--ink); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--yellow); color: var(--ink); }
* { scrollbar-width: thin; scrollbar-color: var(--grey-300) transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- frame: rail + main ---------- */
.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.rail {
  background: var(--paper-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px 16px; min-height: 0;
}
.wordmark { display: flex; align-items: center; gap: 10px; padding: 2px 8px 6px; }
.wordmark-mark { width: 30px; height: 30px; background: var(--orange); border-radius: 9px; display: grid; place-items: center; flex: none; }
.wordmark-mark svg { width: 16px; height: 16px; stroke: var(--ink); }
.wordmark-name { font-weight: 800; font-size: 20px; letter-spacing: -0.01em; }
.rail-role { font-size: 13px; color: var(--grey-600); padding: 0 8px 22px 48px; line-height: 1.3; }
.rail-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -6px; padding: 0 6px; }
.rail-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--grey-600); padding: 0 10px 10px; }
.space-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.space-item {
  display: block; width: 100%; text-align: left; text-decoration: none;
  padding: 9px 12px; border-radius: 12px; color: var(--grey-700); transition: background 150ms;
}
.space-item:hover { background: var(--card); color: var(--ink); }
.space-item.active { background: var(--orange-soft); color: var(--ink); }
.space-item.active .space-title { font-weight: 600; }
.space-title { display: block; font-size: 15px; line-height: 1.4; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.space-sub { display: block; font-size: 12.5px; color: var(--grey-600); line-height: 1.35; }
.rail-empty { font-size: 13.5px; color: var(--grey-600); padding: 0 12px; line-height: 1.5; }
.rail-skel { display: grid; gap: 10px; padding: 4px 12px; }
.rail-switch {
  display: flex; align-items: center; gap: 8px; margin: 12px 4px 0; padding: 0 12px; min-height: 44px;
  border-radius: 999px; border: 1.5px solid var(--ink); font-size: 14px; font-weight: 600; text-decoration: none;
  transition: background 150ms, color 150ms;
}
.rail-switch:hover { background: var(--ink); color: var(--on-ink); }
.rail-switch svg { width: 16px; height: 16px; flex: none; }
.rail-switch + .rail-switch { margin-top: 8px; }
.rail-foot { margin-top: 12px; border-top: 1px solid var(--line); padding: 14px 4px 2px 10px; display: flex; align-items: center; gap: 10px; }
.rail-avatar {
  width: 36px; height: 36px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none;
}
.rail-user { min-width: 0; flex: 1; }
.rail-user-name { font-size: 14px; font-weight: 600; line-height: 1.3; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rail-user-sub { font-size: 12.5px; color: var(--grey-600); line-height: 1.3; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.main { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 32px; border-bottom: 1px solid var(--line); min-height: 64px;
}
.head h2 { font-size: 17px; font-weight: 700; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.head .spacer { flex: 1; }
.page { overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding: 28px 32px 48px; }
.page-inner { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 36px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h3 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.section-head .count { font-size: 14px; color: var(--grey-600); }
.lede { font-size: 15px; color: var(--grey-700); max-width: 65ch; margin: -6px 0 16px; }

/* ---------- badges and chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; white-space: nowrap; flex: none;
}
.badge svg { width: 15px; height: 15px; flex: none; }
.badge.open { background: var(--ok-soft); color: var(--ok-text); }
.badge.guided { background: var(--yellow-soft); color: var(--ink); }
.badge.quiet { background: var(--paper-2); border: 1px solid var(--line); color: var(--grey-700); font-weight: 600; }

/* ---------- forms + buttons ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--grey-700); }
.input, .select {
  height: 44px; min-width: 0; padding: 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  font-size: 16px; color: var(--ink); caret-color: var(--orange); transition: border-color 150ms;
}
.input::placeholder { color: var(--grey-600); }
.input:hover, .select:hover { border-color: var(--grey-300); }
.input:focus, .select:focus { outline: 3px solid var(--ink); outline-offset: 2px; border-color: var(--ink); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.select { appearance: none; padding-right: 38px; cursor: pointer;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231C1916' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center / 14px; }
.hint-line { font-size: 13px; color: var(--grey-600); }
.form-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.form-row .grow { flex: 1 1 220px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  height: 44px; padding: 0 18px; border-radius: 999px; font-size: 15px; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background 150ms, color 150ms, border-color 150ms, opacity 150ms;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--orange); color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: var(--orange-hover); }
.btn-outline { border: 1.5px solid var(--ink); }
.btn-outline:hover:not(:disabled) { background: var(--ink); color: var(--on-ink); }
.btn-ink { background: var(--ink); color: var(--on-ink); }
.btn-ink:hover:not(:disabled) { background: var(--grey-700); }
.btn:disabled { opacity: .55; }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.action {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--grey-700); white-space: nowrap; transition: background 150ms, color 150ms;
}
.action:hover:not(:disabled) { background: var(--paper-2); color: var(--ink); }
.action svg { width: 16px; height: 16px; flex: none; }
.action:disabled { opacity: .55; }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--card); transition: background 150ms; flex: none; }
.icon-btn:hover { background: var(--paper); }
.icon-btn svg { width: 16px; height: 16px; }
.menu-btn { display: none; }

/* inline status under a form: icon + words, never color alone */
.status { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; margin-top: 10px; min-height: 0; }
.status:empty { display: none; }
.status svg { width: 16px; height: 16px; flex: none; margin-top: 3px; }
.status.ok { color: var(--ok-text); }
.status.err { color: var(--danger); }

/* ---------- tables ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
.list th {
  text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--grey-600); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--paper);
}
.list td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--grey-700); }
.list tr:last-child td { border-bottom: 0; }
.list td.strong { color: var(--ink); font-weight: 600; }
.list td.right, .list th.right { text-align: right; }
.list .sub { display: block; font-size: 13px; color: var(--grey-600); font-weight: 400; }
.list tr.is-archived td { background: var(--paper); }

/* ---------- availability banner + pause (TCH-04: obvious, one tap) ---------- */
.avail {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
}
.avail.is-paused { background: var(--yellow-soft); border-color: var(--yellow); }
.avail.is-closed { background: var(--paper-2); }
.avail-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--ok-soft); color: var(--ok-text); }
.avail.is-paused .avail-icon { background: var(--card); color: var(--ink); }
.avail.is-closed .avail-icon { background: var(--card); color: var(--grey-700); }
.avail-icon svg { width: 20px; height: 20px; }
.avail-text { flex: 1 1 260px; min-width: 0; }
.avail-title { font-size: 16.5px; font-weight: 700; line-height: 1.35; }
.avail-sub { font-size: 14.5px; color: var(--grey-700); margin-top: 2px; }
.avail .status { flex-basis: 100%; margin-top: 0; }
.btn-pause { min-width: 168px; }
.head .btn { height: 40px; }
.btn-short { display: none; }

/* ---------- setup form ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px 22px 20px; display: flex; flex-direction: column; gap: 22px; }
fieldset { border: 0; min-width: 0; }
legend, .label-strong { font-size: 15px; font-weight: 700; color: var(--ink); padding: 0; margin-bottom: 10px; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; transition: border-color 150ms, background 150ms; }
.choice:hover { border-color: var(--grey-300); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--ink); background: var(--paper); }
.choice:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.choice-name { display: flex; align-items: center; gap: 8px; font-size: 15.5px; font-weight: 700; }
.choice-name svg { width: 16px; height: 16px; flex: none; }
.choice-tick { margin-left: auto; width: 18px; height: 18px; border-radius: 999px; border: 1.5px solid var(--grey-300); display: grid; place-items: center; }
.choice-tick svg { width: 12px; height: 12px; opacity: 0; }
.choice:has(input:checked) .choice-tick { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.choice:has(input:checked) .choice-tick svg { opacity: 1; }
.choice-text { font-size: 14px; color: var(--grey-700); line-height: 1.5; }
/* checkbox rows (class chat sources): a square tick, and a quiet row when it can't be ticked yet */
.choice.is-check .choice-tick { border-radius: 6px; }
.choice.is-off { cursor: default; background: var(--paper-2); }
.choice.is-off:hover { border-color: var(--line); }
.src-list { display: grid; gap: 10px; }
.src-name { min-width: 0; overflow-wrap: anywhere; }
.choice-name .mat-pill { margin: 0 0 0 4px; font-size: 12.5px; }
.src-warn { padding: 10px 12px; border-radius: 12px; background: var(--orange-soft); color: var(--ink); font-size: 14px; }
.tag { margin-left: 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--grey-600); }
.textarea {
  width: 100%; min-height: 128px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px; line-height: 1.55; color: var(--ink); caret-color: var(--orange); resize: vertical;
}
.textarea:hover { border-color: var(--grey-300); }
.textarea:focus { outline: 3px solid var(--ink); outline-offset: 2px; border-color: var(--ink); }
.textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-foot { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--grey-600); max-width: 60ch; }
.note svg { width: 15px; height: 15px; flex: none; margin-top: 3px; }
.mode-notice { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--orange-soft); color: var(--ink); font-size: 14px; }
.counter { font-size: 13px; color: var(--grey-600); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 600; }
.starter-list { display: grid; gap: 8px; list-style: none; counter-reset: s; }
.starter-list li { display: flex; align-items: center; gap: 10px; }
.starter-list li::before { counter-increment: s; content: counter(s); width: 18px; font-size: 13px; color: var(--grey-600); text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.starter-list .input { flex: 1; }
.form-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 16px; }
.form-actions .status { margin-top: 0; flex: 1 1 240px; }
.status .btn { height: 34px; padding: 0 14px; font-size: 14px; margin-left: 4px; }

/* class hours */
.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-row .choice { flex: 1 1 220px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day { position: relative; }
.day input { position: absolute; opacity: 0; pointer-events: none; }
.day span { display: grid; place-items: center; min-width: 52px; height: 40px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line); font-size: 14px; font-weight: 600; color: var(--grey-700); cursor: pointer; transition: background 150ms, border-color 150ms; }
.day span:hover { border-color: var(--grey-300); }
.day input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.day input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.hours-grid { display: grid; grid-template-columns: 140px 140px minmax(0, 1fr); gap: 12px; }
.hours-detail { display: flex; flex-direction: column; gap: 14px; }
.hours-detail[aria-disabled="true"] { opacity: .5; }

/* recent changes */
.changes { list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.changes li { display: flex; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: baseline; flex-wrap: wrap; }
.changes li:last-child { border-bottom: 0; }
.change-what { flex: 1 1 320px; min-width: 0; color: var(--ink); font-size: 15px; }
.change-who { font-size: 13.5px; color: var(--grey-600); white-space: nowrap; }

/* ---------- class tabs (M9.6 U7): Setup · Materials; links, each its own address ---------- */
.class-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -10px 0 -12px; overflow-x: auto; scrollbar-width: none; }
.class-tab {
  position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; flex: none;
  border-radius: 12px 12px 0 0; font-size: 15px; font-weight: 600; color: var(--grey-700); text-decoration: none;
  transition: background 150ms, color 150ms;
}
.class-tab:hover { background: var(--paper-2); color: var(--ink); }
.class-tab[aria-current="page"] { color: var(--ink); }
.class-tab[aria-current="page"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--orange); }
.class-tab:focus-visible { outline-offset: -3px; }

/* ---------- materials (M9.6 U7) ---------- */
.drop {
  display: flex; align-items: center; gap: 16px; padding: 22px 20px; cursor: pointer;
  background: var(--paper); border: 1.5px dashed var(--grey-300); border-radius: 14px; transition: background 150ms, border-color 150ms;
}
.drop:hover, .drop.is-over { background: var(--paper-2); border-color: var(--ink); }
.drop:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.drop.has-file { background: var(--card); border-style: solid; border-color: var(--ink); }
.drop.is-bad { border-color: var(--danger); }
.drop-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; flex: none; }
.drop-icon svg { width: 20px; height: 20px; }
.drop-text { display: grid; gap: 2px; min-width: 0; }
.drop-main { font-size: 15.5px; color: var(--ink); overflow-wrap: anywhere; }
.drop-main strong { font-weight: 700; }
.drop:not(.has-file) .drop-main strong, .drop-change { text-decoration: underline; text-decoration-color: var(--orange); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.drop-change { font-size: 14px; color: var(--grey-700); white-space: nowrap; }
.drop + .status { margin-top: -12px; }
.mat-list { list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.mat-list > li + li { border-top: 1px solid var(--line); }
.mat-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "icon main pill" "icon acts acts";
  column-gap: 14px; row-gap: 6px; align-items: start; padding: 16px 20px;
}
.mat-icon { grid-area: icon; width: 40px; height: 40px; border-radius: 12px; background: var(--paper-2); color: var(--grey-700); display: grid; place-items: center; }
.mat-icon svg { width: 18px; height: 18px; }
.mat-main { grid-area: main; min-width: 0; display: grid; gap: 2px; }
.mat-title { font-size: 16px; font-weight: 700; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.mat-meta { font-size: 13.5px; color: var(--grey-600); }
.mat-pill { grid-area: pill; margin-top: 4px; }
.mat-message, .mat-sub { display: flex; gap: 8px; align-items: flex-start; max-width: 65ch; font-size: 14px; line-height: 1.5; color: var(--grey-700); margin-top: 6px; }
.mat-message svg, .mat-sub svg { width: 15px; height: 15px; flex: none; margin-top: 3px; }
.mat-message { padding: 10px 12px; border-radius: 12px; background: var(--danger-soft); color: var(--ink); }
.mat-message svg { color: var(--danger); }
.mat-message.is-quote { background: var(--paper-2); }
.mat-message.is-quote svg { color: var(--grey-700); }
.mat-sub.is-warn { color: var(--ink); font-weight: 600; }
.mat-actions { grid-area: acts; display: flex; gap: 4px; flex-wrap: wrap; margin-left: -12px; }
.mat-row.is-removed .mat-title { color: var(--grey-700); font-weight: 600; }
.mat-row.is-removed .mat-icon { background: var(--paper); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.show-removed { margin: 10px 0 0 -12px; }
.show-removed .num { color: var(--grey-600); font-weight: 400; }
#mat-removed { margin-top: 6px; background: var(--paper); }
.spin { animation: spin 900ms linear infinite; transform-origin: 50% 50%; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- page states ---------- */
.state { max-width: 520px; margin: 8vh auto 0; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.state-icon { width: 44px; height: 44px; border-radius: 14px; background: var(--paper-2); border: 1px solid var(--line); display: grid; place-items: center; }
.state-icon svg { width: 20px; height: 20px; color: var(--grey-700); }
.state h3 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; margin-top: 6px; }
.state p { font-size: 15.5px; color: var(--grey-700); max-width: 60ch; }
.state .btn { margin-top: 8px; }
.state .state-who { font-size: 14.5px; color: var(--grey-700); padding: 10px 14px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; }
.state .state-who strong { color: var(--ink); font-weight: 600; }
.state-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.state.inline { margin: 0; max-width: none; padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.state.inline h3 { font-size: 17px; margin-top: 2px; }
.skel { height: 12px; border-radius: 999px; background: var(--paper-2); }
.skel-block { display: grid; gap: 14px; }
.skel-block .skel:nth-child(1) { width: 38%; height: 18px; }
.skel-block .skel:nth-child(2) { width: 100%; height: 44px; border-radius: 12px; }
.skel-block .skel:nth-child(3) { width: 100%; height: 160px; border-radius: 16px; }
.wait-label { font-size: 14px; color: var(--grey-600); }

/* ---------- dialog (confirm only: ending access is the protected-focus case) ---------- */
.dialog-scrim { position: fixed; inset: 0; z-index: 60; background: rgba(28,25,22,.4); display: grid; place-items: center; padding: 24px; }
.dialog { background: var(--card); border-radius: 24px; max-width: 460px; width: 100%; padding: 28px; box-shadow: 0 16px 40px -24px rgba(28,25,22,.35); }
.dialog h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.dialog p { margin-top: 12px; font-size: 15.5px; line-height: 1.6; color: var(--grey-700); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.dialog-scrim:not([hidden]) .dialog { animation: rise 220ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.scrim { display: none; position: fixed; inset: 0; background: rgba(28,25,22,.35); z-index: 40; }

/* ---------- flags (U15): queue, detail, whole chat ---------- */
.rail-nav { list-style: none; margin: 0 0 18px; }
.space-item.nav-item { display: flex; align-items: center; gap: 10px; }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item .space-title { flex: 1; min-width: 0; }
.count-badge {
  min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--ink); color: var(--on-ink); font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { flex: 0 1 260px; }
.recorded { margin-bottom: -14px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; min-height: 44px; padding: 0 14px 0 8px;
  margin: -10px 0 -18px -8px; border-radius: 999px; font-size: 14.5px; font-weight: 600; text-decoration: none; color: var(--grey-700);
  transition: background 150ms, color 150ms;
}
.back-link:hover { background: var(--paper-2); color: var(--ink); }
.back-link svg { width: 16px; height: 16px; }

.flag-list { list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.flag-list > li + li { border-top: 1px solid var(--line); }
.flag-row { display: grid; gap: 6px; padding: 16px 20px; text-decoration: none; color: var(--grey-700); transition: background 150ms; }
.flag-row:hover { background: var(--paper); }
.flag-row:focus-visible { outline-offset: -3px; border-radius: 0; }
.flag-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.flag-who { font-size: 16px; font-weight: 700; color: var(--ink); }
.flag-login { font-weight: 400; font-size: 14px; color: var(--grey-600); margin-left: 4px; }
.flag-top time { margin-left: auto; font-size: 13.5px; color: var(--grey-600); white-space: nowrap; font-variant-numeric: tabular-nums; }
.flag-excerpt { color: var(--ink); font-size: 15.5px; max-width: 70ch; overflow-wrap: anywhere; }
.flag-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13.5px; color: var(--grey-600); }
.chip-cat {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  background: var(--orange-soft); color: var(--ink); font-size: 13px; font-weight: 700; white-space: nowrap;
}
.chip-cat svg { width: 14px; height: 14px; }
.notice-list { list-style: none; display: grid; gap: 8px; }
.notice-list li { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px; font-size: 15px; }
.notice-list svg { width: 18px; height: 18px; flex: none; }
.notice-list .what { flex: 1 1 260px; color: var(--ink); }
.notice-list time { font-size: 13.5px; color: var(--grey-600); }

.flag-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.flag-title h3 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.flag-meta { margin-top: 6px; font-size: 15px; color: var(--grey-700); display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; }
.flag-meta a { font-weight: 600; }
.thread { display: flex; flex-direction: column; gap: 18px; background: var(--paper-2); border-radius: 16px; padding: 22px 20px; }
.thread + .thread { margin-top: 12px; }
.msg { display: flex; flex-direction: column; }
.msg-student { align-items: flex-end; }
.msg-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--grey-600); margin: 0 0 6px 2px; }
.msg-meta .who { font-weight: 700; color: var(--ink); }
.assistant-avatar { width: 26px; height: 26px; border-radius: 8px; background: var(--orange); display: grid; place-items: center; flex: none; }
.assistant-avatar svg { width: 14px; height: 14px; stroke: var(--ink); }
.bubble { max-width: 82%; padding: 14px 18px; font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-student .bubble { background: var(--ink); color: var(--on-ink); border-radius: 20px 20px 8px 20px; }
.msg-student .bubble::selection { background: var(--yellow); color: var(--ink); }
.msg-assistant .bubble { background: var(--card); border: 1px solid var(--line); border-radius: 20px 20px 20px 8px; padding: 16px 20px; }
.state-tag { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--grey-700); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.withheld { max-width: 82%; background: var(--yellow-soft); border: 1px dashed var(--grey-600); border-radius: 16px; padding: 14px 18px; }
.withheld-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; color: var(--ink); }
.withheld-label svg { width: 15px; height: 15px; flex: none; }
.withheld-sub { font-size: 13.5px; color: var(--grey-700); margin-top: 2px; }
.withheld-body { margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.withheld.is-hidden { background: var(--paper-2); }
.act-row { display: flex; gap: 10px; flex-wrap: wrap; }
.act-help { display: grid; gap: 4px; font-size: 14px; color: var(--grey-700); max-width: 70ch; }
.act-help strong { color: var(--ink); }
.closed-line { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--ink); }
.closed-line svg { width: 18px; height: 18px; flex: none; margin-top: 3px; }
.note-form { display: grid; gap: 10px; }
.note-form .textarea { min-height: 96px; }
.note-form .act-row .btn { height: 40px; }

@media (max-width: 700px) {
  .flag-row { padding: 14px 16px; }
  .flag-top time { margin-left: 0; flex-basis: 100%; }
  .bubble, .withheld { max-width: 100%; }
  .thread { padding: 16px 12px; }
  .act-row .btn { flex: 1 1 100%; }
  .filters .field { flex: 1 1 100%; }
  .drop { align-items: flex-start; padding: 18px 16px; gap: 12px; }
  .mat-row { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "icon main" "icon pill" "icon acts"; padding: 14px 16px; column-gap: 12px; }
  .mat-pill { justify-self: start; margin-top: 2px; }
  .class-tab { padding: 0 14px; }
}

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); position: fixed; inset: 0; height: auto; overflow: hidden; }
  .scrim { position: absolute; }
  .menu-btn { display: grid; }
  .rail {
    position: absolute; left: 0; top: 0; bottom: 0; z-index: 50; width: min(300px, 86vw);
    transform: translateX(-105%); transition: transform 240ms var(--ease);
    box-shadow: 0 16px 40px -24px rgba(28,25,22,.35);
  }
  body.rail-open .rail { transform: none; }
  body.rail-open .scrim { display: block; }
}
@media (max-width: 700px) {
  .head { padding: 12px 16px; gap: 10px; }
  .page { padding: 20px 16px 40px; }
  .form-row > .btn { width: 100%; }
  .choices { grid-template-columns: minmax(0, 1fr); }
  .hours-grid { grid-template-columns: 1fr 1fr; }
  .hours-grid .field:last-child { grid-column: 1 / -1; }
  .panel { padding: 18px 16px; }
  .avail .btn-pause { width: 100%; }
  .head .btn-pause { min-width: 0; padding: 0 14px; }
  .head .btn { padding: 0 14px; }
  .head .btn-long { display: none; }
  .head .btn-short { display: inline; }
  /* tables become stacked rows */
  table.list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .list tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .list tr:last-child { border-bottom: 0; }
  .list td { padding: 2px 0; border: 0; }
  .list td[data-label]:not([data-label=""])::before { content: attr(data-label) ": "; color: var(--grey-600); font-size: 13px; }
  .list td.right { text-align: left; padding-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
