/* Understudy keeper screens.

   The visual language follows the owner's Closeout product: a soft grey
   shell, a quiet left rail with one white active row, a white rounded
   workspace, soft-grey panels, black pill actions and one blue accent.
   Status colour stays semantic (PRD 10): green for Protected, amber for
   attention, red only for Frozen, Stepping in and Needs you. Every text
   colour pair below meets WCAG 2.2 AA on the surface it sits on.

   The signature motif is the handoff rail: a lead line that stops at a
   terminal and a standby line that picks up below it and carries on. It
   appears in the mark, the step-in record and the landing page. */

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/instrument-sans.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-500.woff2") format("woff2");
}

:root {
  --canvas: #ffffff;
  --shell: #eceef1;
  --panel: #f4f5f7;
  --panel-strong: #ebedf1;
  --line: #e7e9ee;
  --line-strong: #d4d8e0;
  --ink: #0b0b0c;
  --ink-2: #5b6270;
  --muted: #666d7a;
  --brand: #101114;
  --accent: #3b71f0;
  --accent-ink: #2554cc;
  --accent-soft: #eaf0fe;

  --calm: #17a673;
  --calm-ink: #0e7a52;
  --calm-soft: #e6f7f0;
  --amber: #c98a14;
  --amber-ink: #8a5a00;
  --amber-soft: #fcf3e1;
  --red: #d93b3b;
  --red-ink: #b42323;
  --red-soft: #fdecec;

  --font: "Instrument Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-control: 10px;
  --r-row: 14px;
  --r-panel: 18px;
  --r-big: 24px;

  --shadow-card: 0 1px 2px rgba(11, 11, 12, 0.04), 0 6px 18px rgba(11, 11, 12, 0.05);
  --shadow-float: 0 12px 40px rgba(11, 11, 12, 0.12);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover { text-decoration-thickness: 2px; }

code,
pre {
  font-family: var(--mono);
  font-size: 0.86em;
}

:not(pre) > code {
  padding: 0.1em 0.4em;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.main:focus,
.solo-main:focus,
main:focus { outline: none; }

.skip {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 500;
  text-decoration: none;
}

.skip:focus { top: 12px; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.hint.warn { color: var(--amber-ink); }

.offscreen {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- mark and icons ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
}

.mark { flex-shrink: 0; }
.mark-lead { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.mark-stop { fill: var(--red); }
.mark-standby { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }

.icon {
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- app shell ---------- */

body.app { background: var(--shell); }

.shell {
  display: flex;
  min-height: 100vh;
}

.rail {
  width: 248px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 26px 16px 18px;
  overflow-y: auto;
}

.rail > .brand { padding: 4px 12px 6px; }

.rail-nav,
.rail-foot {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rail-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(11, 11, 12, 0.08);
}

.rail-nav a,
.rail-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.rail-nav a:hover,
.rail-link:hover {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.rail-nav a[aria-current="page"] {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(11, 11, 12, 0.06), 0 4px 12px rgba(11, 11, 12, 0.05);
}

.workspace {
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - 24px);
  margin: 12px 12px 12px 0;
  background: var(--canvas);
  border-radius: 22px;
  box-shadow: 0 1px 2px rgba(11, 11, 12, 0.04), 0 8px 24px rgba(11, 11, 12, 0.04);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--line);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
  min-width: 0;
}

.crumb-sep { color: var(--line-strong); }
.crumb-here { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--calm);
  box-shadow: 0 0 0 0 rgba(23, 166, 115, 0.5);
}

.demo-banner {
  margin: 20px 32px 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 14px;
}

.main {
  max-width: 1120px;
  padding: 28px 32px 56px;
}

/* ---------- buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.button:hover { background: var(--panel); border-color: var(--muted); }

.button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.button.primary:hover { background: #000; }

.button.quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}

.button.quiet:hover { background: var(--panel); color: var(--ink); }

.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.button-plus {
  position: relative;
  width: 12px;
  height: 12px;
}

.button-plus::before,
.button-plus::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 0;
  width: 2px;
  height: 12px;
  border-radius: 1px;
  background: currentColor;
}

.button-plus::after { transform: rotate(90deg); }

.plain-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-ink);
}

.blocked {
  margin-top: 8px;
  font-size: 13px;
  color: var(--amber-ink);
  max-width: 46ch;
}

.blocked a { color: var(--ink); font-weight: 500; }

/* ---------- notices ---------- */

.notice {
  margin-bottom: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--amber-soft);
  color: var(--amber-ink);
  font-size: 14px;
}

.notice.is-error { background: var(--red-soft); color: var(--red-ink); }
.notice.is-ok { background: var(--calm-soft); color: var(--calm-ink); }

.notice.is-ok {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
}

.empty-note {
  padding: 28px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-row);
  color: var(--ink-2);
}

/* ---------- tones ---------- */

.tone-calm { --t: var(--calm); --t-ink: var(--calm-ink); --t-soft: var(--calm-soft); }
.tone-amber { --t: var(--amber); --t-ink: var(--amber-ink); --t-soft: var(--amber-soft); }
.tone-red { --t: var(--red); --t-ink: var(--red-ink); --t-soft: var(--red-soft); }
.tone-neutral { --t: #8a909c; --t-ink: var(--ink-2); --t-soft: var(--panel-strong); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: var(--t-soft, var(--panel-strong));
  color: var(--t-ink, var(--ink-2));
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--t, var(--muted));
}

/* ---------- board ---------- */

.board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.watch-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 28px;
  align-items: stretch;
  margin-bottom: 8px;
}

.hero-copy { padding: 20px 0; }

.hero h1 {
  font-size: 40px;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.032em;
  max-width: 17ch;
}

.hero .lede {
  margin-top: 18px;
  max-width: 58ch;
  font-size: 16px;
  color: var(--ink-2);
}

.hero .watch-action {
  align-items: flex-start;
  margin-top: 28px;
}

.hero .empty {
  grid-column: 1 / -1;
  padding: 16px 18px;
  border-radius: var(--r-row);
  background: var(--panel);
  color: var(--ink-2);
}

.hero-art {
  position: relative;
  min-height: 260px;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 34px;
  padding: 32px 28px;
  background:
    radial-gradient(120% 90% at 18% 12%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 60%),
    radial-gradient(90% 70% at 88% 82%, rgba(37, 84, 204, 0.4) 0%, rgba(37, 84, 204, 0) 65%),
    linear-gradient(158deg, #c9dcf7 0%, #9fbfee 55%, #85aae6 100%);
}

/* The handoff rail, drawn in CSS: a lead line ending in a terminal, and a
   standby line that starts under it and keeps going. */
.handoff {
  position: relative;
  display: block;
  height: 30px;
}

.h-lead,
.h-standby,
.h-stop {
  position: absolute;
  display: block;
  border-radius: 2px;
}

.h-lead { left: 0; top: 6px; width: 58%; height: 3px; background: rgba(11, 11, 12, 0.78); }
.h-stop { left: 58%; top: 0; width: 5px; height: 15px; background: var(--red); }
.h-standby { left: 40%; top: 24px; right: 0; height: 3px; background: #fff; }

.handoff.is-faint .h-lead { width: 72%; background: rgba(255, 255, 255, 0.5); }
.handoff.is-faint .h-standby { left: 64%; background: rgba(255, 255, 255, 0.35); }

.cards {
  display: grid;
  gap: 12px;
}

.card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: #fff;
  transition: border-color 220ms var(--ease);
}

.card:hover { border-color: var(--line-strong); }

.card[data-attention="true"] { border-color: color-mix(in srgb, var(--t, var(--line)) 32%, white); }

.card.tone-red[data-attention="true"] {
  background: linear-gradient(90deg, color-mix(in srgb, var(--red-soft) 70%, white) 0%, #fff 42%);
}

.card-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--t-soft, var(--panel));
}

.card-mark > span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--t, var(--line-strong));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--t, #8a909c) 20%, transparent);
}

.card[data-state="stepping_in"] .card-mark > span,
.card[data-state="first_save"] .card-mark > span,
.card[data-state="building_standby"] .card-mark > span {
  width: 20px;
  height: 20px;
  background: transparent;
  box-shadow: none;
  border: 2.5px solid color-mix(in srgb, var(--t) 25%, transparent);
  border-top-color: var(--t);
}

.card-main { min-width: 0; }

.card-id {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.card-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.012em;
  overflow-wrap: anywhere;
}

.card-name a { text-decoration: none; }
.card-name a:hover { text-decoration: underline; }

.card-status {
  margin-top: 6px;
  max-width: 72ch;
  font-size: 15px;
  color: var(--ink);
}

.tone-red .card-status { font-weight: 500; }

.card-jev {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-2);
}

.card-progress {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--t-ink, var(--ink-2));
}

.card-meter {
  display: none;
  position: relative;
  height: 6px;
  margin-top: 12px;
  max-width: 420px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--t-soft);
}

.card-meter > span {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 55%;
  border-radius: 999px;
  background: var(--t);
}

.card[data-state="stepping_in"] .card-meter,
.card[data-state="first_save"] .card-meter,
.card[data-state="building_standby"] .card-meter { display: block; }

.card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  color: var(--muted);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  max-width: 340px;
}

.card-actions:not(:has(> :not([hidden]):not(:empty))) { display: none; }

.action-note {
  flex-basis: 100%;
  font-size: 13px;
  text-align: right;
}

.action-note:empty { display: none; }
.action-note.is-error { color: var(--red-ink); }
.action-note.is-ok { color: var(--calm-ink); }

.loading .muted { margin-bottom: 12px; }

.is-skeleton .card { grid-template-columns: 44px minmax(0, 1fr); min-height: 96px; }
.is-skeleton .card-mark { background: var(--panel); }

.bone {
  display: block;
  height: 12px;
  width: 80%;
  margin: 6px 0 12px;
  border-radius: 6px;
  background: var(--panel-strong);
}

.bone.short { width: 26%; height: 14px; }
.bone.thin { width: 50%; height: 9px; }

/* ---------- detail ---------- */

.detail > * + * { margin-top: 16px; }

.detail-head.card {
  grid-template-columns: 52px minmax(0, 1fr);
  padding: 28px;
  border-radius: var(--r-big);
  background: linear-gradient(180deg, color-mix(in srgb, var(--t-soft, var(--panel)) 75%, white) 0%, #fff 75%);
}

.detail-head .card-mark { width: 52px; height: 52px; border-radius: 15px; background: #fff; }
.detail-head .card-name { font-size: 30px; letter-spacing: -0.025em; line-height: 1.15; }
.detail-head .card-status { font-size: 17px; margin-top: 10px; }

.detail-head .card-actions {
  grid-column: 2;
  justify-content: flex-start;
  max-width: none;
  margin-top: 6px;
}

.detail-head .action-note { text-align: left; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: #fff;
}

.panel > h2,
.panel-head { margin-bottom: 14px; }

.panel h3 { margin: 18px 0 10px; }

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
}

.panel-head .muted { font-size: 13px; }

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 340px;
  overflow-y: auto;
}

.timeline li {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.timeline li:first-child { border-top: 0; }

.tl-time {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}

.tl-text { font-size: 14px; overflow-wrap: anywhere; }

.signals {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.signal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  grid-template-areas: "name spark" "summary spark";
  align-items: center;
  gap: 4px 16px;
  padding: 14px 16px;
  border-radius: var(--r-row);
  background: var(--panel);
}

.signal h3 { grid-area: name; margin: 0; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.signal .spark { grid-area: spark; width: 100%; height: auto; }
.signal-summary { grid-area: summary; font-size: 14px; }

.spark-base { stroke: var(--line-strong); stroke-width: 1; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: #fff; stroke: var(--accent); stroke-width: 1.75; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-row);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th,
td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: top;
}

thead th {
  background: var(--panel);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}

tbody td { border-top: 1px solid var(--line); }

.num { text-align: right; }

.facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0;
  margin: 0;
}

.facts dt,
.facts dd {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.facts dt { color: var(--ink-2); padding-right: 24px; }
.facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.facts dt:first-of-type,
.facts dd:first-of-type { border-top: 0; }

.rows,
.plain-list,
.pattern-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rows li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.rows li:first-child { border-top: 0; }

.row-status {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}

.row-status[data-status="passed"] { background: var(--calm-soft); color: var(--calm-ink); }
.row-status[data-status="differences"],
.row-status[data-status="failed"] { background: var(--red-soft); color: var(--red-ink); }
.row-status[data-status="running"] { background: var(--accent-soft); color: var(--accent-ink); }

.plain-list li {
  position: relative;
  padding: 10px 0 10px 28px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.plain-list li:first-child { border-top: 0; }

.plain-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 17px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--line-strong);
}

.carried h2,
.not-carried h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.carried h2::before,
.not-carried h2::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.carried { background: linear-gradient(180deg, var(--calm-soft) 0%, #fff 120px); }
.carried h2::before { background: var(--calm); }
.carried .plain-list li::before {
  left: 3px;
  top: 14px;
  width: 6px;
  height: 11px;
  border-radius: 0;
  background: none;
  border: solid var(--calm);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.not-carried { background: linear-gradient(180deg, var(--amber-soft) 0%, #fff 120px); }
.not-carried h2::before { background: var(--amber); }
.not-carried .plain-list li::before {
  top: 19px;
  width: 10px;
  height: 2px;
  border-radius: 1px;
  background: var(--amber);
}

.pattern-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- step-in record ---------- */

.stepin {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-big);
  background: #fff;
}

.stepin[data-outcome="running"] {
  border-color: color-mix(in srgb, var(--accent) 30%, white);
  background: linear-gradient(180deg, var(--accent-soft) 0%, #fff 140px);
}

.stepin[data-outcome="done"] {
  border-color: color-mix(in srgb, var(--calm) 30%, white);
  background: linear-gradient(180deg, var(--calm-soft) 0%, #fff 140px);
}

.stepin[data-outcome="failed"] {
  border-color: color-mix(in srgb, var(--red) 30%, white);
  background: linear-gradient(180deg, var(--red-soft) 0%, #fff 140px);
}

.stepin-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.stepin-head h2 { font-size: 19px; letter-spacing: -0.018em; }

.stepin-rail {
  position: relative;
  display: block;
  width: 44px;
  height: 26px;
}

.stepin-rail > span { position: absolute; display: block; border-radius: 2px; }
.rail-lead { left: 0; top: 6px; width: 24px; height: 3px; background: var(--ink); }
.rail-stop { left: 24px; top: 1px; width: 4px; height: 13px; background: var(--red); }
.rail-standby { left: 16px; top: 19px; right: 0; height: 3px; background: var(--accent); }

.stepin-count {
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
}

.steps {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.step {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  padding: 9px 0;
}

.step::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 39px;
  bottom: -7px;
  width: 2px;
  border-radius: 1px;
  background: var(--line);
}

.step:last-child::before { display: none; }
.step[data-status="done"]::before { background: color-mix(in srgb, var(--calm) 45%, white); }

.step-state {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: #fff;
  overflow: hidden;
  white-space: nowrap;
  text-indent: 120%;
  font-size: 1px;
}

.step[data-status="done"] .step-state { border-color: var(--calm); background: var(--calm); }

.step[data-status="done"] .step-state::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.step[data-status="doing"] .step-state {
  border-color: color-mix(in srgb, var(--accent) 25%, white);
  border-top-color: var(--accent);
}

.step[data-status="failed"] .step-state { border-color: var(--red); background: var(--red); }

.step[data-status="failed"] .step-state::before,
.step[data-status="failed"] .step-state::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 5px;
  width: 2px;
  height: 14px;
  background: #fff;
  transform: rotate(45deg);
}

.step[data-status="failed"] .step-state::after { transform: rotate(-45deg); }

.step-text { padding-top: 3px; font-size: 14.5px; overflow-wrap: anywhere; }
.step[data-status="waiting"] .step-text { color: var(--muted); }
.step[data-status="doing"] .step-text { font-weight: 600; }
.step[data-status="failed"] .step-text { color: var(--red-ink); font-weight: 500; }

.step-detail {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-2);
}

.step-dur {
  padding-top: 5px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.stepin-message p {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 14px;
}

.stepin[data-outcome="failed"] .stepin-message p { background: var(--red-soft); color: var(--red-ink); }
.stepin[data-outcome="done"] .stepin-message p { background: var(--calm-soft); color: var(--calm-ink); font-weight: 500; }

.stepin-success {
  margin-top: 12px;
  padding: 18px;
  border-radius: 16px;
  background: var(--panel);
}

.stepin-success > p + p,
.stepin-success > pre + p { margin-top: 10px; }

.command {
  margin: 10px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--brand);
  color: #e9ebef;
  font-size: 13.5px;
  overflow-x: auto;
  white-space: pre;
}

.command code { font-size: inherit; }

/* ---------- incident ---------- */

.page-head { margin-bottom: 20px; }

.page-head .lede,
.lede {
  margin-top: 8px;
  max-width: 66ch;
  font-size: 15px;
  color: var(--ink-2);
}

.incident > * + *,
.setup > * + *,
.rehearsal > * + * { margin-top: 16px; }

.incident > .page-head + *,
.rehearsal > .page-head + * { margin-top: 0; }

.report {
  padding: 24px;
  border-radius: var(--r-row);
  background: var(--panel);
  font-size: 14.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.report > * + * { margin-top: 0.8em; }
.report h1,
.report h2,
.report h3 { font-size: 16px; }
.report ul,
.report ol { padding-left: 1.3em; }
.report pre { padding: 12px 14px; border-radius: 10px; background: #fff; overflow-x: auto; }
.report table { margin: 0.5em 0; background: #fff; }

.posted { margin-top: 12px; color: var(--calm-ink); font-size: 14px; }

.preview {
  max-height: 48vh;
  margin: 0 0 14px;
  padding: 14px 16px;
  overflow: auto;
  border-radius: 12px;
  background: var(--panel);
  font-size: 12.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- setup ---------- */

.connectors {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: #fff;
}

.connector {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1.1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-top: 1px solid var(--line);
}

.connector:first-child { border-top: 0; }

.conn-tile {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--panel);
  color: var(--ink-2);
  font-size: 16px;
  font-weight: 600;
}

.connector[data-state="ok"] .conn-tile { background: var(--calm-soft); color: var(--calm-ink); }
.connector[data-state="missing"] .conn-tile,
.connector[data-state="not_allowed"] .conn-tile,
.connector[data-state="test_failed"] .conn-tile { background: var(--red-soft); color: var(--red-ink); }

.conn-name h2 { font-size: 15px; }
.conn-name h2 .muted { font-weight: 400; font-size: 13px; }
.conn-name p { margin-top: 2px; font-size: 13px; }
.conn-state { font-size: 13px; color: var(--ink-2); }
.conn-state p + p { margin-top: 4px; }

.conn-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel-strong);
  font-size: 12.5px;
  font-weight: 600;
}

.connector[data-state="ok"] .conn-label { background: var(--calm-soft); color: var(--calm-ink); }
.connector[data-state="missing"] .conn-label,
.connector[data-state="not_allowed"] .conn-label,
.connector[data-state="test_failed"] .conn-label { background: var(--red-soft); color: var(--red-ink); }
.connector[data-state="optional_off"] .conn-label { color: var(--ink-2); }

.conn-action { justify-self: end; }

.hint-block {
  padding: 16px 18px;
  border-radius: var(--r-row);
  background: var(--panel);
}

.hint-block .hint:first-child { margin-top: 0; }
.hint-block .notice { margin: 10px 0 0; }

/* ---------- forms ---------- */

.settings-form.panel { max-width: 760px; }

fieldset {
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  min-width: 0;
}

legend {
  margin-bottom: 10px;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
}

fieldset > p { font-size: 14px; color: var(--ink-2); }

.choice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice legend { width: 100%; }

.choice label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
}

.choice label:has(input:checked) { border-color: var(--ink); background: var(--panel); }
.choice .inline-field { border-radius: var(--r-control); }

.block-label {
  display: block;
  margin: 18px 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.inline-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

input:not([type="radio"]),
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition: border-color 140ms ease, background 140ms ease;
}

input:not([type="radio"]):hover,
textarea:hover { border-color: var(--line-strong); }

input:not([type="radio"]):focus,
textarea:focus { border-color: var(--accent); background: #fff; }

textarea {
  font-family: var(--mono);
  font-size: 13px;
  resize: vertical;
}

.inline-field input[type="number"] { width: 6.5em; }
.inline-field input[type="time"] { width: 8.5em; }

input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
}

.form-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 20px;
}

.form-result { font-size: 13px; }
.form-result.is-ok { color: var(--calm-ink); }
.form-result.is-error { color: var(--red-ink); }

.form-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red-ink);
  font-size: 13px;
}

/* ---------- dialogs ---------- */

.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(11, 11, 12, 0.2);
}

.dialog.wide { width: min(780px, calc(100vw - 32px)); }

.dialog::backdrop { background: rgba(16, 17, 20, 0.45); }

.dialog-form { padding: 28px; }

.dialog-form > h2 {
  margin-bottom: 16px;
  font-size: 21px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.dialog-form > p { font-size: 14px; color: var(--ink-2); }

.dialog-question {
  font-size: 19px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.012em;
}

.dialog .dialog-question { color: var(--ink); }

.dialog-actions { margin-top: 24px; }
.dialog-actions .button { min-height: 46px; }
.dialog-actions .button.primary { flex: 1; }

.picker-wrap { margin-top: 8px; }

.picker {
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--r-row);
}

.picker-row + .picker-row { border-top: 1px solid var(--line); }

.picker-row label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  grid-template-areas: "input name" "input meta";
  align-items: center;
  gap: 2px 12px;
  padding: 12px 16px;
  cursor: pointer;
}

.picker-row input { grid-area: input; }
.picker-name { grid-area: name; font-size: 14px; font-weight: 600; }
.picker-meta { grid-area: meta; font-size: 12.5px; color: var(--muted); }
.picker-row label:hover { background: var(--panel); }
.picker-row label:has(input:checked) { background: var(--accent-soft); }

.options {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.options .choice { margin-top: 18px; }

/* ---------- rehearsal ---------- */

.rehearsal .page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.summary {
  padding: 22px 24px;
  border-radius: var(--r-panel);
  background: var(--panel);
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: -0.005em;
}

.back a { font-size: 14px; font-weight: 500; color: var(--accent-ink); }

/* ---------- one-sentence pages ---------- */

body.solo { background: var(--shell); }

.solo-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px 16px;
}

.solo-card {
  width: 100%;
  max-width: 540px;
  padding: 36px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(11, 11, 12, 0.04), 0 16px 48px rgba(11, 11, 12, 0.08);
}

.message h1 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.message h1.lede {
  margin: 0;
  max-width: none;
  color: var(--ink);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.38;
  letter-spacing: -0.015em;
}

.message > .lede { margin-top: 12px; }
.message-link { margin-top: 24px; }
.message .command { margin-top: 18px; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .card[data-state="stepping_in"] .card-mark > span,
  .card[data-state="first_save"] .card-mark > span,
  .card[data-state="building_standby"] .card-mark > span,
  .step[data-status="doing"] .step-state {
    animation: spin 900ms linear infinite;
  }

  .card[data-state="stepping_in"] .card-meter > span,
  .card[data-state="first_save"] .card-meter > span,
  .card[data-state="building_standby"] .card-meter > span {
    width: 38%;
    animation: travel 1.6s var(--ease) infinite;
  }

  .tone-red:not([data-state="stepping_in"]) .card-mark > span { animation: ring 1.8s ease-out infinite; }
  .live-dot { animation: ring-calm 2s ease-out infinite; }
  .bone { animation: shimmer 1.4s ease-in-out infinite alternate; }
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes travel {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(270%); }
}

@keyframes ring {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--t) 45%, transparent); }
  70% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--t) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--t) 0%, transparent); }
}

@keyframes ring-calm {
  0% { box-shadow: 0 0 0 0 rgba(23, 166, 115, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(23, 166, 115, 0); }
  100% { box-shadow: 0 0 0 0 rgba(23, 166, 115, 0); }
}

@keyframes shimmer { to { opacity: 0.55; } }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .rail { width: 220px; padding-left: 12px; padding-right: 12px; }
  .hero { grid-template-columns: 1fr; }
  .hero-art { min-height: 180px; }
  .connector { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .conn-state { grid-column: 2 / -1; grid-row: 2; }
  .conn-action { grid-column: 3; grid-row: 1; }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }

  .rail {
    position: static;
    width: auto;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 4px;
    padding: 14px 16px 10px;
    overflow: visible;
  }

  .rail > .brand { padding: 4px 8px; margin-right: auto; }
  .rail-nav,
  .rail-foot { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .rail-foot { margin-top: 0; padding-top: 0; border-top: 0; }
  .rail-nav { order: 3; width: 100%; }
  .rail-foot { order: 4; width: 100%; }
  .rail-nav a,
  .rail-link { min-height: 44px; padding: 8px 12px; gap: 8px; }

  .workspace { margin: 0 8px 8px; border-radius: 18px; min-height: 0; }
  .topbar { padding: 12px 18px; min-height: 54px; }
  .demo-banner { margin: 16px 18px 0; }
  .main { padding: 22px 18px 40px; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  h1 { font-size: 25px; }
  .hero h1 { font-size: 30px; }
  .board-head { flex-direction: column; }
  .watch-action { align-items: flex-start; }

  .card { grid-template-columns: 40px minmax(0, 1fr); gap: 12px 14px; padding: 16px; }
  .card-mark { width: 40px; height: 40px; }
  .card-actions { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
  .action-note { text-align: left; }

  .detail-head.card { grid-template-columns: 1fr; padding: 20px; }
  .detail-head .card-mark { display: none; }
  .detail-head .card-actions { grid-column: 1; }
  .detail-head .card-name { font-size: 26px; }

  .stepin { padding: 18px; }
  .stepin-head { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .stepin-rail { display: none; }
  .stepin-count { justify-self: start; }
  .step { grid-template-columns: 28px minmax(0, 1fr); }
  .step-dur { grid-column: 2; padding-top: 0; }

  .signal { grid-template-columns: 1fr; grid-template-areas: "name" "spark" "summary"; }
  .signal .spark { max-width: 240px; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }

  .connector { grid-template-columns: 40px minmax(0, 1fr); padding: 16px; }
  .conn-tile { width: 40px; height: 40px; }
  .conn-state,
  .conn-action { grid-column: 2; grid-row: auto; justify-self: start; }

  .facts { grid-template-columns: 1fr; }
  .facts dt { padding-bottom: 0; }
  .facts dd { text-align: left; border-top: 0; padding-top: 2px; }

  .solo-card { padding: 26px 22px; }
  .dialog-form { padding: 22px; }
}

@media (forced-colors: active) {
  .badge,
  .button,
  .card,
  .panel,
  .stepin,
  .row-status,
  .conn-label { border: 1px solid CanvasText; }
  .step-state { forced-color-adjust: none; }
}
