/* carvel page — the frame: the rail beside the view, the bar over it, the three widths and the phone's tab bar.
   The parts are ui.css's; this sheet owns the grid and the placements, and it
   names no colour, size or motion of its own. It loads last, so no older
   sheet's frame rule wins on a handle. */

/* ---------- the frame ---------- */
#shell.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-width: 0;
  min-height: 0;
}

#middle-head.bar {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: 48px;
  min-width: 0;
  padding: 0 var(--s-4) 0 var(--s-5);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
#bar-title {
  flex: none;
  font-size: var(--text-md);
  font-weight: var(--w-strong);
  white-space: nowrap;
}
/* The bar keeps its 48 px and its width while the parts that can run long cut
   their own text short: an extension's chip hangs a menu below the bar, and
   the bar used to cut that menu off at its own edge. */
#middle-logs { min-width: 0; overflow: hidden; }
/* The slot holds the chip and the menu it opens, so the menu is placed from
   here and is not clipped by the slot either. */
#middle-head-ext { min-width: 0; position: relative; }

/* The bar's tabs are the ui.css part, not the bordered pill the old head drew:
   one fill on the view or seat on show, one hover, and no border. */
#middle-head .tab {
  height: var(--control-h);
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-2);
  font-size: var(--text-md);
  font-weight: var(--w-regular);
  letter-spacing: normal;
  text-transform: none;
}
#middle-head .tab:hover { background: var(--surface-2); color: var(--text); }
#middle-head .tab[aria-current="page"] { background: var(--surface-3); color: var(--text); }
#middle-head .tab:disabled { opacity: 0.45; }

#readout, #shell > .page-view {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
}

/* ---------- the rail ---------- */
#rail.rail {
  padding: var(--s-2);
  gap: 2px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
}
#rail .rail-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: 36px;
  flex: none;
  padding: 0 var(--s-2);
  margin-bottom: var(--s-2);
}
#middle-project {
  font-size: var(--text-md);
  font-weight: var(--w-strong);
  color: var(--text);
}
#rail .nav { flex: none; }
#rail .nav:disabled { opacity: 0.55; }
#rail .nav:disabled:hover { background: none; color: var(--text-2); }
#rail .nav .count, #rail .nav .dot, #rail .nav .seat-state { flex: none; margin-left: auto; }
#rail .nav .seat-state { font-size: var(--text-sm); color: var(--text-3); }

/* A project is a nav row too: the rail's old label capital, its box and its
   square lamp give way to the row's own mark and its counts. */
#rail .project {
  height: var(--row-h);
  padding: 0 var(--s-2);
  border: 0;
  color: var(--text-2);
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
}
#rail .project::before { display: none; }
#rail .project:hover { color: var(--text); }
#rail .project[aria-current="page"] { background: var(--surface-3); color: var(--text); }
#rail .project[data-activity="running"] {
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 26%, transparent);
}
#rail .project[data-activity="running"][data-activity-tone="job"] {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--attn) 26%, transparent);
}
#rail .project[data-activity="running"]:not([aria-current="page"]) {
  background: color-mix(in srgb, var(--ok) 7%, transparent);
}
#rail .project[data-activity="running"][data-activity-tone="job"]:not([aria-current="page"]) {
  background: color-mix(in srgb, var(--attn) 7%, transparent);
}
#rail .project .project-name { margin-right: 0; }
#rail .project .project-running-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  margin-left: auto;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: var(--w-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
#rail .project .project-running-pill.is-run {
  background: var(--ok-soft);
  color: var(--ok);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 36%, transparent);
}
#rail .project .project-running-pill.is-job {
  background: var(--attn-soft);
  color: var(--attn);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--attn) 36%, transparent);
}
#rail .project .project-running-pill .dot {
  margin-left: 0;
  width: 6px;
  height: 6px;
}
#rail .project .project-running {
  border: 0;
  padding: 0;
  margin-left: 0;
  color: inherit;
  font-size: inherit;
  font-weight: var(--w-strong);
  line-height: 1;
}
#rail .project-edit { height: 22px; padding: 0 6px; font-size: var(--text-sm); color: var(--text-3); }

.dot.dot-run {
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent);
  animation: pulse-ok 1.8s var(--ease) infinite;
}
.dot.dot-job {
  background: var(--attn);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--attn) 55%, transparent);
  animation: pulse-attn 2s var(--ease) infinite;
}
@keyframes pulse-ok {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px transparent; }
}
@keyframes pulse-attn {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--attn) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .dot.dot-run, .dot.dot-job { animation: none; }
}

.rail-live-crews {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 6px 14px;
  padding-left: 8px;
  border-left: 1px solid var(--line-strong);
  min-width: 0;
}
.rail-live-crew {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-width: 0;
  padding: 5px 7px;
  border-radius: var(--r-md);
  text-align: left;
  color: var(--text-2);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.rail-live-crew:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.rail-live-crew[aria-current="page"] { background: var(--surface-3); color: var(--text); }
.rail-live-crew:disabled { opacity: 0.7; cursor: default; }
.rail-live-crew-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  width: 100%;
}
.rail-live-crew-top .dot { width: 6px; height: 6px; flex: none; margin-left: 0; }
.rail-live-crew-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: var(--w-strong);
  color: var(--text);
}
.rail-live-crew-state {
  flex: none;
  font-size: var(--text-xs);
  line-height: 1.2;
  padding: 1px 5px;
  border-radius: var(--r-sm);
}
.rail-live-crew-state.is-running, .rail-live-crew-state.is-checking {
  color: var(--ok);
  background: var(--ok-soft);
}
.rail-live-crew-state.is-job {
  color: var(--attn);
  background: var(--attn-soft);
}
.rail-live-crew-model {
  display: inline-block;
  align-self: flex-start;
  max-width: calc(100% - 12px);
  margin-left: 12px;
  padding: 1px 5px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.3;
  color: var(--text-2);
}

/* The foot: what the whole page says about itself, and the two doors out. */
#rail-foot.rail-foot {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  margin-top: auto;
  padding: var(--s-2) var(--s-2) 0;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: var(--text-sm);
}
#rail-foot-status { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
#rail-foot-status > * { min-width: 0; }
#rail-foot-row { position: relative; display: flex; align-items: center; gap: var(--s-1); height: 32px; }
/* The connection is the foot's own line while it has something to say, over the
   row More and Settings sit on; its dot is the whole mark at the 56 px rail. */
.rail-conn { display: inline-flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-2) var(--s-1); white-space: nowrap; }
.rail-conn[data-state="live"] { color: var(--text-2); }
.rail-conn[data-state="reconnecting"] { color: var(--attn); }
#rail-foot .topbar-btn { width: 100%; justify-content: flex-start; }
#rail-foot-row .topbar-btn { width: auto; justify-content: center; }

/* The More menu opens upward from the row More and Settings sit on, over the
   rail's rows. */
#rail-foot #topbar-menu {
  position: absolute;
  z-index: 60;
  top: auto;
  right: 0;
  bottom: calc(100% + var(--s-2));
  left: 0;
  min-width: 0;
  padding: var(--s-2);
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-pop);
}
#rail-foot #topbar-menu[hidden] { display: none; }
#rail-foot #topbar-menu-list { display: flex; flex-direction: column; gap: 2px; }

/* ---------- the Helm's seat: the Inbox beside the Helm's chat ----------
   One seat in two panes. At every desk width the list keeps the left and the
   talk the right, each scrolling by itself, and the divider between them is
   the owner's to drag (web/app-wiring.js keeps its place). On a phone the two
   panes do not fit, so the bottom tab bar keeps its Inbox and Helm pages as
   they were, one at a time. */
#shell.main { --inbox-w: 380px; --split-w: 6px; }

.split-grip {
  display: none;
  position: relative;
  width: var(--split-w);
  cursor: col-resize;
  touch-action: none;
  background: none;
  border: 0;
  padding: 0;
}
.split-grip::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 50%;
  width: 1px;
  margin-left: -0.5px;
  background: var(--line-strong);
  transition: background var(--t-fast) var(--ease);
}
.split-grip:hover::before, .split-grip:focus-visible::before, .split-grip.is-dragging::before {
  inset: 0 auto 0 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
}
.split-grip:focus-visible { outline: none; }

@media (min-width: 720px) {
  #shell[data-view="inbox"] {
    grid-template-columns: clamp(280px, var(--inbox-w), 62%) var(--split-w) minmax(0, 1fr);
  }
  #shell[data-view="inbox"] #middle-head.bar { grid-column: 1 / -1; }
  /* The list keeps its own scroll and the talk its own: a long Inbox never
     moves the chat, and a long chat never moves the Inbox. */
  #shell[data-view="inbox"] #inbox-page {
    grid-column: 1;
    grid-row: 2;
    position: static;
    /* A column, so the talk box sits at the pane's foot and the list grows. */
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg);
  }
  #shell[data-view="inbox"] #seat-split { display: block; grid-column: 2; grid-row: 2; }
  #shell[data-view="inbox"] #readout { grid-column: 3; grid-row: 2; }
  /* The Inbox is a pane, not a page: it fills the width it is given and its own
     rows answer to it (the container queries in inbox.css). */
  #shell[data-view="inbox"] .inbox-body {
    flex: 1 0 auto;
    max-width: none;
    padding: var(--s-4) var(--s-3) var(--s-10);
  }
  /* A pane is read, not walked to: its title is smaller than a page's. */
  #shell[data-view="inbox"] .inbox-headline { font-size: var(--text-xl); }
}

/* A narrow desk: the Inbox keeps the left but never more than 46% of it, so the
   Helm's chat still has a column to talk in. That column is narrow enough that
   the chat's own head takes a second line rather than a second width. */
@media (min-width: 720px) and (max-width: 899px) {
  #shell[data-view="inbox"] {
    grid-template-columns: clamp(280px, min(var(--inbox-w), 46%), 46%) var(--split-w) minmax(0, 1fr);
  }
  #shell[data-view="inbox"] #readout > * { min-width: 0; }
  #shell[data-view="inbox"] :is(#readout-identity, #readout-controls, #readout-status, #readout-meter, .middle-log-name) {
    flex-wrap: wrap;
  }
}

/* ---------- 720 to 1099 px: the rail keeps its icons, and only them ---------- */
@media (min-width: 720px) and (max-width: 1099px) {
  .app { grid-template-columns: var(--rail-w-compact) minmax(0, 1fr); }
  #rail.rail { padding: var(--s-2) 6px; }
  #rail .rail-head { justify-content: center; padding: 0; }
  #middle-project, #rail .rail-head #wordmark-lamp { display: none; }
  #rail .project-edit, #rail .seat-state, #rail .rail-live-crews { display: none; }
  #rail .project { position: relative; }
  #rail .project .project-running-pill {
    position: absolute;
    top: 3px;
    right: 3px;
    height: auto;
    padding: 0;
    margin: 0;
    background: none;
    box-shadow: none;
  }
  #rail .project .project-running-pill .dot { display: inline-block; width: 7px; height: 7px; }
  #rail .project .project-running-pill .project-running { display: none; }
  /* A group's name becomes its hairline: the rows under it stay one column. */
  #rail .rail-label {
    display: block;
    height: 1px;
    padding: 0;
    margin: var(--s-2) var(--s-2) calc(var(--s-2) + 1px);
    overflow: hidden;
    background: var(--line);
    color: transparent;
    font-size: 0;
  }
  #rail-foot.rail-foot { padding: var(--s-2) 0 0; align-items: center; }
  #rail-foot-status, #rail-foot-row { justify-content: center; flex-wrap: wrap; gap: var(--s-1); }
  #rail-foot .topbar-btn { width: auto; justify-content: center; padding: 0 4px; }
  #rail-foot .topbar-btn-label, .rail-conn #connection-word { display: none; }
  #rail-foot-row #settings-button { margin-left: 0; }
  #rail-foot-status .count { display: none; }
  #rail-foot #topbar-menu { left: calc(100% + var(--s-2)); right: auto; bottom: 0; min-width: 232px; }}

/* ---------- below 720 px: no rail, a tab bar at the foot ---------- */
@media (max-width: 719px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100dvh; }
  #rail.rail { display: none; }
  /* The projects are the Fleet view here: it is the one place the phone can
     pick a project, and it is what that tab has always opened. */
  .app[data-view="fleet"] #rail.rail { display: flex; }
  .app[data-view="fleet"] #shell { display: none; }
  /* The rail is a page here, and a page is read with a thumb: 44 px rows. */
  #rail .nav, #rail-foot-row { height: 44px; }
  #rail .rail-live-crew { min-height: 44px; padding: 6px 10px; justify-content: center; }
  #rail .rail-head { height: 44px; }

  #middle-head.bar { height: 52px; gap: var(--s-2); padding: 0 var(--s-3); }
  #middle-head .sep, #tab-inbox { display: none; }
  /* A chip an extension draws in the bar is the wide screen's: the phone's bar
     keeps its title and the log's name, and no control takes a second row. */
  #middle-head-ext { display: none; }

  /* One page at a time; the Inbox wins over a log left open behind it. */
  #readout { display: none; }
  #shell[data-view="chat"] #readout { display: flex; }
  #inbox-page { display: none; }
  body[data-page="inbox"] #inbox-page { display: flex; flex-direction: column; overflow-x: hidden; }
  body[data-page="inbox"] #inbox-page > .inbox-body { flex: 1 0 auto; }
  body[data-page="inbox"] #inbox-page > .talk { margin-top: auto; flex: none; }
  body[data-page="inbox"] #readout,
  body[data-page="scoreboard"] #readout { display: none; }
  /* On mobile Helm/Reckoner seat view, the tab bar highlights Helm and the
     chat header carries the seat switcher, so the duplicate top bar hides. */
  body[data-page="log"] #shell[data-view="chat"]:not(:has(.middle-log-close)) > #middle-head.bar {
    display: none;
  }

  #views.tabbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: var(--tabbar-h);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-rail);
    border-top: 1px solid var(--line);
  }
  #views .tab {
    position: relative;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    height: 100%;
    padding: 0 2px;
    border-radius: 0;
    color: var(--text-3);
    font-size: 10.5px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #views .tab .i { width: 18px; height: 18px; }
  #views .tab[aria-current="page"] { background: var(--surface-3); color: var(--text); }
  #views .tab:disabled { opacity: 0.45; }
  #views .tab .count, #views .tab > .dot {
    position: absolute;
    top: 6px;
    left: 50%;
    margin-left: 6px;
  }
}

/* ---------- the work pane: the split, and the sheet at two widths ----------
   The talk keeps a readable measure (860 px) and the pane takes the rest of
   the column, never under 420 px. Below 1100 px there is no room for both, so
   the pane becomes a sheet over the talk; below 720 px the shell is the whole
   page, so the sheet is the page's width. */
#shell.main { position: relative; }

#shell[data-view="chat"][data-pane="open"] {
  grid-template-columns: minmax(420px, 1fr) minmax(0, 860px);
}
#shell[data-view="chat"][data-pane="open"] #middle-head.bar { grid-column: 1 / -1; }
#shell[data-view="chat"][data-pane="open"] #readout { grid-column: 2; }
/* The talk keeps its measure and wraps inside it: a long tool line, the model
   picks and the meter take a second row rather than the page a second width. */
#shell[data-view="chat"][data-pane="open"] #readout > * { min-width: 0; }
#shell[data-view="chat"][data-pane="open"] :is(#readout-status, #readout-identity, #readout-meter) { flex-wrap: wrap; }

#work-pane {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--line);
}
#work-pane[hidden] { display: none; }
/* The pane is the chat view's: the Inbox, Topics and the Fleet have no file
   beside them, so nothing of the last chat's pane shows over them. */
#shell:not([data-view="chat"]) #work-pane,
#shell:not([data-view="chat"]) #work-pane-toggle { display: none; }

@media (max-width: 1099px) {
  /* The sheet: the talk keeps its column and its measure, and the pane covers
     it, so neither is squeezed by the other. */
  #shell[data-view="chat"][data-pane="open"] { grid-template-columns: minmax(0, 1fr); }
  #shell[data-view="chat"][data-pane="open"] #middle-head.bar { grid-column: 1; }
  #shell[data-view="chat"][data-pane="open"] #readout { grid-column: 1; }
  #work-pane {
    position: absolute;
    z-index: 40;
    inset: 48px 0 0 0;
    border-right: 0;
    box-shadow: var(--shadow-pop);
  }
}

@media (max-width: 719px) {
  /* The phone's bar is 52 px, and its tab bar stays at the foot: the sheet
     sits over the talk, the page's own width. */
  #work-pane { inset: 52px 0 0 0; }
  body[data-page="log"] #shell[data-view="chat"]:not(:has(.middle-log-close)) > #work-pane {
    inset: 0;
  }
}

/* ---------- the Helm's canvas of merged changes ----------
   The same seat as the Inbox: the canvas takes the left and the Helm's chat the
   right. A canvas is read wide, so it takes the larger share and the talk keeps
   a column it can still be read in. Below 720 px it is one page, as the Inbox
   is. The groups are canvas nodes (web/merged-canvas.js): their rules name no
   ancestor, because each is measured in a box of its own before it is placed. */
#merged-page {
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}
body[data-page="merged"] #merged-page { display: flex; }
@media (min-width: 720px) {
  #shell[data-view="merged"] {
    grid-template-columns: minmax(0, 1fr) var(--split-w) clamp(320px, 36%, 620px);
  }
  #shell[data-view="merged"] #middle-head.bar { grid-column: 1 / -1; }
  #shell[data-view="merged"] #merged-page { grid-column: 1; grid-row: 2; position: static; }
  #shell[data-view="merged"] #seat-split { display: block; grid-column: 2; grid-row: 2; pointer-events: none; }
  #shell[data-view="merged"] #readout { grid-column: 3; grid-row: 2; }
  #shell[data-view="merged"] #readout > * { min-width: 0; }
  #shell[data-view="merged"] :is(#readout-identity, #readout-controls, #readout-status, #readout-meter) { flex-wrap: wrap; }
}
@media (max-width: 719px) {
  body[data-page="merged"] #readout { display: none; }
}
#shell:not([data-view="merged"]) #merged-page { display: none; }

.mc-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex: none;
  min-width: 0;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--line);
}
.mc-ranges {
  display: flex;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.mc-ranges::-webkit-scrollbar { display: none; }
.mc-range {
  flex: none;
  height: var(--control-h);
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: var(--text-sm);
  white-space: nowrap;
  cursor: pointer;
}
.mc-range:hover { background: var(--surface-2); color: var(--text); }
.mc-range[aria-checked="true"] { background: var(--surface-3); color: var(--text); }
.mc-range:focus-visible, .mc-host:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.mc-count { flex: none; margin-left: auto; color: var(--text-3); font-size: var(--text-sm); white-space: nowrap; }
.mc-fit { flex: none; }
.mc-stage { position: relative; flex: 1 1 auto; min-height: 0; }
/* The ground: a dot every 28 world pixels, moved and scaled with the camera. */
.mc-host {
  position: absolute;
  inset: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--line-strong) 1px, transparent 1.2px);
  background-size: 28px 28px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.mc-host * { user-select: none; -webkit-user-select: none; }
.mc-host:active, .mc-host.is-panning, .mc-host.is-panning * { cursor: grabbing; }
.mc-say {
  position: absolute;
  top: var(--s-5);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90%, 440px);
  margin: 0;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  color: var(--text-2);
  font-size: var(--text-sm);
  text-align: center;
  pointer-events: none;
}
.mc-say[hidden] { display: none; }
.mc-measure { position: absolute; left: -10000px; top: 0; visibility: hidden; pointer-events: none; }

/* The time axis: each column's day (and hour) at reading size over the canvas,
   whatever the zoom; the canvas's own pointer passes through it. */
.mc-axis {
  position: absolute;
  inset: 0 0 auto 0;
  height: 40px;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(var(--bg) 60%, transparent);
}
.mc-axis-label {
  position: absolute;
  top: 10px;
  left: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: var(--w-strong);
}
.mc-axis-label[hidden] { display: none; }

/* A group: one change, read in under a minute. */
.mc-group {
  position: relative;
  box-sizing: border-box;
  min-height: 220px;
  padding: 22px 24px 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  background: var(--surface-1);
  color: var(--text);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
.mc-group-head {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.mc-title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.25;
  font-weight: var(--w-strong);
  overflow-wrap: anywhere;
}
.mc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0;
  color: var(--text-2);
  font-size: 12.5px;
}
.mc-voyage {
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 1px 7px;
  font-size: var(--text-xs);
}
.mc-pr {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  padding: 1px 8px;
  font-size: var(--text-xs);
  text-decoration: none;
  cursor: pointer;
}
.mc-pr:hover { background: color-mix(in srgb, var(--accent-soft) 160%, var(--accent) 14%); }
.mc-pr:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
.mc-about { font-family: var(--font-read); font-size: 15.5px; line-height: 1.55; color: var(--text); }
.mc-about p { margin: 0 0 10px; }
.mc-about p:first-child { font-size: 16.5px; }
.mc-commits { margin: 0 0 10px; padding-left: 1.2em; color: var(--text-2); font-size: 14px; }
.mc-commits li { margin: 2px 0; }
.mc-more { color: var(--text-3); list-style: none; }
.mc-runs { margin: 10px 0 6px; color: var(--text-2); font-size: 12.5px; }
.mc-runs-count { color: var(--text); font-weight: var(--w-strong); }
.mc-meter {
  height: 4px;
  margin: 0 0 12px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.mc-meter-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 99px;
  background: var(--ok);
  transform-origin: left center;
  transition: transform var(--t-med) var(--ease);
}
.mc-meter.is-full .mc-meter-fill {
  background: linear-gradient(90deg, var(--ok), color-mix(in srgb, var(--ok) 75%, var(--info)));
}
.mc-none { margin: 4px 0 0; color: var(--text-3); font-size: 14px; }
.mc-graph {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg) 68%, var(--surface-1));
  padding: 6px 2px;
}
.mc-graph svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }

/* Far out a group is its title: the poster covers the group and the rest leaves. */
.mc-poster {
  display: none;
  position: absolute;
  inset: 0;
  padding: 28px 32px;
  background: var(--surface-1);
}
.mc-poster p { margin: 0; }
.mc-poster-title {
  font-size: 56px;
  line-height: 1.12;
  font-weight: var(--w-strong);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}
.mc-poster-when { margin-top: 14px !important; font-size: 30px; color: var(--text-2); }
.mc-host.is-far .mc-poster { display: block; }

/* The machine: semantic color by outcome, solid where a real run walked it and
   dashed where it is only drawn. Color never overrides solid-vs-dashed. */
.mg-node-box {
  fill: var(--surface-1);
  stroke: var(--line-strong);
  stroke-width: 1.2;
}
.mg-node-name { font-family: var(--font-mono); font-size: 13.5px; fill: var(--text); }
.mg-node-prefix { font-weight: var(--w-strong); fill: var(--text); }
.mg-node-rest { fill: var(--text); }
.mg-node-sub { font-family: var(--font-mono); font-size: var(--text-xs); fill: var(--text-3); }
.mg-node-dot { fill: none; stroke: var(--text-3); stroke-width: 1.5; }
.mg-node.is-run .mg-node-dot, .mg-node.is-start .mg-node-dot { fill: var(--text-2); stroke: none; }

/* Start state: indigo accent framing */
.mg-node.is-start .mg-node-box {
  fill: color-mix(in srgb, var(--surface-1) 84%, var(--accent) 16%);
  stroke: var(--accent);
  stroke-width: 1.7;
}
.mg-node.is-start .mg-node-prefix, .mg-node.is-start .mg-node-sub { fill: var(--accent); }
.mg-node.is-start .mg-node-dot { fill: var(--accent); }

/* Walked positive outcome: emerald */
.mg-node.tone-ok .mg-node-box {
  fill: color-mix(in srgb, var(--surface-1) 86%, var(--ok) 14%);
  stroke: var(--ok);
  stroke-width: 1.5;
}
.mg-node.tone-ok .mg-node-prefix { fill: var(--ok); }
.mg-node.tone-ok .mg-node-sub { fill: color-mix(in srgb, var(--ok) 82%, var(--text-2)); }
.mg-node.tone-ok .mg-node-dot { fill: var(--ok); stroke: none; }

/* Unwalked positive / informative outcome: calm blue hint */
.mg-node.tone-info .mg-node-box {
  fill: color-mix(in srgb, var(--surface-1) 91%, var(--info) 9%);
  stroke: color-mix(in srgb, var(--info) 55%, var(--line-strong));
}
.mg-node.tone-info .mg-node-prefix { fill: var(--info); }
.mg-node.tone-info .mg-node-dot { stroke: var(--info); }

/* Refusal / error / failure outcome: coral/crimson */
.mg-node.tone-err .mg-node-box {
  fill: color-mix(in srgb, var(--surface-1) 90%, var(--bad) 10%);
  stroke: color-mix(in srgb, var(--bad) 62%, var(--line-strong));
}
.mg-node.tone-err.is-run .mg-node-box {
  fill: color-mix(in srgb, var(--surface-1) 84%, var(--bad) 16%);
  stroke: var(--bad);
  stroke-width: 1.6;
}
.mg-node.tone-err .mg-node-prefix { fill: var(--bad); }
.mg-node.tone-err .mg-node-sub { fill: color-mix(in srgb, var(--bad) 78%, var(--text-2)); }
.mg-node.tone-err .mg-node-dot { stroke: var(--bad); }
.mg-node.tone-err.is-run .mg-node-dot { fill: var(--bad); stroke: none; }

/* Warning / fallback / blocked outcome: amber */
.mg-node.tone-warn .mg-node-box {
  fill: color-mix(in srgb, var(--surface-1) 90%, var(--attn) 10%);
  stroke: color-mix(in srgb, var(--attn) 62%, var(--line-strong));
}
.mg-node.tone-warn.is-run .mg-node-box {
  fill: color-mix(in srgb, var(--surface-1) 84%, var(--attn) 16%);
  stroke: var(--attn);
  stroke-width: 1.6;
}
.mg-node.tone-warn .mg-node-prefix { fill: var(--attn); }
.mg-node.tone-warn .mg-node-sub { fill: color-mix(in srgb, var(--attn) 82%, var(--text-2)); }
.mg-node.tone-warn .mg-node-dot { stroke: var(--attn); }
.mg-node.tone-warn.is-run .mg-node-dot { fill: var(--attn); stroke: none; }

/* Muted / unchanged / :other fallback state: recessed with quiet dashed border */
.mg-node.tone-muted .mg-node-box {
  fill: var(--surface-2);
  stroke: var(--line-strong);
  stroke-dasharray: 4 3;
}
.mg-node.tone-muted.is-run .mg-node-box { stroke-dasharray: none; stroke: var(--text-2); }
.mg-node.tone-muted .mg-node-prefix { fill: var(--text-2); }
.mg-node.tone-muted .mg-node-dot { stroke: var(--text-3); }
.mg-node.tone-muted.is-run .mg-node-dot { fill: var(--text-2); stroke: none; }

/* Edges: dashed when unwalked, solid when walked by a real run */
.mg-edge-line {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.3;
  stroke-dasharray: 5 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mg-edge.is-run .mg-edge-line {
  stroke: var(--ok);
  stroke-width: 1.9;
  stroke-dasharray: none;
}
.mg-edge.tone-info .mg-edge-line { stroke: color-mix(in srgb, var(--info) 58%, var(--line-strong)); }
.mg-edge.tone-err .mg-edge-line { stroke: color-mix(in srgb, var(--bad) 58%, var(--line-strong)); }
.mg-edge.tone-warn .mg-edge-line { stroke: color-mix(in srgb, var(--attn) 60%, var(--line-strong)); }
.mg-edge.tone-muted .mg-edge-line { stroke: var(--line-strong); }
.mg-edge.is-run.tone-ok .mg-edge-line { stroke: var(--ok); }
.mg-edge.is-run.tone-err .mg-edge-line { stroke: var(--bad); }
.mg-edge.is-run.tone-warn .mg-edge-line { stroke: var(--attn); }
.mg-edge.is-run.tone-muted .mg-edge-line { stroke: var(--text-2); }

/* Arrowhead markers match their edge tone */
.mg-arrow { fill: var(--line-strong); }
.mg-arrow.tone-info { fill: color-mix(in srgb, var(--info) 65%, var(--line-strong)); }
.mg-arrow.tone-err { fill: color-mix(in srgb, var(--bad) 65%, var(--line-strong)); }
.mg-arrow.tone-warn { fill: color-mix(in srgb, var(--attn) 68%, var(--line-strong)); }
.mg-arrow.is-run, .mg-arrow.is-run.tone-ok { fill: var(--ok); }
.mg-arrow.is-run.tone-err { fill: var(--bad); }
.mg-arrow.is-run.tone-warn { fill: var(--attn); }
.mg-arrow.is-run.tone-muted { fill: var(--text-2); }

/* Guard label pills: sit cleanly in their own band zone above all edge wires */
.mg-edge-pill {
  fill: var(--surface-2);
  stroke: var(--line-strong);
  stroke-width: 1;
}
.mg-edge-badge.tone-err .mg-edge-pill {
  fill: color-mix(in srgb, var(--surface-1) 88%, var(--bad) 12%);
  stroke: color-mix(in srgb, var(--bad) 42%, var(--line));
}
.mg-edge-badge.tone-warn .mg-edge-pill {
  fill: color-mix(in srgb, var(--surface-1) 88%, var(--attn) 12%);
  stroke: color-mix(in srgb, var(--attn) 45%, var(--line));
}
.mg-edge-badge.tone-info .mg-edge-pill {
  fill: color-mix(in srgb, var(--surface-1) 90%, var(--info) 10%);
  stroke: color-mix(in srgb, var(--info) 40%, var(--line));
}
.mg-edge-badge.is-run .mg-edge-pill {
  fill: color-mix(in srgb, var(--surface-1) 82%, var(--ok) 18%);
  stroke: var(--ok);
}
.mg-edge-badge.is-run.tone-err .mg-edge-pill {
  fill: color-mix(in srgb, var(--surface-1) 82%, var(--bad) 18%);
  stroke: var(--bad);
}
.mg-edge-badge.is-run.tone-warn .mg-edge-pill {
  fill: color-mix(in srgb, var(--surface-1) 82%, var(--attn) 18%);
  stroke: var(--attn);
}
.mg-edge-badge.is-run.tone-muted .mg-edge-pill {
  fill: var(--surface-3);
  stroke: var(--text-2);
}
.mg-edge-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  fill: var(--text-2);
}
.mg-edge-badge.tone-err .mg-edge-label { fill: var(--bad); }
.mg-edge-badge.tone-warn .mg-edge-label { fill: var(--attn); }
.mg-edge-badge.tone-info .mg-edge-label { fill: var(--info); }
.mg-edge-badge.is-run .mg-edge-label { fill: var(--ok); font-weight: var(--w-strong); }
.mg-edge-badge.is-run.tone-err .mg-edge-label { fill: var(--bad); }
.mg-edge-badge.is-run.tone-warn .mg-edge-label { fill: var(--attn); }
.mg-edge-badge.is-run.tone-muted .mg-edge-label { fill: var(--text); }
/* The bar's Merged press says where the owner is; the view's name stays for a
   screen reader, out of sight, so the bar does not say Merged twice. */
body[data-page="merged"] #bar-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
body[data-page="merged"] #middle-head .sep { display: none; }
#middle-head #merged-toggle[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
@media (max-width: 479px) { .mc-count { display: none; } }
