/* sm web app (spec 1710 appendix A). Every colour is a token with a light and
   a dark value; data-theme is system, light or dark (D2). */
:root {
  --bg: #F5F5F2; --panel: #FFFFFF; --panel-2: #EEEEE9; --line: #E0E0D9;
  --ink: #16171B; --ink-2: #555864; --ink-3: #8B8D96;
  --accent: #0B7A90; --sel: #E2F1F4;
  --green: #15803D; --amber: #B45309; --magenta: #A21CAF; --red: #BE123C;
  --cyan: #0E7490; --slate: #64748B; --claude: #C2410C; --codex: #6D28D9;
  --term: #0E0F14; --term-ink: #D7DAE3;
  --shadow: 0 10px 30px rgba(0, 0, 0, .14);
  --rail-w: 9rem; --panel-w: 28rem;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #09090D; --panel: #121219; --panel-2: #1A1A23; --line: #2B2B37;
    --ink: #F5F7FA; --ink-2: #ADB2C2; --ink-3: #777C8B;
    --accent: #5EE7FF; --sel: #143744;
    --green: #4ADE80; --amber: #FBBF24; --magenta: #F0ABFC; --red: #FB7185;
    --cyan: #5EE7FF; --slate: #8B93A7; --claude: #FB923C; --codex: #A78BFA;
    --term: #050507; --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09090D; --panel: #121219; --panel-2: #1A1A23; --line: #2B2B37;
  --ink: #F5F7FA; --ink-2: #ADB2C2; --ink-3: #777C8B;
  --accent: #5EE7FF; --sel: #143744;
  --green: #4ADE80; --amber: #FBBF24; --magenta: #F0ABFC; --red: #FB7185;
  --cyan: #5EE7FF; --slate: #8B93A7; --claude: #FB923C; --codex: #A78BFA;
  --term: #050507; --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 1rem/1.4 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .9rem; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---- layout ---------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
.app.folded { --rail-w: 3.2rem; }
.main { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.content { flex: 1; overflow: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; }

/* ---- rail ------------------------------------------------------------------ */
.rail { background: var(--panel); border-right: 1px solid var(--line); padding: 10px 7px; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden auto; scrollbar-width: none; }
.rail .brand { display: flex; align-items: center; justify-content: space-between; padding: 0 7px 10px; }
.rail .brand a { font: 700 1.133rem var(--mono); color: var(--accent); }
.rail .fold { border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: 2px 4px; border-radius: 5px; }
.rail .fold:hover { background: var(--panel-2); }
.rail .item { display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 6px; color: var(--ink-2); text-decoration: none; white-space: nowrap; position: relative; }
.rail .item:hover { background: var(--panel-2); text-decoration: none; }
.rail .item.on { background: var(--sel); color: var(--ink); font-weight: 600; }
.rail .item svg { flex: none; width: 16px; height: 16px; }
.rail .item .lb { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.rail .item b { font-weight: 600; font-size: .867rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rail .item b.amber { color: var(--amber); }
.rail .item b.magenta { color: var(--magenta); }
.rail .grow { flex: 1; }
.dash { display: flex; flex-direction: column; gap: 7px; padding: 8px 7px 10px; margin: 0 -7px 4px; border-top: 1px solid var(--line); font-size: .8rem; font-variant-numeric: tabular-nums; }
.dash .dh { color: var(--ink-3); font-size: .733rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin: 2px 0 -3px; text-decoration: none; }
.dash a.dh:hover { color: var(--ink-2); }
.dash .dm { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dash .dl { display: flex; align-items: baseline; gap: 4px; color: var(--ink-2); white-space: nowrap; }
.dash .dl .lb { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.dash .dl .sh { display: none; }
.dash .dl b { font-weight: 600; color: var(--ink); }
.dash .dl b.brief, .folded .dash .dl b.full { display: none; }
.folded .dash .dl b.brief { display: inline; }
.dash .dm i { display: block; height: 5px; border-radius: 3px; background: var(--panel-2); position: relative; overflow: hidden; }
.dash .dm i s { position: absolute; top: 0; bottom: 0; left: 0; background: var(--meter-color, var(--green)); }
.dash small { color: var(--ink-3); font-size: .733rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash small.amber { color: var(--amber); }
.dash small.red { color: var(--red); }
.folded .dash { padding: 8px 3px 10px; gap: 6px; }
.folded .dash .dh, .folded .dash small, .folded .dash .dl .lb { display: none; }
.folded .dash .dl { flex-direction: column; align-items: center; gap: 0; font-size: .733rem; }
.folded .dash .dl .sh { display: block; color: var(--ink-3); }
.folded .rail .brand { justify-content: center; padding: 0 0 10px; }
.folded .rail .brand a { display: none; }
.folded .rail .item { justify-content: center; padding: 6px 0; }
.folded .rail .item .lb { display: none; }
.folded .rail .item b { position: absolute; top: 3px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); font-size: 0; }
.folded .rail .item b.zero { display: none; }
.folded .rail .item b.amber { background: var(--amber); }
.folded .rail .item b.magenta { background: var(--magenta); }

/* ---- top bar ---------------------------------------------------------------- */
.bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); min-height: 44px; flex-wrap: nowrap; container-type: inline-size; }
.bar > * { flex: none; }
.bar > .sp { flex: 1; }
.bar h1 { margin: 0; font-size: 1rem; font-weight: 650; white-space: nowrap; }
.bar .sp { flex: 1; }
.bar > .search { flex: 0 1 11rem; min-width: 6rem; }
.search { color: var(--ink-3); border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; background: var(--bg); cursor: pointer; text-align: left; display: flex; justify-content: space-between; gap: 12px; }
.search span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search kbd { font: .867rem var(--ui); color: var(--ink-3); }
.meters { display: flex; gap: 12px; align-items: center; }
.meter { white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); font-size: .867rem; font-variant-numeric: tabular-nums; }
.meter i { display: inline-block; width: 2.4rem; height: 5px; border-radius: 3px; background: var(--panel-2); position: relative; overflow: hidden; }
.meter i s { position: absolute; top: 0; bottom: 0; left: 0; background: var(--meter-color, var(--green)); }
.meter i s.q { background: var(--meter-color, var(--green)); opacity: 1; }
.meter.link { cursor: pointer; }
.offline { color: var(--amber); font-size: .867rem; font-weight: 600; white-space: nowrap; }
.stale-build { color: var(--accent); background: none; border: 1px solid var(--accent); border-radius: 999px; padding: 2px 10px; font-size: .867rem; font-weight: 600; white-space: nowrap; cursor: pointer; }

/* ---- controls --------------------------------------------------------------- */
.btn { border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; color: var(--ink); background: var(--panel); white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; text-decoration: none; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--panel); font-weight: 600; }
.btn.pri:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 1px 7px; font-size: .867rem; }
.btn.on { background: var(--sel); border-color: var(--sel); }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { border: 0; background: none; color: var(--accent); padding: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.icon-btn { border: 0; background: none; color: var(--ink-2); cursor: pointer; padding: 3px 6px; border-radius: 5px; line-height: 1; }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 3px 12px; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--sel); color: var(--ink); }
.inp { border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: var(--bg); width: 100%; }
textarea.inp { resize: vertical; font-size: .9rem; line-height: 1.4; }
select.inp { padding: 3px 6px; }
.inp:focus, .btn:focus-visible, .seg button:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; }

/* ---- status colours (memo table) ------------------------------------------- */
.green { color: var(--green); } .amber { color: var(--amber); } .magenta { color: var(--magenta); }
.red { color: var(--red); } .cyan { color: var(--cyan); } .slate { color: var(--slate); } .muted { color: var(--ink-3); }
.chip { display: inline-block; font-size: .8rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; border-radius: 999px; padding: 1px 7px; background: color-mix(in srgb, currentColor 14%, transparent); }
.ball { font-weight: 550; }
.ball::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: currentColor; vertical-align: 1px; }
.prov { font-size: .8rem; font-weight: 650; letter-spacing: .04em; }
.prov.claude { color: var(--claude); } .prov.codex { color: var(--codex); }
.tk { font: .867rem var(--mono); color: var(--ink-2); }
.sub { font-size: .867rem; color: var(--ink-3); }
.grp { font-size: .867rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin: 6px 0 -4px 2px; }
.empty { color: var(--ink-3); padding: 28px 0; text-align: center; }
.err { color: var(--red); font-size: .9rem; }

/* ---- ring ------------------------------------------------------------------ */
.ring { --size: 2.1rem; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 600; color: var(--ink-2); flex: none;
  background: radial-gradient(closest-side, var(--panel) 76%, transparent 78%), conic-gradient(var(--rc) calc(var(--p) * 1%), var(--panel-2) 0); font-variant-numeric: tabular-nums; }
.ring.none { background: radial-gradient(closest-side, var(--panel) 76%, transparent 78%), conic-gradient(var(--panel-2) 0 100%); color: var(--ink-3); }

/* ---- agents ---------------------------------------------------------------- */
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.sum { display: flex; gap: 16px; color: var(--ink-2); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.sum b { color: var(--ink); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(24rem, 100%), 1fr)); gap: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 6px 8px 9px; display: grid; grid-template-columns: 2.1rem minmax(0, 1fr) auto; gap: 1px 9px; align-items: center; cursor: pointer; text-align: left; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card.sel { background: var(--sel); border-color: var(--sel); }
.card.faded { opacity: .6; }
.card .ring { grid-row: span 3; }
.card .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .ln { grid-column: 2; font-size: .867rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .act { grid-column: 3; grid-row: 1 / span 3; align-self: center; }
.card.child { margin-left: 18px; }
/* Agent cards (1782 F): name and icons; provider, ticket, repo; Agent | Jobs; then You. */
.acard { border-left: 3px solid var(--edge, var(--line)); padding-left: 7px; }
.edge-magenta { --edge: var(--magenta); } .edge-cyan { --edge: var(--cyan); } .edge-amber { --edge: var(--amber); }
.edge-green { --edge: var(--green); } .edge-red { --edge: var(--red); } .edge-line { --edge: var(--line); }
.acard .ring { grid-row: 1 / span 3; }
.acard.tall .ring { grid-row: 1 / span 4; }
.acard .icons { grid-column: 3; grid-row: 1; display: flex; }
.acard .icons .icon-btn { padding: 1px 4px; }
.acard .ln { grid-column: 2 / -1; }
.acard .repo { color: var(--ink-3); }
/* The ticket title on its own line under the name (sm#1900), full card width at every size. */
.acard .ttl { grid-column: 2 / -1; font-size: .933rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.acard.titled .ring { grid-row: 1 / span 4; }
.acard.titled.tall .ring { grid-row: 1 / span 5; }
.card.kb { outline: 2px solid var(--accent); outline-offset: 1px; }
.acard.sel { border-left-color: var(--edge, var(--line)); }
.facts { grid-column: 2 / -1; display: grid; grid-template-columns: 7.2rem minmax(0, 1fr); gap: 0 8px; font-size: .867rem; min-width: 0; }
.fa { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.you { grid-column: 2 / -1; display: flex; align-items: center; gap: 4px; font-size: .867rem; min-width: 0; }
.you > .fa { flex: 1; }
.you .ok { color: inherit; font-weight: 700; padding: 0 6px; margin-left: auto; }
.you > .retire-action { margin-left: auto; }
.retire-action { position: relative; display: inline-flex; flex: none; }
.retire-confirm { position: absolute; z-index: 3; top: calc(100% + 4px); right: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); box-shadow: 0 4px 12px rgba(0, 0, 0, .18); width: max-content; max-width: min(240px, calc(100vw - 24px)); overflow-wrap: anywhere; }
.retire-confirm .btn { flex: none; }
.acts .retire-confirm { left: 0; right: auto; }
.acard-facts { display: flex; flex-direction: column; gap: 2px; }
.grp.sec.magenta { color: var(--magenta); } .grp.sec.cyan { color: var(--cyan); } .grp.sec.amber { color: var(--amber); }
.grp.sec.green { color: var(--green); }
.sum .dot { color: var(--ink-3); margin: 0 -8px; }
.sum .plain-btn.magenta { color: var(--magenta); } .sum .plain-btn.cyan { color: var(--cyan); }
.sum .plain-btn.amber { color: var(--amber); } .sum .plain-btn.green { color: var(--green); }
.sum .plain-btn:not(.muted) b { color: inherit; } .sum .plain-btn.muted { color: var(--ink-2); }
.fold-more { grid-column: 1 / -1; text-align: left; border: 1px dashed var(--line); background: none; border-radius: 8px; padding: 6px 10px; color: var(--ink-3); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fold-more:hover { color: var(--ink); border-color: var(--ink-3); }

/* ---- side panel ------------------------------------------------------------ */
.panel { width: var(--panel-w); border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.details-band { display: flex; flex-direction: column; grid-column: 1 / -1; min-width: 0; max-height: min(75vh, 50rem); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
.details-band .phd { grid-template-columns: minmax(0, 1fr) auto; }
.details-band .phd .ring, .details-band .phd .t { display: none; }
.details-band .phd .s { grid-column: 1; grid-row: 1; }
.details-band .phd .ctl { grid-column: 2; grid-row: 1; }
.details-band .pbody, .details-band .q-panel-body { overflow: visible; }
.details-band:has(> .acts) { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.details-band:has(> .acts) > .acts { grid-column: 1; grid-row: 1; border-bottom: 1px solid var(--line); }
.details-band:has(> .acts) > .phd { grid-column: 2; grid-row: 1; border-bottom: 1px solid var(--line); }
.details-band:has(> .acts) > :not(.acts):not(.phd) { grid-column: 1 / -1; }
.details-band:has(> .acts) .phd .s { text-align: right; }
.app.wide .panel { position: fixed; top: 0; bottom: 0; left: var(--rail-w); right: 0; width: auto; z-index: 20; }
.panel .grip { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 2; }
.panel .grip:hover, .panel .grip.drag { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.app.wide .panel .grip { display: none; }
.phd { padding: 10px 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 2.6rem minmax(0, 1fr) auto; gap: 1px 10px; align-items: center; }
.phd .ring { --size: 2.6rem; grid-row: span 2; font-size: .867rem; }
.phd .t { font-weight: 650; font-size: 1.067rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phd .s { font-size: .867rem; color: var(--ink-2); grid-column: 2; }
.phd .ctl { grid-column: 3; grid-row: 1 / span 2; display: flex; gap: 2px; align-self: start; }
.acts { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; position: relative; }
.tabs { display: flex; gap: 16px; padding: 7px 12px 0; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 0 0 6px; color: var(--ink-3); cursor: pointer; box-shadow: inset 0 -2px 0 transparent; }
.tabs button.on { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.pbody { flex: 1; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 12px; }
.pbody h3 { margin: 0 0 3px; font-size: .867rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.pbody ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.pbody li { font-size: .9rem; }
.pbody .quote { color: var(--ink-2); white-space: pre-wrap; }
.pbody .quote.last-turn { max-height: 16rem; overflow: auto; white-space: normal; overflow-wrap: anywhere; }
.last-turn > :first-child { margin-top: 0; } .last-turn > :last-child { margin-bottom: 0; }
.last-turn ul, .last-turn ol { padding-left: 1.2rem; margin: .3rem 0; } .last-turn p { margin: .3rem 0; }
.last-turn code { font-family: var(--mono); font-size: .92em; } .last-turn pre { overflow-x: auto; }
.you.note { color: var(--ink-2); }
.note-edit { display: flex; gap: 6px; align-items: center; }
.note-edit input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; color: var(--ink); }
.last-turn-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.plain-btn { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; text-align: left; }
.plain-btn:hover { color: var(--accent); }
.msgbox { margin: 0 12px 12px; display: flex; gap: 6px; align-items: flex-end; }
.msgbox textarea { flex: 1; min-height: 2.2rem; max-height: 10rem; }
.pempty { padding: 24px 12px; color: var(--ink-3); }
.tool { display: flex; gap: 10px; font-size: .9rem; }
.tool .when { color: var(--ink-3); font-variant-numeric: tabular-nums; width: 4.5rem; flex: none; }
.summary { white-space: pre-wrap; font-size: .9rem; line-height: 1.5; }

/* ---- popovers, menus, confirm ------------------------------------------------ */
.pop { position: absolute; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 9px; width: min(26rem, calc(100vw - 24px)); }
.pop.menu { padding: 4px; width: auto; min-width: 12rem; gap: 0; }
.pop.menu button { border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.pop.menu button:hover { background: var(--panel-2); }
.pop h2 { margin: 0; font-size: 1rem; font-weight: 650; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pop .line { font-size: .9rem; color: var(--ink-2); display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.pop .line span { overflow: hidden; text-overflow: ellipsis; }
.pop > .seg { align-self: flex-start; }
.pop .row { display: flex; justify-content: flex-end; gap: 6px; }
.fld { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: 8px; align-items: center; }
.fld > .l { color: var(--ink-3); font-size: .867rem; }
.fld.top { align-items: start; }
.confirm { display: flex; gap: 8px; align-items: center; font-size: .9rem; flex-wrap: wrap; }
.check { display: flex; gap: 6px; align-items: center; }
.toggle { width: 34px; height: 20px; padding: 2px; border-radius: 999px; border: 0; background: var(--ink-3); cursor: pointer; flex: none; display: flex; align-items: center; }
.toggle::before { content: ''; width: 16px; height: 16px; border-radius: 50%; background: var(--panel); transition: transform .15s; }
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::before { transform: translateX(14px); }
.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle:disabled { opacity: .5; cursor: default; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.links { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.details-band > .links, .panel > .links { padding: 7px 12px; border-bottom: 1px solid var(--line); }
.link-pair { display: inline-flex; gap: 2px; }
.link-chip { color: var(--ink-2); background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; cursor: pointer; font-size: .867rem; }
.link-chip:hover { color: var(--accent); }
.link-chip.magenta { color: var(--magenta); }.link-chip.amber { color: var(--amber); }.link-chip.red { color: var(--red); }.link-chip.green { color: var(--green); }
.anchor { position: relative; display: inline-flex; }

/* ---- palette ---------------------------------------------------------------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .25); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.palette { width: min(36rem, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; background: none; font-size: 1.067rem; outline: none; }
.palette ul { list-style: none; margin: 0; padding: 4px; max-height: 50vh; overflow: auto; }
.palette li { padding: 6px 10px; border-radius: 6px; display: flex; gap: 10px; align-items: baseline; cursor: pointer; }
.palette li.on { background: var(--sel); }
.palette li .k { font-size: .8rem; color: var(--ink-3); width: 3.6rem; flex: none; text-transform: uppercase; letter-spacing: .05em; }
.palette li .d { color: var(--ink-3); font-size: .9rem; margin-left: auto; white-space: nowrap; }

/* ---- toasts ----------------------------------------------------------------- */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: 7px 14px; border-radius: 8px; box-shadow: var(--shadow); cursor: pointer; border: 0; font-size: .9rem; }
div.toast { cursor: default; display: flex; align-items: center; gap: 12px; }
.toast-action { background: none; border: 0; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 0; }

/* ---- placeholder and terminal pages ------------------------------------------- */
.stub { max-width: 34rem; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px; }
.stub h2 { margin: 0; font-size: 1.2rem; color: var(--ink); }
.term-page { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--term); color: var(--term-ink); z-index: 30; }
.term-bar { position: relative; z-index: 32; height: 40px; flex: 0 0 40px; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel); color: var(--ink); border-bottom: 1px solid var(--line); }
.term-bar .t { font-weight: 650; }
.term-home { font: 700 1.133rem var(--mono); color: var(--accent); text-decoration: none; }
.term-main { flex: 1; min-height: 0; position: relative; display: grid; grid-template-columns: minmax(0, 1fr); }
.term-main.with-switch { grid-template-columns: 15.5rem minmax(0, 1fr); }
.term-body { min-height: 0; min-width: 0; overflow: hidden; padding: 4px; }
.term-switch-wrap { min-height: 0; overflow-y: auto; background: var(--panel); color: var(--ink); border-right: 1px solid var(--line); }
.term-switch { display: flex; flex-direction: column; padding: 4px 0 12px; }
.sw-sec { font: 600 .8rem var(--ui); letter-spacing: .06em; text-transform: uppercase; padding: 10px 12px 3px; text-align: left; border: 0; background: none; color: var(--ink-3); }
.sw-sec.magenta { color: var(--magenta); } .sw-sec.cyan { color: var(--cyan); } .sw-sec.amber { color: var(--amber); } .sw-sec.green { color: var(--green); }
button.sw-sec { cursor: pointer; }
.sw-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; column-gap: 8px; align-items: center; padding: 4px 8px 5px 12px; cursor: pointer; }
.sw-row:hover { background: var(--panel-2); }
.sw-row.cur { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.sw-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sw-dot.muted { background: var(--line); }
.sw-nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-row .ok { font-weight: 700; padding: 0 6px; }
.sw-fact { grid-column: 2 / 4; font-size: .867rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-fact.muted { color: var(--ink-2); }
.term-route { white-space: nowrap; font-size: .9rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.term-bar .icon-btn.on { color: var(--accent); }
.term-bar .t { max-width: 20vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-keys { display: flex; gap: 4px; white-space: nowrap; }
.term-connection { white-space: nowrap; font-size: .9rem; }
.term-bar .retire-confirm { position: fixed; top: 44px; right: 12px; z-index: 32; white-space: normal; overflow-wrap: anywhere; }
.term-bar .retire-confirm .btn { flex: none; }
.term-notice { position: absolute; bottom: 16px; left: 12px; right: 12px; padding: 10px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.term-panel { position: fixed; top: 40px; right: 0; bottom: 0; z-index: 31; width: 28rem; max-width: 100vw; }
@media (max-width: 900px) {
  .term-bar { overflow-x: auto; gap: 6px; padding: 0 6px; }
  .term-bar > * { flex-shrink: 0; }
  .term-bar .t { max-width: 6.667rem; }
  .term-state { display: none; }
}
/* Below 900 px the switcher covers the terminal instead of squeezing it. */
@media (max-width: 899.98px) {
  .term-main.with-switch { grid-template-columns: minmax(0, 1fr); }
  .term-switch-wrap { position: absolute; top: 0; bottom: 0; left: 0; z-index: 2; width: min(15.5rem, 85vw); box-shadow: var(--shadow); }
}
@media (max-width: 720px) {
  .term-page .term-panel { top: 40px; bottom: 0; left: 0; right: 0; width: 100vw; z-index: 31; }
}
@media (max-width: 600px) { .term-panel { width: 100vw; } }

/* Notes page and the same view in the right pane. */
.notes-content { padding: 0; min-height: 0; }
.notes-view { min-height: 0; min-width: 0; height: 100%; display: flex; flex-direction: column; color: var(--ink); background: var(--bg); }
.notes-pane { width: 100%; background: var(--panel); }
.notes-head { padding: 14px 16px 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.notes-head h1 { margin: 0; font-size: 1.25rem; flex: 1; }
.notes-tools { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.notes-tools input[type=search] { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 6px 9px; min-width: 10rem; flex: 1; }
.notes-count { padding: 0 16px 9px; color: var(--ink-3); font-size: .8rem; }
.notes-columns { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr); border-top: 1px solid var(--line); }
.notes-list { overflow: auto; min-width: 0; padding: 10px; border-right: 1px solid var(--line); }
.note-card { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; margin-bottom: 9px; position: relative; }
.note-card.selected { border-color: var(--accent); }
.note-card-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; width: 100%; padding: 10px; text-align: left; border: 0; background: transparent; cursor: pointer; }
.note-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-main small { color: var(--ink-3); }
.note-snippet { grid-column: 1 / -1; color: var(--ink-2); font: .8rem/1.35 var(--mono); white-space: pre-wrap; overflow: hidden; max-height: 5.5em; overflow-wrap: anywhere; }
.note-snippet mark { color: var(--ink); background: color-mix(in srgb, var(--amber) 35%, transparent); }
.notes-actions { display: flex; gap: 3px; flex-wrap: wrap; padding: 0 8px 8px; }
.notes-actions > button, .notes-action-wrap > button { border: 0; background: transparent; color: var(--accent); cursor: pointer; border-radius: 4px; padding: 3px 5px; font-size: .75rem; }
.notes-actions button:hover { background: var(--sel); }
.notes-action-wrap { position: relative; }
.notes-popover { position: fixed; z-index: 35; width: min(19rem, 75vw); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.notes-popover strong { font-size: .85rem; overflow-wrap: anywhere; }
.notes-popover label { display: flex; flex-direction: column; font-size: .8rem; color: var(--ink-2); gap: 3px; }
.notes-popover input, .notes-popover select { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); padding: 5px; color: var(--ink); }
.notes-editor-slot { min-width: 0; min-height: 0; display: flex; }
.notes-editor { min-width: 0; min-height: 0; display: flex; flex-direction: column; flex: 1; background: var(--panel); }
.notes-editor-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.notes-editor-bar strong { flex: 1; min-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-status { color: var(--ink-3); font-size: .8rem; }
.notes-editor textarea { flex: 1; width: 100%; min-height: 16rem; resize: none; border: 0; outline: 0; padding: 14px; color: var(--ink); background: var(--panel); font: 1rem/1.5 var(--mono); tab-size: 2; }
.notes-editor > .notes-actions { padding: 8px 12px; border-top: 1px solid var(--line); }
.notes-history { max-height: 9rem; overflow: auto; padding: 7px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.notes-history button { text-align: left; border: 0; background: none; padding: 5px; color: var(--accent); cursor: pointer; }
.notes-preview { flex: 1; overflow: auto; padding: 12px 16px; overflow-wrap: anywhere; }
.notes-empty { color: var(--ink-3); padding: 16px; }
.notes-dialog-backdrop { position: fixed; inset: 0; z-index: 80; background: #0008; display: grid; place-items: center; }
.notes-dialog { width: min(25rem, calc(100vw - 24px)); background: var(--panel); color: var(--ink); padding: 20px; border-radius: 10px; box-shadow: var(--shadow); }
.notes-dialog h2 { margin: 0; font-size: 1.1rem; }
.notes-dialog p { color: var(--ink-2); }
.notes-dialog button { margin-right: 7px; }
.notes-pane .notes-head { padding: 10px; }
.notes-pane .notes-tools { width: 100%; }
.notes-pane .notes-tools input[type=search] { min-width: 7rem; }
.notes-pane .notes-columns { display: block; overflow: auto; }
.notes-pane .notes-list { overflow: visible; border-right: 0; }
.notes-pane .note-card .notes-editor { border-top: 1px solid var(--line); }
.notes-pane .notes-editor textarea { height: 24em; min-height: 16em; flex: none; }
.term-panel .notes-view { height: 100%; }
@media (max-width: 899.98px) {
  .notes-page .notes-columns { display: block; overflow: auto; }
  .notes-page .notes-list { overflow: visible; border-right: 0; }
  .notes-page .notes-editor-slot { display: none; }
  .notes-page .note-card.selected .notes-editor { display: flex; border-top: 1px solid var(--line); }
  .notes-page .notes-editor textarea { height: 24em; min-height: 16em; flex: none; }
}

/* ---- narrow screens (D9: 390 px) -------------------------------------------- */
@media (max-width: 720px) {
  .app, .app.folded { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; --rail-w: 0px; }
  .main { grid-row: 1; grid-column: 1; }
  .rail { grid-row: 2; grid-column: 1; flex-direction: row; justify-content: space-around; padding: 4px; border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .rail .brand, .rail .grow, .rail .dash { display: none; }
  .rail .item { flex-direction: column; gap: 1px; padding: 4px 6px; font-size: .8rem; }
  .rail .item .lb { display: block; }
  .rail .item b { position: absolute; top: 1px; right: 3px; }
  .rail .item.minor { display: none; }
  .bar { padding: 6px 12px; gap: 8px; }
  .bar .meters, .search kbd { display: none; }
  .bar > .search { min-width: 0; }
  .content { padding: 10px 12px 20px; }
  .panel, .app.wide .panel { position: fixed; inset: 0; width: auto; z-index: 25; border-left: 0; }
  .panel .grip { display: none; }
  .details-band:has(> .acts) { grid-template-columns: minmax(0, 1fr); }
  .details-band:has(> .acts) > .phd { grid-column: 1; grid-row: 1; }
  .details-band:has(> .acts) > .acts { grid-column: 1; grid-row: 2; }
}
/* The top bar sheds GPU, CPU, then Memory as its content area narrows. */
@container (max-width: 560px) { .bar .meters { display: none; } }

/* Settings: section menu and compact, labelled forms; no fixed field widths. */
.settings-page { flex-direction: row; gap: 28px; align-items: flex-start; }
.settings-nav { flex: 0 0 10rem; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; }
.settings-nav a { padding: 7px 10px; border-radius: 6px; color: var(--ink-2); text-decoration: none; }
.settings-nav a.on { background: var(--panel-2); color: var(--ink); font-weight: 600; }
.settings-body { width: 100%; max-width: 46rem; min-width: 0; padding-bottom: 28px; }
.settings-body h2 { font-size: 1.2rem; margin: 0 0 14px; }
.settings-body h3 { font-size: 1rem; margin: 22px 0 12px; }
.settings-body > .sub { margin-bottom: 18px; }
.settings-field { margin: 0 0 12px; min-width: 0; }
.settings-field label { display: flex; flex-direction: column; gap: 6px; }
.settings-field label:has(.toggle) { flex-direction: row; align-items: center; justify-content: space-between; }
.text-size-setting { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.text-size-setting input { flex: 1; min-width: 10rem; accent-color: var(--accent); }
.settings-field .sub { font-size: .867rem; margin: 5px 0; overflow-wrap: anywhere; }
.settings-feedback { display: flex; gap: 8px; align-items: center; min-height: 19px; margin-top: 4px; font-size: .867rem; }
.saved { color: var(--green); }
.settings-error { color: var(--red); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.settings-preview { background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 12px; margin: 0 0 20px; }
.settings-preview .sub, .settings-preview code { display: block; }
.settings-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; margin-bottom: 0; }
.settings-device { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.settings-about { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; }
.settings-about dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .settings-page { flex-direction: column; gap: 20px; }
  .settings-nav { flex: none; flex-direction: row; flex-wrap: wrap; position: static; gap: 2px; }
  .settings-nav a { padding: 6px 8px; font-size: .9rem; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* Board: server-owned ticket clocks and lane order (1710 D6.4). */
.board-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.board-toolbar > .sub { margin-right: auto; }
.board-lane { flex-shrink: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.lane-header { display: flex; gap: 12px; padding: 12px; align-items: center; flex-wrap: wrap; }
.lane-rank { color: var(--ink-3); font: 600 1.333rem var(--mono); }
.lane-heading { flex: 1; min-width: 12rem; }
.ticket-title { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: var(--ink); overflow-wrap: anywhere; }
.ticket-title:hover { color: var(--accent); }
.lane-heading > .ticket-title { font-weight: 600; }
.lane-progress { height: 4px; background: var(--panel-2); display: flex; margin: 6px 0 3px; border-radius: 3px; overflow: hidden; max-width: 22rem; }
.lane-progress .done { background: var(--green); }
.lane-progress .in-progress { background: var(--accent); }
.lane-actions { display: flex; gap: 3px; align-items: center; }
.lane-actions button:disabled { opacity: .4; cursor: default; }
.critical-path { color: var(--ink-3); font-size: .867rem; padding: 0 12px 10px; }
.board-ticket { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.board-ticket.compact { flex: 1 1 20rem; border-top: 0; padding: 0; }
.board-ticket > .links, .board-ticket > .ticket-state { grid-column: 1 / -1; }
.board-ticket .links { min-width: 0; }
.ticket-actions { display: flex; align-items: center; gap: 4px; }
.ticket-state.cyan { color: var(--cyan); }
.other-tickets > h2 { margin: 0; padding: 10px 14px; font-size: .933rem; color: var(--ink-2); }
.ticket-clock { grid-column: 1 / -1; border: 0; padding: 0; background: none; text-align: left; cursor: pointer; display: grid; grid-template-columns: minmax(8rem, 30%) minmax(0, 1fr); gap: 12px; align-items: center; font-size: .9rem; }
.clock-strip { height: 9px; background: var(--panel-2); position: relative; overflow: hidden; border-radius: 2px; }
.clock-segment { position: absolute; height: 100%; background: var(--ink-3); }
.clock-segment.working, .clock-segment.job_running { background: var(--green); }
.clock-segment.job_running { background: repeating-linear-gradient(120deg, var(--green) 0 3px, color-mix(in srgb, var(--green) 40%, var(--panel)) 3px 5px); }
.clock-segment.queue, .clock-segment.review { background: var(--amber); }
.clock-segment.you { background: var(--magenta); }
.clock-segment.quiet, .clock-segment.stalled, .clock-segment.no_agent, .clock-segment.job_quiet { background: var(--red); }
.lane-folds { border-top: 1px solid var(--line); }
.board-fold summary, .other-tickets > summary { padding: 8px 14px; cursor: pointer; color: var(--ink-2); font-size: .9rem; overflow-wrap: anywhere; }
.lane-confirm { padding: 10px 14px; display: flex; gap: 8px; flex-wrap: wrap; background: var(--panel-2); }
.board-lane > .err { margin: 8px 14px; }
.clock-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .867rem; padding: 4px; }
.board-start-overlay { position: fixed; inset: 0; background: #0004; z-index: 39; display: grid; place-items: center; }
.board-start-overlay .pop.ticket-start { position: relative; left: auto !important; top: auto !important; transform: none !important; max-height: calc(100dvh - 32px); overflow: auto; }
.ticket-start .sub { margin: 0; }
.ticket-start .fld .mono { overflow-wrap: anywhere; }
/* Report a bug (1859 B4). */
.bug-report .bug-shot { align-items: center; }
.bug-report .bug-shot > span { flex: 1; }
.bug-report .bug-shot img { width: 6rem; height: 4rem; object-fit: cover; object-position: top left; border: 1px solid var(--line); border-radius: 4px; flex: none; }
.bug-report .line { align-items: center; }
.bug-btn { font-size: 1rem; }
/* Start when ready (1821 F4). */
.when-ready-chip { border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); border-radius: 999px; padding: 2px 10px; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.when-ready-chip.amber { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 50%, var(--line)); }
.when-ready-chip.muted { color: var(--ink-3); }
.when-ready-link { font-size: .867rem; white-space: nowrap; }
.ticket-start .seg { flex-wrap: wrap; }
.board-start-overlay .pop.lane-when-ready { width: min(46rem, calc(100vw - 24px)); }
.lwr-table { display: flex; flex-direction: column; }
.lwr-row { display: grid; grid-template-columns: minmax(0, 1fr) 15rem 6.5rem; gap: 6px 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.lwr-head { font-size: .8rem; color: var(--ink-3); border-top: 0; padding-top: 0; }
.lwr-ticket { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.lwr-row select { width: 100%; }
.lwr-message { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.lwr-message textarea { width: 100%; }
.agent-types { display: flex; flex-direction: column; gap: 6px; margin: 0 0 8px; }
.agent-type { display: grid; grid-template-columns: 7rem 7rem minmax(0, 1fr) 6rem auto; gap: 6px; align-items: center; }
.agent-type.head { font-size: .8rem; color: var(--ink-3); }
.agent-types + .settings-feedback { margin-bottom: 16px; }
.brief-preview { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel-2); padding: 8px; margin: 0; max-height: 14rem; overflow: auto; font: .9rem/1.5 var(--mono); }
@media (max-width: 600px) {
  .ticket-clock { grid-template-columns: 1fr; gap: 5px; }
  .lane-heading { min-width: 0; flex-basis: calc(100% - 40px); }
  .lane-actions { margin-left: auto; }
  .board-toolbar > .sub { width: 100%; }
  .ticket-start .fld { grid-template-columns: 1fr; gap: 3px; }
  .ticket-start .seg button { padding: 3px 8px; }
  .board-ticket:has(.when-ready-chip, .when-ready-link) .ticket-actions { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; }
  .lwr-row { grid-template-columns: minmax(0, 1fr) auto; }
  .lwr-row .lwr-ticket { grid-column: 1 / -1; }
  .lwr-head { display: none; }
  .agent-type { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .agent-type.head { display: none; }
  .agent-type > :nth-child(3) { grid-row: 2; grid-column: 1; }
  .agent-type > :nth-child(4) { grid-row: 2; grid-column: 2; }
  .agent-type > :nth-child(5) { grid-row: 1; grid-column: 3; }
  .agent-type { padding-bottom: 6px; border-bottom: 1px solid var(--line); }
}

/* Inbox, document reader, History and Guestbook (1710 D6.7–8). */
.inbox-layout { flex:1; min-height:0; display:grid; grid-template-columns:17rem minmax(0,1fr); }
.inbox-list { overflow:auto; border-right:1px solid var(--line); background:var(--panel); }
.inbox-filters { padding:12px; position:sticky; top:0; background:var(--panel); z-index:1; }
.inbox-list h2 { font-size:.867rem; text-transform:uppercase; padding:4px 14px; color:var(--ink-3); }
.inbox-list h2.magenta { color:var(--magenta); }
.inbox-row { display:flex; flex-direction:column; gap:5px; text-align:left; width:100%; border:0; border-bottom:1px solid var(--line); background:transparent; padding:12px 14px; cursor:pointer; }
.inbox-row:hover,.inbox-row.selected { background:var(--sel); }
.inbox-row span,.inbox-row small { color:var(--ink-2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; width:100%; }
.inbox-row strong { overflow-wrap:anywhere; }
.inbox-entry { position:relative; border-bottom:1px solid var(--line); }
.inbox-entry .inbox-row { border-bottom:0; padding-right:82px; }
.inbox-entry-action { position:absolute; right:10px; bottom:10px; border:0; background:transparent; color:var(--ink-2); font-size:.8rem; cursor:pointer; }
.inbox-entry-action:hover { color:var(--ink); text-decoration:underline; }
.inbox-fold { border-top:1px solid var(--line); margin-top:12px; }
.inbox-fold-toggle { width:100%; text-align:left; border:0; background:transparent; color:var(--ink-2); padding:12px 14px; cursor:pointer; font-size:.84rem; }
.inbox-fold-toggle:hover { background:var(--sel); }
.inbox-reader,.doc-reader,.thread-reader { display:flex; flex-direction:column; flex:1; min-height:0; min-width:0; }
.inbox-actions,.reader-bar { display:flex; gap:8px; align-items:center; padding:8px 12px; border-bottom:1px solid var(--line); background:var(--panel); flex-wrap:wrap; }
.inbox-actions span,.reader-title { flex:1; min-width:2.667rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.panel:has(.doc-reader.ask-open) { width:min(70vw, calc(var(--panel-w) + 17rem)); }
@media (max-width: 720px) {
  .panel:has(.doc-reader.ask-open) { width:100vw; }
  .doc-reader.ask-open iframe { display:none; }
  .doc-reader.ask-open .doc-ask { width:100%; }
}
.doc-reader-body { display:flex; flex:1; min-height:0; min-width:0; }
.doc-reader iframe { flex:1; width:100%; border:0; min-height:0; min-width:0; background:var(--panel); }
.doc-ask { width:17rem; flex:none; display:flex; flex-direction:column; min-height:0; border-left:1px solid var(--line); }
.doc-ask-head,.doc-ask-actions { display:flex; align-items:center; justify-content:space-between; gap:6px; }
.doc-ask-head { padding:8px; border-bottom:1px solid var(--line); }
.doc-ask-items { flex:1; overflow:auto; padding:8px; font-size:.8rem; }
.doc-ask-item { margin-bottom:8px; overflow-wrap:anywhere; }
.doc-ask-item .b { padding:8px; border-radius:8px; background:var(--panel-2); }
.doc-ask-item .ev { color:var(--ink-3); font-size:.72rem; }
.doc-ask-item .m { color:var(--ink-3); font-size:.7rem; }
.doc-ask-compose { display:flex; flex-direction:column; gap:7px; padding:8px; border-top:1px solid var(--line); }
.doc-ask-compose select,.doc-ask-compose textarea { width:100%; background:var(--panel); color:var(--ink); border:1px solid var(--line); border-radius:6px; padding:6px; }
.doc-ask-compose blockquote { margin:0; padding:6px; border-left:3px solid var(--accent); white-space:pre-wrap; max-height:6rem; overflow:auto; }
.doc-ask-compose blockquote button { float:right; }
.doc-ask-actions [role=alert] { color:var(--red); overflow-wrap:anywhere; }
.reader-bar select { max-width:6.667rem; background:var(--panel); border:1px solid var(--line); }
.reader-print { display:inline-flex; }
.reader-print button + button { border-top-left-radius:0; border-bottom-left-radius:0; border-left:1px solid var(--line); }
.reader-print button:first-child:not(:last-child) { border-top-right-radius:0; border-bottom-right-radius:0; }
.ticket-reader { display:flex; flex-direction:column; flex:1; min-height:0; min-width:0; }
.ticket-reader > .seg { margin:8px 12px; align-self:flex-start; }
.ticket-reader-content { flex:1; overflow:auto; padding:12px 18px; overflow-wrap:anywhere; }
.ticket-reader-content h3 { margin:18px 0 8px; }
.ticket-reader-content .ticket-markdown pre,.ticket-reader-content .ticket-markdown table { display:block; max-width:100%; overflow:auto; }
.ticket-reader-content .ticket-markdown img { max-width:100%; height:auto; }
.ticket-labels { display:flex; gap:6px; flex-wrap:wrap; }
.ticket-comment { border-top:1px solid var(--line); padding:12px 0; }
.thread-items { flex:1; overflow:auto; padding:18px; }
.thread-items .b { border:1px solid var(--line); background:var(--panel); border-radius:10px; padding:12px; margin:10px 0; max-width:90%; overflow-wrap:anywhere; }
.thread-items .me { margin-left:auto; background:var(--sel); white-space:pre-wrap; }
.thread-items .ask { border-color:var(--magenta); }
.thread-items .turn { border-left:3px solid var(--cyan); }
.thread-items .turn .lbl { color:var(--cyan); font-size:.9rem; margin-bottom:6px; }
.thread-entry { margin:10px 0; }
.thread-entry .b { margin:2px 0; }
.thread-entry:has(.me) { display:flex; flex-direction:column; align-items:flex-end; }
.thread-sender { display:block; color:var(--ink-2); font-size:.8rem; margin:0 0 4px 3px; }
.thread-doc-card { display:flex; flex-direction:column; gap:5px; margin:12px 0; padding:12px; border:1px solid var(--line); border-left:3px solid var(--cyan); border-radius:8px; background:var(--panel); max-width:90%; overflow-wrap:anywhere; }
.thread-doc-card small { color:var(--ink-2); }
.thread-doc-actions { display:flex; gap:7px; margin-top:3px; }
.thread-target { display:flex; gap:8px; align-items:center; margin-bottom:8px; color:var(--ink-2); font-size:.83rem; }
.thread-target select { background:var(--bg); color:var(--ink); border:1px solid var(--line); border-radius:6px; padding:4px 7px; max-width:70%; }
.thread-reply-hint { color:var(--ink-2); font-size:.83rem; margin:0 0 8px; }
.inbox-list h2.cyan { color:var(--cyan); }
.thread-items .thread-highlight { background:color-mix(in srgb, var(--magenta) 18%, var(--panel)); box-shadow:0 0 0 2px var(--magenta); }
.thread-items .m,.thread-items .ev { color:var(--ink-3); font-size:.9rem; }
.thread-items .ev { text-align:center; margin:12px; }
.thread-items img { max-width:100%; }
.thread-items pre { overflow:auto; }
.thread-items [data-sm-line] { cursor:pointer; }
.thread-items [data-sm-line]:hover { background:var(--sel); }
.thread-compose { padding:12px; border-top:1px solid var(--line); background:var(--panel); max-height:45%; overflow:auto; }
.thread-compose textarea { display:block; width:100%; min-height:70px; resize:vertical; background:var(--bg); border:1px solid var(--line); border-radius:6px; padding:8px; margin-bottom:8px; }
.thread-compose blockquote { border-left:3px solid var(--magenta); padding:4px 8px; margin:4px 0; display:flex; justify-content:space-between; }
.history-page > * { flex-shrink:0; }
.history-card { min-width:0; overflow-wrap:anywhere; border:1px solid var(--line); background:var(--panel); border-radius:8px; padding:14px; }
.history-heading,.work-links,.list-pagination { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.history-heading span,.history-card small,.history-meta { color:var(--ink-2); }
.history-top { display:flex; gap:12px; flex-wrap:wrap; align-items:center; justify-content:space-between; }
.history-top h2 { margin:0; font-size:1.2rem; }
.history-agent { display:flex; flex-direction:column; gap:6px; }
.history-agent .history-name { color:var(--ink); font-weight:700; }
.history-agent .history-name:hover { color:var(--accent); }
.history-restore { margin-left:auto; }
.history-last-turn { margin:0; color:var(--ink-2); display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; overflow:hidden; }
.history-meta { margin:6px 0; }
.history-card > .links { margin-top:2px; }
.thread-links { padding:7px 12px; border-bottom:1px solid var(--line); }
.handoff-pop .handoff-at { display:flex; gap:6px; align-items:center; flex-wrap:wrap; color:var(--ink-2); font-size:.9rem; }
.handoff-pop .handoff-at b { color:var(--ink); }
.handoff-pop .handoff-at input { width:5rem; }
.pop-rule { border:0; border-top:1px solid var(--line); margin:2px 0; width:100%; }
.handoff-provider { border-top:1px solid var(--line); padding-top:4px; margin-bottom:8px; }
.handoff-provider h3 { margin-top:12px !important; }
.about-title { display:flex; gap:10px; align-items:baseline; }
.about-mark { color:var(--accent); font:700 1.4rem var(--mono); }
.about-rows { display:flex; flex-direction:column; border:1px solid var(--line); border-radius:8px; background:var(--panel); }
.about-row { display:grid; grid-template-columns:10px 8rem minmax(0,1fr); gap:10px; align-items:baseline; padding:10px 14px; border-top:1px solid var(--line); overflow-wrap:anywhere; }
.about-row:first-child { border-top:0; }
.about-label { color:var(--ink-2); }
.about-dot { width:9px; height:9px; border-radius:50%; background:var(--slate); align-self:center; }
.about-dot.green { background:var(--green); } .about-dot.red { background:var(--red); } .about-dot.accent { background:var(--accent); }
.text-button { padding:0; color:var(--accent); border:0; background:none; cursor:pointer; font-weight:600; text-align:left; }
.work-links { margin-top:8px; }
.work-links .btn { max-width:100%; white-space:normal; overflow-wrap:anywhere; text-align:left; }
.guestbook-text { white-space:pre-wrap; }
.guestbook-markdown pre,.guestbook-markdown table { display:block; max-width:100%; overflow:auto; }
.list-filter input { background:var(--panel); border:1px solid var(--line); border-radius:6px; padding:6px 10px; margin-left:8px; max-width:60%; }
@media(max-width:600px) {
  .inbox-layout { display:flex; }
  .inbox-list { width:100%; }
  .inbox-reader { display:none; }
  .inbox-layout.reading .inbox-list { display:none; }
  .inbox-layout.reading .inbox-reader { display:flex; }
  .reader-bar { gap:5px; padding:6px; }
  .reader-title { flex-basis:80px; }
  .about-row { grid-template-columns:10px minmax(0,1fr); }
  .about-value { grid-column:2; }
}
/* Reviews (1768 I3) */
.review-pill { border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); border-radius: 999px; padding: 2px 10px; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.review-pill b { color: var(--ink); font-weight: 600; }
.ticket-review { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.review-editor { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.review-editor > .seg { align-self: flex-start; flex-wrap: wrap; }
.review-editor .sub { margin: 0; }
.review-pickers { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
.review-pickers label { display: flex; flex-direction: column; gap: 3px; }
.review-policy-pop { width: min(30rem, calc(100vw - 32px)); }
.review-banner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 12px; margin: 0 0 18px; border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line)); border-radius: 8px; background: color-mix(in srgb, var(--amber) 8%, var(--panel)); }
.review-banner > span:nth-child(2) { flex: 1 1 16rem; }
.restart-members { flex: 1 1 100%; display: grid; gap: 4px; }
.restart-members > div { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.review-policy-row { display: grid; grid-template-columns: 11rem minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.review-policy-row > span { overflow-wrap: anywhere; }
.review-day p { margin: 6px 0; }
.review-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--panel-2); }
.review-ask { margin: 8px 12px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--magenta) 45%, var(--line)); border-radius: 8px; display: flex; flex-direction: column; gap: 8px; }
.review-ask .row { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 700px) {
  .review-policy-row { grid-template-columns: 1fr auto; }
  .review-policy-row > span:first-child { grid-column: 1 / -1; }
}
/* V3 board: each operational fact has its own column, wrapping on phones. */
.board-content { gap:18px; }
.board-filterbar,.board-presetbar,.board-selectionbar { display:flex;align-items:center;gap:12px;flex-wrap:wrap; }
.board-filterbar .inp { margin-left:auto;max-width:22rem; }
.board-presetbar { padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--panel); }
.launch-presets { display:flex;gap:8px;flex-wrap:wrap; }
.preset { background:var(--panel-2);border:1px solid var(--line);border-radius:6px;padding:8px 12px;color:var(--ink);text-align:left;cursor:pointer;display:flex;flex-direction:column;gap:3px; }
.preset:hover { border-color:var(--accent); }
.preset.on { border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent); }
.preset span { color:var(--ink-2);font-size:.8rem;overflow-wrap:anywhere; }
.board-ticket { grid-template-columns:minmax(0,2.5fr) minmax(0,1fr) minmax(0,1.35fr) minmax(0,1.25fr);gap:16px;padding:16px;align-items:start; }
.board-ticket > div { min-width:0;display:flex;flex-direction:column;gap:6px;overflow-wrap:anywhere; }
.ticket-title-line { display:flex;gap:9px;align-items:flex-start; }
.ticket-title-line input { flex:none;margin-top:4px; }
.ticket-title-line .ticket-title { font-weight:600;line-height:1.5; }
.ticket-state-label { font-size:.78rem;text-transform:capitalize;color:var(--ink-2); }
.ticket-direct-links,.ticket-agent-links { display:flex;gap:8px;flex-wrap:wrap;align-items:center;font-size:.83rem; }
.board-column-label { color:var(--ink-3);font-size:.73rem; }
.board-ticket .ticket-actions { flex-wrap:wrap; }
.board-job { display:flex;flex-direction:column;gap:3px;align-items:flex-start;border:0;background:none;padding:0;text-align:left;font-size:.83rem;cursor:pointer;overflow-wrap:anywhere; }
.board-review { font-size:.83rem;display:flex;flex-direction:column;gap:3px; }
.board-time { font-size:.78rem;color:var(--ink-3); }
.board-time summary,.critical-path summary { cursor:pointer; }
.board-time .ticket-clock { display:flex;flex-direction:column;align-items:stretch;margin:8px 0; }
.board-time .clock-strip { width:100%; }
.board-launch .when-ready-chip { white-space:normal;text-align:left; }
.launch-exact { font-size:.78rem; }
.board-launch .review-pill { text-align:left;white-space:normal; }
.shared-launch.pop { width:min(52rem,calc(100vw - 24px)); }
.shared-launch fieldset { border:0;padding:0;margin:0;min-width:0; }
.launch-config-grid { display:grid;grid-template-columns:1fr 1.5fr 1fr;gap:10px; }
.launch-config-grid .fld { display:flex;flex-direction:column;align-items:stretch;gap:5px; }
.launch-exception { border-top:1px solid var(--line);padding:12px 0; }
.launch-exception summary { cursor:pointer;overflow-wrap:anywhere; }
.launch-exception summary .sub { display:block;margin-top:4px; }
.launch-preview { border:1px solid var(--accent);border-radius:6px;padding:12px;margin:12px 0; }
.launch-preview-item { display:flex;flex-direction:column;gap:5px;padding:10px 0;border-top:1px solid var(--line);overflow-wrap:anywhere; }
.launch-preview pre { white-space:pre-wrap;overflow-wrap:anywhere;font-size:.83rem; }
@media (min-width:600px) and (max-width:1023px) { .board-ticket { grid-template-columns:minmax(0,1.5fr) minmax(0,1fr); } .board-ticket-main { grid-column:1;grid-row:1 / 3; } .board-agent,.board-waits,.board-launch { grid-column:2; } }
@media (max-width:599px) {
 .board-ticket { grid-template-columns:minmax(0,1fr);gap:12px; }
 .board-ticket .ticket-actions { grid-column:auto;grid-row:auto; }
 .board-filterbar .inp { max-width:none;width:100%; }
 .launch-config-grid { grid-template-columns:minmax(0,1fr); }
 .board-content button,.board-content a,.shared-launch button,.shared-launch select { min-height:40px; }
 .ticket-direct-links a { display:inline-flex;align-items:center; }
 .board-start-overlay .pop.ticket-start { max-height:calc(100dvh - 16px); }
 .board-presetbar .launch-presets { width:100%; }
 .launch-presets { display:grid;grid-template-columns:repeat(2,minmax(0,1fr)); }
}
