/* Homepage RSI loop (radar-ui): a closed iteration track around a core of real work, then
   the in-progress list. Layout (grid areas, stage width, card list) is unchanged so the
   loop keeps its 1:1 chip scale; colours come from the site tokens in both themes. */
.home-live {
  --hl-cyan: var(--accent); --hl-active: var(--ok); --hl-duty: #7dd3fc; --hl-pending: var(--warn); --hl-done: #67e8f9;
  --hl-tag: var(--surface-2); --hl-id: var(--ok); --hl-ink: var(--text); --hl-muted: var(--text-2); --hl-line: var(--line-2);
  --hl-panel: var(--surface); --hl-well: var(--surface-2);
  position: relative; display: grid;
  grid-template-columns: minmax(380px, clamp(440px, 32vw, 560px)) minmax(0, 1fr) auto;
  grid-template-areas: "head head stats" "stage now now";
  gap: var(--s-3) var(--s-6);
  color: var(--hl-ink); scroll-margin-top: calc(var(--nav-h) + 24px); isolation: isolate;
}
:root[data-theme="light"] .home-live { --hl-duty: #0369a1; --hl-done: #0e7490; }
:root:not([data-radar-station="codex"]) .home-live { display: none !important; }
.home-live-body { display: contents; }
.home-live [hidden] { display: none !important; }

/* Header band: identity beside metadata; the metadata group drops below as a whole. */
.home-live .hl-head { grid-area: head; min-width: 0; align-self: center; display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-2) var(--s-4); }
.home-live .hl-ident { min-width: 0; display: grid; gap: 4px; }
.home-live .hl-meta { flex: 1 1 240px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--s-3); min-width: 0; padding: 1px 0 1px var(--s-4); border-left: 1px solid var(--hl-line); }
.home-live .hl-controls, .home-live noscript { flex-basis: 100%; }
.home-live .hl-controls:not(:has(button:not([hidden]))) { display: none; }
.home-live .hl-kicker { margin: 0 0 var(--s-1); }
.home-live .hl-account { display: inline-flex; align-items: baseline; gap: 6px; margin: 0; padding: 2px var(--s-2); border: 1px solid var(--hl-line); border-radius: var(--r-sm); background: var(--hl-well); color: var(--hl-muted); font-size: var(--fs-xs); line-height: 1.5; }
.home-live .hl-account strong { color: var(--hl-ink); font-weight: var(--w-semibold); white-space: nowrap; }
.home-live .hl-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); min-width: 0; }
.home-live .hl-title { margin: 0; color: var(--hl-ink); font-size: var(--fs-2xl); font-weight: var(--w-bold); line-height: 1.2; }
.home-live .hl-link { flex: none; padding: 8px 6px; margin: -8px -6px; font-size: var(--fs-sm); font-weight: var(--w-semibold); line-height: 24px; white-space: nowrap; }
.home-live .hl-time { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin: 0; color: var(--hl-muted); font-size: var(--fs-xs); line-height: 1.45; }
.home-live .hl-time::before { content: ""; flex: none; align-self: center; width: 6px; height: 6px; border-radius: 50%; background: var(--hl-active); box-shadow: 0 0 0 3px var(--ok-soft); }
.home-live[data-stale="true"] .hl-time::before { background: var(--hl-pending); box-shadow: 0 0 0 3px var(--warn-soft); }
.home-live .hl-time time { color: var(--hl-ink); font-size: var(--fs-sm); font-weight: var(--w-semibold); font-variant-numeric: tabular-nums; }
.home-live .hl-tz { white-space: nowrap; }
.home-live .hl-status { margin: 0; color: var(--hl-muted); font-size: var(--fs-xs); line-height: 1.5; }
.home-live :is(.hl-time, .hl-status):empty { display: none; }
.home-live .hl-controls button { min-height: 34px; }
.home-live .hl-toggle { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.home-live .hl-toggle::after { content: ""; width: 6px; height: 6px; margin-top: -3px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform var(--dur-2) var(--ease); }
.home-live .hl-toggle[aria-expanded="true"]::after { margin-top: 3px; transform: rotate(225deg); }
.home-live .hl-stats { grid-area: stats; align-self: center; justify-self: end; min-width: 0; }
.home-live .hl-stat-list { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0; }
.home-live .hl-stat { --hl-stage: var(--hl-done); min-width: 0; display: flex; align-items: baseline; gap: var(--s-3); padding: 7px var(--s-3); border: 1px solid var(--hl-line); border-radius: var(--r-md); background: var(--hl-panel); }
.home-live .hl-stat[data-stage="progress"] { --hl-stage: var(--hl-active); border-color: color-mix(in srgb, var(--hl-active) 40%, transparent); background: var(--ok-soft); }
.home-live .hl-stat[data-stage="pending"] { --hl-stage: var(--hl-pending); }
.home-live .hl-stat dt { display: flex; align-items: center; gap: 6px; color: var(--hl-muted); font-size: var(--fs-xs); font-weight: var(--w-semibold); line-height: 1.3; white-space: nowrap; }
.home-live .hl-stat dt::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--hl-stage); }
.home-live .hl-stat dd { margin: 0; color: var(--hl-ink); font-size: var(--fs-xl); font-weight: var(--w-bold); line-height: 1.05; font-variant-numeric: tabular-nums; }

/* Loop SVG on a quiet well. */
.home-live .hl-stage { grid-area: stage; min-width: 0; align-self: start; padding: var(--s-3) 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.home-live .hlw { display: block; width: 100%; height: auto; overflow: visible; pointer-events: none; user-select: none; -webkit-user-select: none; font-family: var(--font-sans); }
.home-live .hlw-dot { fill: color-mix(in srgb, var(--hl-cyan) 12%, transparent); }
.home-live .hlw-track-halo { fill: none; stroke: color-mix(in srgb, var(--hl-cyan) 8%, transparent); stroke-width: 7; }
.home-live .hlw-track { fill: none; stroke: color-mix(in srgb, var(--hl-cyan) 45%, transparent); stroke-width: 1.4; }
.home-live .hlw-comet { fill: none; stroke: var(--accent-strong); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 3 97; animation: hlw-orbit 8s linear calc(var(--hlw-t, 0s) - var(--o, 0) * 8s) infinite; }
.home-live .hlw-comet-tail { fill: none; stroke: var(--hl-cyan); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 9 91; stroke-dashoffset: 6; opacity: .35; animation: hlw-orbit-tail 8s linear calc(var(--hlw-t, 0s) - var(--o, 0) * 8s) infinite; }
.home-live .hlw-chev { fill: none; stroke: var(--hl-cyan); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.home-live .hlw-step-ring { fill: var(--hl-panel); stroke: var(--hl-cyan); stroke-width: 1.4; }
.home-live .hlw-step-dot { fill: var(--hl-cyan); }
.home-live .hlw-step[data-step="feedback"] .hlw-step-ring { stroke: var(--hl-active); }
.home-live .hlw-step[data-step="feedback"] .hlw-step-dot { fill: var(--hl-active); }
.home-live .hlw-step-label { fill: var(--hl-ink); font-size: 11.5px; font-weight: 600; }
.home-live .hlw-step-num { fill: var(--hl-cyan); font-weight: 700; font-variant-numeric: tabular-nums; }
.home-live .hlw-pulse .hlw-step-ring { transform-box: fill-box; transform-origin: center; animation: hlw-step 4s ease-out calc(var(--hlw-t, 0s) + var(--f, 0) * 8s - 8s) infinite; }
.home-live .hlw-core-box { fill: var(--hl-well); stroke: var(--hl-line); stroke-width: 1; }
.home-live .hlw-core-corner { fill: none; stroke: var(--hl-cyan); stroke-width: 1.8; stroke-linecap: round; }
.home-live .hlw-core-glow { opacity: .55; }
.home-live .hlw-feed { fill: none; stroke: var(--hl-line); stroke-width: 1.2; stroke-dasharray: 3 3; }
.home-live .hlw-feed-head { opacity: .9; }
.home-live .hlw-feed-flow { fill: none; stroke: var(--hl-cyan); stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 1.5 9; animation: hlw-feed 1.6s linear var(--hlw-t, 0s) infinite; }
.home-live .hlw-spoke { fill: none; stroke-width: 1.3; opacity: .55; }
.home-live .hlw-spoke-work { stroke: var(--hl-active); }
.home-live .hlw-spoke-role { stroke: var(--hl-duty); }
.home-live .hlw-spoke-end { stroke: none; opacity: .9; }
.home-live .hlw-spoke-end.hlw-spoke-work { fill: var(--hl-active); }
.home-live .hlw-spoke-end.hlw-spoke-role { fill: var(--hl-duty); }
.home-live .hlw-spoke-flow { fill: none; stroke: var(--accent-strong); stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 1.5 12; opacity: .8; animation: hlw-spoke 2.2s linear calc(var(--hlw-t, 0s) - var(--i, 0) * .37s) infinite; }
.home-live :is(.hlw-ticket, .hlw-station)[data-hot] .hlw-spoke { stroke-width: 2; opacity: 1; }
.home-live .hlw-r-halo { fill: color-mix(in srgb, var(--hl-cyan) 5%, transparent); stroke: color-mix(in srgb, var(--hl-cyan) 32%, transparent); stroke-width: 1; }
.home-live .hlw-r-ticks { fill: none; stroke: var(--hl-cyan); stroke-width: 4; stroke-dasharray: 1.3 5.6; opacity: .8; }
.home-live .hlw-r-arc { fill: none; stroke: var(--hl-active); stroke-width: 2.2; stroke-dasharray: 58 16 14 18; stroke-linecap: round; }
.home-live .hlw-r-disc { fill: var(--hl-panel); stroke: var(--hl-line); stroke-width: 1.2; }
.home-live .hlw-r-core { fill: color-mix(in srgb, var(--hl-cyan) 10%, transparent); stroke: color-mix(in srgb, var(--hl-cyan) 28%, transparent); stroke-width: 1; }
.home-live .hlw-r-text { fill: var(--hl-ink); font-size: 19px; font-weight: 800; letter-spacing: .1em; }
.home-live .hlw-flow-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.home-live .hlw-flow-cap { fill: var(--hl-muted); font-size: 11px; font-weight: 600; }
.home-live .hlw-in .hlw-flow-value { fill: var(--hl-pending); }
.home-live .hlw-out .hlw-flow-value { fill: var(--hl-done); }
.home-live .hlw-cap { fill: var(--hl-muted); font-size: 11px; font-weight: 640; letter-spacing: .04em; }
.home-live .hlw-tag { fill: var(--hl-tag); stroke: color-mix(in srgb, var(--hl-active) 60%, transparent); stroke-width: 1.2; }
.home-live .hlw-lamp { fill: var(--hl-active); }
.home-live .hlw-blink { animation: hlw-lamp 2.4s ease-in-out calc(var(--hlw-t, 0s) - var(--i, 0) * .3s) infinite; }
.home-live .hlw-id { fill: var(--hl-id); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.home-live .hlw-chip { fill: var(--hl-panel); stroke: color-mix(in srgb, var(--hl-duty) 50%, transparent); stroke-width: 1.2; }
.home-live :is(.hlw-chip-empty, .hlw-slot) { fill: none; stroke: var(--hl-line); stroke-width: 1; stroke-dasharray: 4 3; }
.home-live .hlw-gear-teeth { fill: var(--hl-duty); stroke: var(--hl-duty); stroke-width: 2.2; stroke-dasharray: 1.9 1.949; }
.home-live .hlw-gear-hub { fill: var(--hl-panel); }
.home-live .hlw-name { fill: var(--hl-duty); font-size: 12.5px; font-weight: 640; }
.home-live .hlw-empty { fill: var(--hl-muted); font-size: 12px; font-weight: 560; }
.home-live .hlw-ticket[data-hot] .hlw-tag { fill: var(--ok-soft); stroke: var(--hl-active); stroke-width: 2; }
.home-live .hlw-station[data-hot] .hlw-chip { fill: color-mix(in srgb, var(--hl-duty) 14%, transparent); stroke: var(--hl-duty); stroke-width: 2; }
.home-live .hlw-spin { transform-box: fill-box; transform-origin: center; animation: hlw-spin 14s linear var(--hlw-t, 0s) infinite; }
.home-live .hlw-spin[data-dir="ccw"] { animation-direction: reverse; }
.home-live .hlw-gear.hlw-spin { animation-duration: 8s; }
.home-live .hlw-arrive { animation: hlw-arrive .7s cubic-bezier(.2, .9, .3, 1.15) both; }
.home-live[data-motion="paused"] .hlw * { animation-play-state: paused !important; }
@keyframes hlw-orbit { to { stroke-dashoffset: -100; } }
@keyframes hlw-orbit-tail { from { stroke-dashoffset: 6; } to { stroke-dashoffset: -94; } }
@keyframes hlw-feed { to { stroke-dashoffset: -10.5; } }
@keyframes hlw-spoke { to { stroke-dashoffset: -13.5; } }
@keyframes hlw-spin { to { transform: rotate(360deg); } }
@keyframes hlw-step { 0% { transform: scale(1.45); stroke-width: 2.2; } 35%, 100% { transform: scale(1); } }
@keyframes hlw-lamp { 50% { opacity: .35; } }
@keyframes hlw-arrive { from { opacity: 0; transform: translateY(-10px); } }

/* Real work and standing roles, hung off one bus that continues the core. */
.home-live .hl-now { grid-area: now; min-width: 0; align-self: start; padding-top: var(--s-1); }
.home-live .hl-now-title { margin: 0 0 var(--s-2); color: var(--hl-muted); font-size: var(--fs-xs); font-weight: var(--w-semibold); line-height: 1.4; }
.home-live .hl-now-tag { padding: 1px 6px; border-radius: var(--r-xs); background: var(--ok-soft); color: var(--hl-id); font-size: var(--fs-2xs); font-weight: var(--w-bold); letter-spacing: .08em; }
.home-live .hl-now-list { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 0; padding: 0 0 0 16px; list-style: none; }
.home-live .hl-now-list::before { content: ""; position: absolute; left: 4px; top: 14px; bottom: 14px; width: 1.5px; border-radius: 2px; background: linear-gradient(180deg, var(--hl-cyan), color-mix(in srgb, var(--hl-cyan) 20%, transparent)); }
.home-live .hl-now-item { position: relative; min-width: 0; display: flex; border: 1px solid var(--line); border-left: 2px solid var(--hl-active); border-radius: var(--r-md); background: var(--hl-panel); }
.home-live .hl-now-item::before { content: ""; position: absolute; left: -15px; top: 20px; width: 12px; height: 1.5px; background: color-mix(in srgb, var(--hl-cyan) 55%, transparent); }
.home-live .hl-now-item::after { content: ""; position: absolute; left: -14.5px; top: 17px; width: 7px; height: 7px; box-sizing: border-box; border: 1.5px solid var(--hl-active); border-radius: 50%; background: var(--bg); }
.home-live .hl-now-item a { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(56px, max-content) minmax(0, 1fr) auto; gap: var(--s-3); align-items: start; min-height: 42px; padding: var(--s-2) var(--s-3); border-radius: inherit; color: inherit; font-size: var(--fs-sm); line-height: 1.5; }
.home-live .hl-now-item a:hover { background: var(--surface-2); text-decoration: none; }
.home-live .hl-now-id { justify-self: start; display: inline-flex; align-items: center; gap: 5px; margin-top: 1px; padding: 1px 7px; border: 1px solid color-mix(in srgb, var(--hl-active) 45%, transparent); border-radius: var(--r-sm); background: var(--ok-soft); color: var(--hl-id); font-size: var(--fs-xs); font-weight: var(--w-bold); line-height: 1.5; white-space: nowrap; font-variant-numeric: tabular-nums; }
.home-live .hl-now-id::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--hl-active); }
.home-live .hl-now-body { min-width: 0; display: grid; gap: 2px; }
.home-live .hl-now-name { min-width: 0; overflow-wrap: anywhere; color: var(--hl-ink); font-weight: var(--w-semibold); }
.home-live .hl-now-progress { min-width: 0; overflow-wrap: anywhere; color: var(--hl-muted); font-size: var(--fs-xs); line-height: 1.45; }
.home-live :is(.hl-role-badge, .hl-state-badge) { margin-top: 3px; padding: 1px 6px; border-radius: var(--r-xs); font-size: var(--fs-2xs); font-weight: var(--w-semibold); white-space: nowrap; }
.home-live .hl-state-badge { background: var(--ok-soft); color: var(--hl-active); }
.home-live .hl-role-badge { background: color-mix(in srgb, var(--hl-duty) 14%, transparent); color: var(--hl-duty); }
.home-live .hl-now-item[data-kind="resident"] { border-left-color: var(--hl-duty); }
.home-live .hl-now-item[data-kind="resident"]::after { border-color: var(--hl-duty); border-radius: 1.5px; transform: rotate(45deg); }
.home-live .hl-now-item[data-kind="resident"] .hl-now-id { border-color: color-mix(in srgb, var(--hl-duty) 45%, transparent); background: color-mix(in srgb, var(--hl-duty) 10%, transparent); color: var(--hl-duty); }
.home-live .hl-now-item[data-kind="resident"] .hl-now-id::before { width: 5px; height: 5px; border-radius: 1px; transform: rotate(45deg); background: var(--hl-duty); }
.home-live .hl-now-item[data-kind="resident"] .hl-now-name { color: var(--hl-muted); font-weight: var(--w-medium); }
.home-live .hl-empty { margin: 0; color: var(--hl-muted); font-size: var(--fs-sm); line-height: 1.5; }
.home-live:is([data-state="unavailable"], :not([data-mounted])) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head"; }
.home-live:is([data-state="unavailable"], :not([data-mounted])) :is(.hl-stage, .hl-stats, .hl-now) { display: none; }

@media (max-width: 980px) {
  .home-live { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "stats" "stage" "now"; }
  .home-live .hl-stats { justify-self: stretch; }
  .home-live .hl-meta { flex-basis: 100%; padding-left: 0; border-left: 0; }
  .home-live .hl-stage { justify-self: center; width: 100%; max-width: 520px; }
  .home-live .hl-now { padding-top: 0; }
}
@media (max-width: 760px) {
  .home-live { gap: var(--s-3); }
  .home-live .hl-meta { gap: 4px var(--s-3); }
  .home-live .hlw-r-text { font-size: 16px; }
  .home-live .hl-title { font-size: var(--fs-xl); }
  .home-live .hl-stat-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .home-live .hl-stat { display: block; padding: 6px 9px; }
  .home-live .hl-stat dt { gap: 5px; }
  .home-live .hl-stat dd { margin-top: 4px; font-size: var(--fs-lg); }
  .home-live .hl-now-list { padding-left: 14px; }
  .home-live .hl-now-item::before { left: -13px; width: 10px; }
  .home-live .hl-now-item::after { left: -12.5px; }
  .home-live .hl-now-item a { grid-template-columns: max-content minmax(0, 1fr); gap: 4px var(--s-2); min-height: 44px; padding: var(--s-2); }
  .home-live .hl-now-body { grid-column: 1 / -1; grid-row: 2; }
  .home-live :is(.hl-role-badge, .hl-state-badge) { justify-self: end; margin-top: 2px; }
}
@media (max-width: 380px) { .home-live .hl-title { font-size: var(--fs-lg); } }
@media (prefers-reduced-motion: reduce) {
  .home-live .hlw * { animation: none !important; }
  .home-live .hlw :is(.hlw-comet, .hlw-comet-tail, .hlw-feed-flow, .hlw-spoke-flow) { display: none; }
}
@media (forced-colors: active) {
  .home-live .hl-now-item::before, .home-live .hl-now-item::after, .home-live .hl-now-list::before { display: none; }
  .home-live .hlw :is(.hlw-core-box, .hlw-chip, .hlw-tag, .hlw-step-ring, .hlw-r-disc, .hlw-gear-hub) { fill: Canvas; stroke: CanvasText; }
  .home-live .hlw :is(text, .hlw-lamp, .hlw-gear-teeth, .hlw-step-dot) { fill: CanvasText; }
  .home-live .hlw :is(.hlw-track, .hlw-comet, .hlw-chev, .hlw-feed, .hlw-feed-flow, .hlw-spoke, .hlw-spoke-flow, .hlw-r-ticks, .hlw-r-arc, .hlw-r-halo, .hlw-r-core, .hlw-gear-teeth, .hlw-core-corner) { stroke: CanvasText; }
  .home-live .hlw .hlw-spoke-end { fill: CanvasText; }
  .home-live .hlw :is(.hlw-dot, .hlw-core-glow, .hlw-track-halo, .hlw-comet-tail) { display: none; }
  .home-live .hl-link { color: LinkText; }
}
@media print { .home-live .hlw * { animation: none !important; } }

/* The homepage RSI panel starts folded on every page load. */
.home-live[data-collapsed="true"] { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head"; gap: 0; }
