/* The shell's chrome (designs/minion-town-spa.md § 1 and § 2). The gutter
   sits on the shorter viewport axis; the corner button at its end paints
   above the stage; an expanded panel shares the chrome's one background
   with no delimiter, and the iframe pane is inset and framed. */
:root {
  --corner-size: 44px;
  --corner-gap: 12px;
  --gutter: calc(var(--corner-size) + 2 * var(--corner-gap));
  /* The command bar's height, above the bottom safe area (style guide). */
  --bar: 64px;
  --chrome-bg: #f2efe8;
  --chrome-fg: #1d1f24;
  --chrome-accent: #2f6f5e;
  --pane-bg: #ffffff;
  --label-fg: #8a5300;
  --path-bg: #dcebe5;
  --path-fg: #1f4f42;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --chrome-bg: #1d1f24;
    --chrome-fg: #e8e6e1;
    --chrome-accent: #7fc8b0;
    --pane-bg: #2a2d33;
  --label-fg: #e2b25e;
  --path-bg: #2b4a41;
  --path-fg: #cfeee3;
    --label-fg: #e2b25e;
    --path-bg: #2b4a41;
    --path-fg: #cfeee3;
  }
}
:root[data-scheme="dark"] {
  color-scheme: dark;
  --chrome-bg: #1d1f24;
  --chrome-fg: #e8e6e1;
  --chrome-accent: #7fc8b0;
  --pane-bg: #2a2d33;
}
:root[data-scheme="light"] { color-scheme: light; }

/* The account fixtures' six colors are in town.css, which /adopt shares. */
.fixture-line { margin: -0.5rem 0 1rem; font-size: 0.9rem; }
.fixture-line .fp, .account-rows .fp, .account-rows .credits { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; opacity: 0.75; }

body.shell {
  background: var(--chrome-bg);
  color: var(--chrome-fg);
  height: 100vh;
  /* svh keeps the bottom chrome at the small mobile viewport. The keyboard
     can cover it, but its arrival never lifts the profile button above the
     keys or changes the control's distance from the viewport edge. */
  height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "chrome stage" "chrome bar";
}
#stage { grid-area: stage; position: relative; z-index: 0; overflow: auto; background: var(--chrome-bg); scroll-padding-bottom: var(--bar); }
#chrome {
  grid-area: chrome;
  position: relative;
  z-index: 10;
  background: var(--chrome-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
}
body.shell:not([data-ready]) #chrome, body.shell:not([data-ready]) #bar { visibility: hidden; }
#gutter { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0; }
/* Each place's button keeps one box, open or not, so opening one moves and
   resizes no other (N1): the open place is marked by its outline alone. */
#gutter .place { box-sizing: border-box; flex: none; width: 40px; height: 40px; margin: 0; padding: 0; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; outline-offset: -2px; }
#gutter .place svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; }
#gutter .place[aria-current="page"] { outline: 2px solid currentColor; }
#gutter .place:focus-visible { outline: 3px solid var(--focus, #4a8af4); }
/* `tabs` (N4): a level one place at a time, the current or focused one;
   the arrows still step through the rest. */
#gutter[data-tabs] .place:not([aria-current]):not(:focus) { display: none; }
#gutter[data-tabs]:not(:has([aria-current])):not(:focus-within) .place:first-child { display: grid; }
#inventory-list[data-tabs] > li:not(:focus-within) { display: none; }
#inventory-list[data-tabs]:not(:focus-within) > li:first-child { display: revert; }
#corner {
  width: var(--corner-size);
  height: var(--corner-size);
  margin: var(--corner-gap);
  border: 0;
  border-radius: 50%;
  background: var(--chrome-accent);
  color: var(--chrome-bg);
  font: 600 22px/1 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  position: relative;
}
#corner[data-fixture] { background: var(--fixture); color: var(--fx-ink); }
#corner .glyph, #corner .initial { grid-area: 1 / 1; display: grid; place-items: center; }
#corner .glyph svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#corner .initial { font-size: 20px; line-height: 1; letter-spacing: -0.03em; }
#corner:focus-visible { outline: 3px solid var(--chrome-fg); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Settings, the Inventory and the Mailbox are chrome pseudo-clips: one
   circle, the command bar's first cell, carries the open panel's glyph and
   opens a small named menu with its Close (designs/minion-town-command-bar.md
   § 4). */
#panel-corner {
  position: relative;
  flex: none;
  width: var(--corner-size);
  height: var(--corner-size);
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chrome-fg);
  color: var(--chrome-bg);
  cursor: pointer;
  display: grid;
  place-items: center;
}
/* Idle (no pseudo-clip open), the corner keeps its slot, disabled: the
   crumbs and the field never move with the mode (the UX audit's F7). */
#panel-corner:disabled { opacity: 0.35; cursor: default; }
#panel-corner:disabled .menu-badge { display: none; }
#panel-corner .panel-glyph { grid-area: 1 / 1; display: grid; place-items: center; }
#panel-corner .panel-glyph[hidden] { display: none; }
#panel-corner .panel-glyph svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#panel-corner .menu-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  border: 2px solid var(--chrome-bg);
  border-radius: 50%;
  background: var(--chrome-accent);
  color: var(--chrome-bg);
  font: 700 13px/10px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  text-align: center;
}
#panel-corner:focus-visible { outline: 3px solid var(--chrome-accent); outline-offset: 2px; }

/* The pseudo-clip's corner menu rises above the bar from its cell, apart
   from the profile menu (which opens from the gutter); only one of the two
   is open at a time. */
#panel-menu {
  position: absolute;
  z-index: 20;
  left: var(--bar-pad);
  bottom: calc(100% + 8px);
  max-height: var(--bar-rise);
  overflow: auto;
  box-sizing: border-box;
  min-width: 11rem;
  padding: 0.5rem;
  border-radius: 14px 14px 14px 2px;
  background: var(--pane-bg);
  color: var(--chrome-fg);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
}
#panel-menu[hidden] { display: none; }
#panel-menu .menu-head { margin: 0 0.6rem 0.3rem; font-size: 0.8rem; font-weight: 600; }
#panel-menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  text-align: left;
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  cursor: pointer;
}
#panel-menu button:hover, #panel-menu button:focus-visible { background: var(--chrome-bg); }
#panel-menu button:focus-visible { outline: 2px solid var(--chrome-accent); outline-offset: -2px; }

/* The maker: a rounded square in the tonal fill, its plus in the accent,
   the bar's next cell after the pseudo-clip's corner; its menu rises above
   the bar from it as the corner's does. */
#maker {
  flex: none;
  width: var(--corner-size);
  height: var(--corner-size);
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--pane-bg);
  color: var(--chrome-accent);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.2);
  cursor: pointer;
  display: grid;
  place-items: center;
}
#maker:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
#maker svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
#maker:focus-visible { outline: 3px solid var(--chrome-accent); outline-offset: 2px; }
#maker-menu {
  position: absolute;
  z-index: 20;
  left: calc(var(--bar-pad) + var(--corner-size) + var(--bar-gap));
  bottom: calc(100% + 8px);
  max-height: var(--bar-rise);
  overflow: auto;
  box-sizing: border-box;
  min-width: 11rem;
  padding: 0.5rem;
  border-radius: 14px 14px 14px 2px;
  background: var(--pane-bg);
  color: var(--chrome-fg);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
}
#maker-menu[hidden] { display: none; }
#maker-menu .menu-head { margin: 0 0.6rem 0.3rem; font-size: 0.8rem; font-weight: 600; }
#maker-menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  text-align: left;
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  cursor: pointer;
}
#maker-menu button:hover, #maker-menu button:focus-visible { background: var(--chrome-bg); }
#maker-menu button:focus-visible { outline: 2px solid var(--chrome-accent); outline-offset: -2px; }

/* The corner's menu rises from the command bar's top edge, as the bar's own
   menus do, and never covers the bar or its crumbs (the UX bible's H1 and
   K3): the bar is --bar tall plus the bottom safe area, lifted by
   --keyboard where the browser does not resize the layout. */
#menu {
  --menu-floor: calc(var(--bar) + env(safe-area-inset-bottom) + var(--keyboard, 0px) + 8px);
  position: fixed;
  left: calc(var(--gutter) + 4px);
  bottom: var(--menu-floor);
  z-index: 20;
  min-width: 15rem;
  max-height: calc(100svh - var(--menu-floor) - 8px);
  overflow: auto;
  padding: 0.5rem;
  border-radius: 14px 14px 14px 2px;
  background: var(--pane-bg);
  color: var(--chrome-fg);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
  transform-origin: bottom left;
  animation: grow 120ms ease-out;
}
@keyframes grow { from { transform: scale(0.6); opacity: 0; } }
#menu button, #menu a {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
#menu button:hover:not(:disabled), #menu a:hover { background: var(--chrome-bg); }
#menu button:disabled { opacity: 0.5; cursor: default; }
#menu .menu-head { margin: 0.5rem 0.6rem 0.1rem; font-size: 0.8rem; opacity: 0.7; }
#menu .menu-who { margin: 0.25rem 0.6rem 0.5rem; font-size: 0.875rem; }
#appearance .segmented { display: flex; gap: 2px; }
#appearance .segmented button { text-align: center; }
#appearance .segmented button[aria-checked="true"] { background: var(--chrome-accent); color: var(--pane-bg); }
#menu-accounts { max-height: min(40vh, 16rem); overflow-y: auto; }
#menu-accounts button { display: flex; align-items: center; gap: 0.2em; }
#menu-accounts button[aria-checked="true"] { font-weight: 600; }
#menu-accounts .fp { opacity: 0.7; font-size: 0.85em; margin-left: auto; padding-left: 0.6em; }
.settings-items { list-style: none; margin: 0; padding: 0; }
.settings-items li { margin: 0.35rem 0; }
#menu [data-when="in"] { display: none; }
body[data-signed-in="true"] #menu [data-when="in"] { display: block; }
body[data-signed-in="true"] #menu [data-when="out"] { display: none; }
/* The @ai entries show only where the town runs the controller. */
body:not([data-ai="on"]) #menu [data-ai] { display: none; }
#menu .menu-sep { height: 1px; margin: 0.4rem 0.6rem; background: color-mix(in srgb, currentColor 20%, transparent); }
/* Settings' account list (the accounts, the tab's first). */
.settings-head { margin: 1.5rem 0 0.5rem; font-size: 1.05rem; }
.account-rows { list-style: none; margin: 0 0 0.75rem; padding: 0; }
.account-rows .account-row { display: flex; align-items: center; gap: 0.25rem; min-height: 44px; }
#panel .account-rows .account-row > button { flex: 1; margin: 0.25rem 0; text-align: left; }
.account-rows .account-row[data-active="true"] .row-note { font-weight: 600; }
.account-rows .account-row .row-note { padding: 0.4rem 0; }
#panel .account-rows .account-row .undo { flex: 0 0 auto; margin: 0.25rem 0; }
/* The panel's buttons carry their own colors: an engine's native button
   (WebKit's, in a dark scheme) can put white text on light grey. The
   2 px border is a default button's, so no target grows; torrent.nexus's
   bevel overrides it. Rows and chips keep their own. */
body[data-pseudo-clip] #panel button:not(.link):not(.row):not(.chip) {
  background: var(--pane-bg);
  color: var(--chrome-fg);
  border: 2px solid color-mix(in srgb, var(--chrome-fg) 35%, transparent);
  border-radius: 6px;
}
body[data-pseudo-clip] #panel button:not(.link):not(.row):not(.chip):disabled { opacity: 0.6; cursor: default; }
body[data-pseudo-clip] #panel button:not(.link):not(.row):not(.chip):hover:not(:disabled) { background: var(--chrome-bg); }
.colors { display: flex; flex-wrap: wrap; gap: 0.5rem; border: 0; padding: 0; margin: 0.75rem 0; }
.colors label { display: inline-flex; align-items: center; gap: 0.25rem; }

.flush { background: var(--chrome-bg); border: 0; box-shadow: none; }
#landing, #panel { max-width: 36rem; margin: 0 auto; padding: 3rem 1.25rem; }
#panel h1:focus { outline: none; }
#panel label { display: block; margin: 1rem 0; }
#panel input { display: block; width: 100%; box-sizing: border-box; padding: 0.5rem; font: inherit; margin-top: 0.25rem; }
#panel button { font: inherit; padding: 0.5rem 1rem; margin: 0 0.5rem 0.5rem 0; cursor: pointer; }
#panel button.link { padding: 0; border: 0; background: none; color: inherit; text-decoration: underline; }

/* The Inventory (designs/minion-town-spa.md § 4): list and detail side by
   side on a stage wider than 720 px, one at a time otherwise. One surface,
   no rule between them. */
body[data-panel="inventory"] #panel { max-width: 64rem; }
/* `full` (N4): the open frame takes the stage; the bar, corner and gutter
   keep their boxes (H1). After the panels' own widths, which it overrides. */
body[data-full] #landing, body[data-full] #panel { max-width: none; padding: 1rem 1.25rem; }
#panel label.inline { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0 0.75rem 0.5rem 0; }
#panel label.inline input[type="text"] { display: inline-block; width: 12rem; margin: 0; }
#panel label.check input { display: inline; width: auto; margin: 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0 0 1rem; }
.crumbs .sep { opacity: 0.6; }
#panel .crumbs button.link, #picker .crumbs button { margin: 0; }
.inventory-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.inventory-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows .quiet, .rows .empty { padding: 0.75rem 0.5rem; opacity: 0.7; }
#panel .rows button.row, #picker .rows button.row {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; min-height: 44px;
  margin: 0; padding: 0.5rem 0.6rem; border: 0; border-radius: 8px;
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.rows button.row:hover:not(:disabled), .rows button.row[aria-pressed="true"], .rows button.row[aria-selected="true"] {
  background: color-mix(in srgb, var(--chrome-accent) 18%, transparent);
}
.rows button.row:disabled { opacity: 0.45; cursor: default; }
.rows button.row[data-special] .name { font-style: italic; opacity: 0.8; }
.rows .glyph { width: 1.5rem; text-align: center; }
.rows .name { flex: 1; overflow-wrap: anywhere; }
.rows .chevron { opacity: 0.6; }
.detail h2 { margin: 0 0 0.25rem; overflow-wrap: anywhere; }
.detail .quiet { opacity: 0.75; }
.detail .actions { margin: 1rem 0; }
.detail .text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 24rem; overflow: auto; padding: 0.75rem; border-radius: 8px; background: var(--pane-bg); }
#panel button.danger { color: #b3261e; }
body[data-pseudo-clip] #panel button.danger:not(.link):not(.row) { color: #b3261e; border-color: color-mix(in srgb, #b3261e 45%, transparent); }
.detail .back { display: none; }
#inventory[data-selected="true"] .detail .back { display: inline; }
#inventory[data-selected="true"] .rows, #inventory[data-selected="true"] .inventory-tools { display: none; }
@media (min-width: 720px) and (min-aspect-ratio: 1/1) {
  .inventory-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  #inventory[data-selected="true"] .rows { display: block; }
  #inventory[data-selected="true"] .inventory-tools { display: flex; }
  #inventory[data-selected="true"] .detail .back { display: none; }
}

/* The path picker (designs/minion-town-spa-chips.md § 4): an anchored
   popover on a fine pointer; on a coarse one a sheet over the stage that
   rises to 8 px below its top, below the chrome and its corner button. */
#picker {
  position: absolute; z-index: 1; top: 4rem; right: 1.5rem; width: min(24rem, calc(100% - 3rem));
  max-height: calc(100% - 6rem); display: flex; flex-direction: column; box-sizing: border-box;
  padding: 1rem; border-radius: 12px; background: var(--chrome-bg); color: var(--chrome-fg);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
}
#picker[hidden] { display: none; }
#picker h2 { margin: 0 0 0.5rem; font-size: 1.05rem; overflow-wrap: anywhere; }
#picker input { font: inherit; padding: 0.5rem; box-sizing: border-box; width: 100%; }
#picker .rows { flex: 1; overflow: auto; margin: 0.5rem 0; min-height: 6rem; }
#picker .crumbs button { font: inherit; padding: 0.25rem 0.5rem; border-radius: 6px; border: 0; background: var(--pane-bg); color: inherit; cursor: pointer; }
#picker .picker-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
#picker .picker-foot label { display: flex; align-items: center; gap: 0.5rem; flex: 1 1 100%; }
#picker .picker-foot button { font: inherit; padding: 0.5rem 1rem; cursor: pointer; }
@media (pointer: coarse) {
  #clip-grant:not([hidden]) { bottom: calc(100% - 6px); }
  #picker { top: 8px; left: 0; right: 0; bottom: 0; width: auto; max-height: none; border-radius: 12px 12px 0 0; }
  #picker .rows button.row { min-height: 52px; }
  #picker .crumbs button { min-height: 44px; min-width: 44px; }
  #picker[data-mode="search"] { bottom: auto; height: calc(min(var(--picker-viewport, 100%), 100%) - 8px); }
}

#pane {
  position: absolute;
  inset: 8px;
  border-radius: 10px;
  background: var(--pane-bg);
  overflow: hidden;
}
#pane iframe { width: 100%; height: 100%; border: 0; display: block; }
/* The guard before a plain clip's frame (shell.js frameGuard): focusable, never seen. */
#clip-grant:not([hidden]) { display: flex; position: absolute; z-index: 30; left: 12px; right: 12px; bottom: calc(100% - 4px); box-sizing: border-box; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.6rem 0.75rem; border-radius: 8px 8px 0 0; background: var(--pane-bg); color: var(--chrome-fg); box-shadow: 0 4px 18px rgb(0 0 0 / 0.28); }
#clip-grant > p { margin: 0; flex: 1 1 auto; }
#clip-grant > button { min-height: 44px; font: inherit; }
#pane > .frame-guard { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#pane .pane-note { position: absolute; inset: 0; margin: auto; height: 1.5em; text-align: center; opacity: 0.5; pointer-events: none; }

@media (max-aspect-ratio: 1/1) {
  body.shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto var(--gutter);
    grid-template-areas: "stage" "bar" "chrome";
  }
  #chrome { flex-direction: row-reverse; }
  #gutter { flex-direction: row; padding: 0 8px; }
  #menu { --menu-floor: calc(var(--gutter) + var(--bar) + env(safe-area-inset-bottom) + var(--keyboard, 0px) + 8px); left: var(--corner-gap); }
  /* The chrome row under the bar is the first thing the keyboard covers:
     the bar rises only by the inset beyond it, to sit on the keys. */
  body.shell #bar { margin-bottom: max(0px, calc(var(--keyboard, 0px) - var(--gutter))); }
}

/* The inbox (designs/minion-town-spa.md § 5; chips in minion-town-spa-chips.md § 1). */
#inbox .segmented { margin-bottom: 0.75rem; }
#inbox .segmented button[aria-pressed="true"] { font-weight: 600; }
.inbox-filter { display: flex; gap: 0.5rem; align-items: center; }
.messages .message-row { padding: 0.6rem 0; border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent); list-style: none; }
/* The focused message, which the command bar acts on (§ 5). */
.messages .message-row[data-focused] { box-shadow: inset 3px 0 0 var(--chrome-accent); padding-left: 0.6rem; }
.messages .message-row:focus { outline: none; }
.messages .message-row:focus-visible { outline: 2px solid var(--chrome-accent); outline-offset: 2px; }
.messages .message-row.sent { margin-left: 2.5rem; text-align: right; }
.messages .message-row.reply { margin-left: 1.25rem; }
.messages .message-row.sent.reply { margin-left: 3.75rem; }
/* A failed turn sits under the message it failed on, on the sender's side. */
.messages .message-row.turn-failed { margin-left: 2.5rem; text-align: right; border-right: 3px solid #b3261e; }
.messages .message-row.turn-failed .error { color: #b3261e; margin: 0.25rem 0; }
:root[data-scheme="dark"] .messages .message-row.turn-failed .error { color: #ffb4ab; }
.messages .echo { opacity: 0.6; }
.messages .first { display: none; }
.messages .text { margin: 0.3rem 0; white-space: pre-wrap; }
/* A message's Markdown (message-render.js): body type throughout, headings
   only a step above it, code plain, a table scrolling inside the message. */
.messages .text.md { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.messages .message-row.sent .text.md { text-align: left; display: inline-block; max-width: 100%; }
.text.md > :first-child { margin-top: 0; }
.text.md > :last-child { margin-bottom: 0; }
.text.md p, .text.md ul, .text.md ol, .text.md blockquote, .text.md pre, .text.md .md-table-scroll { margin: 0 0 0.5rem; }
.text.md ul, .text.md ol { padding-left: 1.25rem; }
.text.md .md-heading { font-size: 1em; line-height: 1.35; font-weight: 600; margin: 0.6rem 0 0.25rem; }
.text.md .md-h1 { font-size: 1.13em; }
.text.md .md-h2 { font-size: 1.07em; }
.text.md blockquote { padding-left: 0.6rem; border-left: 3px solid color-mix(in srgb, currentColor 25%, transparent); }
.text.md code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; }
.text.md :not(pre) > code { padding: 0 0.2rem; border-radius: 3px; background: color-mix(in srgb, currentColor 10%, transparent); }
.text.md pre { position: relative; overflow-x: auto; padding: 0.5rem 0.6rem; border-radius: 6px; background: color-mix(in srgb, currentColor 8%, transparent); white-space: pre; overflow-wrap: normal; }
.text.md .md-code-fence-language { display: block; font-size: 0.8em; opacity: 0.7; margin-bottom: 0.2rem; }
.text.md .md-table-scroll { max-width: 100%; overflow-x: auto; }
.text.md table { border-collapse: collapse; font-size: 0.95em; width: max-content; }
.text.md th, .text.md td { max-width: 20rem; padding: 0.2rem 0.5rem; border: 1px solid color-mix(in srgb, currentColor 20%, transparent); text-align: left; vertical-align: top; overflow-wrap: normal; }
.text.md hr { border: 0; border-top: 1px solid color-mix(in srgb, currentColor 20%, transparent); }
.text.md a.md-link { color: var(--chrome-accent); }
.text.md .md-link-host { font-size: 0.85em; opacity: 0.75; }
.composer-preview { grid-column: 1 / -1; padding: 0.5rem 0.6rem; border-radius: 6px; border: 1px dashed color-mix(in srgb, currentColor 25%, transparent); }
.composer-preview[hidden] { display: none; }
.messages .foot { padding-top: 0.75rem; }
.sender { font-weight: 600; }
.sender.stranger .glyph { font-weight: 400; margin-right: 0.15rem; }
#inbox .chip { font: inherit; font-size: 0.95em; padding: 0.05rem 0.5rem; margin: 0 0.1rem; cursor: pointer; min-height: 1.6em; }
#inbox .chip.label, #composer .chip.label { border: 1.5px dashed var(--label-fg); color: var(--label-fg); background: transparent; border-radius: 999px; font-style: italic; }
#inbox .chip.path { border: 0; background: var(--path-bg); color: var(--path-fg); border-radius: 3px; font-style: normal; }
.chip-wrap { position: relative; display: inline-block; }
.chip-pop { position: absolute; left: 0; top: 100%; z-index: 5; background: var(--pane-bg); border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: 6px; padding: 0.25rem; white-space: nowrap; }
.chip-pop[hidden] { display: none; }
.composer { position: relative; display: grid; grid-template-columns: 1fr auto auto auto auto; gap: 0.4rem; align-items: end; margin-top: 1rem; }
/* The composer's Ask menu rises from its button, at the right. */
#composer-actions { position: absolute; bottom: 100%; right: 0; z-index: 6; min-width: 11rem; padding: 0.4rem; background: var(--pane-bg); border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: 6px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.25); }
#composer-actions[hidden] { display: none; }
#composer-actions button { display: block; width: 100%; min-height: 44px; text-align: left; font: inherit; padding: 0.4rem 0.6rem; border: 0; border-radius: 6px; background: none; color: inherit; cursor: pointer; }
#composer-actions button:hover, #composer-actions button:focus-visible { background: var(--path-bg); color: var(--path-fg); }
.composer[hidden] { display: none; }
.composer textarea { grid-column: 1; font: inherit; width: 100%; box-sizing: border-box; }
.composer-chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.composer-menu { position: absolute; bottom: 100%; left: 0; z-index: 6; min-width: 16rem; max-height: 18rem; overflow: auto; background: var(--pane-bg); border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: 6px; padding: 0.4rem; }
.composer-menu[hidden] { display: none; }
.composer-menu li { list-style: none; padding: 0.3rem 0.5rem; min-height: 1.5rem; cursor: pointer; }
.composer-menu li[aria-selected="true"] { background: var(--path-bg); color: var(--path-fg); }
@media (pointer: coarse) { .composer-menu li { min-height: 44px; display: flex; align-items: center; } }

.mail-kind { font-weight: 650; margin: 0.35rem 0; }
.mail-form, .mail-definition { margin: 0.5rem 0; padding: 0.75rem; border-radius: 8px; background: var(--pane-bg); text-align: left; overflow: hidden; }
.mail-form .text { margin-bottom: 0.75rem; }
.form-field { display: grid; grid-template-columns: minmax(7rem, 0.7fr) minmax(0, 1.3fr) auto; gap: 0.35rem 0.5rem; align-items: center; margin: 0.55rem 0; }
.form-field label, .form-label { font-weight: 600; overflow-wrap: anywhere; }
.form-field input:not([type="checkbox"]) { min-width: 0; width: 100%; box-sizing: border-box; font: inherit; }
.form-field input[type="checkbox"] { justify-self: start; }
.form-field .chip { justify-self: start; overflow-wrap: anywhere; }
.form-hint, .field-error { grid-column: 2 / -1; }
.field-error { color: #b3261e; }
.form-gate { display: block; margin: 0.75rem 0; }
.form-review { margin: 0.75rem 0 0.35rem; font-weight: 600; }
.sent-answer strong { margin-right: 0.75rem; }
.definition-source { box-sizing: border-box; width: 100%; max-height: 18rem; overflow: auto; white-space: pre; padding: 0.75rem; border-radius: 6px; background: color-mix(in srgb, var(--chrome-bg) 55%, transparent); color: inherit; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.definition-source.expanded { max-height: none; }
.definition-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 0.75rem; }
.definition-slots { margin: 0.35rem 0 0; padding-left: 1.4rem; }
.definition-slots li { overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .form-field { grid-template-columns: minmax(0, 1fr) auto; }
  .form-field label, .form-label { grid-column: 1 / -1; }
  .form-hint, .field-error { grid-column: 1 / -1; }
}

/* The share panel (designs/minion-town-spa.md § 7): the one-time link and
   the capability document as two cards of equal size and weight, side by
   side in landscape, stacked in portrait with the link first. */
.share label, .invite label { display: block; margin: 0.5rem 0 1rem; }
.share textarea, .invite textarea { display: block; width: 100%; box-sizing: border-box; margin-top: 0.25rem; font: inherit; }
.share-cards { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-aspect-ratio: 1/1) { .share-cards { grid-template-columns: 1fr 1fr; } }
.share-card { padding: 1rem; border-radius: 8px; background: var(--pane-bg); }
.share-card h3 { margin: 0 0 0.5rem; }
.share-card label.check { margin: 0.75rem 0 0; }
.share-made { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.share-made input { flex: 1; min-width: 12rem; font: inherit; }
.share-made p { flex-basis: 100%; margin: 0; }
.share-audience { margin: 1rem 0; opacity: 0.8; }
.share-row { display: flex; gap: 0.5rem; align-items: baseline; padding: 0.4rem 0.6rem; }
.share .quiet, .invite .quiet { opacity: 0.75; }
.share-introduce { margin: 1rem 0; }
.share-introduce form { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: baseline; }
.share-introduce label.inline { margin: 0; }

/* The @ai chrome (ai.js): key rows, the subagent form, the inspector block and the thread line. */
.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: #6f7682; vertical-align: middle; margin-right: 0.25rem; }
.dot[data-state="ready"], .dot[data-state="asleep"] { background: #16805c; }
.dot[data-state="awake"] { background: var(--accent, #2867b2); }
.dot[data-state="paused"], .dot[data-state="waiting-limit"], .dot[data-state="waiting-credits"], .dot[data-state="unavailable"], .dot[data-state="needs-key"] { background: #b7791f; }
.dot[data-state="crashed"], .dot[data-state="revoked"] { background: #a33b33; }
.dot[data-state="detached"], .dot[data-state="retired"] { background: #6f7682; }
.ai-key-form, .ai-subagent { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem 0.75rem; margin: 0.75rem 0; }
.ai-key-form label, .ai-subagent label.inline { display: flex; flex-direction: column; gap: 0.25rem; min-width: 10rem; }
.ai-subagent h2, .ai-subagent .fine { flex-basis: 100%; }
.ai-subagent label.check { flex-direction: row; align-items: center; min-height: 44px; }
.ai-inspector { margin: 1rem 0; padding: 0.75rem; border-radius: 12px; background: var(--pane-bg); }
.ai-inspector h3 { margin: 0 0 0.25rem; font-size: 1rem; }
/* Screen A's rows and Settings › Inference's: dot, text, actions; the
   actions wrap under the text on a narrow stage. */
.ai-rows { list-style: none; margin: 0 0 1rem; padding: 0; }
.ai-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent); }
.ai-row-text { display: flex; flex-direction: column; flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.ai-row-actions { display: flex; flex-wrap: wrap; }
#panel .ai-row-actions button { margin: 0.25rem 0.5rem 0.25rem 0; }
.ai-empty p { margin: 0.5rem 0; }
.quiet { opacity: 0.8; }
.ai-strong { font-weight: 600; margin: 0.25rem 0; overflow-wrap: anywhere; }
.ai-secret label { margin-bottom: 0.25rem; }
/* The primary action carries the accent; the destructive confirmation the danger color. */
body[data-pseudo-clip] #panel button.primary:not(.link):not(.row), #panel #ai-dialog button.primary { background: #2867b2; color: #fff; border: 2px solid #2867b2; border-radius: 6px; }
body[data-pseudo-clip] #panel button.primary:not(.link):not(.row):disabled, #panel #ai-dialog button.primary:disabled { opacity: 0.55; cursor: default; }
body[data-pseudo-clip] #panel button.primary:not(.link):not(.row):not(.chip):hover:not(:disabled), #panel #ai-dialog button.primary:hover:not(:disabled) { background: #1f5797; }
#panel #ai-dialog button.danger:hover:not(:disabled) { background: #8a2f28; }
#panel #ai-dialog button.danger { background: #a33b33; color: #fff; border: 2px solid #a33b33; border-radius: 6px; }
#panel .error { color: #b3261e; }
/* In the dark, a destructive button keeps its own surface: an engine's native
   dark button (#6b6b6b) is too light behind the light red. */
:root[data-scheme="dark"] #panel .error { color: #ffb4ab; }
:root[data-scheme="dark"] body[data-pseudo-clip] #panel button.danger:not(.link):not(.row) { color: #ffb4ab; border-color: color-mix(in srgb, #ffb4ab 55%, transparent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) #panel .error { color: #ffb4ab; }
  :root:not([data-scheme="light"]) body[data-pseudo-clip] #panel button.danger:not(.link):not(.row) { color: #ffb4ab; border-color: color-mix(in srgb, #ffb4ab 55%, transparent); }
}
/* Screen B's review and Screen C's cards: one column on a phone, two when there is room. */
.ai-review { margin: 0.75rem 0 1.5rem; }
.ai-review h2:focus, .ai-inspector h3:focus { outline: 2px solid var(--chrome-accent); outline-offset: 2px; }
#ai-review-body, .ai-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; margin: 0.75rem 0; }
@media (min-width: 720px) { #ai-review-body, body[data-panel="ai-inference-panel"] .ai-cards { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.ai-card { padding: 0.75rem; border-radius: 12px; background: var(--pane-bg); border: 1px solid color-mix(in srgb, currentColor 20%, transparent); min-width: 0; }
.ai-card h3, .ai-card h4 { margin: 0 0 0.25rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.85; }
.ai-card p { margin: 0.25rem 0; }
.ai-card progress { width: 100%; height: 0.5rem; }
.ai-card ul.ai-chips { list-style: none; padding: 0; margin: 0.25rem 0; }
.ai-chips .chip.path[data-attenuation="all"], .ai-reach-list li[data-attenuation="all"] .quiet { background: #fff0dc; color: #7a4310; }
.ai-reach-list { list-style: none; padding: 0; margin: 0.25rem 0; }
.ai-reach-list li { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; padding: 0.2rem 0; overflow-wrap: anywhere; }
.ai-confirm { display: grid; gap: 0.5rem; margin: 0.5rem 0; }
#panel label.ai-amber { display: flex; align-items: center; gap: 0.5rem; margin: 0; padding: 0.5rem 0.75rem; border-radius: 8px; background: #fff0dc; color: #5c3209; min-height: 44px; box-sizing: border-box; }
#panel label.ai-amber input { width: auto; margin: 0; }
.ai-inspector .ai-copy { margin: 0.25rem 0 0.5rem; }
.ai-turns ul { margin: 0.25rem 0; padding-left: 1.2rem; font-size: 0.9rem; }
.ai-turns h4 { margin: 0.5rem 0 0; font-size: 0.9rem; }
/* The one dialog for confirmations and sheets (ai.js). */
#ai-dialog { max-width: min(32rem, calc(100vw - 2rem)); box-sizing: border-box; border: 0; border-radius: 12px; padding: 1.25rem; background: var(--chrome-bg); color: var(--chrome-fg); }
#ai-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
#ai-dialog h2 { margin: 0 0 0.75rem; font-size: 1.1rem; overflow-wrap: anywhere; }
#ai-dialog p, #ai-dialog li { overflow-wrap: anywhere; }
#ai-dialog label { display: block; margin: 0.75rem 0; }
#ai-dialog label.check { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; }
#ai-dialog input:not([type="checkbox"]) { display: block; width: 100%; box-sizing: border-box; padding: 0.5rem; font: inherit; margin-top: 0.25rem; }
#panel #ai-dialog button { font: inherit; padding: 0.5rem 1rem; margin: 0 0.5rem 0.5rem 0; cursor: pointer; background: var(--pane-bg); color: var(--chrome-fg); border: 2px solid color-mix(in srgb, var(--chrome-fg) 35%, transparent); border-radius: 6px; }
#ai-dialog .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; margin-top: 1rem; }
#ai-dialog .ai-chips .chip.path { flex-wrap: wrap; }
#panel button:focus-visible, #panel #ai-dialog button:focus-visible, #ai-dialog input:focus-visible, #ai-dialog select:focus-visible, #panel select:focus-visible, #panel input:focus-visible { outline: 3px solid var(--chrome-accent); outline-offset: 2px; }
@media (pointer: coarse) {
  #panel .ai-row-actions button, #panel #ai-dialog button, #panel .ai-inspector button, #panel .ai-review button, #panel .ai-key-form button, .inbox-inference button, #panel .ai-subagent button, #ai-settings button { min-height: 44px; min-width: 44px; }
  .ai-chips .chip.path select, .ai-chips .chip-remove { min-height: 44px; min-width: 44px; }
  #panel .ai-key-form select, #panel .ai-subagent select, #panel .ai-key-form input, #panel .ai-subagent input:not([type="checkbox"]), #ai-dialog input:not([type="checkbox"]), #ai-dialog select { min-height: 44px; box-sizing: border-box; }
  #panel .ai-key-form select, #panel .ai-subagent select, #ai-dialog select { min-width: 44px; }
}
@media (prefers-reduced-motion: reduce) { #ai-dialog, #ai-dialog::backdrop { transition: none; animation: none; } }
@media (forced-colors: active) {
  .dot { forced-color-adjust: none; border: 1px solid CanvasText; }
  #panel button.primary, #panel #ai-dialog button.primary, #panel #ai-dialog button.danger { forced-color-adjust: auto; border: 2px solid ButtonText; }
  #panel label.ai-amber { border: 2px solid CanvasText; }
}
.inbox-inference { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 1rem 0 0; min-height: 44px; }
.ai-reach { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; flex-basis: 100%; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ai-chips .chip.path { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.5rem; border-radius: 3px; background: var(--path-bg); color: var(--path-fg); min-height: 32px; }
.ai-chips .chip.path select { font: inherit; min-height: 28px; }

/* The maker's group in a pseudo-clip's corner menu: New folder and the
   reserved New subagent… row (inventory-app-chrome § 3). */
#panel-menu-new { margin-top: 0.25rem; padding-top: 0.25rem; border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
#panel-menu-new .menu-head { margin-top: 0.3rem; }
#panel-menu button[hidden] { display: none; }

/* New subagent: one panel, four history-addressable steps. */
.ai-steps { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; list-style: none; margin: 0 0 0.5rem; padding: 0; font-size: 0.9rem; counter-reset: step; }
.ai-steps li { counter-increment: step; opacity: 0.8; }
.ai-steps li::before { content: counter(step) " "; font-weight: 600; }
.ai-steps li[aria-current="step"] { opacity: 1; font-weight: 700; }
.ai-wizard .ai-step { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem 0.75rem; flex-basis: 100%; }
.ai-wizard .ai-step[hidden] { display: none; }
.ai-wizard .ai-step > label:not(.check), .ai-limits > label:not(.check) { display: flex; flex-direction: column; gap: 0.25rem; min-width: 10rem; }
.ai-wizard .ai-step .fine, .ai-wizard .ai-reach, .ai-wizard #ai-review-body, .ai-wizard .ai-confirm { flex-basis: 100%; }
.ai-limits { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem 0.75rem; flex-basis: 100%; }
.ai-wizard label.check { display: flex; flex-direction: row; align-items: center; gap: 0.4rem; min-height: 44px; }
.ai-wizard .actions { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ai-wizard .error { flex-basis: 100%; }
.ai-mail-list { list-style: none; padding: 0; margin: 0.25rem 0; }
.ai-mail-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 0.5rem; padding: 0.25rem 0; border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent); overflow-wrap: anywhere; }
.ai-mail-list li .line { grid-column: 1 / -1; }
#ai-dialog fieldset { border: 0; margin: 0.5rem 0; padding: 0; }
#ai-dialog legend { font-weight: 600; margin-bottom: 0.25rem; }
#ai-dialog select { display: block; width: 100%; box-sizing: border-box; padding: 0.5rem; font: inherit; margin-top: 0.25rem; min-height: 44px; }

/* The command bar (the tower's designs/minion-town-command-bar.md § 3 and
   § 4): its own grid row under the stage, never hidden and never over
   content, so the stage, the pane's iframe and the panel end at its top edge.
   It is --bar tall in every state, plus the bottom safe area. Leading, the
   pseudo-clip menu and the maker as 44 px cells, then the place crumbs; in
   the middle the chips and the field, one row that scrolls sideways rather
   than wrapping; trailing, Close. Under the row, the hint line, which carries
   the status in landscape. Everything the bar opens rises above it. */
#bar {
  --bar-pad: 12px;
  --bar-gap: 8px;
  --bar-rise: calc(100svh - var(--bar) - var(--gutter) - 16px);
  grid-area: bar;
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--bar-gap);
  box-sizing: border-box;
  height: calc(var(--bar) + env(safe-area-inset-bottom));
  padding: 0 var(--bar-pad) env(safe-area-inset-bottom);
  /* The software keyboard's inset where the browser does not resize the
     layout for it (shell.js sets --keyboard from visualViewport): the
     bar's row rides above the keys, the stage gives up the height. */
  margin-bottom: var(--keyboard, 0px);
  background: var(--chrome-bg);
  color: var(--chrome-fg);
}
.bar-main { flex: 1 1 auto; min-width: 0; display: grid; grid-template-rows: 32px 16px; row-gap: 2px; align-content: center; }
.bar-row { display: flex; align-items: center; gap: 0.5rem; min-width: 0; height: 32px; font-size: 16px; line-height: 24px; }
#bar .crumbs { flex: 0 0 min(30%, 22rem); min-width: 0; max-width: 45%; margin: 0; padding: 0 2px; flex-wrap: nowrap; gap: 0.3rem; white-space: nowrap; overflow: hidden; }
#bar .crumbs > * { flex: none; }
#bar .crumbs .crumb[aria-current="page"] { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#bar .crumbs .crumb[aria-current="page"] { font-weight: 600; }
#bar .crumbs .crumb-glyph { flex: none; display: grid; place-items: center; }
#bar .crumbs .crumb-glyph svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#bar button.link { margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
#bar button.link:focus-visible { outline: 2px solid var(--chrome-accent); outline-offset: -2px; }
/* The root crumb is a control for its level (N6) but reads as a crumb: where
   it is the current place it has no .link, and must not fall back to the
   browser's button, whose font and padding change the row's height (F7). */
#bar .crumbs button.crumb.level { margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
#bar .crumbs button.crumb.level:focus-visible { outline: 2px solid var(--chrome-accent); outline-offset: -2px; }
/* A clip's own modes (K3): after a divider with the clip's icon, each an
   outlined chip, never the shell's plain crumb, so a clip's words never
   look like the shell's. */
#bar .crumbs .clip-divider { display: grid; place-items: center; opacity: 0.8; }
#bar .crumbs .clip-divider svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#bar .crumbs .clip-crumb { padding: 1px 0.4rem; border: 1px dashed currentColor; border-radius: 999px; line-height: 1.2; }
.command-line { flex: 1 1 0; min-width: 0; height: 32px; box-sizing: border-box; display: flex; flex-wrap: nowrap; align-items: center; gap: 0.25rem; padding: 0 0 0 0.4rem; overflow: hidden; border-radius: 6px; border: 1px solid color-mix(in srgb, currentColor 30%, transparent); background: var(--pane-bg); color: var(--chrome-fg); }
.command-line::-webkit-scrollbar { display: none; }
.command-line:focus-within { outline: 2px solid var(--chrome-accent); outline-offset: 1px; }
#bar .command-line input#command { flex: 1 1 0; min-width: 0; height: 100%; box-sizing: border-box; margin: 0; padding: 0 0.2rem; border: 0; background: transparent; color: inherit; font: inherit; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
#bar .command-line input#command:focus { outline: none; }
.command-chips { display: inline-flex; flex: 0 1 auto; min-width: 0; max-width: 45%; flex-wrap: nowrap; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.command-chips::-webkit-scrollbar { display: none; }
#bar .command-default { flex: none; height: 100%; margin: 0; padding: 0 0.5rem; border-radius: 6px; border: 1px solid color-mix(in srgb, currentColor 35%, transparent); background: transparent; color: inherit; font: inherit; font-size: 0.85em; white-space: nowrap; cursor: pointer; }
#bar .command-default[hidden] { display: none; }
#bar .command-default[data-mode="message"] { border-color: var(--chrome-accent); }
.command-chips[hidden] { display: none; }
.command-chips .chip { display: inline-block; white-space: nowrap; font-size: 0.95em; padding: 0.05rem 0.5rem; border-radius: 3px; background: var(--path-bg); color: var(--path-fg); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.command-chips .chip.command { border-radius: 999px; font-weight: 600; }
.command-chips .chip.word, .command-chips .chip.number { background: color-mix(in srgb, currentColor 12%, transparent); color: inherit; }
/* The context chip (the tower's designs/minion-town-command-bar.md § 4):
   what is in focus, dim and dashed until a command takes it as a chip. Its
   text keeps the bar's contrast; only the border and the face are quiet. */
#bar .chip.context { flex: none; display: inline-block; white-space: nowrap; font-size: 0.95em; padding: 0 0.5rem; border-radius: 3px; border: 1px dashed color-mix(in srgb, currentColor 55%, transparent); background: transparent; color: inherit; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
#bar .chip.context[hidden] { display: none; }
.command-menu .menu-group + .menu-group { margin-top: 0.4rem; }
/* A file argument's input sits in the row after the field. */
#bar .command-line input#command-file { flex: none; margin: 0; max-width: 14rem; font: inherit; font-size: 0.85em; }
#bar .command-line input#command-file[hidden] { display: none; }
/* The menu rises above the bar, capped under the viewport's top. */
.command-menu { position: absolute; bottom: calc(100% + 8px); left: var(--bar-pad); z-index: 6; box-sizing: border-box; min-width: min(20rem, calc(100% - 2 * var(--bar-pad))); max-width: calc(100% - 2 * var(--bar-pad)); max-height: min(24rem, var(--bar-rise)); overflow: auto; background: var(--pane-bg); color: var(--chrome-fg); border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: 6px; padding: 0.4rem; box-shadow: 0 6px 24px rgb(0 0 0 / 0.25); animation: bar-fade 120ms ease-out; }
@keyframes bar-fade { from { opacity: 0; } }
.command-menu[hidden] { display: none; }
.command-menu .menu-head { margin: 0 0.5rem 0.3rem; font-size: 0.8rem; opacity: 0.7; }
.command-menu .empty { margin: 0.3rem 0.5rem; opacity: 0.7; }
.command-menu .options { list-style: none; margin: 0; padding: 0; }
.command-menu li { display: flex; gap: 0.75rem; align-items: center; box-sizing: border-box; padding: 0.3rem 0.5rem; min-height: 44px; border-radius: 4px; cursor: pointer; }
.command-menu li[aria-selected="true"] { background: var(--path-bg); color: var(--path-fg); }
.command-menu .option-name { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: nowrap; }
.command-menu .option-detail { flex: 1; font-size: 0.9em; overflow-wrap: anywhere; }
/* A multi-line argument's textarea rises above the bar, with Done beside
   Ctrl+Enter. */
.command-more { position: absolute; bottom: calc(100% + 8px); left: var(--bar-pad); right: var(--bar-pad); z-index: 6; box-sizing: border-box; max-height: var(--bar-rise); display: grid; grid-template-columns: 1fr auto; gap: 0.4rem; align-items: end; padding: 0.5rem; border-radius: 8px; background: var(--pane-bg); box-shadow: 0 6px 24px rgb(0 0 0 / 0.25); }
.command-more[hidden] { display: none; }
#bar .command-more textarea { width: 100%; box-sizing: border-box; margin: 0; min-height: 6rem; max-height: calc(var(--bar-rise) - 1rem); resize: vertical; font: inherit; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
#bar .command-more button, #bar-close { flex: none; min-height: 32px; height: 32px; min-width: 44px; box-sizing: border-box; padding: 0 0.75rem; font: 16px/24px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; border: 2px solid color-mix(in srgb, var(--chrome-fg) 35%, transparent); border-radius: 6px; background: var(--pane-bg); color: var(--chrome-fg); cursor: pointer; }
#bar .command-more button:hover, #bar-close:hover { background: var(--chrome-bg); }
#bar .command-more button kbd { font: inherit; font-size: 0.8em; opacity: 0.8; }
#bar .command-more button:focus-visible, #bar-close:focus-visible { outline: 3px solid var(--chrome-accent); outline-offset: 2px; }
/* H4: on the desktop row, Close shares the command row's 24 px text
   baseline, not the centre of the taller bar. The row starts 7 px into
   the 64 px bar; the phone's single rows centre their own controls. */
@media (min-width: 601px) {
  #bar #bar-close { align-self: start; margin-top: calc((var(--bar) - 50px) / 2); }
}
#bar-close:disabled { opacity: 0.35; cursor: default; }
#bar-close:disabled:hover { background: var(--pane-bg); }
#bar-close .bar-close-glyph { display: none; }
/* H5: one focus stop and one scrollable line across the bar's physical
   bottom. Status and errors never replace it. The data attributes are kept
   in step with scrollLeft by command.js, so only obscured edges get cues. */
.bar-hint { position: absolute; left: 0; right: 0; bottom: env(safe-area-inset-bottom); height: 16px; min-width: 0; font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; background: color-mix(in srgb, var(--chrome-fg) 8%, var(--chrome-bg)); }
.bar-hint::before, .bar-hint::after { position: absolute; z-index: 1; top: 0; bottom: 0; width: 24px; pointer-events: none; color: var(--chrome-fg); }
.bar-hint:has(#command-hint[data-overflow-left])::before { content: "‹"; left: 0; padding-left: 2px; background: linear-gradient(to right, var(--chrome-bg) 35%, transparent); }
.bar-hint:has(#command-hint[data-overflow-right])::after { content: "›"; right: 0; padding-right: 2px; text-align: right; background: linear-gradient(to left, var(--chrome-bg) 35%, transparent); }
.bar-hint p { box-sizing: border-box; width: 100%; min-width: 0; margin: 0; padding: 0 12px; height: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; outline-offset: -2px; }
.bar-hint p::-webkit-scrollbar { display: none; }
.bar-hint p:focus-visible { outline: 2px solid var(--chrome-accent); }
.modeline { opacity: 0.85; }
.modeline kbd { font: inherit; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; padding: 0 0.3em; border-radius: 3px; border: 1px solid color-mix(in srgb, currentColor 35%, transparent); }
/* H3/H8: the banderole grows upward over the stage, overlaps the bar by
   four pixels, and shares the command row's edges. As an absolutely
   positioned grid item in column 3 it takes bar-main's area (the row's
   left and right), and its bottom is measured from the bar's own height. */
.command-banderole { display: none; position: absolute; z-index: 30; grid-column: 3 / 4; grid-row: 1 / -1; left: 0; right: 0; bottom: calc(var(--bar) - 4px); box-sizing: border-box; max-height: calc(100svh - var(--keyboard, 0px) - var(--bar) - 4px - env(safe-area-inset-bottom)); overflow: auto; border-radius: 8px 8px 0 0; box-shadow: 0 4px 18px rgb(0 0 0 / 0.28); background: var(--chrome-fg); color: var(--chrome-bg); }
.command-banderole:has(#status:not(:empty):not([data-faded])), .command-banderole:has(#command-help:not([hidden])) { display: block; }
.command-banderole #status { margin: 0; padding: 0.6rem 0.75rem; font-size: 0.9rem; line-height: 1.35; white-space: normal; }
.command-banderole #status.error { background: #b3261e; color: #fff; }
.command-banderole #status[data-faded], .command-banderole #status:empty { display: none; }
#command-help { padding: 0.75rem; background: var(--pane-bg); color: var(--chrome-fg); }
#command-help[hidden] { display: none; }
#command-help h2 { margin: 0 0 0.6rem; font-size: 1rem; }
.command-help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); gap: 0.75rem; }
.command-help-group h3 { margin: 0 0 0.25rem; font-size: 0.85rem; }
.command-help-group dl { margin: 0; }
.command-help-group dt { float: left; clear: left; margin-right: 0.5rem; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 600; }
.command-help-group dd { margin: 0 0 0.3rem; overflow-wrap: anywhere; }
#command-help-close { display: block; min-width: 44px; min-height: 44px; margin: 0.75rem 0 0 auto; font: inherit; }
/* In portrait, one crumb: the current place, a button when it is a
   control for its level (N6); the field gives up width. */
@media (max-aspect-ratio: 1/1) {
  #bar .crumbs .sep, #bar .crumbs .crumb:not([aria-current="page"]) { display: none; }
  #bar .crumbs { max-width: none; }
  .command-line { min-width: 6rem; }
  #bar .command-line input#command { flex-basis: 5rem; min-width: 5rem; }
}
/* A coarse pointer keeps the 16 px hint line and uses a 44 px field. */
@media (pointer: coarse) {
  .bar-main { grid-template-rows: 44px 16px; }
  .bar-row, .command-line { height: 44px; }
  .command-banderole { bottom: calc(var(--bar) - 6px); }
}
@media (prefers-reduced-motion: reduce) {
  .command-menu { animation: none; }
}
/* The `/` button at the field's trailing edge (§ 6): the menu for touch. */
#bar #command-slash { flex: none; align-self: stretch; width: 32px; height: calc(100% + 2px); box-sizing: border-box; margin: -1px -1px -1px 0; padding: 0; border: 1px solid color-mix(in srgb, currentColor 30%, transparent); border-width: 1px 1px 1px 1px; border-radius: 0 6px 6px 0; background: var(--pane-bg); color: inherit; font: 600 1rem/24px ui-monospace, "SF Mono", Menlo, Consolas, monospace; cursor: pointer; }
#bar #command-slash:hover, #bar #command-slash[aria-expanded="true"] { background: color-mix(in srgb, currentColor 12%, var(--pane-bg)); }
#bar #command-slash:focus-visible { outline: 2px solid var(--chrome-accent); outline-offset: -2px; }
/* A chip is taken back by a tap, with those after it (§ 6, Touch). */
.command-chips .chip { cursor: pointer; }
/* Busy: the field waits, the command chip spins. */
#bar .command-line input#command:disabled { opacity: 0.6; }
.command-chips .chip.busy .spinner { display: inline-block; width: 0.7em; height: 0.7em; margin-left: 0.35em; vertical-align: -0.05em; box-sizing: border-box; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: bar-spin 0.8s linear infinite; }
@keyframes bar-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .command-chips .chip.busy .spinner { animation: none; border-right-color: currentColor; opacity: 0.6; }
}
/* A status past its 4 s, or an error past the next key: its text stays in
   the live region, unseen, and the hint line's keys return (§ 4). */
/* The portrait crumb's ancestors (§ 4): a button after the one crumb, its
   menu rising above the bar. Landscape shows every crumb, so no button. */
#crumbs-up { display: none; }
#crumbs-menu, #crumb-siblings { position: absolute; z-index: 20; left: var(--bar-pad); bottom: calc(100% + 8px); max-height: var(--bar-rise); overflow: auto; box-sizing: border-box; min-width: 11rem; padding: 0.5rem; border-radius: 14px; background: var(--pane-bg); color: var(--chrome-fg); box-shadow: 0 6px 24px rgb(0 0 0 / 0.25); }
#crumbs-menu[hidden], #crumb-siblings[hidden] { display: none; }
#crumbs-menu button, #crumb-siblings button { display: block; width: 100%; min-height: 44px; text-align: left; font: inherit; padding: 0.4rem 0.6rem; border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; }
#crumbs-menu button:hover, #crumbs-menu button:focus-visible, #crumb-siblings button:hover, #crumb-siblings button:focus-visible { background: var(--chrome-bg); }
#crumb-siblings button[aria-current] { font-weight: 600; }
/* H6: at phone and zoom widths, navigation gets one row and the field the
   entire next row between the 12 px insets. DOM wrappers become transparent
   grid participants; this does not change the bar's box between modes. */
@media (max-width: 600px) {
  :root { --bar: 104px; }
  #bar {
    grid-template-columns: 44px 44px minmax(0, 1fr) 44px;
    grid-template-rows: 44px 44px 16px;
    column-gap: 8px;
    row-gap: 0;
    align-content: start;
  }
  .command-banderole { max-height: calc(100svh - var(--bar) - max(var(--gutter), var(--keyboard, 0px)) - 2px - env(safe-area-inset-bottom)); }
  #panel-corner { grid-column: 1; grid-row: 1; }
  #maker { grid-column: 2; grid-row: 1; }
  .bar-main, .bar-row { display: contents; }
  #bar .crumbs { grid-column: 3; grid-row: 1; align-self: center; max-width: none; padding: 0; }
  #crumbs-up { grid-column: 3; grid-row: 1; justify-self: end; z-index: 1; }
  #bar-close { grid-column: 4; grid-row: 1; align-self: center; height: 44px; margin-top: 0; }
  .command-banderole { grid-column: 1 / 5; }
  .command-line { grid-column: 1 / 5; grid-row: 2; width: 100%; height: 44px; }
  .command-chips { max-width: 40%; }
}
@media (max-aspect-ratio: 1/1) {
  #bar #crumbs-up { display: grid; place-items: center; flex: none; width: 32px; height: 32px; margin: 0 0 0 -0.3rem; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
  #bar #crumbs-up:disabled { opacity: 0.35; cursor: default; }
  /* One crumb and four fixed slots: the crumb takes a third of the row,
     and Close is its glyph, its name kept in aria-label (F7). */
  #bar .crumbs { flex-basis: 34%; }
  #bar-close { padding: 0; width: 44px; }
  #bar-close .bar-close-text { display: none; }
  #bar-close .bar-close-glyph { display: inline; font-size: 1.4rem; line-height: 1; }
  #bar #crumbs-up:focus-visible { outline: 2px solid var(--chrome-accent); outline-offset: -2px; }
}
/* On a coarse pointer the `/` button and the crumb's are 44 px, the field's
   type 16 px so the phone does not zoom into it, and the command menu is a
   sheet over the stage, up to 60 % of it (the picker's convention). */
@media (pointer: coarse) {
  /* The touch default is one 44 px glyph: text would not fit beside the
     field and the sticky `/` button on a phone. Its aria-label still names
     the full default and who a message would go to. */
  #bar #command-default { width: 44px; min-width: 44px; min-height: 44px; padding: 0; display: grid; place-items: center; font-size: 0; }
  #bar #command-default::before { content: "⌘"; font-size: 16px; }
  #bar #command-default[data-mode="message"]::before { content: "✉"; }
  #bar #command-slash { width: 44px; height: 44px; margin: 0; }
  #bar #crumbs-up { width: 44px; height: 44px; }
  #bar .command-line { border: 0; box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 30%, transparent); }
  #bar .command-line input#command { font-size: 16px; }
  #bar .command-menu { left: 0; right: 0; bottom: 100%; min-width: 0; max-width: none; max-height: calc(0.6 * (100svh - var(--keyboard, 0px) - var(--bar) - var(--gutter))); border-radius: 12px 12px 0 0; border-width: 1px 0 0; padding: 0.5rem 0.75rem; }
}

/* The overview (the tower's designs/command-and-control-bible.md, N7): the
   whole tree of places, drawn over the stage only, so the chrome column and
   the bar keep their boxes (H1). */
body[data-overview] #stage { overflow: hidden; }
#overview { position: absolute; left: 0; right: 0; height: 100%; z-index: 4; overflow: auto; box-sizing: border-box; padding: 1rem 1.25rem; background: var(--chrome-bg); }
#overview[hidden] { display: none; }
.overview-head { margin: 0 0 0.75rem; font-size: 1rem; font-weight: 600; }
.overview-place { display: block; margin: 0.15rem 0 0.15rem calc(var(--depth) * 1.5rem); padding: 0.3rem 0.6rem; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); border-radius: 6px; max-width: 24rem; cursor: pointer; }
.overview-place.clip { font-weight: 600; }
.overview-place, .overview-new { touch-action: none; user-select: none; -webkit-user-select: none; }
.overview-new { margin: 0 0 0.6rem; padding: 0.3rem 0.7rem; border: 1px dashed color-mix(in srgb, currentColor 40%, transparent); border-radius: 6px; background: transparent; color: inherit; font: inherit; cursor: grab; }
.overview-drop { position: absolute; height: 0; border-top: 3px solid var(--accent, Highlight); pointer-events: none; transform: translateY(-1.5px); }
.overview-drop[hidden] { display: none; }
.overview-place[aria-selected="true"] { outline: 2px solid var(--accent, Highlight); outline-offset: 1px; background: color-mix(in srgb, var(--accent, Highlight) 14%, transparent); }
