/* The dashboard's styles (docs/specs/dashboard.md §4): system fonts, light and dark from prefers-color-scheme, usable at
   360 px and with the keyboard alone, visible focus, WCAG AA contrast (every text colour below is checked against the
   surfaces it sits on), short transitions only, none with prefers-reduced-motion. Restrained: tinted neutrals and one
   accent (petrol), used for actions, the current selection, links and Alexander's own messages. */

:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: oklch(0.99 0.002 230);
  --raised: oklch(0.965 0.005 230);
  --surface: oklch(1 0 0);
  --ink: oklch(0.23 0.015 240);
  --ink-2: oklch(0.40 0.015 240);
  --ink-3: oklch(0.48 0.012 240);
  --line: oklch(0.90 0.006 240);
  --line-strong: oklch(0.62 0.01 240);
  --chip: oklch(0.93 0.006 240);
  --code-bg: oklch(0.955 0.006 240);
  --hover: oklch(0.5 0.02 240 / 0.07);
  --active: oklch(0.5 0.02 240 / 0.13);
  --accent: oklch(0.47 0.09 205);
  --accent-hover: oklch(0.42 0.09 205);
  --accent-ink: oklch(1 0 0);
  --accent-text: oklch(0.45 0.09 205);
  --accent-soft: oklch(0.955 0.022 205);
  --focus: oklch(0.55 0.13 205);
  --ok: oklch(0.58 0.14 150);
  --ok-bg: oklch(0.94 0.05 150);
  --ok-ink: oklch(0.38 0.09 150);
  --warn-dot: oklch(0.62 0.14 65);
  --warn-bg: oklch(0.95 0.045 85);
  --warn-ink: oklch(0.42 0.08 65);
  --danger: oklch(0.50 0.17 27);
  --danger-bg: oklch(0.955 0.025 27);
  --toast-bg: oklch(0.25 0.015 240);
  --toast-ink: oklch(0.97 0.004 240);
  --scrim: oklch(0.15 0.01 240 / 0.38);
  --shadow: 0 8px 28px oklch(0.2 0.02 240 / 0.14), 0 1px 3px oklch(0.2 0.02 240 / 0.1);

  --radius: 10px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --rail: 248px;
  --side: 340px;
  --z-sticky: 10;
  --z-scrim: 20;
  --z-panel: 30;
  --z-popover: 40;
  --z-toast: 50;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.18 0.008 240);
    --raised: oklch(0.21 0.01 240);
    --surface: oklch(0.24 0.011 240);
    --ink: oklch(0.93 0.006 240);
    --ink-2: oklch(0.80 0.008 240);
    --ink-3: oklch(0.70 0.01 240);
    --line: oklch(0.31 0.01 240);
    --line-strong: oklch(0.54 0.012 240);
    --chip: oklch(0.30 0.01 240);
    --code-bg: oklch(0.21 0.01 240);
    --hover: oklch(0.9 0.01 240 / 0.06);
    --active: oklch(0.9 0.01 240 / 0.11);
    --accent: oklch(0.78 0.09 200);
    --accent-hover: oklch(0.84 0.09 200);
    --accent-ink: oklch(0.2 0.03 210);
    --accent-text: oklch(0.80 0.09 200);
    --accent-soft: oklch(0.25 0.03 205);
    --focus: oklch(0.8 0.1 200);
    --ok: oklch(0.72 0.15 150);
    --ok-bg: oklch(0.3 0.05 150);
    --ok-ink: oklch(0.85 0.1 150);
    --warn-dot: oklch(0.8 0.14 80);
    --warn-bg: oklch(0.29 0.05 75);
    --warn-ink: oklch(0.88 0.09 85);
    --danger: oklch(0.75 0.14 27);
    --danger-bg: oklch(0.27 0.05 27);
    --toast-bg: oklch(0.93 0.006 240);
    --toast-ink: oklch(0.2 0.01 240);
    --scrim: oklch(0.05 0.01 240 / 0.55);
    --shadow: 0 8px 28px oklch(0 0 0 / 0.45), 0 1px 3px oklch(0 0 0 / 0.4);
  }
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font: 15px/1.45 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { line-height: 1.25; text-wrap: balance; }
p { text-wrap: pretty; }
a { color: var(--accent-text); text-underline-offset: 2px; }
code, pre, kbd { font-family: var(--mono); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.main:focus, .main:focus-visible, .auth:focus, .msg:focus { outline: none; }
.msg:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

.skip {
  position: fixed; left: 8px; top: -60px; z-index: var(--z-toast);
  min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer;
}
.skip:focus { top: 8px; }

/* Boot (index.html's own markup, before the script runs) */

.root { min-height: 100dvh; }
.boot { min-height: 100dvh; display: grid; place-items: center; color: var(--ink-3); }

/* Buttons and controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500; line-height: 1.2; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
.btn:hover { background: var(--hover); }
.btn:active { background: var(--active); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; opacity: 0.7; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:active { background: var(--accent); }
.btn--quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--quiet:hover { color: var(--ink); background: var(--hover); }
.btn--small { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--small { width: 32px; }
.btn--wide { width: 100%; }
.btn--danger-text, .btn--danger-text:hover { color: var(--danger); }
.icon { width: 20px; height: 20px; flex: none; }
.btn--small .icon { width: 17px; height: 17px; }

.input {
  width: 100%; min-height: 40px; padding: 8px 10px;
  font-size: 16px; line-height: 1.35;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:focus-visible { outline-offset: 0; border-color: var(--focus); }
textarea.input { resize: vertical; }
.input--select { padding-right: 28px; }
.input--mono { font-family: var(--mono); font-size: 13px; }
.checkbox { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.fields { display: flex; flex-direction: column; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.badge {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.badge--neutral { background: var(--chip); color: var(--ink-2); }
.badge--kind { background: var(--chip); color: var(--ink); }
.badge--ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge--accent { background: var(--accent-soft); color: var(--accent-text); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--big { width: 10px; height: 10px; }
.dot--on { background: var(--ok); }
.dot--off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.dot--warn { background: var(--warn-dot); }

.note { margin: 8px 0 0; font-size: 13.5px; }
.note--error { color: var(--danger); }
.note--hint, .hint { color: var(--ink-3); }
.hint { margin: 0 0 12px; font-size: 13px; }
.callout { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13.5px; }
.callout p { margin: 0 0 6px; }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.segmented-item {
  min-height: 32px; padding: 0 12px; border: 0; background: var(--surface); color: var(--ink-2);
  font-size: 13px; cursor: pointer; transition: background-color 150ms var(--ease);
}
.segmented-item + .segmented-item { border-left: 1px solid var(--line-strong); }
.segmented-item:hover { background: var(--hover); }
.segmented-item[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.segmented-item:focus-visible { outline-offset: -2px; }

.disclosure { margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.disclosure-summary { padding: 10px 14px; font-size: 14px; font-weight: 500; cursor: pointer; border-radius: var(--radius); }
.disclosure-summary:hover { background: var(--hover); }
.disclosure > :not(summary) { margin: 0 14px 14px; }

/* States */

.state { padding: 28px 16px; text-align: center; color: var(--ink-2); }
.state-title { margin: 0 0 4px; font-size: 15px; font-weight: 600; color: var(--ink); }
.state-body { max-width: 46ch; margin: 0 auto; font-size: 14px; }
.state--error .state-title { color: var(--danger); }
.state .btn { margin-top: 12px; }
.card .state { padding: 12px 8px; }
.list-status:empty { display: none; }

.skeleton { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; }
.skeleton-line { height: 12px; border-radius: 6px; background: var(--chip); animation: pulse 1.4s ease-in-out infinite; }
.skeleton-line--short { width: 60%; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* The shell: the top bar and the view; the rooms rail from 900 px; the room panel inline from 1240 px */

.shell {
  display: grid; height: 100dvh;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top" "main";
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 2px;
  min-height: 52px; padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  background: var(--raised); border-bottom: 1px solid var(--line);
}
.topbar-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 6px; }
.topbar-title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-sub { font-size: 12px; color: var(--ink-3); line-height: 1.2; }
.topbar-sub:empty { display: none; }

.live { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 8px; font-size: 12.5px; color: var(--ink-3); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.live[data-state="live"] .live-dot { background: var(--ok); }
.live[data-state="connecting"] .live-dot, .live[data-state="reconnecting"] .live-dot { background: var(--warn-dot); }
.live[data-state="offline"] .live-dot { background: var(--danger); }
/* On a phone the word is hidden only while live (the green dot alone); connecting, reconnecting and offline say so in
   words too, so the state never rests on colour alone. */
@media (max-width: 599px) {
  .live[data-state="live"] .live-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

.rail { grid-area: rail; display: none; }
.main { grid-area: main; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.tabs {
  display: flex; gap: 2px; padding: 0 8px; overflow-x: auto; scrollbar-width: thin;
  border-bottom: 1px solid var(--line); background: var(--raised); flex: none;
}
.tab {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 12px;
  color: var(--ink-2); font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap;
  border-radius: 6px 6px 0 0; transition: color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.tab:hover { color: var(--ink); background: var(--hover); }
.tab[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.tab:focus-visible { outline-offset: -2px; }
.tab-count { min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 11.5px; font-weight: 700; text-align: center; }

.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-panel);
  width: min(var(--side), calc(100vw - 40px));
  background: var(--raised); border-left: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(100%); visibility: hidden;
  transition: transform 220ms var(--ease), visibility 0s linear 220ms;
}
.shell--panel-open .panel { transform: none; visibility: visible; box-shadow: var(--shadow); transition: transform 220ms var(--ease); }
.scrim { position: fixed; inset: 0; z-index: var(--z-scrim); background: var(--scrim); }

@media (min-width: 900px) {
  .shell { grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-areas: "rail top" "rail main"; }
  .rail {
    display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
    padding: 10px 8px max(10px, env(safe-area-inset-bottom));
    background: var(--raised); border-right: 1px solid var(--line);
  }
  .topbar-back, .topbar-settings { display: none; }
  .topbar { padding-left: 12px; }
}
@media (min-width: 1240px) {
  .shell--room { grid-template-columns: var(--rail) minmax(0, 1fr) var(--side); grid-template-areas: "rail top panel" "rail main panel"; }
  .shell--room .panel { grid-area: panel; position: static; width: auto; transform: none; visibility: visible; box-shadow: none; transition: none; }
  .topbar-panel, .panel-close, .scrim { display: none !important; }
}

.rail-brand { display: flex; align-items: center; gap: 9px; padding: 8px 10px 14px; color: var(--ink); font-weight: 650; text-decoration: none; }
.rail-title { margin: 0; padding: 8px 10px 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.rail-rooms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.rail-empty { padding: 6px 10px; font-size: 13px; color: var(--ink-3); }
.rail-foot { margin-top: auto; padding: 12px 10px 2px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: var(--ink-2); }
.rail-hub { display: flex; align-items: center; gap: 8px; }
.rail-settings { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); text-decoration: none; min-height: 32px; border-radius: 6px; }
.rail-settings:hover { color: var(--ink); }
.rail-settings .icon { width: 18px; height: 18px; }

.auth-mark {
  position: relative; display: inline-block; width: 18px; height: 18px; flex: none;
  border-radius: 5px; background: var(--accent);
}
.auth-mark::after { content: ""; position: absolute; inset: 5px; border-radius: 2px; background: var(--accent-soft); }

/* Pages (everything but the timeline): one scrolling column */

.page { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.page-inner { max-width: 880px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.page-inner--narrow { max-width: 640px; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin: 24px 0 10px; }
.page-inner > .section-head:first-child, .page-inner > :first-child .section-head { margin-top: 4px; }
.section-title { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.section-tools { display: flex; align-items: center; gap: 8px; }
.list-more { display: flex; justify-content: center; margin: 14px 0; }

.card { margin-bottom: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card-text { margin: 0; font-size: 14px; color: var(--ink-2); }
.card-text--spaced { margin-top: 10px; }
.card-steps { margin: 8px 0 0; padding-left: 22px; font-size: 14px; color: var(--ink-2); }
.card-steps li + li { margin-top: 4px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px 16px; margin: 0; }
.facts dt { font-size: 12px; color: var(--ink-3); }
.facts dd { margin: 1px 0 0; font-size: 14px; overflow-wrap: anywhere; }

.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 8px; padding: 9px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row-main { flex: 1; min-width: 0; }
.row-title { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 500; }
.row-meta { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.enrol-result { margin-top: 12px; }
.enrol-code { margin: 0; font-size: 14px; }
.enrol-code code, .auth-code code { font-weight: 600; font-size: 15px; letter-spacing: 0.08em; }

/* Overview */

.hub-card { margin-bottom: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hub-state { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 12px; margin-bottom: 14px; }
.hub-state .dot { margin-top: 6px; }
.hub-state > div { flex: 1 1 200px; min-width: 0; }
.hub-state-title { margin: 0; font-size: 16px; font-weight: 650; }
.hub-state-text { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); }

.room-list { list-style: none; margin: 0 0 16px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.room-list li + li { border-top: 1px solid var(--line); }
.room-link { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; color: inherit; text-decoration: none; transition: background-color 150ms var(--ease); }
.room-link:hover { background: var(--hover); }
.room-link:focus-visible { outline-offset: -2px; }
.room-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; min-width: 0; }
.room-repo { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.room-host { font-size: 12.5px; color: var(--ink-3); }
.room-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; color: var(--ink-2); }
.room-online { display: inline-flex; align-items: center; gap: 6px; }
.room-link--compact { gap: 2px; padding: 7px 10px; border-radius: 7px; }
.room-link--compact .room-repo { font-size: 14px; font-weight: 500; }
.room-link--compact .room-meta { gap: 2px 8px; font-size: 12px; color: var(--ink-3); }
.room-link[aria-current="page"] { background: var(--accent-soft); }
.room-link[aria-current="page"] .room-repo { color: var(--accent-text); font-weight: 600; }

.machine-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.machine { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.machine-name { font-family: var(--mono); font-size: 13px; margin-right: auto; }

/* Banner (paused, offline) */

.banner { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 8px 14px; font-size: 13.5px; flex: none; }
.banner--warn { background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid var(--line); }
.banner .icon { width: 18px; height: 18px; }
.banner-text { flex: 1 1 220px; }

/* Timeline */

.timeline-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.timeline-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.timeline-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 0 14px; }
.timeline-scroll:focus-visible { outline-offset: -2px; }
.timeline-view--drop .timeline-scroll { outline: 2px dashed var(--accent); outline-offset: -8px; }
.timeline-older { display: flex; margin: 6px auto; }
.timeline-start { margin: 10px 0; text-align: center; font-size: 12.5px; color: var(--ink-3); }
.timeline-status { max-width: 920px; margin: 0 auto; padding: 0 12px; }
.timeline-status:empty { display: none; }
.timeline { list-style: none; max-width: 920px; margin: 0 auto; padding: 0 8px; }

.day { display: flex; justify-content: center; margin: 14px 0 6px; }
.day span { padding: 1px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font-size: 12px; color: var(--ink-3); }
.gap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 10px; margin: 10px 0; padding: 4px 10px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); font-size: 12.5px; color: var(--ink-2);
}

.msg { position: relative; margin: 2px 0; padding: 8px 10px 4px; border-radius: var(--radius); transition: background-color 150ms var(--ease), box-shadow 300ms var(--ease); }
.msg + .msg { margin-top: 4px; }
.msg--agent:hover { background: var(--hover); }
.msg--human { background: var(--accent-soft); }
.msg--target { box-shadow: inset 0 0 0 2px var(--accent); }
.msg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 13px; }
.msg-from { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.msg--agent .msg-from { font-family: var(--mono); font-size: 12.5px; }
.msg--human .msg-from { color: var(--accent-text); }
.msg-kind { align-self: center; padding: 0 6px; border-radius: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; line-height: 1.6; text-transform: uppercase; text-decoration: none; }
.msg-kind--agent { background: var(--chip); color: var(--ink-2); }
.msg-kind--human { background: var(--accent); color: var(--accent-ink); }
.msg-kind--handoff { background: var(--warn-bg); color: var(--warn-ink); }
.msg-machine { font-size: 12px; color: var(--ink-3); }
.msg-time { margin-left: auto; display: inline-flex; gap: 6px; font-size: 12px; color: var(--ink-3); text-decoration: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.msg-time:hover { color: var(--ink-2); text-decoration: underline; }
.msg-replyto { display: flex; align-items: center; gap: 5px; min-width: 0; margin: 3px 0 1px; font-size: 12.5px; color: var(--ink-2); text-decoration: none; }
.msg-replyto .icon { width: 14px; height: 14px; flex: none; color: var(--ink-3); }
.msg-replyto:hover .reply-text { text-decoration: underline; }
.reply-from { font-weight: 600; flex: none; }
.reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--ink-3); }

.msg-body { margin-top: 2px; overflow-wrap: anywhere; }
.msg-body p, .mem-text p, .handoff-goal p, .handoff-last p, .handoff-list p { margin: 0 0 6px; }
.msg-body > :last-child, .mem-text > :last-child, .handoff-goal > :last-child, .handoff-last > :last-child { margin-bottom: 0; }
:is(.msg-body, .mem-text, .handoff-goal, .handoff-list, .handoff-last) code { padding: 0.08em 0.35em; border-radius: 4px; background: var(--code-bg); font-size: 0.875em; }
:is(.msg--human) .msg-body code { background: var(--surface); }
:is(.msg-body, .handoff-last) pre {
  max-width: 100%; margin: 6px 0; padding: 8px 10px; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.45; tab-size: 4;
}
:is(.msg-body, .handoff-last) pre code { padding: 0; background: none; font-size: inherit; }
pre[data-lang]::before { content: attr(data-lang); display: block; margin-bottom: 4px; font: 11px var(--font); color: var(--ink-3); }

.msg-files { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 6px; }
.msg-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; min-height: 30px; font-size: 12px; color: var(--ink-3); }
.msg-route { flex: 1 1 auto; min-width: 0; }
.msg-noreply { padding: 0 6px; border-radius: 4px; background: var(--warn-bg); color: var(--warn-ink); font-size: 11.5px; font-weight: 600; line-height: 1.6; }
.msg-reply { margin-left: auto; }
@media (hover: hover) {
  .msg-reply { opacity: 0; transition: opacity 150ms var(--ease); }
  .msg:hover .msg-reply, .msg:focus-within .msg-reply { opacity: 1; }
}

.refs { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 6px 0 0; padding: 0; font-size: 12.5px; }
/* A path ref is one long word: it may break anywhere rather than widen the timeline past the screen. */
.ref { min-width: 0; overflow-wrap: anywhere; }
.ref a { color: var(--accent-text); }
.ref-note { color: var(--ink-3); }

.file { max-width: 100%; }
.file-link {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; min-height: 36px; padding: 5px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); text-decoration: none;
}
.file-link:hover { border-color: var(--line-strong); }
.file-link .icon { width: 17px; height: 17px; color: var(--ink-3); }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 500; }
.file-meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.file--image { margin: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.file-image-link { display: block; max-width: 100%; border-radius: var(--radius-sm); }
/* No width here: the width and height attributes (message.js imageBox) give an image its box before it loads, and
   height: auto keeps their ratio when max-width narrows it. The caps are for an image whose size is not known. */
.file-image { display: block; height: auto; max-width: min(100%, 420px); max-height: 320px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--code-bg); }
.file-caption .file-link { border: 0; padding: 0 2px; min-height: 28px; background: none; }
.file--text { display: flex; flex-direction: column; gap: 4px; width: min(100%, 640px); }
.file-preview {
  margin: 0; max-height: 9.6em; overflow: hidden; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--code-bg);
  font: 12.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
.file-preview:focus { max-height: 24em; overflow: auto; }
.file--gone { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }
.file--gone .icon { width: 16px; height: 16px; }

.new-pill {
  position: absolute; left: 50%; bottom: 12px; z-index: var(--z-sticky); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 14px;
  border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer;
}
.new-pill .icon { width: 16px; height: 16px; }

/* Composer */

.composer {
  position: relative; flex: none;
  padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: var(--raised); border-top: 1px solid var(--line);
}
.composer > * { max-width: 920px; margin-left: auto; margin-right: auto; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer-input {
  flex: 1; min-width: 0; min-height: 42px; max-height: 40vh; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); color: var(--ink);
  font-size: 16px; line-height: 1.4; resize: none; field-sizing: content;
}
.composer-input::placeholder { color: var(--ink-3); opacity: 1; }
.composer-input:focus-visible { outline-offset: 0; border-color: var(--focus); }
.composer-send, .composer-attach { width: 42px; min-height: 42px; border-radius: 12px; }
.composer-under { display: flex; justify-content: space-between; gap: 8px; min-height: 18px; margin-top: 4px; padding: 0 4px; font-size: 12px; color: var(--ink-3); }
.composer-route { margin: 0; }
.composer-route strong { color: var(--ink-2); font-weight: 600; }
.composer-count { white-space: nowrap; font-variant-numeric: tabular-nums; }
.composer-count--over { color: var(--danger); font-weight: 600; }
.composer-problem:empty { display: none; }
.composer-reply {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 3px 3px 3px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px;
}
.composer-reply .icon { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.composer-reply-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-files { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 1px 1px 1px 9px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 12.5px;
}
.chip .icon { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.chip-meta { color: var(--ink-3); white-space: nowrap; }
.chip--error { border-color: var(--danger); }
.chip--error .chip-meta, .chip--error .icon { color: var(--danger); }
.chip--uploading .chip-meta { color: var(--ink-2); }

.mentions {
  position: absolute; left: 10px; bottom: calc(100% - 4px); z-index: var(--z-popover);
  width: min(420px, calc(100% - 20px)); max-height: 260px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.mention { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 8px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.mention:hover { background: var(--hover); }
.mention--active { background: var(--accent-soft); }
.mention-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mention-value { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.mention-detail { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--ink-3); }

/* The room panel */

.panel-inner { padding: 10px 14px calc(18px + env(safe-area-inset-bottom)); }
.panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 40px; margin-bottom: 6px; }
.panel-title { margin: 0; font-size: 15px; font-weight: 650; }
.side-controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.side-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; font-weight: 500; }
.side-section { padding: 12px 0 10px; }
.side-section + .side-section { border-top: 1px solid var(--line); }
.side-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-size: 13.5px; font-weight: 650; }
.side-count { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.side-body .state { padding: 6px 0; text-align: left; }
.side-body .state-title { font-size: 13px; font-weight: 400; color: var(--ink-3); }
.side-body .skeleton { padding: 4px 0; }
.side-more { display: inline-block; margin-top: 8px; font-size: 13px; }

.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.person { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 8px; font-size: 13px; }
.person-handle { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.person-machine { grid-column: 2 / 4; font-size: 12px; color: var(--ink-3); }
.person-seen { grid-row: 1; grid-column: 3; font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.queue-entry + .queue-entry { margin-top: 10px; }
.queue-head { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 13px; }
.queue-count { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.queue-list { list-style: none; margin: 0; padding: 0 0 0 16px; display: flex; flex-direction: column; gap: 2px; }
.queue-link { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--ink-2); text-decoration: none; }
.queue-link:hover { color: var(--ink); text-decoration: underline; }
.queue-seq { color: var(--ink-3); font-variant-numeric: tabular-nums; }

.handoff-mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.handoff-mini p { margin: 0; }
.handoff-mini-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 4px; font-size: 12.5px; }
.handoff-mini-goal { font-size: 13px; margin-top: 2px !important; }

/* Memory */

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .input--search { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .filters { grid-template-columns: minmax(0, 1fr) auto auto; }
  .filters .input--search { grid-column: auto; }
}
.mem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mem { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.mem--proposed { border-color: var(--line-strong); }
.mem--rejected, .mem--superseded, .mem--forgotten { color: var(--ink-2); }
.mem-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; }
.mem-by { margin-left: auto; color: var(--ink-3); }
.mem-text { margin-top: 6px; overflow-wrap: anywhere; }
.mem-where { margin: 4px 0 0; font-size: 12px; color: var(--ink-3); overflow-wrap: anywhere; }
.mem-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mem-problem:empty { display: none; }
.mem-edit .fields { margin-bottom: 4px; }
.mem-list--compact .mem { padding: 8px 10px; }
.mem-list--compact .mem-text { font-size: 14px; }
.mem-add .fields { margin-top: 4px; }

/* Handoffs */

.crumb { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; font-size: 13.5px; }
.handoffs { display: flex; flex-direction: column; gap: 12px; }
.handoff { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.handoff-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; }
.branch { padding: 1px 6px; border-radius: 4px; background: var(--code-bg); font-size: 12.5px; overflow-wrap: anywhere; }
.branch-link { padding: 0; border: 0; background: none; color: var(--accent-text); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; border-radius: 4px; }
.sha { font-size: 12px; color: var(--ink-3); }
.handoff-by { margin-left: auto; font-size: 12.5px; color: var(--ink-3); }
.handoff-git { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.handoff-goal { margin-top: 8px; font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.handoff-block { margin-top: 10px; }
.handoff-label { margin: 0 0 3px; font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.handoff-list { margin: 0; padding-left: 18px; font-size: 14px; overflow-wrap: anywhere; }
.handoff-list li + li { margin-top: 2px; }
.handoff-list--code { list-style: none; padding-left: 0; }
.handoff-list--code code { font-size: 12.5px; }
.handoff-commands { margin: 0; padding: 8px 10px; overflow-x: auto; border-radius: var(--radius-sm); background: var(--code-bg); font-size: 12.5px; line-height: 1.5; }
.handoff-last { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.handoff-message { display: inline-block; margin-top: 10px; font-size: 13px; }

/* Files */

.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.file-row { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.file-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 6px; font-size: 12.5px; color: var(--ink-3); }
.file-row-meta .btn { margin-left: auto; }
.file-row-msg { margin-left: 4px; }
.file-row .file-image { max-height: 180px; }

/* Sign-in and enrolment */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
.auth-card { width: min(400px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 32px; font-weight: 650; }
.auth-title { margin: 0 0 8px; font-size: 24px; font-weight: 700; letter-spacing: -0.015em; }
.auth-text { margin: 0 0 20px; color: var(--ink-2); }
.auth-code { margin: 0 0 16px; font-size: 14px; color: var(--ink-2); }
.auth-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.auth-hint { margin: 20px 0 0; font-size: 13px; color: var(--ink-3); }
.auth-problem:empty { display: none; }

/* Dialog, toasts */

.dialog {
  width: min(420px, calc(100vw - 32px)); padding: 20px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.dialog::backdrop { background: var(--scrim); }
.dialog-title { margin: 0 0 8px; font-size: 17px; font-weight: 650; }
.dialog-body { margin: 0; font-size: 14px; color: var(--ink-2); }
.dialog-problem:empty { display: none; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toasts {
  position: fixed; left: 50%; top: calc(60px + env(safe-area-inset-top)); z-index: var(--z-toast); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; pointer-events: auto;
  border-radius: var(--radius); background: var(--toast-bg); color: var(--toast-ink); box-shadow: var(--shadow); font-size: 14px;
  animation: toast-in 180ms var(--ease);
}
.toast-text { flex: 1; min-width: 0; }
.toast .btn, .toast .btn:hover { color: inherit; }
/* The page's focus colour is drawn on the toast's own background, against which it can be too faint (dark mode's light
   toast): a focused control in a toast is ringed in the toast's text colour, which has the contrast of text there. */
.toast :focus-visible { outline-color: currentColor; }
.toast--error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* Motion off when asked */

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