:root { --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
header { display: flex; align-items: center; gap: 20px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 600; font-size: 16px; }
nav button { background: none; border: 1px solid transparent; color: var(--muted); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; }
nav button.active { color: var(--text); background: var(--bg); border-color: var(--line); }
.sysinfo { margin-left: auto; color: var(--muted); font-size: 12px; font-family: var(--mono); text-align: right; }
.sysinfo b { color: var(--text); font-weight: 500; }
main { padding: 16px 18px 60px; max-width: 1500px; margin: 0 auto; }
.tab { display: none; } .tab.active { display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
.panel summary { padding: 10px 14px; cursor: pointer; font-weight: 500; }
.panel form { padding: 4px 14px 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.grid label.row { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.grid .wide { grid-column: 1 / -1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; font-family: var(--mono); font-size: 13px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
button { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 11px; cursor: pointer; font: inherit; font-size: 13px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger:hover { border-color: var(--bad); color: var(--bad); }
button.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tbody tr:hover { background: var(--hover); }
tbody tr.selected { background: var(--sel); }
tbody tr.clickable { cursor: pointer; }
td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
td.trunc { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.child { color: var(--muted); }
.child td:first-child::before { content: "└ "; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.badge.running { background: var(--sel); color: var(--accent); }
.badge.success { background: var(--ok-bg); color: var(--ok); }
.badge.failed, .badge.error, .badge.lost { background: var(--bad-bg); color: var(--bad); }
.badge.killed, .badge.timeout { background: var(--warn-bg); color: var(--warn); }
.badge.managed { background: var(--panel-2); color: var(--muted); }
.badge.queued { background: var(--panel-2); color: var(--warn); }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 0 0 10px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.split.open { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.detail { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; position: sticky; top: 64px; max-height: calc(100vh - 80px); display: flex; flex-direction: column; gap: 10px; }
.detail h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; font-size: 12.5px; }
.detail dt { color: var(--muted); } .detail dd { margin: 0; font-family: var(--mono); word-break: break-all; }
.detail pre { flex: 1; min-height: 200px; margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; overflow: auto; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.on-toggle { width: 34px; height: 18px; border-radius: 9px; background: var(--toggle); position: relative; cursor: pointer; border: none; padding: 0; }
.on-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.on-toggle.on { background: var(--ok); } .on-toggle.on::after { left: 18px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); padding: 10px 16px; border-radius: 8px; font-size: 13px; max-width: 80vw; z-index: 10; }
#toast.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } .split.open { grid-template-columns: 1fr; } .detail { position: static; max-height: none; } td.trunc { max-width: 160px; } }
/* path picker */
.pp { position: relative; }
.pp input { width: 100%; }
.pp-menu { position: absolute; left: 0; right: 0; top: calc(100% + 2px); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; max-height: 260px; overflow: auto; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.pp-item { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; cursor: pointer; font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.pp-item.active, .pp-item:hover { background: var(--sel); }
.pp-item .src { margin-left: auto; color: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }
.pp-item .src.fs { color: var(--accent); }
.pp-empty { padding: 8px 10px; color: var(--muted); font-size: 12px; }
/* v2: agents/apps tabs, dialog, docs */
.api-link { color: var(--accent); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 5px 11px; font-size: 13px; font-weight: 600; }
.api-link:hover { border-color: var(--accent); }
.toolbar .right { margin-left: auto; }
.section-title { font-size: 14px; font-weight: 500; color: var(--muted); margin: 18px 0 8px; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; width: min(760px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h3 { margin: 0 0 4px; font-size: 16px; }
dialog form.grid { padding: 0; }
.app-name { font-weight: 600; }
.app-desc { color: var(--muted); font-size: 12px; max-width: 360px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; background: var(--hover); color: var(--muted); border: 1px solid var(--line); }
.pill.on { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.link { color: var(--accent); cursor: pointer; text-decoration: none; } .link:hover { text-decoration: underline; }

.sessions { font-size: 12.5px; }
.session { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; border-top: 1px solid var(--line); }
.session code { font-family: var(--mono); font-size: 12px; }
.detail pre.screen { white-space: pre; font-size: 11.5px; line-height: 1.25; }
.detail form.keys input { min-width: 0; flex: 1; }
.detail details.meta summary { cursor: pointer; font-size: 12.5px; list-style: none; }
.detail details.meta summary::before { content: "▸ "; } .detail details.meta[open] summary::before { content: "▾ "; }
.detail details.meta dl { margin-top: 6px; }
.sess a { white-space: nowrap; display: inline-block; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--dim); vertical-align: middle; }
.dot.idle { background: var(--ok); } .dot.working, .dot.busy { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot.waiting_input, .dot.waiting { background: var(--warn); }
.sess { line-height: 1.3; } .sess code { font-size: 11px; }
.sesscell { max-width: 280px; min-width: 160px; }
.sess > div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess > div + div { white-space: normal; }

/* ---------------------------------------------------------------- phones (and narrow windows) */
@media (max-width: 720px) {
  body { font-size: 15px; }
  header { padding: 8px 12px; gap: 10px; }
  .sysinfo { display: none; }
  /* tabs: a full-width row under the brand (not a fixed bottom bar: iOS Safari's own bottom toolbar sits over that and eats the taps) */
  header { padding-bottom: 0; }
  nav { order: 10; flex-basis: 100%; display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -12px; padding: 2px 6px 6px; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav button { flex: 1 0 auto; padding: 9px 10px; font-size: 13.5px; border-radius: 8px; }
  main { padding: 12px 10px calc(24px + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px; padding: 9px 10px; }            /* 16px stops iOS from zooming the page */
  button { padding: 9px 12px; font-size: 14px; } button.small { padding: 7px 10px; font-size: 13px; }
  .toolbar .right { margin-left: 0; }
  /* tables become cards */
  table, tbody { display: block; background: none; border: 0; }
  thead { display: none; }
  tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
  tbody tr:hover { background: var(--panel); }
  tbody tr.selected { border-color: var(--accent); }
  td { display: block; padding: 0; border: 0; max-width: none !important; }
  td[data-l]::before { content: attr(data-l) " "; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
  td.trunc, td.full, td.sesscell, td.row { flex-basis: 100%; min-width: 0; max-width: none; }
  td.trunc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  td.row { padding-top: 6px; gap: 8px; }
  td.status { margin-left: auto; }
  .sess > div:first-child { white-space: normal; }
  .child td:first-child::before { content: "↳ "; }
  /* runs: the detail takes the whole screen */
  .split.open > table { display: none; }
  body.run-open { overflow: hidden; }
  .detail { position: fixed; inset: 0; z-index: 7; border: 0; border-radius: 0; max-height: none; overflow: auto; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
  .detail h3 { position: sticky; top: -10px; background: var(--panel); padding: 8px 0; z-index: 1; }
  .detail dl { grid-template-columns: 1fr; gap: 1px; } .detail dt { font-size: 11px; margin-top: 4px; } .detail dd { font-size: 12.5px; }
  .detail pre { min-height: 45vh; font-size: 11px; }
  .detail pre.screen { font-size: 10.5px; line-height: 1.3; }
  .detail form.keys { position: sticky; bottom: 0; background: var(--panel); padding: 6px 0; }
  .detail form.keys input { flex: 1 1 100%; }
  .session { flex-direction: column; align-items: stretch; }
  /* dialogs go full screen */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; overflow: auto; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
  .pp-menu { max-height: 40vh; }
}
@media (pointer: coarse) { button, .on-toggle { min-height: 36px; } nav button { min-height: 40px; } }

/* Workspace design system: every color is a token, set per theme below (Settings → Appearance) */
:root, :root[data-theme="wave"] {
  color-scheme:dark; --bg:#16131a; --sidebar:#1a1620; --panel:#1f1a25; --panel-2:#262030; --sunken:#120f16; --term-bg:#110e14;
  --line:#332b3d; --text:#f2eaef; --muted:#b4a6b9; --dim:#8b7e92; --accent:#f6c9a6; --accent-ink:#2b1a10; --accent-hover:#fbd9bf;
  --sel:#352a40; --sel-line:#5a4870; --hover:#2a2334; --hover-line:#705c84; --toggle:#4a3f56; --toggle-on:#a985b8;
  --ok:#9fd8b4; --ok-bg:#1f3328; --bad:#f0a0a0; --bad-bg:#3a2226; --warn:#e8c58a; --warn-bg:#3a2f1c; --backdrop:#0a070cb3;
}
:root[data-theme="wave-light"] {
  color-scheme:light; --bg:#fbf6f3; --sidebar:#f4ebe8; --panel:#ffffff; --panel-2:#f6eff1; --sunken:#faf5f3; --term-bg:#1d1822;
  --line:#e6dbe1; --text:#2a2230; --muted:#6c6074; --dim:#93879a; --accent:#8a5ea2; --accent-ink:#ffffff; --accent-hover:#9c71b4;
  --sel:#f0e4f4; --sel-line:#d7c1e2; --hover:#f7eff5; --hover-line:#c8b2d4; --toggle:#d9cfe0; --toggle-on:#a985b8;
  --ok:#2c7a50; --ok-bg:#e2f2e8; --bad:#b0403e; --bad-bg:#f8e2e1; --warn:#946510; --warn-bg:#f6ebd6; --backdrop:#2a223066;
}
:root[data-theme="forest"] {
  color-scheme:dark; --bg:#111312; --sidebar:#151816; --panel:#191c1a; --panel-2:#1c201d; --sunken:#121613; --term-bg:#0d110e;
  --line:#2c312d; --text:#edf0eb; --muted:#a0aaa2; --dim:#7e8a80; --accent:#c4ef91; --accent-ink:#17220d; --accent-hover:#d3f7a8;
  --sel:#293322; --sel-line:#3b4930; --hover:#202620; --hover-line:#65765b; --toggle:#424c44; --toggle-on:#719653;
  --ok:#95d6ae; --ok-bg:#213629; --bad:#f09a98; --bad-bg:#382424; --warn:#e5c284; --warn-bg:#3d2f14; --backdrop:#050a07b3;
}
[hidden] { display:none !important; }
body { font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; -webkit-font-smoothing:antialiased; }
button,input,select,textarea,a { -webkit-tap-highlight-color:transparent; }
button,a,input,select,textarea,summary { touch-action:manipulation; }
button { min-height:38px; border-radius:8px; font-weight:500; transition:background .15s,border-color .15s; }
button:hover { background:var(--hover); border-color:var(--hover-line); }
button.primary { color:var(--accent-ink); box-shadow:0 1px 2px #0002; }
button.primary:hover { background:var(--accent-hover); }
button.small { min-height:32px; padding:6px 10px; }
button.danger { color:var(--muted); }
button.danger:hover { background:var(--bad-bg); color:var(--bad); }
:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
a { color:var(--accent); }
.skip-link { position:fixed; top:-80px; left:16px; z-index:50; padding:12px; background:var(--panel); }
.skip-link:focus { top:12px; }
.brand { display:flex; align-items:center; gap:11px; text-decoration:none; color:var(--text); font-size:15px; letter-spacing:-.3px; }
.brand-mark { width:32px; height:32px; flex-shrink:0; border-radius:9px; display:block; }
.brand small { display:block; color:var(--muted); font-size:10px; font-weight:400; margin-top:3px; letter-spacing:.1px; }
/* top bar: brand, pages, machine, New session */
.console .topbar { position:sticky; top:0; z-index:5; display:flex; flex-wrap:nowrap; align-items:center; gap:22px; padding:12px 24px; padding-top:max(12px, env(safe-area-inset-top)); background:var(--bg); border-bottom:1px solid var(--line); }
.console nav { display:flex; gap:2px; min-width:0; }
.console nav button { min-height:34px; padding:6px 14px; font-size:13.5px; border:0; border-radius:999px; background:transparent; color:var(--muted); white-space:nowrap; }
.console nav button:hover { background:var(--hover); color:var(--text); }
.console nav button.active { background:var(--panel-2); color:var(--text); font-weight:600; }
.topbar-right { margin-left:auto; display:flex; align-items:center; gap:14px; min-width:0; }
.topbar .sysinfo { margin:0; font-family:var(--mono); font-size:11.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#new-session-btn { min-height:36px; padding:7px 16px; border-radius:999px; white-space:nowrap; }
.console main { padding:18px 24px 32px; max-width:1800px; margin:0 auto; }
.page-top { display:flex; align-items:center; gap:18px; min-height:44px; margin-bottom:18px; font-size:12px; }
body[data-tab="console"] .page-top { display:none; }
#refresh-btn { min-height:30px; padding:4px 10px; color:var(--muted); background:transparent; }
.connection { color:var(--muted); font-size:11px; white-space:nowrap; }.connection::before { content:""; display:inline-block; width:6px; height:6px; margin-right:7px; border-radius:50%; background:var(--warn); }.connection.online::before { background:var(--ok); box-shadow:0 0 0 4px color-mix(in srgb, var(--ok) 5%, transparent); }
h1 { margin:0; font-size:19px; line-height:1.3; font-weight:580; letter-spacing:-.4px; white-space:nowrap; }
.toolbar { margin-bottom:14px; gap:12px; }.toolbar .muted { font-size:12px; }.toolbar label { display:flex; align-items:center; gap:7px; }
input,select,textarea { border-radius:8px; padding:10px 12px; background:var(--sunken); min-width:0; max-width:100%; }
input[type=checkbox] { accent-color:var(--accent); width:16px; height:16px; margin:0 4px 0 0; }
.grid { gap:18px; }.grid > * { min-width:0; }.grid label { gap:8px; font-size:12px; }.grid .row { gap:8px; }
.panel { border-radius:12px; margin-bottom:22px; }.panel summary { padding:17px 20px; font-size:13px; }.panel form { padding:12px 20px 22px; }
table { border-collapse:separate; border-spacing:0; border-radius:12px; table-layout:fixed; }
th { padding:13px 14px; font-size:10px; text-transform:uppercase; letter-spacing:.8px; background:var(--panel-2); }
td { padding:12px 14px; font-size:12px; overflow-wrap:anywhere; }tbody tr:last-child td { border-bottom:0; }tbody tr:hover { background:var(--hover); }td.row { display:flex; gap:6px; }
td.trunc { max-width:220px; }tbody tr.selected { background:var(--sel); }
.badge { text-transform:none; letter-spacing:0; font-size:11px; padding:4px 9px; font-weight:500; }.badge.running { background:var(--ok-bg); color:var(--ok); }.badge.managed { background:var(--panel-2); color:var(--muted); }.badge.success { background:var(--ok-bg); }
.pill { padding:4px 9px; font-size:11px; background:var(--panel-2); }
.section-title { margin:30px 0 14px; color:var(--text); font-size:15px; }
/* Process lists prioritize session identity, with details and actions below. */
.proc-table { display:block; background:transparent; border:0; overflow:visible; }
.proc-table thead { display:none; }
.proc-table tbody { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.proc-table tbody tr { display:flex; flex-wrap:wrap; align-items:center; gap:12px; padding:20px; border:1px solid var(--line); border-radius:12px; background:var(--panel); min-width:0; }
.proc-table td { display:block; padding:0; border:0; min-width:0; }
.proc-table td:first-child { order:1; color:var(--muted); margin-left:auto; font-size:10px; }.proc-table td:first-child::before { content:"PID "; }
.proc-table td:nth-child(2) { order:0; font-size:12px; font-weight:600; text-transform:capitalize; }
.proc-table td:nth-child(3) { order:2; flex-basis:100%; max-width:none; min-width:0; padding:5px 0; }
.sess > div:first-child { white-space:normal; font-size:16px; font-weight:500; line-height:1.5; letter-spacing:-.2px; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.sess > div + div { margin-top:5px; overflow-wrap:anywhere; line-height:1.6; }.dot.working { background:var(--accent); box-shadow:none; }
.proc-table td:nth-child(4) { order:3; flex-basis:100%; max-width:100%; color:var(--muted); font-size:11px; }
.proc-table td:nth-child(5) { order:4; flex-basis:100%; max-width:100%; color:var(--dim); font-size:10px; background:var(--sunken); border:1px solid var(--line); border-radius:6px; padding:8px 10px; }
.proc-table td:nth-child(n+6):nth-child(-n+9) { order:5; color:var(--text); font-size:11px; }.proc-table td[data-l]::before { content:attr(data-l) " "; color:var(--muted); font-size:10px; text-transform:uppercase; margin-right:3px; }
.proc-table td:last-child:not([colspan]) { order:6; flex-basis:100%; display:flex; border-top:1px solid var(--line); padding-top:14px; margin-top:2px; }
.proc-table tr:has(td[colspan]) { grid-column:1/-1; justify-content:center; padding:50px; }.proc-table td[colspan] { margin:0; }.proc-table td[colspan]::before { content:none; }
.proc-table tr.child { opacity:.7; }
#app-table th:first-child { width:25%; }#app-table th:nth-child(2) { width:27%; }
#wf-table th:first-child { width:42%; }#wf-table th:nth-child(2) { width:15%; }#wf-table th:nth-child(4) { width:64px; }#wf-table th:last-child { width:230px; }
#type-table th:first-child { width:23%; }#type-table th:nth-child(3) { width:24%; }
#runs-table th:nth-child(2) { width:30%; }
.app-name { margin-bottom:5px; font-size:15px; }.app-desc { line-height:1.7; }
.on-toggle { width:40px; height:24px; min-height:24px; border-radius:20px; background:var(--toggle); }.on-toggle::after { width:18px; height:18px; top:3px; left:3px; }.on-toggle.on::after { left:19px; }.on-toggle.on { background:var(--toggle-on); }
.split.open { grid-template-columns:minmax(260px,.8fr) minmax(0,1.2fr); }
.split.open #runs-table th:nth-child(n+3),.split.open #runs-table td:nth-child(n+3) { display:none; }.split.open #runs-table th:first-child { width:55px; }
.detail { top:20px; max-height:calc(100dvh - 40px); padding:20px; border-radius:12px; gap:16px; }.detail h3 { flex-wrap:wrap; font-size:17px; }.detail pre { min-height:300px; line-height:1.7; padding:16px; background:var(--term-bg); }.detail details.meta { overflow-wrap:anywhere; }.detail details.meta summary { line-height:1.7; }.detail dl { padding:12px 0; }.detail dd { max-height:220px; overflow:auto; }.session { padding:12px 0; gap:12px; }.session > div { overflow-wrap:anywhere; }
dialog { padding:28px; width:min(720px,calc(100vw - 32px)); max-height:calc(100dvh - 48px); border-radius:16px; }dialog h3 { font-size:23px; letter-spacing:-.5px; margin-bottom:8px; }dialog::backdrop { background:var(--backdrop); backdrop-filter:blur(5px); }#preview { white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.7; }#preview:empty { display:none; }
#toast { max-width:calc(100vw - 32px); bottom:calc(22px + env(safe-area-inset-bottom)); box-shadow:0 8px 40px #0004; }
@media (min-width:1700px) { .proc-table tbody { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media (max-width:1200px) { .console main { padding-inline:20px; }.proc-table tbody { grid-template-columns:1fr; }.split.open { grid-template-columns:1fr; }.split.open > table { display:none; }.detail { position:static; max-height:none; } }
@media (max-width:900px) {
  .console .topbar { flex-wrap:wrap; gap:10px 14px; padding:10px 16px 0; padding-top:max(10px, env(safe-area-inset-top)); }
  .brand-mark { width:28px; height:28px; }.topbar .sysinfo { display:none; }
  .console nav { order:10; flex-basis:100%; margin:0 -8px; padding:0 4px 8px; overflow-x:auto; scrollbar-width:none; }
  .console nav button { flex:1 0 auto; min-height:40px; }
  .console main { padding:14px 16px 40px; }.page-top { height:auto; min-height:50px; flex-wrap:wrap; gap:10px; padding:8px 0; }
  table,tbody { display:block; border:0; background:none; }thead { display:none; }
  tbody tr { display:flex; flex-wrap:wrap; align-items:center; gap:12px; min-width:0; background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:18px; margin-bottom:12px; }
  td { display:block; padding:0; border:0; min-width:0; max-width:100% !important; }td.full,td.trunc,td.row { flex-basis:100%; }td.row { padding-top:12px; border-top:1px solid var(--line); }td.status { margin-left:auto; }
  td[data-l]::before { content:attr(data-l) " "; color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.4px; }td.full { overflow-wrap:anywhere; }.proc-table tbody tr { margin:0; }
  tbody tr.selected { border-color:var(--toggle-on); }.split.open #runs-table td:nth-child(n+3) { display:block; }
  /* markdown tables in chat stay tables (they scroll sideways); the card layout drops their headers */
  .md thead { display:table-header-group; }.md tbody { display:table-row-group; }.md tbody tr { display:table-row; padding:0; margin:0; border:0; border-radius:0; background:none; }.md th,.md td { display:table-cell; padding:4px 8px; border:1px solid var(--line); }
  button.small { min-height:40px; } .grid { grid-template-columns:1fr; }
  .detail { position:fixed; inset:0; z-index:7; border-radius:0; max-height:100dvh; padding:20px 20px calc(20px + env(safe-area-inset-bottom)); overflow:auto; }
  body.run-open { overflow:hidden; }.detail h3 { position:sticky; top:-20px; background:var(--panel); padding:14px 0; z-index:1; }.detail pre { flex:1 0 45dvh; min-height:240px; }.detail dl { grid-template-columns:1fr; }.detail dt { margin-top:8px; }.detail .keys { position:sticky; bottom:0; background:var(--panel); padding-block:10px; }
}
@media (max-width:540px) {
  .console nav button { padding:6px 11px; font-size:13px; }
  .console main { padding:12px 14px calc(30px + env(safe-area-inset-bottom)); }.page-top { font-size:10px; }.connection { font-size:0; }.connection::before { margin:0; }.people { display:none; }
  #new-session-btn { padding:7px 13px; }
  .toolbar { gap:10px; margin-bottom:16px; }.toolbar .right { flex-basis:100%; margin:2px 0 0; }.toolbar select { flex:1 1 130px; width:0; }.toolbar #runs-count { flex-basis:100%; }
  input,select,textarea { font-size:16px; min-height:44px; }.grid label { font-size:12px; }input[type=checkbox] { min-height:0; }button,button.small { min-height:44px; } .on-toggle { min-height:44px; width:48px; background:transparent; }.on-toggle::before { content:""; position:absolute; inset:10px 0; border-radius:15px; background:var(--toggle); }.on-toggle.on::before { background:var(--toggle-on); }.on-toggle::after { top:13px; left:4px; }.on-toggle.on::after { left:26px; }
  .proc-table tbody tr { padding:16px; gap:10px; }.proc-table td:last-child:not([colspan]) { gap:8px; }.proc-table td:nth-child(2) { font-size:11px; }.sess > div:first-child { font-size:15px; }
  td.row { gap:8px; }td.row button { flex-grow:1; }.panel summary { padding:16px; }.panel form { padding:8px 16px 20px; }
  dialog { width:100%; height:100dvh; max-height:100dvh; max-width:100%; margin:0; border-radius:0; padding:24px 18px calc(24px + env(safe-area-inset-bottom)); }.detail { padding-inline:14px; }.detail h3 { font-size:16px; }.detail pre { font-size:12px; }.detail .session { align-items:stretch; flex-direction:column; }.detail .keys input { flex:1 1 100%; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { transition:none !important; scroll-behavior:auto !important; } }
.pill,.badge { white-space:nowrap; }
select { font-family:inherit; }
@media (min-width:901px) and (max-width:1200px) {
  #app-table,#wf-table,#type-table,#app-table tbody,#wf-table tbody,#type-table tbody { display:block; background:none; border:0; }
  #app-table thead,#wf-table thead,#type-table thead { display:none; }
  #app-table tr,#wf-table tr,#type-table tr { display:flex; flex-wrap:wrap; align-items:center; gap:14px; padding:20px; margin-bottom:14px; background:var(--panel); border:1px solid var(--line); border-radius:12px; }
  #app-table td,#wf-table td,#type-table td { display:block; padding:0; border:0; min-width:0; max-width:100%; }
  #app-table td.full,#wf-table td.full,#type-table td.full { flex-basis:100%; }
  #app-table td.row,#wf-table td.row,#type-table td.row { display:flex; flex-basis:100%; padding-top:14px; border-top:1px solid var(--line); }
  td[data-l]::before { content:attr(data-l) " "; color:var(--muted); font-size:10px; text-transform:uppercase; }
}
.form-error { padding:12px; border:1px solid var(--bad); border-radius:8px; color:var(--bad); background:var(--bad-bg); font-size:13px; overflow-wrap:anywhere; }

/* ---------------------------------------------------------------- console: session list + pane */
/* The window is the top bar over the session list (a drawer from the left, ☰ in the top bar: docked beside the page on
   wide screens, over it on phones) and the page, which scrolls on its own. Sessions fills it with the selected session. */
body.console { height:100dvh; display:flex; flex-direction:column; overflow:hidden; }
.app-body { flex:1; min-height:0; display:flex; }
.console main { flex:1; min-width:0; min-height:0; overflow-y:auto; overscroll-behavior:contain; }
body[data-tab="console"] main { overflow:hidden; display:flex; flex-direction:column; padding-bottom:16px; }
body[data-tab="console"] #tab-console.active { flex:1; min-height:0; display:flex; flex-direction:column; }
.console-view { flex:1; min-height:0; display:flex; }
.rail { min-width:0; min-height:0; display:flex; flex-direction:column; gap:12px; }
.rail-bar { flex:none; display:flex; align-items:center; gap:8px; }
.rail-bar > .rail-resume { margin-left:auto; }
.rail-tabs { flex-shrink:0; }
.drawer-x { display:grid; flex:none; width:36px; height:36px; min-height:36px; padding:0; place-items:center; font-size:20px; line-height:1; color:var(--muted); background:transparent; border:0; border-radius:50%; }
.rail-strip { flex:1; min-height:0; display:flex; flex-direction:column; gap:8px; overflow-y:auto; overscroll-behavior:contain; padding:2px 4px 12px 2px; scrollbar-width:thin; }
.rail-head { flex:none; margin-top:8px; padding:12px 2px 2px; border-top:1px solid var(--line); color:var(--muted); font-size:10px; letter-spacing:1px; text-transform:uppercase; line-height:1.5; }
.rail-item { flex:none; display:flex; flex-direction:column; gap:6px; min-height:0; padding:12px 14px; text-align:left; font:inherit; font-weight:400; color:var(--text); text-decoration:none; background:var(--panel); border:1.5px solid var(--line); border-radius:14px; }
.rail-item:hover { background:var(--hover); border-color:var(--hover-line); }
.rail-item.active { background:var(--panel-2); border-color:var(--accent); }
.rail-item.needs:not(.active) { border-color:var(--warn); }
/* the pin sits in the item's top-right corner: faint until hovered, solid when pinned */
.rail-slot { position:relative; flex:none; display:flex; }
.rail-slot > .rail-item { flex:1; min-width:0; }
.rail-slot > .rail-item .tile-act { padding-right:28px; }
.rail-pin { position:absolute; top:6px; right:6px; width:28px; height:28px; min-height:0; padding:0; display:grid; place-items:center; color:var(--muted); background:transparent; border:0; border-radius:50%; opacity:0; }
.rail-pin::before { content:""; width:15px; height:15px; background:currentColor; -webkit-mask:var(--pin-icon) center / contain no-repeat; mask:var(--pin-icon) center / contain no-repeat; }
.rail-pin { --pin-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 1.75h5M6.5 1.75v4L4 8.75h8L9.5 5.75v-4M8 8.75v5.5'/%3E%3C/svg%3E"); }
.rail-slot.pinned .rail-pin { --pin-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='black' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 1.75h5M6.5 1.75v4L4 8.75h8L9.5 5.75v-4z'/%3E%3Cpath d='M8 8.75v5.5' fill='none'/%3E%3C/svg%3E"); color:var(--accent); opacity:1; }
.rail-slot:hover .rail-pin, .rail-pin:focus-visible { opacity:.7; }
.rail-pin:hover { opacity:1 !important; color:var(--text); background:var(--hover); }
.rail-slot.pinned .rail-pin:hover { color:var(--accent-hover); }
@media (hover:none) { .rail-pin { opacity:.45; width:36px; height:36px; top:2px; right:2px; } }
.rail-strip > .rail-head:first-child { margin-top:0; padding-top:2px; border-top:0; }
.tile-act { display:flex; align-items:center; gap:7px; font-size:12px; color:var(--muted); }
.tile-act .dot { margin:0; }
.tile-act.working { color:var(--ok); }
.tile-act.waiting_input { color:var(--warn); }
.rail-title { font-size:14.5px; font-weight:600; line-height:1.3; letter-spacing:-.1px; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.rail-sub { color:var(--muted); font-family:var(--mono); font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rail-item.flat .rail-sub { white-space:normal; overflow-wrap:anywhere; }
.rail-sub.dim { color:var(--dim); }
.rail-sub .wf-tag { font-family:var(--sans); }
/* the last six minutes, one bar per 30 s: how much of it the session spent working */
.meter { display:flex; align-items:flex-end; gap:3px; height:18px; }
.meter i { flex:none; width:5px; border-radius:2px; background:var(--accent); transition:height .3s; }
.meter i.idle { background:var(--toggle); }
.meter i.wait { background:var(--warn); }
.meter i.none { background:var(--line); }
.tile-new { flex:none; display:flex; align-items:center; justify-content:center; gap:8px; min-height:44px; padding:8px; color:var(--muted); background:transparent; border:1.5px dashed var(--toggle); border-radius:14px; }
.tile-new span { font-size:18px; line-height:1; }
.tile-new:hover { color:var(--text); background:var(--hover); }
.rail-item.flat { background:transparent; }
.rail-item.flat:hover { background:var(--panel-2); }
.rail-item.flat .rail-title .dot { margin-right:6px; }
.rail-item.flat button { width:100%; }
.rail-item.flat .row { gap:6px; margin-top:2px; }.rail-item.flat .row button { flex:1 1 auto; width:auto; }
/* the ☰ in the top bar that opens the list where it is a drawer; amber dot when a session needs you */
.drawer-btn { position:relative; flex:none; display:grid; place-items:center; width:38px; height:38px; min-height:38px; padding:0; color:var(--text); background:var(--panel-2); border:0; border-radius:50%; }
.drawer-btn.alert::after { content:""; position:absolute; top:5px; right:5px; width:9px; height:9px; border-radius:50%; background:var(--warn); box-shadow:0 0 0 2px var(--bg); }
.drawer-backdrop { position:fixed; inset:0; z-index:29; background:var(--backdrop); }
.rail { position:fixed; z-index:30; inset:0 auto 0 0; width:min(340px, 86vw); padding:14px 12px; padding-top:max(14px, env(safe-area-inset-top)); padding-bottom:max(12px, env(safe-area-inset-bottom)); background:var(--bg); border-right:1px solid var(--line); box-shadow:0 0 40px #0006; transform:translateX(-105%); visibility:hidden; transition:transform .22s ease, visibility 0s .22s; }
body.drawer-open .rail { transform:none; visibility:visible; transition:transform .22s ease; }
/* Wide enough to share: the open list docks beside the session instead of covering it, and stays while you work. */
@media (min-width:900px) {
  .rail, body.drawer-open .rail { position:static; z-index:auto; width:auto; flex:0 0 300px; display:none; padding:18px 14px 12px 20px; background:var(--sidebar); border-right:1px solid var(--line); box-shadow:none; transform:none; visibility:visible; transition:none; }
  body.drawer-open .rail { display:flex; }
  .drawer-backdrop { display:none !important; }
}

.pane { flex:1; min-width:0; min-height:0; display:flex; flex-direction:column; gap:12px; }
.pane-head { flex:none; display:flex; align-items:center; justify-content:space-between; gap:10px 16px; flex-wrap:wrap; }
.pane-id { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; min-width:0; }
.pane h2 { margin:0; font-family:var(--display); font-size:24px; font-weight:700; line-height:1.25; letter-spacing:-.02em; overflow-wrap:anywhere; }
.pane-meta { flex-basis:100%; font-size:11.5px; overflow-wrap:anywhere; }
.pane-meta code { margin-left:8px; }
.chip { display:inline-flex; align-items:center; padding:3px 10px; font-size:12px; line-height:1.5; color:var(--muted); text-decoration:none; white-space:nowrap; background:var(--panel-2); border-radius:999px; }
.chip.ok { color:var(--ok); background:var(--ok-bg); }
a.chip:hover { text-decoration:underline; }
.pane-actions { gap:8px; }
.pane-actions button { border-radius:999px; }
.pane .chat { flex:1; height:auto; min-height:0; background:transparent; border:0; }
.pane-foot { flex:none; font-size:10.5px; }
.term-hint { flex:none; font-size:11px; }
#select-btn.on { background:var(--accent); color:var(--term-bg); border-color:transparent; }
body.term-full .term-hint { margin-top:-4px; }
.pane-empty { display:flex; flex-direction:column; align-items:center; gap:14px; padding:56px 10px; text-align:center; }
.pane-empty h2 { font-size:22px; }
.pane-empty p { margin:0; max-width:430px; font-size:13px; line-height:1.7; }

@media (max-width:900px) {
  body[data-tab="console"] main { padding-top:12px; }
  .console-view { gap:12px; }
  .pane h2 { font-size:19px; }
  .pane-actions { width:100%; }
  .pane form.keys { position:sticky; bottom:0; padding-block:8px; background:var(--panel); }
  .pane form.keys input { flex:1 1 100%; }
}
@media (max-width:700px) {
  .pane-head { gap:8px; }
  .pane-meta { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .pane-actions { flex-wrap:nowrap; overflow-x:auto; margin:0 -14px; padding:0 14px; scrollbar-width:none; }
  .pane-actions::-webkit-scrollbar { display:none; }
  .pane-actions > * { flex:none; }
  .pane-foot { display:none; }
}

/* people: who you are, who else is here */
.page-top-right { display:flex; align-items:center; gap:14px; min-width:0; }
.people { color:var(--muted); font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.people b { color:var(--text); font-weight:600; }
.people button { margin-left:8px; }
dialog.login { width:min(420px, calc(100vw - 32px)); }
dialog.login [hidden] { display:none; }
.by { color:var(--muted); }

/* live terminal (xterm.js over a websocket to tmux) */
/* A fixed height, never "grow to fit": the fit addon sizes the terminal from this box, so a box that grew with the
   terminal would feed back (more rows → taller box → more rows) up to the row cap. Here it takes what is left of the
   window-high pane, which doesn't depend on the terminal either. */
.pane .term { position:relative; flex:1; height:auto; min-height:240px; padding:0; background:var(--term-bg); border:1px solid var(--line); border-radius:8px; overflow:hidden; }
/* the padding goes on .xterm: the fit addon subtracts the terminal element's padding, not its parent's */
.pane .term .xterm { height:100%; padding:8px; }
.pane .term-status { position:absolute; top:8px; right:12px; z-index:5; font-size:11px; color:var(--muted); background:color-mix(in srgb, var(--term-bg) 80%, transparent); padding:2px 8px; border-radius:6px; }
.pane .term-status:empty { display:none; }
.pane .term-history { position:absolute; inset:0; z-index:4; display:flex; flex-direction:column; gap:4px; padding:8px; background:var(--term-bg); }
.pane .term-history-bar { flex:none; align-self:flex-start; font-size:11px; color:var(--muted); background:var(--panel-2); border:1px solid var(--line); padding:2px 8px; border-radius:6px; cursor:pointer; }
.pane .term-history-body { flex:1; min-height:0; margin:0; overflow-y:auto; overscroll-behavior:contain; color:var(--hist-fg); white-space:pre-wrap; overflow-wrap:anywhere; outline:none; scrollbar-width:thin; scrollbar-color:color-mix(in srgb, var(--hist-fg) 25%, transparent) transparent; }

/* full-screen terminal: just the session, edge to edge */
body.term-full .topbar, body.term-full .page-top, body.term-full .rail, body.term-full .pane-foot { display:none; }
body.term-full main { margin:0; padding:0; max-width:none; }
body.term-full .console-view { display:block; }
body.term-full .pane { position:fixed; inset:0; top:0; max-height:none; gap:8px; padding:8px 12px 10px; background:var(--bg); z-index:20; }
body.term-full .pane .term { min-height:0; }
body.term-full .pane-head { align-items:center; }
body.term-full .pane h2 { font-size:16px; }
body.term-full .pane-meta { margin-top:2px; }

/* ---------------------------------------------------------------- compact layout: advanced sub-nav, workflows, connect */
.subnav { display:flex; gap:2px; padding:3px; background:var(--sidebar); border:1px solid var(--line); border-radius:9px; overflow-x:auto; scrollbar-width:none; }
.subnav::-webkit-scrollbar { display:none; }
.subnav button { min-height:28px; padding:4px 12px; font-size:12px; border:0; background:transparent; color:var(--muted); border-radius:7px; white-space:nowrap; }
.subnav button.active { background:var(--sel); color:var(--accent); }
.wf-name { min-height:0; padding:0; border:0; background:none; font-size:14px; font-weight:600; color:var(--text); text-align:left; }
.wf-name:hover { background:none; color:var(--accent); }
.wf-sub { font-size:11.5px; margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.wf-tag { color:var(--accent); margin-right:6px; }
.group-tag { cursor:pointer; }
.group-tag:hover { text-decoration:underline; }
td.empty { padding:28px 14px; text-align:center; }
details.more { border-top:1px solid var(--line); padding-top:10px; }
details.more summary { cursor:pointer; font-size:12px; }
details.more > .grid { margin-top:14px; }
dialog .hint { margin:0; font-size:12px; }
#cron-label small { font-size:11px; }
.card { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:18px 20px; margin-bottom:16px; max-width:980px; }
.card h2 { margin:0; font-size:15px; font-weight:600; }
.card > p { margin:6px 0 14px; font-size:13px; }
.card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
.card-head form input { width:240px; min-height:32px; padding:6px 10px; }
/* Advanced → Usage: a bar per plan-limit window, with a tick at the even-pace point */
.usage-plan { margin-left:8px; vertical-align:2px; }
.usage-row + .usage-row { margin-top:16px; }
.usage-line { display:flex; justify-content:space-between; gap:12px; font-size:13px; margin-bottom:6px; }
.usage-pct { font-family:var(--mono); } .usage-pct.warn { color:var(--warn); } .usage-pct.bad { color:var(--bad); }
.usage-bar { position:relative; height:8px; border-radius:4px; background:var(--panel-2); border:1px solid var(--line); }
.usage-fill { height:100%; border-radius:3px; background:var(--ok); } .usage-fill.warn { background:var(--warn); } .usage-fill.bad { background:var(--bad); }
.usage-tick { position:absolute; top:-4px; bottom:-4px; width:2px; margin-left:-1px; background:var(--text); opacity:.55; border-radius:1px; }
.usage-meta { font-size:12px; margin-top:6px; }
.usage-note { font-size:12px; max-width:980px; }
.card table { border:1px solid var(--line); }
.copy-row { display:flex; align-items:center; gap:8px; margin-top:8px; }
.copy-row code { flex:1; min-width:0; padding:8px 10px; background:var(--sunken); border:1px solid var(--line); border-radius:8px; overflow-wrap:anywhere; font-size:12px; }
.new-key { margin-bottom:14px; padding:12px 14px; border:1px solid var(--sel-line); background:var(--sel); border-radius:10px; font-size:13px; }
#key-table th:first-child { width:34%; }#key-table th:last-child { width:110px; }
@media (max-width:900px) {
  .page-top .subnav { order:3; flex-basis:100%; }
  .copy-row { flex-wrap:wrap; }.copy-row code { flex-basis:100%; }
  .card-head form { width:100%; }.card-head form input { flex:1; width:auto; }
  .wf-sub { white-space:normal; }
}

/* settings: color scheme picker */
.themes { display:grid; grid-template-columns:repeat(auto-fill, minmax(170px, 1fr)); gap:12px; }
.theme { display:flex; flex-direction:column; align-items:stretch; gap:10px; min-height:0; padding:10px; text-align:left; background:var(--panel-2); border:1px solid var(--line); border-radius:12px; }
.theme:hover { border-color:var(--hover-line); }
.theme[aria-checked="true"] { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.theme-swatch { display:flex; height:54px; border-radius:8px; overflow:hidden; border:1px solid var(--line); }
.theme-swatch span { flex:1; }
.theme-name { font-size:13px; font-weight:600; }
.theme-name small { display:block; font-weight:400; color:var(--muted); font-size:11px; margin-top:2px; }
#ended-read.chat { flex:1; min-height:0; overflow:auto; display:flex; flex-direction:column; gap:10px; padding:14px; background:var(--sunken); border:1px solid var(--line); border-radius:8px; }
#ended-read.chat .msg { max-width:80ch; white-space:pre-wrap; overflow-wrap:anywhere; font-size:13px; line-height:1.5; }
#ended-read.chat .msg.user { align-self:flex-end; padding:8px 12px; background:var(--sel); border:1px solid var(--sel-line); border-radius:12px; }
#ended-read.chat .msg.tool { color:var(--dim); font-family:var(--mono); font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
#ended-read.chat pre.screen { margin:0; border:0; padding:0; }

/* ---------------------------------------------------------------- view switch (Chat / Terminal) */
.seg { display:inline-flex; border:1px solid var(--line); border-radius:7px; overflow:hidden; }
.seg button { border:0; border-radius:0; background:transparent; color:var(--muted); }
.seg button + button { border-left:1px solid var(--line); }
.seg button.on { background:var(--sel); color:var(--accent); }
.dot.busy { background:var(--accent); } .dot.waiting { background:var(--warn); } .dot.shell { background:var(--ok); }

/* ---------------------------------------------------------------- chat view (public/chat.js) */
.chat { position:relative; display:flex; flex-direction:column; min-height:0; min-width:0; height:max(360px, calc(100dvh - 330px)); background:var(--sunken); border:1px solid var(--line); border-radius:8px; }
body.term-full .pane .chat { flex:1; height:auto; }
.chat-scroll { flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:18px 22px 12px; }
.chat-list { display:flex; flex-direction:column; gap:22px; max-width:900px; margin:0 auto; }
.chat-state { max-width:900px; margin:30px auto; text-align:center; font-size:13px; }
.chat-state[hidden] { display:none; }
/* No content-visibility:auto here: a turn scrolled into view for the first time would change from its placeholder
   height to its real one, and on a phone that shifts the chat under a scrolling finger. The window is 30 turns. */
.chat-turn { display:flex; flex-direction:column; gap:8px; }
.chat-user { align-self:flex-end; max-width:min(85%, 720px); display:flex; flex-direction:column; gap:8px; padding:10px 14px; background:var(--panel-2); border:1px solid var(--line); border-radius:14px 14px 4px 14px; }
.chat-user-text { white-space:pre-wrap; overflow-wrap:anywhere; }
.chat-cmd { align-self:flex-start; font-family:var(--mono); font-size:12.5px; color:var(--accent); }
.chat-assistant { line-height:1.6; overflow-wrap:anywhere; }
.md > :first-child { margin-top:0; } .md > :last-child { margin-bottom:0; }
.md p, .md ul, .md ol, .md pre, .md table, .md blockquote { margin:0 0 10px; }
.md h1, .md h2, .md h3, .md h4 { margin:16px 0 8px; font-size:15px; line-height:1.4; } .md h1 { font-size:17px; }
.md code { font-family:var(--mono); font-size:12.5px; background:var(--panel-2); padding:1px 5px; border-radius:4px; }
.md pre { overflow-x:auto; padding:10px 12px; background:var(--panel-2); border:1px solid var(--line); border-radius:6px; }
.md pre code { background:none; padding:0; font-size:12px; }
.md table { border-collapse:collapse; table-layout:auto; width:auto; display:block; overflow-x:auto; border:0; background:none; }
.md th, .md td, .md tbody tr:last-child td { border:1px solid var(--line); padding:4px 8px; font-size:13px; }
/* the chat's overflow-wrap:anywhere let auto layout squeeze columns to one letter; break-word keeps whole words as the minimum */
.md th, .md td { overflow-wrap:break-word; min-width:6ch; }
.md th { color:var(--text); font-weight:600; text-transform:none; letter-spacing:normal; background:var(--panel-2); }
.md blockquote { padding-left:12px; border-left:3px solid var(--line); color:var(--muted); }
.md a { color:var(--accent); }
.md hr { border:0; border-top:1px solid var(--line); }

.chat-row { display:flex; align-items:center; gap:8px; width:100%; min-width:0; padding:5px 8px; text-align:left; font:inherit; font-size:13px; color:var(--muted); background:transparent; border:1px solid transparent; border-radius:6px; }
button.chat-row:hover { background:var(--hover); border-color:var(--line); color:var(--text); }
.chat-row.failed .chat-label { color:var(--bad); }
.chat-label { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-icon { flex:none; width:16px; text-align:center; font-family:var(--mono); font-size:12px; opacity:.8; }
.chev { flex:none; width:10px; height:10px; position:relative; }
.chev::before { content:""; position:absolute; inset:2px; border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor; transform:rotate(-45deg); transition:transform .12s; }
.open > .chev::before { transform:rotate(45deg); }
.chev.none::before { display:none; }
.chat-badge { flex:none; padding:0 7px; border-radius:9px; font-size:11px; background:var(--panel-2); color:var(--muted); border:1px solid var(--line); }
.chat-badge.bad { color:var(--bad); border-color:color-mix(in srgb, var(--bad) 40%, transparent); background:var(--bad-bg); }
.chat-badge.warn { color:var(--warn); border-color:color-mix(in srgb, var(--warn) 40%, transparent); background:var(--warn-bg); }
.chat-badge.ok { color:var(--ok); border-color:color-mix(in srgb, var(--ok) 40%, transparent); background:var(--ok-bg); }
.chat-diffstat { flex:none; font-family:var(--mono); font-size:11.5px; } .chat-diffstat .add { color:var(--ok); } .chat-diffstat .del { color:var(--bad); }
.chat-spin { flex:none; width:11px; height:11px; border:2px solid var(--sel-line); border-top-color:var(--accent); border-radius:50%; animation:chat-spin .8s linear infinite; }
@keyframes chat-spin { to { transform:rotate(360deg); } }
.chat-group { display:flex; flex-direction:column; }
.chat-group-body { margin-left:13px; padding-left:8px; border-left:1px solid var(--line); }
.chat-fold { display:flex; align-items:center; gap:8px; width:100%; min-width:0; padding:6px 8px; font-size:13px; color:var(--muted); background:transparent; border:1px solid var(--line); border-radius:8px; text-align:left; }
.chat-fold .muted { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-fold:hover { color:var(--text); border-color:var(--hover-line); }
.chat-folded { display:flex; flex-direction:column; gap:8px; padding:4px 0 4px 10px; border-left:1px solid var(--line); margin-left:12px; }
.chat-details { display:flex; flex-direction:column; gap:8px; margin:4px 0 8px 26px; min-width:0; }
.chat-out { margin:0; max-height:320px; overflow:auto; padding:9px 11px; background:var(--sunken); border:1px solid var(--line); border-radius:6px; font-family:var(--mono); font-size:12px; line-height:1.45; white-space:pre-wrap; overflow-wrap:anywhere; color:var(--text); }
.chat-out.cmd { color:var(--accent); max-height:160px; }
.chat-out.bad { border-color:color-mix(in srgb, var(--bad) 40%, transparent); }
.chat-more { align-self:flex-start; margin-top:6px; }
.chat-thinking { white-space:pre-wrap; color:var(--muted); font-size:13px; font-style:italic; }
.chat-diff { overflow-x:auto; border:1px solid var(--line); border-radius:6px; background:var(--sunken); font-family:var(--mono); font-size:12px; line-height:1.5; max-height:480px; overflow-y:auto; }
.chat-diff .dl { display:grid; grid-template-columns:42px 42px minmax(0,1fr); min-width:max-content; }
.chat-diff .ln { padding:0 6px; text-align:right; color:var(--dim); user-select:none; }
.chat-diff .tx { padding:0 10px 0 4px; white-space:pre; }
.chat-diff .add { background:var(--ok-bg); } .chat-diff .add .tx { color:var(--text); }
.chat-diff .del { background:var(--bad-bg); } .chat-diff .del .tx { color:var(--text); }
.chat-diff .hunk { color:var(--muted); background:var(--panel-2); }
.chat-todo { list-style:none; margin:2px 0 4px 26px; padding:0; font-size:13px; }
.chat-todo li { display:flex; gap:8px; color:var(--muted); } .chat-todo li.in_progress { color:var(--text); } .chat-todo li.completed { text-decoration:line-through; opacity:.7; }
.chat-kv { display:grid; grid-template-columns:max-content minmax(0,1fr); gap:3px 12px; margin:0; font-size:12px; }
.chat-kv dt { color:var(--muted); } .chat-kv dd { margin:0; font-family:var(--mono); white-space:pre-wrap; overflow-wrap:anywhere; max-height:200px; overflow:auto; }
.chat-images { display:flex; flex-wrap:wrap; gap:8px; }
.chat-img img { display:block; max-width:min(320px, 100%); max-height:240px; border-radius:6px; border:1px solid var(--line); background:var(--sunken); }
.chat-plan { padding:12px 14px; border:1px solid var(--sel-line); border-radius:10px; background:var(--panel-2); }
.chat-plan-head { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.chat-sub-result { padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:var(--sunken); font-size:13px; }
.chat-sub { display:flex; flex-direction:column; gap:6px; padding-left:10px; border-left:2px solid var(--line); }
.chat-event { display:flex; gap:8px; align-items:flex-start; font-size:12.5px; color:var(--muted); }
.chat-event pre { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; font-family:var(--mono); font-size:12px; max-height:200px; overflow:auto; }
.chat-event.bad { color:var(--bad); } .chat-event.warn { color:var(--warn); }
.chat-raw { font-size:11px; opacity:.6; }
.chat-divider { display:flex; flex-direction:column; align-items:center; gap:4px; font-size:11.5px; color:var(--muted); }
.chat-divider > span { display:flex; align-items:center; gap:10px; width:100%; }
.chat-divider > span::before, .chat-divider > span::after { content:""; flex:1; border-top:1px dashed var(--line); }
.chat-divider details { width:100%; } .chat-divider summary { text-align:center; cursor:pointer; }
.chat-earlier { align-self:center; }
.chat-main { position:relative; flex:1; min-height:0; display:flex; flex-direction:column; }
.chat-body { position:relative; flex:1; min-height:0; display:flex; }
.chat-col { flex:1; min-width:0; display:flex; flex-direction:column; }
/* the files panel (FilesPanel in chat.js): beside the conversation, over it on a narrow screen */
.chat-files { flex:0 0 min(48%, 760px); min-width:0; display:flex; flex-direction:column; border-left:1px solid var(--line); background:var(--panel); }
.chat-files[hidden] { display:none; }
.chat-files-head { display:flex; align-items:center; gap:8px; padding:8px 8px 8px 12px; border-bottom:1px solid var(--line); }
.chat-files-path { flex:1; min-width:0; display:flex; flex-direction:column; font-family:var(--mono); font-size:12.5px; }
.chat-files-path > * { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-files-path .muted { font-size:11px; direction:rtl; text-align:left; }
.chat-files-x { padding:0 8px; font-size:20px; line-height:1.1; background:transparent; border:0; color:var(--muted); }
.chat-files-x:hover { color:var(--text); }
.chat-files-bar { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:6px 12px; border-bottom:1px solid var(--line); }
.chat-files-bar .seg button { padding:3px 10px; font-size:12px; }
.chat-files-body { flex:1; min-height:0; overflow:auto; overscroll-behavior:contain; padding:10px 12px; }
.chat-files-body .chat-diff { max-height:none; overflow:visible; min-width:max-content; }
.chat-files-edit { display:flex; flex-direction:column; gap:6px; margin-bottom:16px; }
.chat-files-edit-head { display:flex; gap:10px; font-size:12px; }
.chat-files-note { padding:8px 0; font-size:13px; } .chat-files-note.bad { color:var(--bad); }
.chat-files-img img { display:block; max-width:100%; border:1px solid var(--line); border-radius:6px; background:var(--sunken); }
.chat-files-md { max-width:780px; line-height:1.6; overflow-wrap:anywhere; }
.chat-files-md img { max-width:100%; }
.chat-code { position:relative; display:grid; grid-template-columns:auto minmax(0,1fr); min-width:max-content; font-family:var(--mono); font-size:12px; line-height:18px; }
.chat-code pre { position:relative; z-index:1; margin:0; padding:8px 0; font:inherit; line-height:inherit; white-space:pre; background:none; border:0; }
.chat-code-ln { padding-right:10px !important; text-align:right; color:var(--dim); user-select:none; border-right:1px solid var(--line); }
.chat-code-tx { padding-left:12px !important; }
.chat-code-mark { position:absolute; left:0; right:0; height:18px; background:var(--sel); border-left:2px solid var(--accent); }
.chat-diff .ln.go { cursor:pointer; } .chat-diff .ln.go:hover { color:var(--accent); text-decoration:underline; }
a.chat-path { color:var(--accent); text-decoration:none; border-bottom:1px dotted color-mix(in srgb, var(--accent) 60%, transparent); cursor:pointer; }
a.chat-path:hover { border-bottom-style:solid; }
a.chat-path-guess:not(:hover) { border-bottom-style:dashed; }
.chat-edited { display:flex; flex-direction:column; gap:1px; padding:6px; background:var(--panel); border:1px solid var(--line); border-radius:8px; }
.chat-edited-head { padding:1px 8px 4px; font-size:12px; }
.chat-edited .chat-icon { color:var(--accent); }
.chat-edited-more { align-self:flex-start; margin:4px 8px 2px; }
.chat-pasted { min-width:0; }
.chat-pasted > summary { list-style:none; cursor:pointer; display:flex; gap:8px; align-items:baseline; font-size:12px; min-width:0; }
.chat-pasted-peek { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-family:var(--mono); color:var(--dim); }
.chat-pasted > summary::-webkit-details-marker { display:none; }
.chat-pasted[open] > summary .chev::before { transform:rotate(45deg); }
.chat-pasted > pre { margin-top:6px; }
.chat-jump { position:absolute; right:16px; bottom:12px; z-index:3; box-shadow:0 6px 18px rgba(0,0,0,.5); }
.chat-jump[hidden], .chat-banner[hidden] { display:none; }
.chat-banner { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0 10px 8px; padding:9px 12px; font-size:13px; border:1px solid color-mix(in srgb, var(--warn) 40%, transparent); background:var(--warn-bg); color:var(--warn); border-radius:8px; }
.chat-banner { flex-direction:column; align-items:stretch; }
.chat-banner-head { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.chat-screen { margin:0; max-height:200px; overflow:auto; padding:8px 10px; background:var(--sunken); color:var(--text); border:1px solid var(--line); border-radius:6px; font-family:var(--mono); font-size:11.5px; line-height:1.35; white-space:pre; }
.chat-screen[hidden] { display:none; }
.chat-cards { display:flex; flex-direction:column; gap:8px; max-height:60%; overflow-y:auto; padding:0 10px 8px; }
.chat-cards[hidden] { display:none; }
.chat-card { display:flex; flex-direction:column; gap:10px; max-width:900px; width:100%; margin:0 auto; padding:12px 14px; font-size:13px; background:var(--panel); border:1px solid color-mix(in srgb, var(--warn) 50%, transparent); border-radius:10px; }
.chat-card.busy { opacity:.6; }
.chat-card-head { display:flex; align-items:center; gap:8px; overflow-wrap:anywhere; }
.chat-card-head b { color:var(--warn); font-weight:600; }
.chat-card .chat-out, .chat-card .chat-diff { max-height:220px; }
.chat-card-plan { max-height:260px; overflow:auto; padding:10px 12px; background:var(--sunken); border:1px solid var(--line); border-radius:8px; }
.chat-opts { display:flex; flex-direction:column; gap:6px; }
.chat-opt { display:flex; align-items:flex-start; gap:10px; min-height:0; padding:7px 10px; text-align:left; font-weight:400; background:var(--panel-2); border:1px solid var(--line); border-radius:8px; }
.chat-opt:hover, .chat-opt.on { border-color:var(--accent); background:var(--sel); }
.chat-opt .key { flex:none; width:18px; height:18px; display:grid; place-items:center; margin-top:1px; font-family:var(--mono); font-size:11px; color:var(--muted); border:1px solid var(--line); border-radius:4px; }
.chat-opt.on .key { color:var(--accent-ink); background:var(--accent); border-color:var(--accent); }
.chat-opt-text { display:flex; flex-direction:column; gap:2px; min-width:0; overflow-wrap:anywhere; }
.chat-opt-text .muted { font-size:12px; }
.chat-q { display:flex; flex-direction:column; gap:6px; }
.chat-q-text { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
.chat-note-row { display:flex; gap:8px; }
.chat-note { flex:1; min-width:0; padding:7px 10px; font:inherit; font-size:13px; color:var(--text); background:var(--sunken); border:1px solid var(--line); border-radius:8px; }
.chat-note:focus { outline:none; border-color:var(--sel-line); }
.chat-card-foot { display:flex; gap:8px; justify-content:flex-end; }
.chat-compose { position:relative; display:flex; flex-direction:column; gap:8px; padding:10px 12px 8px; border-top:1px solid var(--line); background:var(--panel); border-radius:0; }
.chat-input-row { display:flex; align-items:flex-end; gap:8px; max-width:900px; width:100%; margin:0 auto; }
.chat-input { flex:1; min-width:0; resize:none; min-height:38px; max-height:220px; padding:9px 12px; font:inherit; font-size:14px; line-height:1.4; color:var(--text); background:var(--sunken); border:1px solid var(--line); border-radius:10px; }
.chat-input:focus { outline:none; border-color:var(--sel-line); }
.chat-input:disabled { opacity:.6; }
.chat-attach { flex:none; width:38px; height:38px; padding:0; font-size:20px; line-height:1; border-radius:10px; }
.chat-send { flex:none; height:38px; padding:0 16px; border-radius:10px; }
.chat-stop { flex:none; height:38px; color:var(--bad); border-color:color-mix(in srgb, var(--bad) 40%, transparent); border-radius:10px; }
.chat-stop[hidden], .chat-ask[hidden], .chat-slash[hidden] { display:none; }
.chat-chips { display:flex; flex-wrap:wrap; gap:6px; max-width:900px; width:100%; margin:0 auto; }
.chat-chips:empty { display:none; }
.chat-chip { display:inline-flex; align-items:center; gap:6px; max-width:240px; padding:3px 4px 3px 4px; font-size:12px; background:var(--panel-2); border:1px solid var(--line); border-radius:8px; }
.chat-chip.bad { border-color:color-mix(in srgb, var(--bad) 50%, transparent); color:var(--bad); }
.chat-chip img { width:28px; height:28px; object-fit:cover; border-radius:5px; }
.chat-chip .name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-chip .x { padding:0 6px; min-height:0; font-size:14px; line-height:1.2; background:transparent; border:0; color:var(--muted); }
.chat-chip .x:hover { color:var(--text); }
.chat-ask { display:flex; flex-direction:column; gap:8px; max-width:900px; width:100%; margin:0 auto; padding:9px 12px; font-size:13px; background:var(--warn-bg); color:var(--warn); border:1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius:8px; }
.chat-ask-draft { font-family:var(--mono); font-size:12px; color:var(--text); white-space:pre-wrap; overflow-wrap:anywhere; }
.chat-slash { position:absolute; left:12px; right:12px; bottom:100%; z-index:4; max-width:900px; margin:0 auto 6px; max-height:300px; overflow:auto; padding:4px; background:var(--panel); border:1px solid var(--line); border-radius:10px; box-shadow:0 10px 30px rgba(0,0,0,.45); }
.chat-slash-item { display:flex; align-items:center; gap:10px; width:100%; min-height:0; padding:6px 9px; text-align:left; font:inherit; font-size:13px; color:var(--text); background:transparent; border:0; border-radius:6px; }
.chat-slash-item.sel, .chat-slash-item:hover { background:var(--sel); }
.chat-slash-item .name { flex:none; font-family:var(--mono); font-size:12.5px; color:var(--accent); }
.chat-slash-item .desc { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--muted); font-size:12px; }
.chat-pending { margin-top:22px; }
.chat-pending:empty { display:none; }
.chat-user.pending { opacity:.75; border-style:dashed; }
.chat-user.pending.failed { opacity:1; border-color:color-mix(in srgb, var(--bad) 50%, transparent); }
.chat-pending-state { display:flex; align-items:center; gap:7px; font-size:11.5px; color:var(--muted); }
.chat-user.pending.failed .chat-pending-state { color:var(--bad); }
.chat-user.queued { border-style:dashed; }
.chat.drop { outline:2px dashed var(--accent); outline-offset:-4px; }
.chat-foot { display:flex; align-items:center; gap:12px; padding:8px 12px; border-top:1px solid var(--line); font-size:11.5px; }
.chat-pill { display:inline-flex; align-items:center; gap:7px; color:var(--text); white-space:nowrap; }
.chat-foot-note { flex:1; min-width:0; }
.chat-usage { font-family:var(--mono); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
.chat-usage[hidden] { display:none; }
.chat-usage.hot { color:var(--warn); }
/* the live task list above the composer */
.chat-todos { max-width:900px; width:calc(100% - 20px); margin:0 auto 8px; border:1px solid var(--line); border-radius:8px; background:var(--panel); max-height:40%; overflow-y:auto; }
.chat-todos[hidden] { display:none; }
.chat-todos-head { display:flex; align-items:center; gap:8px; width:100%; padding:6px 10px; font:inherit; font-size:13px; text-align:left; color:var(--text); background:transparent; border:0; }
.chat-todos-head .muted { flex:none; font-size:12px; }
.chat-todos .chat-todo { margin:0 0 8px 34px; }
/* text Claude is still writing (MessageDisplay), until the transcript has the message */
.chat-assistant.streaming > .md > :last-child::after { content:"▍"; margin-left:2px; color:var(--accent); animation:chat-caret 1s steps(1) infinite; }
@keyframes chat-caret { 50% { opacity:0; } }
.chat-dialog { width:min(1040px, 96vw); height:min(88dvh, 1000px); padding:14px 16px 16px; }
.chat-dialog[open] { display:flex; flex-direction:column; gap:12px; }
.chat-dialog-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.chat-dialog-head .muted { font-size:11px; margin-top:4px; overflow-wrap:anywhere; }
#chat-dialog-body { flex:1; min-height:0; display:flex; }
#chat-dialog-body .chat { flex:1; height:auto; }
@media (max-width:900px) {
  .chat-files { position:absolute; inset:0; z-index:6; border-left:0; border-radius:8px 8px 0 0; }
}
@media (max-width:700px) {
  .chat { height:calc(100dvh - 260px); }
  .chat-scroll { padding:12px 12px 8px; }
  .chat-user { max-width:92%; }
  .chat-details, .chat-todo { margin-left:8px; }
  .chat-foot-note { display:none; }
  .chat-usage { flex:1; }
  .chat-compose { padding:8px 8px 6px; }
  .chat-input, .chat-note { font-size:16px; } /* under 16px, iOS zooms the page on focus */
  .chat-cards { padding:0 6px 6px; }
  .chat-opt .key { display:none; }
  .chat-send { padding:0 12px; }
}
/* highlight.js, in the console's palette */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color:#c4a7f0; }
.hljs-string, .hljs-attr-value, .hljs-regexp { color:#b5df8c; }
.hljs-number, .hljs-literal { color:#f0b77e; }
.hljs-comment, .hljs-quote { color:#6c776e; font-style:italic; }
.hljs-title, .hljs-section, .hljs-function .hljs-title { color:#8cc8f0; }
.hljs-attr, .hljs-variable, .hljs-template-variable, .hljs-property { color:#e6c07b; }
.hljs-meta, .hljs-type { color:#7fd6c2; }
.hljs-deletion { color:var(--bad); } .hljs-addition { color:var(--ok); }
:root[data-theme="wave-light"] .hljs-keyword, :root[data-theme="wave-light"] .hljs-selector-tag, :root[data-theme="wave-light"] .hljs-built_in { color:#7a3fb0; }
:root[data-theme="wave-light"] .hljs-string, :root[data-theme="wave-light"] .hljs-attr-value, :root[data-theme="wave-light"] .hljs-regexp { color:#3b7a1f; }
:root[data-theme="wave-light"] .hljs-number, :root[data-theme="wave-light"] .hljs-literal { color:#a5560f; }
:root[data-theme="wave-light"] .hljs-comment, :root[data-theme="wave-light"] .hljs-quote { color:#8a8190; }
:root[data-theme="wave-light"] .hljs-title, :root[data-theme="wave-light"] .hljs-section, :root[data-theme="wave-light"] .hljs-function .hljs-title { color:#1f63a8; }
:root[data-theme="wave-light"] .hljs-attr, :root[data-theme="wave-light"] .hljs-variable, :root[data-theme="wave-light"] .hljs-template-variable, :root[data-theme="wave-light"] .hljs-property { color:#8a5a00; }
:root[data-theme="wave-light"] .hljs-meta, :root[data-theme="wave-light"] .hljs-type { color:#147a68; }

/* ---------------------------------------------------------------- type and finish */
/* Instrument Sans for text, Bricolage Grotesque for names and titles (both OFL, in vendor/fonts). */
@font-face { font-family:"Instrument Sans"; font-style:normal; font-weight:400 700; font-display:swap; src:url(/vendor/fonts/instrument-sans-latin.woff2) format("woff2"); }
@font-face { font-family:"Bricolage Grotesque"; font-style:normal; font-weight:600 700; font-display:swap; src:url(/vendor/fonts/bricolage-grotesque-latin.woff2) format("woff2"); }
:root { --sans:"Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; --display:"Bricolage Grotesque", var(--sans); }
body { font-family:var(--sans); }
.brand { font-family:var(--display); font-size:19px; font-weight:700; letter-spacing:-.02em; }
.brand-mark { width:30px; height:30px; }
h1 { font-family:var(--display); font-size:22px; font-weight:700; letter-spacing:-.02em; }
dialog h3, .card h2 { font-family:var(--display); font-weight:700; letter-spacing:-.01em; }
/* status dots: working is go (green), waiting on you is amber, idle is an empty ring */
.dot.working, .dot.busy { background:var(--ok); box-shadow:none; }
.dot.idle { background:transparent; box-shadow:inset 0 0 0 1.5px var(--muted); }
.dot.waiting_input, .dot.waiting { background:var(--warn); }
/* pill switches */
.subnav { padding:3px; border-radius:999px; background:var(--sunken); }
.subnav button { min-height:30px; padding:4px 13px; border-radius:999px; font-size:12.5px; }
.subnav button.active { background:var(--panel-2); color:var(--text); font-weight:600; }
.seg { padding:3px; gap:2px; border-radius:999px; background:var(--sunken); }
.seg button, .seg button + button { min-height:28px; padding:4px 13px; border:0; border-radius:999px; }
.seg button.on { background:var(--panel-2); color:var(--text); font-weight:600; }
/* chat: bubbles for you, a rounded box to type in */
.chat-list { max-width:820px; }
.chat-user { background:var(--panel-2); border:0; border-radius:18px 18px 4px 18px; padding:11px 16px; }
.chat-compose { border-top:0; background:transparent; padding:6px 0 4px; }
.chat-input-row { max-width:820px; align-items:center; padding:6px 6px 6px 10px; background:var(--panel); border:1px solid var(--line); border-radius:22px; }
.chat-input-row:focus-within { border-color:var(--sel-line); }
.chat-input { background:transparent; border:0; padding:8px 4px; }
.chat-attach { border:0; background:transparent; border-radius:999px; }
.chat-send, .chat-stop { border-radius:999px; }
.chat-foot { border-top:0; max-width:820px; width:100%; margin:0 auto; padding:4px 12px 0; }
.pane .chat-compose, .pane .chat-foot { background:transparent; }

/* ---------------------------------------------------------------- phones: give the conversation the screen */
@media (max-width:700px) {
  /* one row: ☰, pages (swipe), connection, + */
  .console .topbar { flex-wrap:nowrap; gap:10px; padding:8px 12px; padding-top:max(8px, env(safe-area-inset-top)); }
  .brand > span { display:none; }
  .brand-mark { width:30px; height:30px; }
  .console nav { order:0; flex:1 1 auto; flex-basis:auto; min-width:0; margin:0; padding:0; }
  .console nav button { flex:none; min-height:36px; padding:6px 12px; font-size:14px; }
  .topbar-right { gap:8px; flex:none; }
  #refresh-btn, #new-session-btn .label { display:none; }
  #new-session-btn { width:36px; min-height:36px; height:36px; padding:0; font-size:20px; line-height:1; border-radius:50%; }
  .drawer-btn { width:36px; height:36px; min-height:36px; }
  .brand { display:none; }
  /* the session: title and Remote Control on one line, then the actions */
  body[data-tab="console"] main { padding:10px 14px max(6px, env(safe-area-inset-bottom)); }
  .console-view { gap:10px; }
  .pane { gap:8px; }
  .pane-id { flex-wrap:nowrap; width:100%; }
  .pane h2 { font-size:18px; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .pane h2 #pane-label { overflow:hidden; text-overflow:ellipsis; }
  .pane-id .chip.mono, .pane-meta { display:none; }
  .pane-id .chip { flex:none; }
  .pane-actions button, .pane-actions .seg button { min-height:34px; }
  .chat-compose { padding-top:4px; }
  .chat-foot { padding-top:2px; }
}


/* ---------------------------------------------------------------- Advanced → System: machine usage and capacity */
.sys-headline { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:20px; margin-bottom:16px; }
.sys-big { display:flex; align-items:baseline; gap:12px; flex-wrap:wrap; }
.sys-big b { font-size:40px; line-height:1; font-weight:600; letter-spacing:-1px; color:var(--accent); font-variant-numeric:tabular-nums; }
.sys-big span { color:var(--muted); font-size:14px; }
.sys-blocked { margin-top:12px; padding:9px 12px; border-radius:8px; background:var(--warn-bg); color:var(--warn); font-size:12.5px; }
.sys-math { list-style:none; margin:14px 0 0; padding:0; display:grid; gap:6px; font-size:12.5px; color:var(--muted); font-variant-numeric:tabular-nums; }
.sys-math li > span:first-child { display:inline-block; min-width:76px; color:var(--dim); font-size:10px; text-transform:uppercase; letter-spacing:.6px; }
.sys-math li.binds { color:var(--text); }.sys-math li.binds > span:first-child { color:var(--accent); }
.sys-math b { color:var(--text); }
.sys-meters { display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:14px; }
.use-card { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:16px 18px; min-width:0; }
.use-head { display:flex; justify-content:space-between; align-items:baseline; gap:10px; margin-bottom:10px; }
.use-head span { color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.8px; }
.use-head b { font-size:14px; font-weight:560; font-variant-numeric:tabular-nums; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.use-bar { display:flex; height:10px; border-radius:6px; overflow:hidden; background:var(--sunken); border:1px solid var(--line); }
.use-bar .seg { display:block; height:100%; transition:width .4s ease; }
.seg.lw { background:var(--accent); }.seg.out { background:var(--warn); }.seg.rest { background:var(--toggle); }.seg.free { background:transparent; }.seg.warn { background:var(--bad); }
.use-legend { display:flex; flex-wrap:wrap; gap:4px 12px; margin-top:10px; font-size:11px; color:var(--muted); font-variant-numeric:tabular-nums; }
.use-legend span { display:inline-flex; align-items:center; gap:5px; }
.use-legend i { width:8px; height:8px; border-radius:2px; display:inline-block; }.use-legend i.free { border:1px solid var(--line); background:var(--sunken); }
.use-sub { margin-top:8px; font-size:11px; color:var(--dim); font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
#sys-runs-table th:first-child, #sys-outside-table th:first-child { width:46%; }
#sys-outside-table th:first-child { width:22%; }#sys-outside-table th:nth-child(2) { width:34%; }
#sys-runs-table td, #sys-outside-table td { font-variant-numeric:tabular-nums; }
#sys-outside-table td.trunc { max-width:none; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sys-note { font-size:11.5px; margin:14px 2px 0; }
@media (max-width:540px) { .sys-headline { padding:16px; } .sys-big b { font-size:34px; } .use-card { padding:14px 16px; } .sys-meters { grid-template-columns:1fr; } }
.sys-cwd { color:var(--dim); font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }

/* ---------------------------------------------------------------- folder browser */
/* The 📁 inside a path field opens it: recent folders to tap, or the disk one folder at a time. */
.pp input { padding-right:40px; }
.pp-browse { position:absolute; top:50%; right:3px; transform:translateY(-50%); width:34px; height:30px; min-height:0; padding:0; display:grid; place-items:center; color:var(--muted); background:transparent; border:0; border-radius:6px; }
.pp-browse::before { content:""; width:17px; height:17px; background:currentColor; -webkit-mask:var(--folder-icon) center / contain no-repeat; mask:var(--folder-icon) center / contain no-repeat; }
.pp-browse { --folder-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M1.75 4.25a1 1 0 0 1 1-1h3.5l1.5 1.5h5.5a1 1 0 0 1 1 1v6.75a1 1 0 0 1-1 1H2.75a1 1 0 0 1-1-1z'/%3E%3C/svg%3E"); }
.pp-browse:hover { color:var(--text); background:var(--hover); }
@media (pointer:coarse) {
  .pp-browse { width:42px; height:36px; color:var(--accent); }
  .pp input { padding-right:48px; }
  .pp-item { padding:12px; font-size:13.5px; white-space:normal; overflow-wrap:anywhere; }
}
.dir-dialog[open] { display:flex; flex-direction:column; gap:12px; width:min(560px, calc(100vw - 32px)); height:min(80dvh, 680px); padding:20px; }
.dir-head { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.dir-head h3 { margin:0; }
.dir-tabs { flex:none; align-self:flex-start; }
.dir-tabs button { min-height:34px; padding:6px 18px; font-size:13px; }
.dir-crumbs { flex:none; display:flex; align-items:center; gap:2px; overflow-x:auto; scrollbar-width:none; white-space:nowrap; font-size:13px; }
.dir-crumbs::-webkit-scrollbar { display:none; }
.dir-crumbs[hidden] { display:none; }
.dir-crumbs button { flex:none; min-height:32px; padding:4px 8px; font:inherit; color:var(--accent); background:transparent; border:0; border-radius:6px; }
.dir-crumbs button:hover { background:var(--hover); }
.dir-crumbs button.here { color:var(--text); font-weight:600; }
.dir-sep { color:var(--dim); }
#dir-filter { flex:none; width:100%; font-size:16px; }
.dir-list { flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; display:flex; flex-direction:column; gap:2px; margin:0 -6px; padding:0 6px; }
.dir-row { display:flex; align-items:stretch; gap:2px; }
.dir-item { flex:1; min-width:0; min-height:48px; display:flex; align-items:center; gap:12px; padding:8px 12px; text-align:left; font:inherit; color:var(--text); background:transparent; border:0; border-radius:10px; }
.dir-item:hover, .dir-into:hover { background:var(--hover); }
.dir-name { flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; font-size:15px; font-weight:500; overflow-wrap:anywhere; }
.dir-name small { color:var(--muted); font-family:var(--mono); font-size:11.5px; font-weight:400; }
.dir-src { flex:none; color:var(--dim); font-size:11.5px; }
.dir-go { flex:none; color:var(--dim); font-size:20px; }
.dir-into { flex:none; width:48px; min-height:48px; padding:0; font-size:20px; color:var(--dim); background:transparent; border:0; border-radius:10px; }
.dir-foot { flex:none; display:flex; }
.dir-foot button { flex:1; min-height:46px; font-size:15px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dir-foot button[hidden] { display:none; }
@media (max-width:700px) {
  .dir-dialog[open] { width:100%; max-width:100%; height:100dvh; max-height:100dvh; margin:0; border-radius:0; padding:max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); }
}
