:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f4ef, #111110);
  --surface: light-dark(#fffdf9, #1a1917);
  --raised: light-dark(#faf7f1, #22201d);
  --hover: light-dark(#f2ede3, #26241f);
  --line: light-dark(#e7e1d5, #2e2b26);
  --line-strong: light-dark(#8c8274, #83796b);
  --ink: light-dark(#1f1a14, #ece7de);
  --muted: light-dark(#5f574b, #b3ab9e);
  --faint: light-dark(#70675d, #ada49a);
  --accent: light-dark(#8b1e24, #e57a80);
  --gold: light-dark(#a8822c, #d6b25e);
  --focus: light-dark(#5a2380, #c9a2ff);
  --captain: light-dark(#886000, #ecc46d);
  --attn: light-dark(#9a5700, #f3bf62);
  --flag: light-dark(#b3261e, #ff8985);
  --flag-bg: light-dark(#fdecea, #3a1714);
  --attn-bg: light-dark(#fdf3dc, #33280f);
  --run: light-dark(#1d5fbf, #79b8ff);
  --handoff: light-dark(#007477, #79d7dc);
  --wait: var(--attn);
  --wait-bg: light-dark(#fdf3dc, #33280f);
  --ok: light-dark(#187345, #a2d7a4);
  --idle: light-dark(#70675d, #ada49a);
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --row: 1.9rem;
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

body { margin: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.phalanx-board { max-width: 112rem; margin: 0 auto; padding: 0 clamp(.5rem, 2vw, 1.5rem) 3rem; }
.phalanx-board :focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: 3px; }
.phalanx-board a { color: var(--run); text-decoration: none; }
.phalanx-board a:hover { text-decoration: underline; }
.phalanx-board code { font: 12px var(--mono); }
.faint { color: var(--faint); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

.phalanx-board button, #operator-report button, .phalanx-board a.button {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: .2rem .6rem; cursor: pointer;
}
.phalanx-board a.button { display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box; text-decoration: none; }
.phalanx-board button:hover:not(:disabled), .phalanx-board a.button:hover { background: var(--hover); }
.phalanx-board button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.phalanx-board button.ghost:hover { color: var(--ink); background: var(--hover); }
.phalanx-board button.link { border: 0; background: none; padding: 0; color: var(--run); }
.phalanx-board input {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: .3rem .5rem;
}

/* Top bar: brand, navigation, freshness and controls on one row; counts below. */
.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem;
  padding: .35rem 0; margin-bottom: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.bar > .brand { order: 0; }
.bar > .board-navigation { order: 1; }
.bar > .bar-end { order: 2; }
.bar > .counts, .bar > .toolbar-panel, .bar > .toolbar-applied { order: 4; }
.bar-end {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .35rem .6rem;
  min-width: 0; max-width: 100%; margin-left: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.brand h1 { display: flex; margin: 0; font-size: inherit; }
/* The heading takes programmatic focus after sign-in for screen readers only. */
.brand h1:focus { outline: none; }
.phalanx-board .brand-lockup {
  display: inline-grid; grid-template-columns: 44px auto; align-items: center; gap: 10px;
  padding: 10px 0 0; color: var(--accent); text-decoration: none;
  font-family: "Palatino Linotype", Palatino, Georgia, serif; font-weight: 700;
}
.phalanx-board .brand-lockup:hover { text-decoration: none; }
.brand-shield { display: block; width: 44px; height: 44px; overflow: visible; }
.brand-letters { position: relative; }
.brand-name { display: block; font-size: 21px; line-height: 1.1; letter-spacing: .115em; }
.brand-motto {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 5px;
  color: var(--captain); font-size: 14px; font-style: italic; line-height: 1.1; letter-spacing: .035em;
}
.brand-motto::before, .brand-motto::after { content: ""; height: 1px; flex: 1; background: currentColor; opacity: .65; }
.brand .sub {
  align-self: flex-end; margin-bottom: 2px; padding-left: .6rem; border-left: 1px solid var(--line);
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
}
.brand-rank, .brand-tip-outline { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .brand-shield, .brand-letters { transition: transform 420ms cubic-bezier(.2,.8,.2,1); }
  .brand-crest { transition: transform 520ms cubic-bezier(.3,.05,.15,1); }
  .brand-rim-cap { transition: transform 420ms ease-out, opacity 420ms ease-out; }
  .brand-tip-outline { transition: opacity 350ms ease-out; }
  .brand-rank { transition: transform 550ms ease-out, opacity 550ms ease-out; }
  .brand-lockup:focus { --brand-rise: -5px; --brand-crest: -16px; --brand-cap: -7px; --brand-open: 0; --brand-tip: 1; --brand-rank-one: .23; --brand-rank-two: .11; }
  @media (hover: hover) and (pointer: fine) {
    .brand-lockup:hover { --brand-rise: -5px; --brand-crest: -16px; --brand-cap: -7px; --brand-open: 0; --brand-tip: 1; --brand-rank-one: .23; --brand-rank-two: .11; }
  }
  .brand-shield, .brand-letters { transform: translateY(var(--brand-rise, 0px)); }
  .brand-crest { transform: translateY(var(--brand-crest, 0px)); }
  .brand-rim-cap { transform: translateY(var(--brand-cap, 0px)); opacity: var(--brand-open, 1); }
  .brand-tip-outline { opacity: var(--brand-tip, 0); }
  .brand-rank-one { opacity: var(--brand-rank-one, 0); transform: translateY(calc(var(--brand-rise, 0px) * -1.4)); }
  .brand-rank-two { opacity: var(--brand-rank-two, 0); transform: translateY(calc(var(--brand-rise, 0px) * -3.4)); }
}
.health {
  display: inline-flex; align-items: center; gap: .4rem; min-width: 0; max-width: 100%;
  padding: .15rem .6rem; border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface); color: var(--muted); font-size: 12px; white-space: nowrap;
}
.health strong { color: var(--ink); font-weight: 600; }
.health-note { overflow: hidden; text-overflow: ellipsis; }
.health-endpoint { padding-left: .4rem; border-left: 1px solid var(--line); }
.health .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.h-live .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.h-stale .dot { background: var(--wait); }
.h-down .dot { background: var(--flag); }
.h-down { background: var(--flag-bg); color: var(--flag); border-color: color-mix(in srgb, var(--flag) 35%, transparent); }
.h-stale { background: var(--wait-bg); color: var(--wait); border-color: color-mix(in srgb, var(--wait) 35%, transparent); }
.h-down strong, .h-down .faint { color: var(--flag); }
.h-stale strong, .h-stale .faint { color: var(--wait); }
.counts { display: flex; flex: 1 0 100%; flex-wrap: wrap; gap: .25rem 1rem; margin: 0; padding: 0; list-style: none; color: var(--muted); }
.counts:empty { display: none; }
.counts strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.counts .t-attn, .counts .t-attn strong { color: var(--attn); }
.counts .t-wait strong { color: var(--wait); }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; max-width: 100%; gap: .15rem; }
.actions .tool-button {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-width: 36px; min-height: 36px; padding: .15rem; box-sizing: border-box;
}
.actions .new-item { padding-inline: .4rem; font-weight: 600; color: var(--accent); }
.tool-button[aria-expanded="true"], .actions .tool-button.is-active {
  border-color: var(--gold); background: var(--raised);
}
.tool-button[aria-expanded="true"] { box-shadow: inset 0 -3px var(--gold); }
.toolbar-settings > summary, .toolbar-account > summary {
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
  color: var(--ink); cursor: pointer; list-style: none;
}
.toolbar-settings > summary::-webkit-details-marker, .toolbar-account > summary::-webkit-details-marker { display: none; }
.toolbar-settings[open] > summary, .toolbar-account[open] > summary { border-color: var(--gold); box-shadow: inset 0 -3px var(--gold); }
.toolbar-settings-panel, .toolbar-account .account-panel {
  position: absolute; z-index: 4; right: 0; top: calc(100% + .35rem);
  box-sizing: border-box; width: min(28rem, calc(100vw - 3rem)); max-height: 65dvh; overflow: auto;
  padding: .75rem; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
  box-shadow: 0 6px 18px #0002;
}
.toolbar-settings:not([open]) > .toolbar-settings-panel, .toolbar-account:not([open]) > .account-panel { display: none; }
.toolbar-account .account-panel { width: min(18rem, calc(100vw - 2rem)); }
#operator-account-label { margin: 0; font-size: 12px; }
#operator-account-name { margin: .15rem 0 0; font-weight: 600; overflow-wrap: anywhere; }
#operator-account-role { margin: .15rem 0 .75rem; font-size: 12px; }
.account-panel button { width: 100%; min-height: 44px; }
.toolbar-settings-panel label { display: grid; gap: .25rem; }
.toolbar-settings-panel input, .toolbar-settings-panel select, .toolbar-settings-panel button { min-width: 44px; min-height: 44px; max-width: 100%; box-sizing: border-box; }
.toolbar-settings-panel select { width: 100%; font: inherit; color: var(--ink); background: var(--surface); }
.tool-badge { font-size: 10px; font-weight: 700; }
.tool-button::after {
  content: attr(data-tooltip); display: none; position: absolute; z-index: 5; top: 100%;
  right: 0; width: max-content; max-width: min(15rem, calc(100vw - 3rem)); padding: .35rem .5rem;
  border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface);
  color: var(--ink); font-size: 12px; font-weight: 400;
}
.tool-button:not(.tooltip-dismissed):hover::after,
.tool-button:not(.tooltip-dismissed):focus-visible::after { display: block; }
.toolbar-panel {
  flex: 1 0 100%; min-width: 0; max-width: 100%; box-sizing: border-box;
  padding: .5rem; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--raised);
}
.toolbar-panel[hidden] { display: none; }
.toolbar-applied { display: flex; flex: 1 0 100%; flex-wrap: wrap; gap: .25rem .75rem; min-width: 0; color: var(--muted); }
.toolbar-applied > span { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.board-navigation, .board-search, .board-filters, .detail-links {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: .5rem 0;
}
.board-navigation { flex: 1 1 auto; justify-content: center; margin: 0; gap: .25rem; }
.phalanx-board .board-navigation a {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 0 .7rem;
  border-radius: 6px; color: var(--muted); font-weight: 500;
}
.phalanx-board .board-navigation a:hover { color: var(--ink); background: var(--hover); text-decoration: none; }
.phalanx-board .board-navigation a[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px var(--accent); border-radius: 6px 6px 0 0; }
/* Below one-row width, navigation drops to its own row under the brand and controls. */
@media (max-width: 1100px) {
  .bar > .board-navigation { order: 4; flex: 1 0 100%; justify-content: flex-start; }
  .health-note { display: none; }
}
.board-search { margin: 0; }
.board-search label { display: flex; flex: 1 1 16rem; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; }
.board-search input { flex: 1; min-width: 0; width: 100%; }
.board-filters { position: relative; gap: .35rem; }
.filter-dropdown { min-width: 0; max-width: min(16rem, 100%); }
.filter-dropdown summary {
  display: flex; align-items: center; gap: .35rem; min-height: 44px;
  padding: .3rem .6rem; box-sizing: border-box; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
}
.filter-dropdown summary::after { content: "▾"; margin-left: auto; }
.filter-dropdown summary::marker { content: ""; }
.filter-dropdown summary::-webkit-details-marker { display: none; }
.filter-dropdown[open] summary, .filter-dropdown summary:hover { background: var(--hover); }
.filter-dropdown.is-selected summary { border-color: var(--gold); }
.filter-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.filter-panel {
  position: absolute; z-index: 3; top: calc(100% + .35rem); left: 0; right: 0;
  padding: .6rem; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); box-shadow: 0 4px 12px #0002;
}
.board-filters label { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.board-filters input { width: 20rem; max-width: 100%; }
.board-filters > a { display: inline-flex; align-items: center; padding: 0 .6rem; }
.board-navigation a, .board-search button, .board-search input,
.board-filters button, .board-filters input, .board-filters > a, .detail-links a { min-height: 44px; box-sizing: border-box; }

/* Sections. */
.sec { margin: .9rem 0 0; }
.sections > .sec:first-child { margin-top: .4rem; }
.sec h2 {
  display: flex; align-items: center; gap: .5rem; margin: 0 0 .25rem; padding: 0 .25rem;
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.count {
  font-size: 11px; font-weight: 600; letter-spacing: 0; padding: 0 .45rem; border-radius: 99px;
  background: var(--raised); border: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums;
}
.count.t-attn { background: var(--attn); border-color: var(--attn); color: light-dark(#fffdf9, #1a1917); }
.count.t-wait { color: var(--wait); border-color: color-mix(in srgb, var(--wait) 40%, transparent); }
.sec-needs .rows.items { border-color: color-mix(in srgb, var(--attn) 35%, var(--line)); }
.empty { margin: 0; padding: .4rem .75rem; color: var(--faint); border: 1px dashed var(--line); border-radius: 8px; }
.warn { margin: .25rem .25rem 0; color: var(--wait); }
.scout-details > summary { cursor: pointer; color: var(--muted); }
.scout-details > summary > h2 {
  display: inline-flex; flex-wrap: wrap; max-width: calc(100% - 1.5rem);
  margin: 0; vertical-align: middle;
}
.scout-disclosure { font-weight: 400; letter-spacing: 0; text-transform: none; }
.scout-details .plain { margin: .5rem 0; }
.scout-details p { margin: .5rem .25rem; overflow-wrap: anywhere; }

/* Rows: one line each, aligned columns. */
.rows {
  margin: 0; padding: 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.rows.flags { margin-bottom: .35rem; }
.rows > li, .fgroup { border-top: 1px solid var(--line); }
.rows > li:first-child, .fgroup:first-child { border-top: 0; }
.line {
  display: grid; align-items: center; column-gap: .75rem;
  grid-template-columns: 1rem minmax(14rem, 2.6fr) minmax(5rem, .7fr) 8.5rem 7rem 3.6rem 6rem minmax(10rem, 2.4fr);
  min-height: var(--row); padding: 0 .6rem; cursor: default;
}
.line > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.items .line { cursor: pointer; }
.items .line:hover, .fgroup > summary:hover { background: var(--hover); }
.closed .line { grid-template-columns: 1rem minmax(14rem, 2.6fr) minmax(5rem, .7fr) 8.5rem 7rem 3.6rem 6rem minmax(8rem, 1.4fr); }
.name { display: flex; align-items: center; gap: .4rem; }
.name > button.title {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 0; background: none; padding: 0; text-align: start; font-weight: 550; color: var(--ink);
}
.name > button.title:hover { background: none; text-decoration: underline; }
.repo, .stage, .writer, .stat { color: var(--muted); }
.age, .dur, .pr { font-variant-numeric: tabular-nums; text-align: right; }
.age { color: var(--muted); }
.closed .age { text-align: left; }
.reason { color: var(--muted); }
.t-attn .reason, .t-fail .reason { color: var(--ink); }
.writer.w-busy { color: var(--run); }
.writer.w-launching { color: var(--muted); }
.writer.w-error { color: var(--wait); }
.writer.w-stopped { color: var(--flag); }

.glyph { font-weight: 700; text-align: center; font-size: 12px; }
.glyph.t-attn { color: var(--attn); }
.glyph.t-fail { color: var(--flag); }
.glyph.t-run { color: var(--run); }
.glyph.t-run .mark-captain { color: var(--captain); }
.glyph.t-wait, .glyph.t-idle, .glyph.t-muted { color: var(--idle); }
.glyph.t-handoff { color: var(--handoff); }
.glyph.t-ok { color: var(--ok); }
.row.t-attn > .line { box-shadow: inset 3px 0 var(--attn); }
.row.t-fail > .line { box-shadow: inset 3px 0 var(--flag); }

.chip {
  flex: none; font-size: 10.5px; line-height: 1.5; padding: 0 .4rem; border-radius: 4px; white-space: nowrap;
}
.c-attn { color: var(--flag); background: var(--flag-bg); }
.c-warn { color: var(--wait); background: var(--wait-bg); }
.c-info { color: var(--muted); background: var(--raised); }
.t-info { color: var(--muted); }
.c-good { color: var(--ok); background: var(--raised); }

.glyph > [aria-hidden] { display: inline-block; line-height: 1; }
.status-mark { vertical-align: -.12em; }
.mark-run { height: 1.333333em; }
.chip .flag-mark { font-size: 1em; }
.flag-mark { color: var(--flag); }
.t-info .flag-mark, .c-info .flag-mark { color: var(--muted); }
.c-good .flag-mark, .fgroup.t-ok .flag-mark { color: var(--ok); }
.captain-ref { display: inline-flex; align-items: baseline; gap: .3em; }
.captain-ended, .captain-ended .stat, .captain-ended .reason { color: var(--muted); }
.captain-ended strong { font-weight: 400; }
.ended-captains { margin-top: .35rem; }
.ended-captains > summary { cursor: pointer; color: var(--muted); padding: .3rem .6rem; }

/* Flag groups. */
.fgroup > summary { list-style: none; cursor: pointer; grid-template-columns: 1rem minmax(12rem, 1.4fr) minmax(10rem, 4fr) 3.4rem; }
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary .name strong::before { content: "▸ "; color: var(--faint); }
.fgroup[open] > summary .name strong::before { content: "▾ "; }
.flist { margin: 0; padding: 0 0 .25rem; list-style: none; background: var(--raised); }
.flist .line { grid-template-columns: 1rem minmax(12rem, 1.4fr) minmax(10rem, 4fr) 3.4rem; min-height: 1.6rem; color: var(--muted); }

.captains .line { grid-template-columns: 1rem minmax(10rem, 1.2fr) 11rem 4.5rem max-content minmax(0, 4fr); }

/* Inline detail: keeps the row in place. */
.detail {
  padding: .6rem .9rem .8rem 2.3rem; background: var(--raised); border-top: 1px dashed var(--line);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem;
}
.goal {
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 10.5em; overflow: auto;
  padding: .45rem .6rem; background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
}
.facts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); gap: .15rem 1.25rem; margin: 0;
}
.facts > div { display: grid; grid-template-columns: 6.5rem 1fr; gap: .5rem; min-width: 0; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.block h4 {
  margin: 0 0 .25rem; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}
.block { min-width: 0; overflow-wrap: anywhere; }
.block > .pre { margin: 0; }
.work-brief > summary { cursor: pointer; color: var(--muted); padding: .2rem 0; }
.work-brief > p { margin: 0; }
.brief-list { margin: .25rem 0 0; padding-left: 1.4rem; display: grid; gap: .35rem; }
.brief-list li { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.block .plain { margin: 0; padding: 0; list-style: none; display: grid; gap: .15rem; }
.ask { padding: .5rem .6rem; border-left: 3px solid var(--attn); background: var(--attn-bg); border-radius: 0 6px 6px 0; }
.ask p { margin: .2rem 0; }
.options { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0; padding: 0; list-style: none; }
.options li { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; padding: .05rem .5rem; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface); }
.options li.default { border-color: var(--ink); font-weight: 600; }
.cmd { display: inline-block; padding: .15rem .4rem; background: var(--surface); border-radius: 4px; overflow-wrap: anywhere; }
.rail { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.rail li {
  padding: .05rem .5rem; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); white-space: nowrap;
}
.rail li.now { border-color: var(--run); color: var(--run); }
.rail li.back, .timeline tr.back td { color: var(--wait); }
.loop { color: var(--wait); font-weight: 700; }
.scroll { max-height: 18rem; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.timeline { width: 100%; border-collapse: collapse; }
.timeline th {
  position: sticky; top: 0; text-align: left; font-weight: 600; color: var(--faint);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.timeline th, .timeline td { padding: .15rem .6rem; vertical-align: top; }
.timeline td:first-child, .timeline td:nth-child(2), .timeline td:nth-child(3), .timeline td:nth-child(4) { white-space: nowrap; }
.timeline tbody tr + tr td { border-top: 1px solid var(--line); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; padding: .3rem .25rem 0; }
.detail .pager { padding: 0; }

/* Narrow: two lines per row. */
@media (max-width: 760px) {
  .phalanx-board :is(button, a, summary, input), #operator-session :is(button, input),
  #operator-report :is(button, a) {
    min-width: 44px; min-height: 44px; box-sizing: border-box;
  }
  .phalanx-board a, #operator-report a {
    display: inline-flex; align-items: center; justify-content: center;
  }
  .phalanx-board .name > button.title { min-height: 44px; flex: 1; }
  .phalanx-board .fgroup > summary { min-height: 44px; }
  .line, .closed .line, .captains .line, .fgroup > summary, .flist .line {
    display: flex; flex-wrap: wrap; column-gap: .55rem; padding: .3rem .6rem; min-height: 0;
  }
  .line > .glyph { width: 1rem; flex: none; }
  .line > .name { flex: 1 1 calc(100% - 6rem); }
  .line > .age { order: 1; flex: none; }
  .line > :not(.glyph, .name, .age) { order: 2; font-size: 12px; }
  .line > .repo { margin-left: 1.55rem; }
  .line > .reason { flex: 1 1 100%; padding-left: 1.55rem; }
  .line > .dur { display: inline; }
  .captains .line > .stat:first-of-type { margin-left: 1.55rem; }
  .detail { padding-left: .9rem; }
  .bar { gap: .25rem .75rem; }
  .actions { gap: .15rem; }
  .actions .tool-button { min-width: 44px; min-height: 44px; }
  .actions .new-item { padding-inline: .4rem; }
  .toolbar-settings-panel { left: 0; right: auto; }
  .tool-button::after { max-width: 11rem; }
  .actions > .new-item::after, .actions > [data-action="search"]::after,
  .actions > [data-action="filters"]::after { right: auto; left: 0; }
}

/* Sign-in card and report dialog. */
#operator-session { padding-bottom: 0; }
#operator-session-status { margin: .5rem 0; }
#operator-session-status:empty { display: none; }
.connect-card:has(> #operator-connect[hidden]) #operator-endpoint { display: none; }
.connect-card:has(> #operator-connect:not([hidden])) {
  box-sizing: border-box; display: flex; flex-direction: column; gap: 1rem;
  width: min(25rem, 100%); margin: clamp(1.5rem, 10vh, 6rem) auto 0; padding: 2rem 1.75rem 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 1px 2px #0000000d, 0 12px 32px #0000001a;
}
#operator-connect { display: flex; flex-direction: column; gap: 1.25rem; }
#operator-connect[hidden] { display: none; }
.connect-brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.connect-shield { width: 56px; height: 56px; margin-bottom: .6rem; }
#operator-connect h1 {
  display: flex; flex-direction: column; align-items: center; gap: .15rem; margin: 0;
  font: 700 24px/1.1 "Palatino Linotype", Palatino, Georgia, serif;
}
.connect-name { color: var(--accent); letter-spacing: .14em; text-transform: uppercase; }
.connect-product {
  color: var(--muted); font: 600 11px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: .22em; text-transform: uppercase;
}
.connect-motto {
  display: flex; align-items: center; gap: .5rem; width: 11rem; margin: .5rem 0 0;
  color: var(--captain); font: italic 15px/1.2 "Palatino Linotype", Palatino, Georgia, serif;
}
.connect-motto::before, .connect-motto::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .55; }
#operator-google:not([hidden]) { display: flex; flex-direction: column; gap: 1.25rem; }
.phalanx-board a.connect-google {
  justify-content: center; gap: .65rem; width: 100%; min-height: 48px;
  background: var(--surface); border-color: var(--line-strong); border-radius: 8px;
  font-weight: 600; font-size: 14px; color: var(--ink);
  box-shadow: 0 1px 2px #00000014;
}
.phalanx-board a.connect-google:hover { background: var(--hover); text-decoration: none; }
.connect-divider {
  display: flex; align-items: center; gap: .75rem; margin: 0;
  color: var(--faint); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
}
.connect-divider::before, .connect-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.connect-token { display: flex; flex-direction: column; gap: .5rem; }
.connect-token > label[for] { font-weight: 600; }
.phalanx-board .connect-token input#operator-token { width: 100%; min-height: 44px; box-sizing: border-box; padding: .4rem .65rem; border-radius: 8px; }
#operator-connect .remember { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; }
#operator-connect .remember input { min-width: 0; min-height: 0; margin: 0; }
.connect-token .remember-help { margin: 0; color: var(--muted); font-size: 12px; }
.phalanx-board .connect-token button[type="submit"] {
  width: 100%; min-height: 44px; margin-top: .25rem; border-radius: 8px; font-weight: 600;
}
/* Without Google, the access token is the primary path. */
#operator-connect:has(#operator-google[hidden]) .connect-token button[type="submit"] {
  color: light-dark(#fffdf9, #1a1917); background: var(--accent); border-color: var(--accent);
}
#operator-connect:has(#operator-google[hidden]) .connect-token button[type="submit"]:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
}
.connect-card:has(> #operator-connect:not([hidden])) #operator-session-status {
  margin: 0; padding: .55rem .75rem; border-radius: 8px;
  background: var(--raised); border: 1px solid var(--line); color: var(--ink); font-size: 12.5px;
}
#operator-endpoint {
  margin: 0; padding-top: .9rem; border-top: 1px solid var(--line);
  color: var(--faint); font-size: 11.5px; text-align: center; overflow-wrap: anywhere;
}
#operator-report {
  box-sizing: border-box; width: min(52rem, calc(100vw - 1rem)); max-height: 84dvh;
  overflow: hidden; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 0;
}
#operator-report[open] { display: flex; flex-direction: column; }
.report-heading {
  display: flex; flex: none; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .25rem .5rem .25rem 1.25rem; border-bottom: 1px solid var(--line);
}
#operator-report h2 { margin: 0; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.report-controls { display: flex; flex: none; gap: .15rem; }
#operator-report .report-heading button {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; width: 36px; height: 36px; padding: 0; font-size: 24px;
}
#operator-report .report-heading button:disabled { opacity: .5; cursor: default; }
#operator-report .report-heading button:hover { background: var(--hover); }
#operator-report-body { min-height: 0; overflow: auto; scrollbar-gutter: stable; padding: 0 1.25rem 1rem; }
#operator-report-status:empty, #operator-report-copy-status:empty { display: none; }
#operator-report :focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
#operator-report::backdrop { background: #0008; }
#operator-report-content { overflow-wrap: anywhere; font: 13px/1.5 system-ui, sans-serif; }
#operator-report-content pre { white-space: pre-wrap; font-family: var(--mono); }
#operator-report-content table { border-collapse: collapse; display: block; overflow: auto; }
#operator-report-content th, #operator-report-content td { border: 1px solid var(--line); padding: .3rem .6rem; }
@media (max-width: 760px), (pointer: coarse) {
  .actions .tool-button { min-width: 44px; min-height: 44px; }
  #operator-report .report-heading button { width: 44px; height: 44px; }
}

#operator-create {
  box-sizing: border-box; width: min(42rem, calc(100vw - 1rem)); max-height: 90dvh; overflow-y: auto;
  margin: auto; padding: 1rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 10px;
}
#operator-create::backdrop { background: #0008; }
.create-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.create-heading h2 { margin: 0; font-size: 16px; }
#operator-create fieldset { border: 0; padding: 0; margin: .75rem 0; min-width: 0; }
#operator-create label { display: block; margin-top: .5rem; }
#operator-create input, #operator-create select, #operator-create textarea {
  box-sizing: border-box; width: 100%; font: inherit; color: var(--ink); background: var(--raised);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: .4rem .5rem;
}
#operator-create textarea { resize: vertical; }
#operator-create .create-options { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
#operator-create-errors { color: var(--flag); white-space: pre-wrap; overflow-wrap: anywhere; }
#operator-create [aria-invalid="true"] { border-color: var(--flag); }
#operator-create button, #operator-create input, #operator-create select { min-height: 44px; }
#operator-create :disabled { opacity: .65; cursor: default; }
@media (max-width: 480px) {
  .bar { column-gap: .2rem; }
  .actions .new-item > span { display: none; }
  /* The freshness chip shares the brand row; the controls take the next row, docked right. */
  .bar-end { display: contents; }
  .bar-end > .health { order: 2; margin-left: auto; }
  .bar-end > .actions { order: 3; flex-grow: 1; }
  .brand { gap: .45rem; }
  .phalanx-board .brand-lockup { grid-template-columns: 36px auto; gap: 8px; }
  .brand-shield { width: 36px; height: 36px; }
  .brand-name { font-size: 17px; }
  .brand-motto { margin-top: 3px; font-size: 12px; }
  .brand .sub { padding-left: .45rem; font-size: 11px; }
  .health-endpoint { display: none; }
  .connect-card:has(> #operator-connect:not([hidden])) { margin-top: .75rem; padding: 1.5rem 1.1rem 1rem; }
  .counts { column-gap: .25rem; }
  #operator-create .create-options { grid-template-columns: 1fr; }
}

/*
 * Motion. Everything here is skipped under prefers-reduced-motion.
 * Rows are rebuilt on every read, so looping animations start at --clock (set by the script to minus
 * the page clock) to stay in phase across rebuilds, and one-shot effects start at --since.
 */
@media (prefers-reduced-motion: no-preference) {
  /* Torches: the Live dot and attention counts send out a slow ring. */
  .h-live .dot { --pulse: var(--ok); animation: beacon 2.4s ease-out var(--clock, 0s) infinite; }
  .count.t-attn { --pulse: var(--attn); animation: beacon 2.4s ease-out var(--clock, 0s) infinite; }
  @keyframes beacon {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pulse) 55%, transparent); }
    70%, 100% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--pulse) 0%, transparent); }
  }

  /* The 12-by-16 row icon renders SVG units as pixels, keeping the wave at 2px. */
  .mark-run .spear {
    animation: formation 2.2s ease-in-out var(--clock, 0s) infinite;
  }
  .mark-run .spear-center { animation-delay: calc(var(--clock, 0s) + .22s); }
  .mark-run .spear-right { animation-delay: calc(var(--clock, 0s) + .44s); }
  @keyframes formation {
    0%, 70%, 100% { transform: translateY(0); }
    30% { transform: translateY(-2px); }
  }

  /* A live Captain's heart beats. */
  .captains .row.t-run .beat { display: inline-block; animation: heartbeat 1.6s ease-in-out var(--clock, 0s) infinite; }
  @keyframes heartbeat {
    0%, 34%, 100% { transform: none; }
    8% { transform: scale(1.3); }
    16% { transform: scale(1); }
    24% { transform: scale(1.18); }
  }

  /* A changed row gets a stroke of gold ink and a fresh seal on its state. */
  .row.changed > .line { position: relative; isolation: isolate; }
  .row.changed > .line::before {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0;
    background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 34%, transparent), color-mix(in srgb, var(--gold) 16%, transparent));
    transform-origin: left;
    animation: inkstroke 2.4s ease-out var(--since, 0s);
  }
  .row.changed > .line > .glyph { animation: seal .5s cubic-bezier(.3, 1.5, .6, 1) var(--since, 0s) backwards; }
  @keyframes inkstroke {
    0% { opacity: 1; transform: scaleX(0); }
    18% { opacity: 1; transform: scaleX(1); }
    100% { opacity: 0; transform: scaleX(1); }
  }
  @keyframes seal { from { opacity: 0; transform: scale(2.2) rotate(-20deg); } }

  /* Details unroll like a scroll. */
  .detail { animation: unroll .32s cubic-bezier(.2, .8, .2, 1) var(--since, 0s) backwards; }
  @keyframes unroll { from { clip-path: inset(0 0 100% 0); opacity: .3; } }

  /* Changing the theme spills ink outward from the toggle. */
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
  ::view-transition-new(root) { animation: inkspill .55s cubic-bezier(.4, 0, .2, 1); }
  @keyframes inkspill {
    from { clip-path: circle(0 at var(--ink-x, 100%) var(--ink-y, 0)); }
    to { clip-path: circle(var(--ink-r, 150vmax) at var(--ink-x, 100%) var(--ink-y, 0)); }
  }
}
