/* The HUD is paper too: parchment cards with ink text and ink hairlines by day; at night the dark room's deep-blue
   paper with parchment text. Inks come from the scene's palette (lab/src/paper/palette.js) or a tone step of one.
   Teal means one thing: a tool is running now (and the live badge). app/src/ui.js stamps body[data-hud]. */
:root {
  --font: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Songti SC", serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --page: #e6d8bb; --bg: rgba(244, 236, 217, 0.97); --card: #f2e8d2; --line: rgba(44, 42, 39, 0.26); --rule: rgba(44, 42, 39, 0.5);
  --text: #2c2a27; --muted: #6b6253; --accent: #0b746e; --on-accent: #f2e8d2; --hover: rgba(44, 42, 39, 0.07);
  --shadow: 1px 2px 0 rgba(44, 42, 39, 0.16), 0 6px 14px -8px rgba(44, 42, 39, 0.35);
  --think: #33506b; --act: #0b746e; --perm: #886015; --wait: #7a4e6e; --compact: #476c85; --err: #af462f; --idle: #9a8f7a; --ok: #497054;
  /* the landing note is parchment in both skies (at night a sheet under a lamp), so its inks do not follow the HUD */
  --note-paper: #f2e8d2; --note-ink: #2c2a27; --note-edge: rgba(44, 42, 39, 0.6);
}
body[data-hud="dark"] {
  --page: #17222f; --bg: rgba(33, 50, 69, 0.96); --card: #233649; --line: rgba(242, 232, 210, 0.22); --rule: rgba(242, 232, 210, 0.45);
  --text: #f2e8d2; --muted: #b3a88f; --accent: #3cc7bf; --on-accent: #17222f; --hover: rgba(242, 232, 210, 0.08);
  --shadow: 1px 2px 0 rgba(0, 0, 0, 0.3), 0 8px 18px -8px rgba(0, 0, 0, 0.6);
  --think: #a9c2d6; --act: #3cc7bf; --perm: #e3b75c; --wait: #cfa3c3; --compact: #93b6cf; --err: #ec8d70; --idle: #8f8875; --ok: #a7c78b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: var(--font); font-size: 13px; color: var(--text); background: var(--page); transition: background 0.4s; }
#app { position: fixed; inset: 0; }
#app canvas { display: block; outline: none; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.panel { background: var(--bg); border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--shadow); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mono { font-family: var(--mono); }
button { font: inherit; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 2px; padding: 4px 10px; cursor: pointer; white-space: nowrap; transition: background 0.15s, color 0.15s, transform 0.1s; }
button:hover { background: var(--hover); }
button:active { transform: translateY(1px); }
button.on { background: var(--text); color: var(--card); border-color: var(--text); font-weight: 600; }

/* top-left: brand + source */
#top { position: absolute; left: 14px; right: 14px; top: 14px; display: flex; align-items: flex-start; gap: 12px; pointer-events: none; }
#top > * { pointer-events: auto; }
#brand { flex: 0 1 330px; min-width: 220px; padding: 10px 13px 9px; }
#brand .title { font-family: var(--serif); font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 8px; letter-spacing: 0.005em; }
#brand .title .ver { font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-accent); background: var(--accent); border-radius: 2px; padding: 2px 7px; }
#brand .title .ver.ended { color: var(--text); background: transparent; box-shadow: inset 0 0 0 1px var(--muted); }
#source { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#source .live { background: var(--accent); }
#source .live.tick { animation: pulse 0.5s ease-out; }
#source .off { background: var(--idle); }
@keyframes pulse { from { box-shadow: 0 0 0 0 var(--accent); } to { box-shadow: 0 0 0 7px transparent; } }
#crumbs { display: flex; align-items: center; gap: 5px; margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
#crumbs .sep { color: var(--muted); }
#crumbs button { padding: 2px 9px; font-weight: 600; }
#crumbs button.on { background: var(--hover); color: var(--text); border-color: var(--rule); }

/* top-right: one settings button; the panel under it keeps every switch */
#settings { margin-left: auto; position: relative; }
#settings-btn { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; background: var(--bg); border-color: var(--line); }
#settings-panel[hidden] { display: none; }
#settings-panel { position: absolute; right: 0; top: 40px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: calc(100vw - 28px); z-index: 3; }
/* the speaker beside it (app/src/sound.js): off until a click; its panel keeps the two switches */
#sound { margin-left: auto; position: relative; }
#sound + #settings { margin-left: 0; }
#sound-btn { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; background: var(--bg); border-color: var(--line); }
#sound-btn.on { background: var(--text); border-color: var(--text); }
#sound-panel[hidden] { display: none; }
#sound-panel { position: absolute; right: 0; top: 40px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; width: max-content; z-index: 3; }
.grp { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; }
.grp label { font-family: var(--serif); font-size: 12px; font-style: italic; color: var(--muted); }
.seg { flex-wrap: wrap; }
.seg { display: flex; gap: 2px; }
.seg button { padding: 3px 7px; font-size: 12px; }

/* KPI row */
#kpis { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.chip { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.chip b { font-size: 14px; font-weight: 800; min-width: 12px; text-align: right; }
.chip span { color: var(--muted); }
.chip.hot { animation: hot 1.3s ease-in-out infinite; }
@keyframes hot { 50% { box-shadow: 0 0 0 4px var(--hover); } }

/* the tour's caption: a paper strip at the top centre while the camera tours */
#caption { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); max-width: min(420px, calc(100vw - 420px)); padding: 6px 14px 7px; font-family: var(--serif); font-size: 14px; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
#caption[hidden] { display: none; }
@media (max-width: 760px) { #caption { top: auto; bottom: 64px; max-width: calc(100vw - 32px); } }

/* detail */
#detail { position: absolute; right: 14px; top: 70px; width: 318px; max-height: calc(100vh - 190px); overflow: auto; padding: 12px 14px 11px; font-size: 12.5px; }
#detail.compact { width: 296px; padding: 10px 13px 9px; }
#detail.compact .head { font-size: 14px; }
#detail .more { color: var(--muted); font-size: 11.5px; margin-top: 7px; }
/* the reading guide sits low on the right: at street level, not over the rooftops */
#detail.guide { top: auto; bottom: 58px; width: 292px; }
#detail.guide .guide { font-size: 12px; }
#detail .head { display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-size: 16px; font-weight: 700; }
#detail .head .dot { width: 12px; height: 12px; }
#detail .head .role { font-family: var(--font); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 2px; border: 1px solid var(--line); margin-left: auto; white-space: nowrap; }
#detail .sub { color: var(--muted); margin-top: 4px; font-size: 12px; }
/* a sub line wraps between its fields, never inside one; a field wider than the card is cut with an ellipsis */
#detail .sub .f { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
#detail .head { overflow-wrap: anywhere; }
#detail .row .f { white-space: nowrap; }
#detail .agent-rows { display: grid; gap: 4px; margin-top: 8px; }
#detail .agent-row { display: flex; align-items: center; gap: 7px; width: 100%; min-width: 0; padding: 4px 8px; text-align: left; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 2px; cursor: pointer; }
#detail .agent-row:hover { background: var(--hover); }
#detail .agent-row b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#detail .agent-row .muted { margin-left: auto; white-space: nowrap; font-size: 11.5px; }
.state { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 8px; border-radius: 2px; font-weight: 600; margin-top: 10px; border: 1px solid var(--line); }
.state small { font-weight: 500; color: var(--muted); font-family: var(--mono); }
.row { display: grid; grid-template-columns: 64px 1fr; gap: 10px; margin-top: 8px; align-items: baseline; }
.row .k { color: var(--muted); }
.row .v { min-width: 0; overflow-wrap: anywhere; line-height: 1.45; }
.bar { display: grid; grid-template-columns: 70px 1fr 24px; gap: 8px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); }
.bar .track { height: 5px; border-radius: 1px; background: var(--hover); border: 1px solid var(--line); overflow: hidden; }
.bar .track i { display: block; height: 100%; background: var(--muted); }
.bar b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.sep-line { height: 0; border-top: 1px dashed var(--line); margin: 11px 0 3px; }
.pills { display: flex; flex-wrap: wrap; gap: 5px; }
.pill { font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 2px; background: var(--card); border: 1px solid var(--line); cursor: pointer; font-weight: 600; }
.pill:hover { background: var(--hover); }
.guide { color: var(--muted); line-height: 1.65; }
.guide b { color: var(--text); }

/* town news + legend */
/* town news (ui.js renderNews): one grid for both sections so names line up; every line is one line, cut at the end */
#ticker { position: absolute; left: 14px; bottom: 14px; width: min(440px, calc(100vw - 28px)); padding: 4px 12px 8px; display: flex; flex-direction: column; }
#ticker.expanded { width: min(640px, calc(100vw - 28px)); height: 50vh; max-height: calc(100vh - 90px); }
@media (max-width: 900px) { #ticker:not(.folded) { width: calc(100vw - 28px); } }
#ticker .news-grip { position: absolute; left: 0; right: 0; top: -4px; height: 9px; cursor: ns-resize; touch-action: none; }
#ticker .news-bar { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--rule); padding: 2px 0 4px; margin-bottom: 3px; }
#ticker .news-head { display: flex; align-items: center; border: 0; border-radius: 0; padding: 0; margin-right: auto; font-family: var(--serif); font-size: 13px; font-weight: 700; color: var(--text); background: transparent; white-space: nowrap; }
#ticker .news-fold { margin-left: 10px; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); }
#ticker .news-chips { display: flex; gap: 2px; }
#ticker .news-chips button { border: 1px solid transparent; border-radius: 3px; padding: 1px 6px; font-size: 11px; color: var(--muted); background: transparent; white-space: nowrap; }
#ticker .news-chips button.on { color: var(--text); border-color: var(--rule); }
#ticker .news-size { display: flex; align-items: center; justify-content: center; width: 22px; height: 20px; padding: 0; border: 1px solid transparent; border-radius: 3px; color: var(--muted); background: transparent; }
#ticker .news-size:hover, #ticker .news-chips button:hover { color: var(--text); }
#ticker.folded { width: auto; height: auto; padding-bottom: 6px; }
#ticker.folded .news-bar { border-bottom: 0; margin-bottom: 0; }
#ticker.folded #ticker-list, #ticker.folded .news-chips, #ticker.folded .news-size, #ticker.folded .news-grip { display: none; }
#ticker.folded .news-fold { transform: rotate(-135deg) translate(-2px, -2px); }
#ticker-list { display: grid; grid-template-columns: [t] auto [ic] 14px [who] fit-content(18ch) [x] minmax(0, 1fr); column-gap: 7px; align-content: start; font-size: 12px; min-height: 0; }
#ticker.expanded #ticker-list { flex: 1; overflow-y: auto; grid-template-columns: [t] auto [ic] 14px [who] fit-content(45%) [x] minmax(0, 1fr); }
#ticker-list ul { display: contents; list-style: none; }
#ticker-list ul[hidden] { display: none; }
#ticker-list li { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center; padding: 2px 0; white-space: nowrap; border-radius: 2px; }
#ticker-list li[data-session] { cursor: pointer; }
#ticker-list li[data-session]:hover { background: var(--hover); }
#ticker-list li.empty { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
#ticker-list li .t { grid-column: t; color: var(--muted); font-family: var(--mono); font-size: 11px; font-variant-numeric: tabular-nums; }
#ticker-list li .ic-cell { grid-column: ic; display: flex; color: var(--muted); }
#ticker-list li .who { grid-column: who; display: flex; align-items: center; gap: 5px; min-width: 0; color: var(--text); }
#ticker-list li .who .dot { flex: none; width: 7px; height: 7px; border-radius: 50%; }
#ticker-list li .nm, #ticker-list li .x, #ticker-list li .detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#ticker-list li .x { grid-column: x; color: var(--text); }
#ticker-list li .detail { grid-column: who / -1; padding-left: 12px; color: var(--muted); font-family: var(--mono); font-size: 11px; }
#ticker-list li.tc-err .x, #ticker-list li.tc-err .ic-cell { color: var(--err); }
#ticker-list ul.news-now li .ic-cell { color: var(--text); }
#ticker-list li.fresh { animation: slide 0.25s ease-out; }
/* no fade: on a busy frame the animation can stall at its first keyframe, and a row at opacity 0 read as an empty gap */
@keyframes slide { from { transform: translateX(-6px); } }
#ticker .roof-0 { background: #cc5a3f; } #ticker .roof-1 { background: #dda63a; } #ticker .roof-2 { background: #6f93ad; } #ticker .roof-3 { background: #8daa76; } #ticker .roof-4 { background: #7a4e6e; }
#legend { position: absolute; left: calc(50% + 44px); bottom: 14px; transform: translateX(-50%); display: flex; gap: 10px; padding: 6px 12px; font-size: 12px; color: var(--muted); flex-wrap: nowrap; justify-content: center; white-space: nowrap; }
#legend .li { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
#legend .li b { color: var(--text); font-variant-numeric: tabular-nums; min-width: 13px; text-align: right; font-size: 13px; }
#hint { position: absolute; right: 14px; bottom: 14px; padding: 7px 12px; font-size: 12px; color: var(--muted); line-height: 1.6; white-space: nowrap; }
#hint b { color: var(--text); font-weight: 600; }
#fatal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(23, 34, 47, 0.94); color: #ec8d70; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; padding: 28px; z-index: 9; }
#fatal.show { display: flex; }
/* folded guide: a single "?" button in the corner */
#detail.folded { width: auto; padding: 0; overflow: visible; }
.guide-q { width: 34px; height: 34px; border: 0; background: transparent; color: var(--text); font: italic 700 18px/1 var(--serif); cursor: pointer; }
.guide-x { margin-left: auto; border: 0; background: transparent; color: var(--muted); font: 700 18px/1 inherit; cursor: pointer; padding: 0 2px; }
/* place and resident labels (app/src/labels.js): HTML over the canvas, positioned through the CSSOM */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#labels .tag { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 5px; padding: 1px 6px 2px; background: var(--card); border: 1px solid var(--rule); border-radius: 1px; box-shadow: 1px 1px 0 var(--line); white-space: nowrap; font-size: 11.5px; line-height: 15px; color: var(--text); }
/* the thread down to the anchor (labels.js THREAD px) and the pin at its end; --thread moves it off the middle of a
   tag pushed in from a side of the screen */
#labels .tag::after { content: ""; position: absolute; left: var(--thread, 50%); top: 100%; width: 1px; height: 10px; background: var(--rule); }
#labels .tag::before { content: ""; position: absolute; left: calc(var(--thread, 50%) - 1.5px); top: calc(100% + 8.5px); width: 4px; height: 4px; border-radius: 50%; background: var(--text); }
#labels .tag.off { visibility: hidden; }
#labels .tag b { display: inline-block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
#labels .tag .sub { font-family: var(--mono); font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
#labels .tag .dot { width: 6px; height: 6px; }
#labels .tag .dot-none { display: none; }
#labels .tag.hot { border-color: var(--text); box-shadow: 1px 1px 0 var(--rule); z-index: 1; }
@media (max-width: 1180px) { #detail.guide:not(.folded) { width: min(292px, calc(100vw - 28px)); } #settings { max-width: calc(100vw - 340px); } #hint { display: none; } }
/* a narrow pane keeps the card: beside the brand while there is room, else a sheet over the foot of the screen */
@media (max-width: 1000px) { #detail:not(.guide) { width: min(296px, calc(100vw - 372px)); max-height: calc(100vh - 160px); font-size: 12px; } }
@media (max-width: 640px) { #detail:not(.guide) { left: 14px; right: 14px; width: auto; top: auto; bottom: 14px; max-height: 46vh; z-index: 4; } }
@media (max-width: 1000px) { #legend { display: none; } }


/* ---- nothing below is styled inline: a strict CSP blocks style attributes, so colours are classes and the
        few numeric values (bar widths) are set through the CSSOM after rendering ---- */
.muted { color: var(--muted); }
.crumb-tag { padding: 2px 4px; }
.dot-text { background: var(--text); }

/* state -> colour: bc-* paints a dot, tc-* paints text */
.bc-thinking { background: var(--think); } .tc-thinking { color: var(--think); }
.bc-acting { background: var(--act); } .tc-acting { color: var(--act); }
.bc-awaiting_permission { background: var(--perm); } .tc-awaiting_permission { color: var(--perm); }
.bc-waiting { background: var(--wait); } .tc-waiting { color: var(--wait); }
.bc-compacting { background: var(--compact); } .tc-compacting { color: var(--compact); }
.bc-error { background: var(--err); } .tc-error { color: var(--err); }
.bc-idle, .bc-stalled { background: var(--idle); } .tc-idle, .tc-stalled { color: var(--muted); } /* --idle is a dot's grey, too light for text */
.bc-spawning, .bc-done { background: var(--text); } .tc-spawning, .tc-done { color: var(--text); }

/* tone -> colour, for the event ticker and highlights */
.tc-act { color: var(--act); }
.tc-think { color: var(--think); }
.tc-perm { color: var(--perm); }
.tc-wait { color: var(--wait); }
.tc-err { color: var(--err); }
.tc-ok { color: var(--ok); }
.tc-idle { color: var(--muted); }

.bar .track i { width: 0; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:hover { background: transparent; }

/* site entry (app/src/site.js): the share gate, the landing card, the link to the lanes view */
#site-gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(44, 42, 39, 0.28); z-index: 20; }
body[data-hud="dark"] #site-gate { background: rgba(10, 16, 24, 0.5); }
#site-gate[hidden] { display: none; }
/* the gate is the landing note's parchment card in both skies */
#site-gate .panel { max-width: 460px; padding: 16px 20px 18px; background: var(--note-paper); color: var(--note-ink); border: 1px solid var(--note-edge); border-radius: 1px; opacity: 1; }
body[data-hud="dark"] #site-gate .panel { box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.35), 0 0 46px -6px rgba(255, 214, 150, 0.4), 0 14px 22px -10px rgba(0, 0, 0, 0.7); }
#site-gate .gate-title { font-family: var(--serif); font-size: 17px; font-weight: 700; padding-bottom: 6px; border-bottom: 1px solid var(--note-edge); }
#site-gate .gate-msg { margin-top: 10px; font-size: 14px; line-height: 1.55; }
#site-gate .gate-pin[hidden] { display: none; }
#site-gate .gate-pin { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
#site-gate .pin-boxes { display: flex; gap: 6px; }
#site-gate .pin-digit { width: 2.2em; height: 2.6em; padding: 0; text-align: center; font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--note-ink); background: var(--note-paper); border: 1px solid var(--note-edge); border-radius: 1px; caret-color: var(--note-ink); }
#site-gate .pin-digit:focus { outline: 2px solid var(--note-ink); outline-offset: 1px; }
#site-gate .pin-open { font-weight: 700; color: var(--note-ink); background: transparent; border-color: var(--note-edge); }
#site-gate .pin-open:hover { background: rgba(44, 42, 39, 0.07); }
/* the landing card is a note lying on the desk in front of the model: parchment, a little turned, its foot towards
   the viewer */
#landing { position: fixed; left: 50%; bottom: 7vh; width: min(500px, calc(100vw - 32px)); padding: 18px 22px 16px; z-index: 10; background: var(--note-paper); color: var(--note-ink); border: 1px solid var(--note-edge); opacity: 1; filter: none; border-radius: 1px; transform: translateX(-50%) perspective(900px) rotateX(14deg) rotate(-1.2deg); transform-origin: 50% 100%; box-shadow: 2px 3px 0 rgba(44, 42, 39, 0.18), 0 14px 22px -10px rgba(20, 16, 10, 0.55); }
body[data-hud="dark"] #landing { box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.35), 0 0 46px -6px rgba(255, 214, 150, 0.4), 0 14px 22px -10px rgba(0, 0, 0, 0.7); }
#landing::before { content: ""; position: absolute; left: 50%; top: -7px; width: 54px; height: 14px; transform: translateX(-50%) rotate(2deg); background: rgba(221, 166, 58, 0.55); }
#landing .landing-lead { margin: 0; font-family: var(--serif); font-size: 17px; font-weight: 700; line-height: 1.45; }
#landing .landing-prompt { margin: 12px 0 14px; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; border: 1px dashed var(--note-edge); border-radius: 1px; user-select: text; -webkit-user-select: text; }
#landing .landing-copy { font-weight: 700; color: var(--note-ink); background: transparent; border-color: var(--note-edge); }
#landing .landing-copy:hover { background: rgba(44, 42, 39, 0.07); }
#brand .lanes-link { margin-left: auto; font-family: var(--font); font-size: 12px; font-weight: 600; color: var(--text); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
#brand .lanes-link:hover { text-decoration: underline; }
#public-note { margin-top: 5px; font-size: 12px; color: var(--muted); display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
#public-note[hidden] { display: none; }
#public-note .pub { font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); border: 1px solid var(--line); border-radius: 2px; padding: 1px 6px; }

/* clean capture mode (?shot=1): no HUD, no gate or landing card; labels=0 also hides every name label */
body.capture #hud, body.capture #landing, body.capture #site-gate { display: none !important; }
body.capture-nolabels #labels { display: none; }

/* a narrow landing page keeps the note and the model: the news folds away */
@media (max-width: 900px) {
  body.landing #ticker { display: none; }
  #landing { bottom: 12px; padding: 12px 14px 10px; transform: translateX(-50%) perspective(900px) rotateX(10deg) rotate(-1deg); }
  #landing .landing-lead { font-size: 14px; }
  #landing .landing-prompt { margin: 8px 0 10px; padding: 7px 9px; font-size: 11px; line-height: 1.5; }
}
/* owner-link detail rows: one line each, the full text on hover */
#detail .target { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
#detail .row .v .target + .muted { white-space: nowrap; }
#detail .marks span { margin-right: 4px; font-weight: 700; }
#detail .mk-ok { color: var(--ok); }
#detail .mk-fail { color: var(--err); }
#detail .tl-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 2px 0 4px; }
/* the name column is as wide as the longest name in view (capped), the target takes the rest; one line per call */
#detail .tl { list-style: none; margin: 0; padding: 0; max-height: 34vh; overflow-y: auto; display: grid; grid-template-columns: fit-content(18ch) minmax(0, 1fr) auto 12px; column-gap: 6px; align-content: start; }
#detail .tl li { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: baseline; font-size: 11.5px; padding: 1px 0; white-space: nowrap; }
#detail .tl li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#detail .tl li .n .srv { color: var(--muted); }
#detail .tl li .target { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#detail .tl li .m { display: flex; align-self: center; }
#detail .tl li .d { text-align: right; color: var(--muted); white-space: nowrap; }
#detail .tl-more { font-size: 11px; color: var(--muted); margin-top: 2px; }
#detail .tl li.fail .m, #detail .tl li.fail .d { color: var(--err); }
#detail .lanes-open { font-weight: 600; color: var(--text); text-underline-offset: 3px; }

/* the agent drawer (app/src/drawer.js): owner link and demo only; wide on the right, the whole width when narrow */
#drawer { position: fixed; top: 14px; right: 14px; max-height: calc(100vh - 28px); width: min(760px, 56vw); display: flex; flex-direction: column; z-index: 6; padding: 0; background: var(--card); }
#drawer[hidden] { display: none; }
@media (max-width: 900px) { #drawer { left: 14px; width: auto; } }
body.drawer-open #detail { display: none; }
#drawer .dr-head { display: flex; align-items: flex-start; gap: 8px; padding: 12px 14px 10px; border-bottom: 1px solid var(--rule); }
#drawer .dr-facts { flex: 1; min-width: 0; }
#drawer .dr-name { display: flex; align-items: center; gap: 7px; font-family: var(--serif); font-size: 17px; font-weight: 700; color: var(--text); }
#drawer .dr-line { display: flex; flex-wrap: wrap; column-gap: 14px; row-gap: 2px; margin-top: 4px; font-size: 12px; color: var(--text); }
#drawer .dr-line .f { white-space: nowrap; }
#drawer .dr-line .f.cut { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#drawer .dr-line .k { color: var(--muted); }
#drawer .dr-close { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--rule); border-radius: 3px; background: transparent; color: var(--text); }
#drawer .dr-body { flex: 0 1 auto; min-height: 0; overflow-y: auto; padding: 8px 14px 14px; font-size: 13px; color: var(--text); }
#drawer .dr-earlier { display: block; margin: 4px auto 10px; padding: 3px 12px; border: 1px solid var(--rule); border-radius: 3px; background: transparent; color: var(--text); font-size: 12px; }
#drawer .dr-note, #drawer .dr-muted { color: var(--muted); font-size: 12px; margin: 6px 0; }
#drawer .dr-error { color: var(--err); font-size: 12px; margin: 6px 0; }
#drawer .dr-turn { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
#drawer .dr-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
#drawer .dr-quote { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--rule); background: var(--hover); }
#drawer .dr-quote > :first-child, #drawer .dr-reply > :first-child { margin-top: 0; }
#drawer .dr-quote > :last-child, #drawer .dr-reply > :last-child { margin-bottom: 0; }
#drawer .dr-calls { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: 14px fit-content(18ch) minmax(0, 1fr) auto; column-gap: 8px; }
#drawer .dr-call { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
#drawer .dr-row { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center; padding: 2px 0; border: 0; border-radius: 2px; background: transparent; color: var(--text); font-size: 12px; text-align: left; white-space: nowrap; cursor: pointer; }
#drawer .dr-row:hover { background: var(--hover); }
#drawer .dr-row .m { display: flex; color: var(--muted); }
#drawer .dr-call.error .dr-row .m, #drawer .dr-call.error .dr-row .n { color: var(--err); }
#drawer .dr-row .n, #drawer .dr-row .a { overflow: hidden; text-overflow: ellipsis; }
#drawer .dr-row .n .srv, #drawer .dr-row .a, #drawer .dr-row .d { color: var(--muted); }
#drawer .dr-io { grid-column: 2 / -1; margin: 2px 0 8px; }
#drawer .dr-io .k { font-size: 11px; color: var(--muted); margin: 4px 0 2px; }
#drawer .dr-io pre { margin: 0; max-height: 18em; overflow: auto; padding: 6px 8px; background: var(--hover); font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
#drawer .dr-all { margin-top: 3px; padding: 1px 8px; border: 1px solid var(--rule); border-radius: 3px; background: transparent; color: var(--text); font-size: 11px; }
#drawer .dr-reply { line-height: 1.5; overflow-wrap: anywhere; }
#drawer .dr-reply pre, #drawer .dr-quote pre { overflow-x: auto; padding: 6px 8px; background: var(--hover); font-size: 12px; }
#drawer .dr-reply table { border-collapse: collapse; display: block; overflow-x: auto; }
#drawer .dr-reply th, #drawer .dr-reply td { border: 1px solid var(--line); padding: 2px 8px; text-align: left; }
#drawer .md-url { color: var(--muted); }
#drawer .dr-foot { margin: 6px 0 0; font-size: 11px; color: var(--muted); }
#detail .head .open-drawer { margin-left: auto; padding: 1px 8px; border: 1px solid var(--rule); border-radius: 3px; background: transparent; color: var(--text); font-size: 11px; font-family: inherit; font-weight: 400; }
