/* The Stuurman design system: paper and ink. Reference: docs/design-system/index.html.
   One paper ground, ink, ruled lines, and a sheet for what is above the page.
   State colours report state only: green underway / on watch, red all stop,
   amber in doubt, magenta a turn running. Signal flags identify crew members. */

@font-face { font-family: "Archivo"; src: url("./fonts/archivo-latin.woff2") format("woff2"); font-weight: 400 800; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("./fonts/jetbrains-mono-latin.woff2") format("woff2"); font-weight: 400 500; font-display: swap; }

/* ---- tokens ---- */
:root {
  --bg: #F4F1E9; --surface-raised: #FFFDF8; --surface-sunken: #DCE9F0;
  --text: #0E1620; --text-secondary: #47515D; --text-tertiary: #5F6975;
  --hairline: rgba(14, 22, 32, 0.14); --border-strong: #7C8693;
  --primary: #0E1620; --on-primary: #FFFDF8;
  --ok: #0A8548; --ok-text: #0A6E3C; --on-ok: #FFFFFF;
  --danger: #D12B1E; --danger-text: #B42318; --on-danger: #FFFFFF;
  --warning: #B07800; --warning-text: #7A4B00; --on-warning: #1C1300;
  --info: #B0148E; --info-text: #94127A; --on-info: #FFFFFF;
  --focus: #1D6FD8;
  /* The colours of the International Code of Signals flags in web/src/flags/.
     They belong to the flags and report no state: the red of a flag is not the
     red of all stop. The drawings carry these values as plain fill attributes
     (the PNG pictures are rendered from the same files), and a test keeps the
     two in step. They are the same in both themes. */
  --flag-red: #D12B1E; --flag-blue: #1747A6; --flag-yellow: #FFD21E; --flag-black: #10151C; --flag-white: #FFFFFF;
  --hover-overlay: rgba(14, 22, 32, 0.06); --press-overlay: rgba(14, 22, 32, 0.12);
  --fill-hover: rgba(127, 127, 127, 0.22);
  --selection: rgba(29, 111, 216, 0.22);
  --shadow-float: 0 10px 22px -12px rgba(14, 22, 32, 0.45);

  --font-text: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --type-tab: 600 10px/12px var(--font-text);
  --type-telegraph: 700 11px/14px var(--font-text);
  --type-eyebrow: 600 12px/14px var(--font-text);
  --type-meta: 400 13px/18px var(--font-text);
  --type-label: 600 14px/20px var(--font-text);
  --type-body: 400 15px/22px var(--font-text);
  --type-read: 400 16px/25px var(--font-text);
  --type-lead: 400 18px/26px var(--font-text);
  --type-section: 700 15px/22px var(--font-text);
  --type-name: 700 18px/24px var(--font-text);
  --type-title: 800 30px/36px var(--font-text);
  --type-figure: 700 44px/1 var(--font-text);
  --type-subtitle: 800 24px/30px var(--font-text);
  --type-figure-small: 700 36px/1 var(--font-text);
  --type-body-large: 400 16px/24px var(--font-text);
  --type-control: 600 16px/20px var(--font-text);
  /* the largest words grow with the window */
  --size-state: clamp(40px, 13vw, 150px); --leading-state: 0.84;
  --size-claim: clamp(40px, 7vw, 96px); --leading-claim: 0.92;
  --size-wake: clamp(120px, 22vh, 220px);
  --type-mono: 400 13px/20px var(--font-mono);
  --type-mono-small: 400 11px/14px var(--font-mono);
  --type-mono-label: 500 12px/14px var(--font-mono);
  --type-mono-name: 500 15px/22px var(--font-mono);
  --type-code: 500 18px/24px var(--font-mono);
  --rule: 1px solid var(--hairline); --rule-ink: 1px solid var(--text); --rule-head: 2px solid var(--text); --outline: 1.5px solid var(--text);
  --space-1: 2px; --space-2: 4px; --space-3: 8px; --space-4: 12px; --space-5: 16px; --space-6: 24px;
  --space-7: 32px; --space-8: 48px; --space-9: 64px;
  --radius-1: 3px; --radius-2: 6px; --radius-inner: 4px; --radius-glyph: 0.04em;
  --dur-quick: 120ms; --dur-base: 200ms; --dur-pulse: 1600ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --gutter: 16px; --column: clamp(1200px, 90vw, 1920px); --control: 36px; --bar: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0A0F15; --surface-raised: #111922; --surface-sunken: #132432;
  --text: #E9EEF3; --text-secondary: #A9B4C1; --text-tertiary: #8491A1;
  --hairline: rgba(233, 238, 243, 0.14); --border-strong: #6C7A8C;
  --primary: #E9EEF3; --on-primary: #0A0F15;
  --ok: #3DD68C; --ok-text: #5BE0A0; --on-ok: #04150B;
  --danger: #FF6B5E; --danger-text: #FF8E84; --on-danger: #2B0502;
  --warning: #F5B93A; --warning-text: #F7C968; --on-warning: #1E1500;
  --info: #F06ADB; --info-text: #F590E4; --on-info: #22041D;
  --focus: #7CB7FF;
  --hover-overlay: rgba(233, 238, 243, 0.07); --press-overlay: rgba(233, 238, 243, 0.13);
  --selection: rgba(124, 183, 255, 0.30);
  --shadow-float: 0 10px 22px -12px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}
@media (min-width: 600px) { :root { --gutter: 24px; } }
@media (min-width: 900px) { :root { --gutter: 40px; } }
@media (pointer: coarse) { :root { --control: 44px; } }

/* ---- base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body, #root { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--text); font: var(--type-body); font-variant-numeric: tabular-nums; background: var(--bg); }
::selection { background: var(--selection); }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
h1, h2 { text-wrap: balance; }
p { text-wrap: pretty; }
h1 { font: var(--type-title); font-stretch: 112%; letter-spacing: -0.03em; }
h2 { font: var(--type-section); font-stretch: 105%; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
code, .mono { font: var(--type-mono); overflow-wrap: anywhere; }
.muted { color: var(--text-secondary); }
.hint { font: var(--type-meta); color: var(--text-secondary); max-width: 44ch; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.glyph { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; }
.glyph .knock { stroke: var(--bg); }
/* A crew member's signal flag: who they are, never a state. The drawing has its
   own outline and margin; a crew member with no flag shows a dashed blank. */
.flag { width: 28px; height: 28px; flex: none; }
.flag.large { width: 44px; height: 44px; }
.flag.blank { color: var(--text-tertiary); }

/* ---- controls: rectangles; one filled a view ---- */
button, input, select, textarea { font: inherit; color: var(--text); }
button { min-height: var(--control); padding: 6px var(--space-5); border: var(--outline); border-radius: var(--radius-1); background-color: transparent; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; transition: background-color var(--dur-quick); }
button:hover { background-image: linear-gradient(var(--hover-overlay), var(--hover-overlay)); }
button:active { background-image: linear-gradient(var(--press-overlay), var(--press-overlay)); }
button.primary { background-color: var(--primary); border-color: var(--primary); color: var(--on-primary); }
button.primary:hover { background-image: linear-gradient(var(--fill-hover), var(--fill-hover)); }
button.danger { border-color: var(--danger); color: var(--danger-text); background-color: transparent; }
button.danger-fill { background-color: var(--danger); border-color: var(--danger); color: var(--on-danger); }
button.quiet { border-color: transparent; color: var(--text-secondary); }
button.small { min-height: max(28px, calc(var(--control) - 8px)); padding: 2px var(--space-4); font: var(--type-label); }
button.icon-only { padding: 0; width: var(--control); }
button:disabled { color: var(--text-tertiary); border: 1px dashed var(--border-strong); background: none; cursor: not-allowed; }
button.link { min-height: 0; padding: var(--space-2) 0; border: 0; background: none; color: inherit; font-weight: 600; text-decoration: none; }
button.link:hover { background-image: none; text-decoration: underline; text-underline-offset: 3px; }
p button.link { text-decoration: underline; text-underline-offset: 3px; }
@media (pointer: coarse) { button.link { padding-block: var(--space-4); } }

input, select, textarea { min-height: var(--control); padding: 6px var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-1); background: var(--surface-raised); min-width: 0; max-width: 100%; }
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
textarea:disabled, input:disabled { color: var(--text-tertiary); border-style: dashed; background: none; cursor: not-allowed; }
label { display: block; font: var(--type-label); margin-bottom: var(--space-2); }
.field { display: grid; align-content: start; min-width: 0; }
.field .hint { margin-top: var(--space-2); }
/* A hint that is a line of facts of its own (the Ship's sizes, where the log's older entries went). */
.hint.wide { max-width: none; overflow-wrap: anywhere; }
main > .hint.wide { max-width: var(--column); }
.row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }

/* ---- shell: the top bar is a ruled line ---- */
.bridge { display: flex; flex-direction: column; height: 100dvh; }
.bridge.halted::before { content: ""; position: fixed; inset: 0 0 auto 0; height: 3px; background: var(--danger); z-index: 6; }
.topbar { flex: none; padding: env(safe-area-inset-top, 0px) var(--gutter) 0; border-bottom: var(--rule-ink); position: relative; z-index: 2; }
.topbar-in { max-width: var(--column); margin-inline: auto; display: flex; align-items: stretch; gap: var(--space-6); min-height: var(--bar); }
.brand { display: flex; align-items: center; gap: 10px; font: var(--type-name); font-stretch: 112%; letter-spacing: -0.01em; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; flex: none; }
/* The Ship's name beside the logo: one line, cut with an ellipsis. */
.ship-name { align-self: center; flex: 0 1 auto; min-width: 6ch; max-width: 24ch; margin: 0 0 0 calc(-1 * var(--space-3)); padding-left: var(--space-5); border-left: var(--rule); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--type-section); font-stretch: 105%; color: var(--text-secondary); }
.nav { display: flex; gap: var(--space-6); margin-left: var(--space-3); }
.nav button { position: relative; min-height: 0; padding: 0; border: 0; border-radius: 0; color: var(--text-secondary); font: var(--type-label); font-weight: 500; }
.nav button:hover { background-image: none; color: var(--text); }
.nav button[aria-current="page"] { color: var(--text); font-weight: 600; }
.nav button[aria-current="page"]::after { content: ""; position: absolute; inset: auto 0 -1px 0; height: 4px; background: var(--text); }
.nav .nav-icon { display: none; width: 20px; height: 20px; }
.count { display: inline-flex; align-items: center; gap: 3px; color: var(--warning-text); font-weight: 600; }
.count .glyph { width: 12px; height: 12px; }
.tools { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.tools > button { border-color: transparent; color: var(--text-secondary); padding: 0; width: var(--control); }
.signout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
main { position: relative; flex: 1; min-height: 0; overflow-y: auto; overflow-x: clip; padding: var(--space-7) var(--gutter) var(--space-9); }
main > * { max-width: var(--column); margin-inline: auto; }
main > * + * { margin-top: var(--space-8); }

/* Eight links (the Database page, with developer features on) still leave room for the telegraph. */
@media (max-width: 1299px) { .topbar-in, .nav { gap: var(--space-5); } }
@media (max-width: 1199px) { .nav { gap: var(--space-4); } }
@media (max-width: 1099px) { .nav { gap: var(--space-3); } }
@media (max-width: 1199px) { .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } .ship-name { margin-left: 0; padding-left: 0; border-left: 0; } }
/* Under 1000 px the bar has no room for the links beside the telegraph, and the
   stop must stay on screen: the links become a tab bar on the sheet, at the foot.
   A tab is never narrower than its label: when the tabs do not fit, the bar
   scrolls sideways (the Bridge brings the current tab into view). */
@media (max-width: 999px) {
  .topbar-in { justify-content: space-between; }
  .nav { position: fixed; inset: auto 0 0 0; z-index: 3; margin: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(max-content, 1fr); gap: 0; overflow-x: auto; overscroll-behavior-x: contain; padding: 0 var(--space-2) env(safe-area-inset-bottom, 0px); background: var(--surface-raised); border-top: var(--rule-ink); box-shadow: var(--shadow-float); }
  .nav button { flex-direction: column; gap: var(--space-1); min-height: 56px; padding: 6px var(--space-1); color: var(--text-tertiary); font: var(--type-tab); }
  /* The bar scrolls sideways, which clips a ring drawn outside a tab at the top and the foot: it goes inside. */
  .nav button:focus-visible { outline-offset: -4px; }
  .nav button[aria-current="page"]::after { inset: -1px var(--space-3) auto var(--space-3); }
  .nav .nav-icon { display: block; }
  .nav .count { position: absolute; top: var(--space-2); left: calc(50% + 8px); }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 719px) {
  body { font: var(--type-body-large); }
  main { padding-top: var(--space-6); }
}
@media (max-width: 419px) {
  .brand { display: none; }
  .topbar-in { flex-wrap: wrap; align-items: center; padding-block: var(--space-3); }
  .ship-name { order: -1; flex: 1 0 100%; max-width: none; }
  .tools { gap: var(--space-2); flex: 1; justify-content: space-between; }
  .telegraph > button { min-width: 0; padding: 0 var(--space-4); }
  /* the telegraph is at the left here: its question opens to the right */
  .popover { left: 0; right: auto; }
}

/* ---- order telegraph: a plate with two sectors and a pointer ---- */
.telegraph { position: relative; display: flex; border: var(--outline); border-radius: var(--radius-2); background: var(--surface-raised); box-shadow: var(--shadow-float); }
.telegraph > button { min-height: calc(var(--control) - 2px); min-width: 112px; padding: 0 14px; border: 0; border-radius: 0; color: var(--text-secondary); font: var(--type-telegraph); font-stretch: 110%; letter-spacing: 0.08em; text-transform: uppercase; transition: none; }
.telegraph > button + button { border-left: var(--outline); }
.telegraph > button .glyph { width: 9px; height: 9px; }
.telegraph .t-stop { color: var(--danger-text); }
.telegraph.underway .t-under { background-color: var(--ok); color: var(--on-ok); border-radius: var(--radius-inner) 0 0 var(--radius-inner); cursor: default; }
.telegraph.underway .t-under:hover { background-image: none; }
.telegraph.halted .t-stop { background-color: var(--danger); color: var(--on-danger); border-radius: 0 var(--radius-inner) var(--radius-inner) 0; }
.telegraph.halted .t-under { color: var(--text); }
.telegraph.unknown, .telegraph.reading { border-style: dashed; }
.telegraph.underway::before, .telegraph.halted::before { content: ""; position: absolute; top: -9px; border: 6px solid transparent; border-top: 7px solid var(--text); border-bottom: 0; transform: translateX(-50%); pointer-events: none; }
.telegraph.underway::before { left: 25%; }
.telegraph.halted::before { left: 75%; }
/* the sheet: what is above the page */
.popover, .confirm, .console { border: var(--outline); border-radius: var(--radius-2); background: var(--surface-raised); box-shadow: var(--shadow-float); }
.popover { position: absolute; top: calc(100% + 10px); right: 0; z-index: 4; width: min(320px, calc(100vw - 2 * var(--gutter))); padding: var(--space-5); display: grid; gap: var(--space-4); white-space: normal; text-transform: none; }
.popover .row { justify-content: flex-end; }

/* ---- page furniture: sections stand on the paper, under a rule ---- */
.page { display: grid; gap: var(--space-7); align-content: start; }
.page-head { display: grid; gap: var(--space-2); }
.lead { color: var(--text-secondary); max-width: 60ch; font: var(--type-lead); }
.section { display: grid; gap: var(--space-4); min-width: 0; align-content: start; }
.section-head { display: flex; align-items: baseline; gap: var(--space-4); flex-wrap: wrap; padding-top: 10px; border-top: var(--rule-head); }
/* a section whose heading stands alone has the same rule */
.section > h2:first-child, .section > header:first-child { padding-top: 10px; border-top: var(--rule-head); }
.section-head .aside { margin-left: auto; color: var(--text-tertiary); font: var(--type-meta); }
.section-head button.aside { min-height: 0; padding: 0; border: 0; text-decoration: underline; text-underline-offset: 3px; }
.empty { padding-block: var(--space-4) var(--space-6); color: var(--text-secondary); display: grid; gap: var(--space-4); justify-items: start; }
.split { display: grid; gap: var(--space-8); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: var(--space-9); } }

/* notices: between two rules in the state's colour; no fill */
.error, .ok { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4) 0; border-top: 2px solid; border-bottom: 1px solid; font: var(--type-label); font-weight: 500; overflow-wrap: anywhere; }
.error > .glyph, .ok > .glyph { margin-top: 2px; }
.error { color: var(--danger-text); border-color: var(--danger); }
.error.is-warning { color: var(--warning-text); border-color: var(--warning); }
.error.is-incomplete { border-top-style: dashed; border-bottom-style: dashed; }
.ok { color: var(--ok-text); border-color: var(--ok); }

/* state: word, shape, then colour; never a fill */
.state-tag { display: inline-flex; align-items: center; gap: 6px; font: var(--type-meta); font-weight: 600; white-space: nowrap; vertical-align: middle; }
.state-tag.ok-tone { color: var(--ok-text); }
.state-tag.off-tone { color: var(--text-secondary); }
.state-tag.busy-tone { color: var(--info-text); }
.state-tag.doubt-tone { color: var(--warning-text); }
.state-tag.bad-tone { color: var(--danger-text); }
.state-tag.busy-tone .glyph { animation: turn var(--dur-pulse) linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }

/* tables: no box; hairlines between rows */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: var(--space-3) var(--space-5) var(--space-3) 0; color: var(--text-tertiary); font: var(--type-meta); white-space: nowrap; }
td { padding: 11px var(--space-5) 11px 0; border-top: var(--rule); vertical-align: middle; overflow-wrap: break-word; }
th:last-child, td:last-child { padding-right: 0; }
tbody:last-child tr:last-child td { border-bottom: var(--rule); }
td.mono { overflow-wrap: break-word; }
th.num, td.num { text-align: right; white-space: nowrap; }
td.when, td time { white-space: nowrap; }
td.when { font: var(--type-mono); color: var(--text-secondary); }
td .who { display: flex; align-items: center; gap: var(--space-4); }
td .who button.link { font: var(--type-mono-name); }
/* On a phone a row becomes a labelled list, so its actions stay on screen. */
@media (max-width: 719px) {
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; }
  table.stack tr { padding: var(--space-4) 0; border-top: var(--rule); }
  table.stack tbody:last-child tr:last-child td { border-bottom: 0; }
  table.stack td { border: 0; padding: 3px 0; display: flex; gap: var(--space-4); justify-content: space-between; align-items: center; text-align: right; }
  table.stack td::before { content: attr(data-label); flex: none; color: var(--text-tertiary); font: var(--type-meta); text-align: left; }
  table.stack td:empty { display: none; }
  table.stack td.actions { display: block; text-align: left; padding-top: var(--space-3); }
  table.stack td.actions::before { display: none; }
}

/* ---- sign in: the claim, the mark's heading line, one control on the sheet ---- */
.signin { flex: none; max-width: 440px; margin: 0 auto; padding: 14vh var(--gutter) var(--space-8); overflow: visible; }
.signin > * + * { margin-top: var(--space-5); }
.signin .wordmark { display: flex; align-items: center; gap: var(--space-4); font: var(--type-title); font-stretch: 116%; letter-spacing: -0.03em; }
.signin .wordmark svg { width: 36px; height: 36px; }
.signin button { width: 100%; min-height: 44px; }

.arrival { flex: none; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; min-height: 100dvh; padding: 0 var(--gutter); overflow: clip; }
.arrival > * { max-width: none; margin: 0; }
.arrival > * + * { margin-top: 0; }
.arrival-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--bar); padding-top: env(safe-area-inset-top, 0px); border-bottom: var(--rule-ink); }
.arrival-top h1 { display: flex; align-items: center; gap: 10px; font: var(--type-name); font-stretch: 112%; letter-spacing: -0.01em; }
.arrival-top h1 svg { width: 22px; height: 22px; flex: none; }
.arrival-top button.icon-only { border-color: transparent; color: var(--text-secondary); }
.arrival-sky { align-self: end; justify-self: center; display: grid; justify-items: center; gap: var(--space-5); padding: var(--space-8) 0 var(--space-7); text-align: center; }
.claim { font: var(--type-title); font-size: var(--size-claim); line-height: var(--leading-claim); font-stretch: 125%; letter-spacing: -0.045em; text-wrap: balance; max-width: 11em; }
.claim span { display: block; color: var(--text-tertiary); }
.arrival-sky .lead { max-width: 34ch; }
.deck { display: grid; justify-items: center; }
.console { position: relative; z-index: 1; width: min(100%, 420px); display: grid; gap: var(--space-3); padding: var(--space-3); }
.console button { width: 100%; min-height: 52px; padding: 0 var(--space-6); font: var(--type-control); gap: 10px; }
.console button .glyph { transition: transform var(--dur-base) var(--ease-standard); }
.console button:hover:not(:disabled) .glyph { transform: translateX(3px); }
.console button:disabled { border: var(--outline); background-color: color-mix(in srgb, var(--primary) 70%, transparent); border-color: transparent; color: var(--on-primary); cursor: progress; }
.console .error, .console .ok { padding-inline: var(--space-3); }
.console .waiting { padding: var(--space-1) var(--space-5) 6px; color: var(--text-secondary); font: var(--type-meta); text-align: center; }
.console .field { padding: var(--space-3) var(--space-3) var(--space-2); }
.console label { margin-bottom: var(--space-3); }
.console input { width: 100%; min-height: 52px; padding: 0 var(--space-5); text-align: center; font: var(--type-code); letter-spacing: 0.14em; }
.console input::placeholder { letter-spacing: 0.14em; }
.console input.ship-name-input { font: var(--type-name); font-stretch: 105%; letter-spacing: -0.01em; text-align: left; }
.console .hint { margin-top: var(--space-3); max-width: none; }
.console .hint code { white-space: nowrap; }
/* The Ship's name above the button, in the face it has in the top bar. */
.arrival-ship { margin: var(--space-2) var(--space-4) var(--space-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font: var(--type-name); font-stretch: 105%; letter-spacing: -0.01em; }
/* the mark, its heading line drawn up to the control */
.wake { display: flex; flex-direction: column; align-items: center; height: var(--size-wake); padding-bottom: calc(var(--space-7) + env(safe-area-inset-bottom, 0px)); }
.wake .heading { position: relative; flex: 1; width: 1px; margin-bottom: -3px; background: var(--border-strong); overflow: hidden; }
.wake svg { width: 40px; height: 40px; flex: none; color: var(--text); }
/* busy: light runs up the heading line into the control */
.arrival.is-busy .wake .heading::after { content: ""; position: absolute; left: 0; width: 1px; height: 72px; bottom: -72px; background: linear-gradient(transparent, var(--text), transparent); animation: rise 1400ms var(--ease-standard) infinite; }
@keyframes rise { to { bottom: 100%; } }
@media (prefers-reduced-motion: reduce) { .arrival.is-busy .wake .heading { background: var(--text); } }
/* refused: the control shakes its head once */
.arrival.is-refused .console { animation: refuse 420ms var(--ease-standard); }
@keyframes refuse { 20% { transform: translateX(-7px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } 88% { transform: translateX(1px); } }

/* ---- overview: the Ship's state is a headline ---- */
.ship-state { display: grid; min-width: 0; }
.ship-state .eyebrow { font: var(--type-eyebrow); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-tertiary); }
.state-word { display: flex; align-items: center; gap: 0.16em; margin: 14px 0 0 -0.03em; font: var(--type-title); font-size: var(--size-state); line-height: var(--leading-state); font-stretch: 125%; letter-spacing: -0.05em; }
.state-word strong { font-weight: inherit; min-width: 0; }
.state-word i { flex: none; width: 0.5em; height: 0.5em; margin-top: 0.06em; }
.ship-state.underway .state-word i { border-radius: 50%; background: var(--ok); }
.ship-state.halted .state-word i { border-radius: var(--radius-glyph); background: currentColor; }
.ship-state.unknown .state-word i, .ship-state.reading .state-word i { border: 0.04em dashed currentColor; border-radius: var(--radius-glyph); }
.ship-state.unknown .state-word, .ship-state.reading .state-word { color: var(--text-secondary); font-size: var(--size-claim); line-height: var(--leading-claim); }
.state-line { margin-top: var(--space-6); color: var(--text-secondary); font: var(--type-lead); }
.ship-state .row { margin-top: var(--space-4); gap: var(--space-3) var(--space-5); }
.ship-state .row:empty { display: none; }
.figures { margin-top: var(--space-8); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: var(--rule-head); border-bottom: var(--rule); }
.figure, button.figure { display: flex; align-items: baseline; justify-content: flex-start; gap: var(--space-4); min-height: 0; padding: var(--space-5) var(--space-3) var(--space-5) var(--space-5); border: 0; border-left: var(--rule); border-radius: 0; background-color: transparent; font-weight: 400; text-align: left; white-space: normal; }
.figure:first-child { padding-left: 0; border-left: 0; }
.figure b { font: var(--type-figure); letter-spacing: -0.03em; }
.figure span { color: var(--text-secondary); font: var(--type-label); font-weight: 400; }
.figure.busy b, .figure.busy span { color: var(--info-text); }
.figure.doubt b, .figure.doubt span { color: var(--warning-text); }
@media (max-width: 719px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { padding-left: 0; border-left: 0; }
  .figure:nth-child(n + 3) { border-top: var(--rule); }
  .figure b { font: var(--type-figure-small); }
  .figure, button.figure { flex-direction: column; gap: var(--space-2); }
}
/* halted: the band is red from edge to edge of the window */
.ship-state.halted { position: relative; isolation: isolate; color: var(--on-danger); padding-block: var(--space-7) 1px; }
.ship-state.halted::before { content: ""; position: absolute; z-index: -1; inset: 0 calc(50% - 50vw); background: var(--danger); }
main:has(> .page:first-child > .page-head + .ship-state.halted) { padding-top: 0; }
.ship-state.halted .eyebrow, .ship-state.halted .state-line, .ship-state.halted .figure, .ship-state.halted .figure span, .ship-state.halted .figure b, .ship-state.halted .state-tag { color: inherit; }
.ship-state.halted .figures { border-color: currentColor; }
.ship-state.halted .figure { border-color: color-mix(in srgb, currentColor 35%, transparent); }
.ship-state.halted button.primary { background-color: var(--on-danger); border-color: var(--on-danger); color: var(--danger); }
.ship-state.halted button:not(.primary):not(.figure) { border-color: currentColor; color: inherit; }
.ship-state.halted :focus-visible { outline-color: var(--on-danger); }
/* its question is on the sheet, in ink */
.ship-state.halted .confirm { color: var(--text); }
.ship-state.halted .confirm button.primary { background-color: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.ship-state.halted .confirm :focus-visible { outline-color: var(--focus); }
.ship-state .confirm { flex: 1 1 100%; }

.glance { display: grid; gap: var(--space-8) var(--space-9); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1000px) { .glance { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } .glance > .wide { grid-column: 1 / -1; } }
.glance .section { gap: 0; }
.crew-list { list-style: none; }
.crew-list li { display: flex; align-items: center; gap: var(--space-5); padding: 14px 0; border-bottom: var(--rule); }
.crew-list .flag { width: 44px; height: 44px; }
.crew-list .names { display: grid; min-width: 0; margin-right: auto; justify-items: start; }
.crew-list .names span { color: var(--text-secondary); font: var(--type-meta); }
.crew-list .names button.link { padding: 0; font: var(--type-mono-name); }

/* ---- today's watch: the Ship's day as a ruler ---- */
.ruler { display: block; width: 100%; height: auto; }
/* a flag in a lane takes its size from the drawing, not from the page */
.ruler .flag { width: auto; height: auto; }
.ruler text { font: var(--type-mono-small); fill: var(--text-tertiary); }
.ruler .name { font: var(--type-mono-label); fill: var(--text); }
.ruler .at { fill: var(--text); font-weight: 500; }
.ruler .tick { stroke: var(--text); stroke-width: 1; }
.ruler .lane { stroke: var(--hairline); stroke-width: 1; }
.ruler .now { stroke: var(--text); stroke-width: 1.5; }
.ruler .ahead { fill: var(--surface-sunken); }
.ruler .bar { fill: var(--info); }
.ruler .bar.failed { fill: var(--danger); }
.ruler .bar.stopped, .ruler .bar.interrupted { fill: none; stroke: var(--warning); stroke-width: 1.5; stroke-dasharray: 3 2; }
/* a lane's flag and name open the hail */
.ruler .who { cursor: pointer; }
.ruler .who:hover .name, .ruler .who:focus-visible .name { text-decoration: underline; }

/* fit out */
.fitout { padding-top: var(--space-4); border-top: var(--rule-head); display: grid; gap: var(--space-4); }
.fitout ol { list-style: none; display: grid; }
.fitout li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: var(--space-2) var(--space-4); padding-block: var(--space-4); border-top: var(--rule); }
.fitout li > .glyph { margin-top: 3px; }
.fitout li > :not(.glyph) { grid-column: 2; }
.fitout li.done { color: var(--text-secondary); }
.fitout li.done > .glyph { color: var(--ok-text); }
.fitout li strong { font-weight: 600; }
.fitout li.done strong { font-weight: 400; }
.fitout form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-3); align-items: end; max-width: 520px; }
.fitout form label { grid-column: 1 / -1; margin: 0; }
.fitout li > button { justify-self: start; }
p.fitout.done { display: flex; padding-block: var(--space-4); border-top: var(--rule); border-bottom: var(--rule); }

/* ---- crew ---- */
.signon { display: grid; gap: var(--space-4); }
.signon input, .signon select { width: 100%; }
.signon input { font: var(--type-mono); }
.signon > button { justify-self: start; }
.signon textarea { width: 100%; padding: var(--space-3) var(--space-4); font: var(--type-mono); resize: vertical; }
.signon .check, .settings-developer .check, .db-form .check, .ext-pick .check { display: flex; align-items: center; gap: var(--space-3); }
.signon .check input, .settings-developer .check input, .db-form .check input, .ext-pick .check input { width: auto; min-height: 0; }
.settings-developer .check, .db-form .check { margin: 0; }

/* ---- hail ---- */
main > .hail { height: 100%; min-height: 380px; display: flex; flex-direction: column; gap: var(--space-4); max-width: 860px; }
.hail-head { display: flex; gap: var(--space-3) var(--space-4); align-items: center; flex-wrap: wrap; padding-bottom: var(--space-4); border-bottom: var(--rule-head); }
.hail-head h1 { font: var(--type-subtitle); font-stretch: 108%; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.hail-head .right { margin-left: auto; }
.confirm { padding: var(--space-5); display: grid; gap: var(--space-4); max-width: 560px; }
td .confirm, td [role="group"] { box-shadow: none; border: 0; padding: 0; background: none; display: grid; gap: var(--space-3); }
.conversation { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: var(--space-3) 2px; display: flex; flex-direction: column; gap: var(--space-6); }
.conversation > .muted { margin: auto; text-align: center; }
.conversation .earlier { align-self: center; }
.turn { display: grid; gap: var(--space-3); }
.turn .when { font: var(--type-mono-small); color: var(--text-tertiary); justify-self: end; }
.turn .origin { font: var(--type-meta); color: var(--text-secondary); justify-self: end; overflow-wrap: anywhere; }
.prompt, .reply, .turn .error { white-space: pre-wrap; overflow-wrap: anywhere; }
.prompt { justify-self: end; max-width: min(60ch, 86%); padding: 10px var(--space-5); border-radius: var(--radius-1); background: var(--primary); color: var(--on-primary); }
.reply { justify-self: start; max-width: 68ch; font: var(--type-read); }
.turn .error { justify-self: start; max-width: min(68ch, 92%); }
.turn .error.is-interrupted { border-style: dashed; border-color: var(--warning); color: var(--warning-text); }
.turn .hint { margin-top: var(--space-2); }
.working { display: flex; align-items: center; gap: var(--space-3); color: var(--info-text); font-weight: 500; }
.working-bar { display: inline-flex; gap: 3px; }
.working-bar i { width: 6px; height: 6px; background: var(--info); opacity: 0.25; animation: fill var(--dur-pulse) steps(1) infinite; }
.working-bar i:nth-child(2) { animation-delay: 400ms; }
.working-bar i:nth-child(3) { animation-delay: 800ms; }
@keyframes fill { 0%, 74% { opacity: 1; } 75%, 100% { opacity: 0.25; } }
.divider { display: flex; align-items: center; gap: var(--space-3); color: var(--text-tertiary); font: var(--type-meta); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: var(--rule); }
.compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-3); align-items: end; padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5); border: 1px solid var(--border-strong); border-radius: var(--radius-1); background: var(--surface-raised); }
.compose:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.compose textarea { width: 100%; resize: none; border: 0; padding: 6px 0; background: none; outline: none; min-height: 0; }
.compose textarea:disabled { background: none; }
.compose .reason { grid-column: 1 / -1; padding-bottom: var(--space-2); }
.compose p.muted { font: var(--type-meta); }
@media (max-height: 500px) { main > .hail { min-height: 0; } }

/* ---- hosts and approvals: what waits is under an amber rule ---- */
.pending-hosts, .pending-approvals { list-style: none; display: grid; gap: var(--space-6); }
.pending-hosts li, .pending-approvals li { padding-top: var(--space-4); border-top: 2px solid var(--warning); display: grid; gap: var(--space-3); }
.pending-hosts .top, .pending-approvals .top { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.host-name { font: var(--type-mono-name); overflow-wrap: anywhere; }
.pending-hosts .row input, .pending-approvals .row input { flex: 1 1 14ch; }
.pending-approvals section { display: grid; gap: var(--space-3); min-width: 0; }
.pending-approvals h3 { display: flex; align-items: center; gap: var(--space-3); font: var(--type-section); overflow-wrap: anywhere; }
.pending-approvals h4 { margin: 0; font: var(--type-meta); font-weight: 600; color: var(--text-secondary); }
.proposal-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.proposal-fields { margin: 0; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.proposal-fields dt { font: var(--type-meta); color: var(--text-secondary); }
.proposal-fields dd { margin: 0; overflow-wrap: anywhere; }
.proposal-file, .slack-manifest { margin: 0; padding: var(--space-4); overflow: auto; background: var(--surface-raised); border: var(--rule); border-radius: var(--radius-1); font: var(--type-mono); }
.proposal-file { max-height: 320px; white-space: pre-wrap; overflow-wrap: anywhere; }
.proposal-edit { display: grid; gap: var(--space-3); min-width: 0; }
.proposal-edit .fields { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.proposal-edit .field label { margin-bottom: var(--space-2); }
.proposal-edit textarea.short { min-height: 0; }
.proposal-edit textarea { width: 100%; min-height: 160px; padding: var(--space-4); font: var(--type-mono); resize: vertical; }
.approved-with { display: grid; gap: var(--space-3); min-width: 0; }
.approved-with summary { cursor: pointer; font-weight: 600; padding-block: var(--space-2); }
.approved-with details > :not(summary) { margin-top: var(--space-3); }
td.actions .row > .danger { border-color: transparent; }
td.actions .row > :not(.danger) + .danger { margin-left: var(--space-4); }
.block-form { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.block-form input { width: 100%; }
.block-form #block-host { font: var(--type-mono); }
.block-form > button { justify-self: start; }

/* ---- extensions: the Ship's list, each crew member's set, and the start set of a sign-on ---- */
.ext-cell { display: grid; gap: var(--space-1); min-width: 0; justify-items: start; }
.ext-facts { list-style: none; display: flex; flex-wrap: wrap; gap: 0 var(--space-4); font: var(--type-meta); }
.ext-facts strong { font-weight: 600; }
.ext-why summary { cursor: pointer; color: var(--text-secondary); font: var(--type-meta); }
.ext-why ul { list-style: none; margin-top: var(--space-2); display: grid; gap: var(--space-1); color: var(--text-secondary); font: var(--type-mono-small); overflow-wrap: anywhere; }
.ext-set { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.ext-set li { display: inline-flex; align-items: center; gap: var(--space-2); }
/* an MCP server's command: each part in its own ruled box, so an argument with a space is seen as one */
.ext-command { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ext-command li { padding: 0 var(--space-2); border: var(--rule); border-radius: var(--radius-1); white-space: pre-wrap; }
.ext-pick { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: var(--space-2); }
.ext-pick legend { padding: 0; margin-bottom: var(--space-2); font: var(--type-label); }
.ext-pick .check { margin: 0; font: var(--type-mono); }
@media (max-width: 719px) {
  table.stack td .ext-cell { justify-items: end; }
  table.stack td .ext-facts, table.stack td .ext-set, table.stack td .ext-command { justify-content: flex-end; }
}

/* the Ship's repository on the Overview: a line that opens */
.repository > div:first-child > button { padding-left: 0; text-decoration: underline; text-underline-offset: 3px; }

/* ---- settings ---- */
.settings-form { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); align-items: start; }
.settings-form select, .settings-form input { width: 100%; }
.settings-form .save-row { margin-top: var(--space-2); }
.settings-form h2 { margin-top: var(--space-5); padding-top: 10px; border-top: var(--rule-head); }
@media (min-width: 720px) { .settings-form { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-7); } .settings-form .save-row, .settings-form h2 { grid-column: 1 / -1; } }
@media (min-width: 1600px) { .settings-form { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---- ship's log: a ledger ---- */
.search { display: flex; gap: var(--space-3); max-width: 520px; }
.search input { flex: 1; }
table.log td { vertical-align: baseline; }
table.log tr.day th { padding: var(--space-5) 0 var(--space-2); color: var(--text-secondary); font: var(--type-meta); font-weight: 600; border-top: var(--rule); }
table.log tbody:first-of-type tr.day th { border-top: 0; }
table.log thead + tbody tr.day th { padding-top: var(--space-3); }
table.log .time { font: var(--type-mono); color: var(--text-tertiary); white-space: nowrap; width: 1%; }
table.log .who { white-space: nowrap; width: 1%; }
table.log .who .via { color: var(--text-tertiary); font: var(--type-meta); }
table.log .what { white-space: nowrap; width: 1%; font-weight: 600; padding-right: var(--space-6); }
table.log .what .mono { font-weight: 400; }
.facts { display: flex; flex-wrap: wrap; gap: 2px var(--space-5); align-items: baseline; font: var(--type-mono); color: var(--text-secondary); }
.facts .subject { color: var(--text); overflow-wrap: anywhere; }
.facts .state-tag { align-self: center; }
.facts .fact { overflow-wrap: anywhere; }
.facts .k { margin-right: 6px; color: var(--text-tertiary); }
@media (max-width: 719px) {
  table.log thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.log, table.log tbody { display: block; }
  table.log tr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px var(--space-4); padding: var(--space-4) 0; border-top: var(--rule); }
  table.log tr.day { display: block; padding: 0; border-top: 0; }
  table.log tr.day + tr { border-top: 0; padding-top: 0; }
  table.log tr.day th { display: block; border-top: var(--rule); }
  table.log td { display: block; padding: 0 !important; border: 0 !important; width: auto !important; white-space: normal !important; }
  table.log td.what, table.log td.detail { grid-column: 1 / -1; }
  table.log td.detail:has(.facts:empty) { display: none; }
}

/* ---- slack (the Fit-out step and an app's panel) ---- */
.slack-step, .slack-app { display: grid; gap: var(--space-5); min-width: 0; }
.slack-part { display: grid; gap: var(--space-3); align-content: start; min-width: 0; }
.slack-step > .slack-part + .slack-part, .slack-app > .slack-part { padding-top: var(--space-4); border-top: var(--rule); }
.slack-part h3 { font: var(--type-section); }
.slack-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-3); align-items: end; max-width: 520px; }
.slack-form label { grid-column: 1 / -1; margin: 0; }
.slack-form input { font: var(--type-mono); }
form.slack-form.stacked { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.slack-form .field label { margin-bottom: var(--space-2); }
.slack-form.stacked > button { justify-self: start; }
.slack-step summary, .slack-app summary { cursor: pointer; font-weight: 600; padding-block: var(--space-3); }
.slack-step details > :not(summary), .slack-app details > :not(summary) { margin-top: var(--space-3); }
.slack-manifest { max-height: 240px; }
.slack-steps { display: grid; gap: var(--space-2); padding-left: var(--space-6); }
.checks { list-style: none; display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: var(--space-4); }
.checks li { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; align-items: baseline; padding-block: var(--space-3); border-top: var(--rule); }
.checks li:first-child { border-top: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .working-bar i:nth-child(2) { opacity: 1; }
}
@media (forced-colors: active) { .telegraph.halted .t-stop, .telegraph.underway .t-under { border: 2px solid; } }

/* ---- developer features: the line across the top, Settings' switch, the Database page ---- */
/* The line is amber and dashed: while it shows, the Ship's state may not be what the Helm believes. */
.developer-line { flex: none; margin: 0; text-align: center; text-wrap: balance; padding: calc(var(--space-2) + env(safe-area-inset-top, 0px)) var(--gutter) var(--space-2); color: var(--warning-text); border-bottom: 2px dashed var(--warning); font: var(--type-meta); font-weight: 600; position: relative; z-index: 3; }
.developer-line .glyph { display: inline-block; width: 12px; height: 12px; margin-right: var(--space-3); vertical-align: -1px; }
.developer-line time { font: var(--type-mono); font-weight: 500; white-space: nowrap; }
.developer-line a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.developer-line + .topbar { padding-top: 0; }
.db-layout { display: grid; gap: var(--space-7); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .db-layout { grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); } }
.db-tables { border-top: var(--rule-head); }
.db-tables ul { list-style: none; }
.db-tables li + li { border-top: var(--rule); }
.db-tables button { width: 100%; justify-content: flex-start; flex-wrap: wrap; white-space: normal; text-align: left; padding-inline: var(--space-3); border: 0; border-left: 4px solid transparent; border-radius: 0; color: var(--text); font-weight: 500; }
.db-tables button[aria-current="true"] { border-left-color: var(--text); }
.db-tables button[aria-current="true"] .mono { font-weight: 500; }
.db-count { margin-left: auto; color: var(--text-tertiary); font: var(--type-mono); }
.db-rows { display: grid; gap: var(--space-7); min-width: 0; }
.db-rows > .empty { padding-top: 10px; border-top: var(--rule-head); }
.db-table { display: grid; gap: var(--space-4); min-width: 0; }
.db-head { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; padding-top: 10px; border-top: var(--rule-head); }
.db-head h2 { margin-right: auto; font: var(--type-mono-name); overflow-wrap: anywhere; }
.db-filter { display: flex; gap: var(--space-3); }
.db-filter input { width: min(260px, 100%); }
.db-cell { display: block; max-height: 160px; overflow: auto; white-space: pre-wrap; overflow-wrap: break-word; max-width: 60ch; }
@media (min-width: 720px) { .db-table td.actions .row { flex-wrap: nowrap; } }
.db-paging { padding-top: var(--space-4); border-top: var(--rule); }
.db-form { max-width: 760px; }
.db-form textarea { width: 100%; }
.db-form .field > input:not([type="checkbox"]) { width: 100%; }
