/* zynAI: neutral zinc surfaces, true-black dark mode, one violet accent. Tokens first; everything else uses them. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#fafafa, #000000);
  --surface: light-dark(#ffffff, #0d0d0f);
  --surface-2: light-dark(#f4f4f5, #151518);
  --surface-3: light-dark(#e4e4e7, #1e1e22);
  --text: light-dark(#18181b, #f2f2f3);
  --muted: light-dark(#52525b, #a3a3ad);
  --border: light-dark(#e4e4e7, #26262b);
  --border-strong: light-dark(#d4d4d8, #3d3d45);
  --accent: light-dark(#6d28d9, #7c3aed);
  --on-accent: #ffffff;
  --link: light-dark(#6d28d9, #b8a4fb);
  --good: light-dark(#166534, #86efac); --good-bg: light-dark(#e3f6e8, #0f3322);
  --warn: light-dark(#92400e, #fcd34d); --warn-bg: light-dark(#fff1d6, #3b2c0a);
  --bad: light-dark(#b91c1c, #fca5a5); --bad-bg: light-dark(#fde4e4, #3b1218);
  --radius: 16px; --radius-sm: 10px;
  --shadow: light-dark(0 8px 28px rgba(24,24,27,.07), 0 8px 28px rgba(0,0,0,.45));
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.55 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 12px; }
a { color: var(--link); }
.muted, .meta { color: var(--muted); font-size: .9rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; padding: 8px 16px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; font-weight: 600; transition: background .12s, border-color .12s; }
button:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, black); border-color: color-mix(in srgb, var(--accent) 86%, black); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: var(--border); }
button.danger { color: var(--bad); }
button.small { padding: 4px 11px; font-size: .85rem; white-space: nowrap; flex: none; }
input, select, textarea { width: 100%; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 12px; }
label > input, label > select { margin-top: 5px; font-weight: 400; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.error { color: var(--bad); background: var(--bad-bg); border-radius: var(--radius-sm); padding: 9px 13px; font-weight: 600; }
.ok { color: var(--good); background: var(--good-bg); border-radius: var(--radius-sm); padding: 9px 13px; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grow { flex: 1; }
.pill { white-space: nowrap; flex: none; display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--surface-3); color: var(--muted); }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--link); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* shell */
.topbar { display: flex; align-items: center; gap: 6px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; margin-right: 14px; letter-spacing: -.02em; }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.nav a { padding: 7px 14px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--on-accent); }
.badge { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 7px; font-size: .75rem; margin-left: 6px; }
.icon-btn { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; border-radius: 50%; background: var(--surface-2); border-color: var(--border); }
.page { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
.page-narrow { max-width: 460px; margin: 10vh auto; padding: 0 20px; }
.center { text-align: center; }
.section { margin-bottom: 32px; }
.section > .row { margin-bottom: 12px; }
.empty { color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 28px; text-align: center; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.segmented button { border: 0; background: transparent; padding: 6px 16px; }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); color: var(--text); }
.session-card { display: flex; flex-direction: column; gap: 6px; }
.session-card h3 { margin: 0; }
.session-card .row:last-child { margin-top: 6px; }
.linkbox { margin-top: 12px; padding: 14px; background: var(--good-bg); border-radius: var(--radius-sm); }
.linkbox p { color: var(--text); margin-bottom: 8px; }
.linkrow { display: flex; gap: 8px; } .linkrow input { font-family: var(--mono); font-size: .82rem; }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 24px; width: min(480px, 92vw); box-shadow: var(--shadow); }
dialog.resizable { resize: both; overflow: auto; min-width: 300px; min-height: 160px; max-width: 98vw; max-height: 96vh; }
.modal-drag { cursor: move; touch-action: none; user-select: none; }
dialog::backdrop { background: rgba(0,0,0,.55); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; max-width: 90vw; }

/* the terminal workspace */
.workspace { display: flex; flex-direction: column; height: calc(100vh - 57px); }
/* Once signed in the page is exactly the screen: the bar on top, the rest scrolls inside (no stray bar at the very bottom). */
#app:has(> .topbar) { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
#app:has(> .topbar) > .app-body { flex: 1; min-height: 0; display: flex; }
.app-content { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.app-content > main { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.app-content > .workspace { flex: 1; min-height: 0; height: auto; }
.workspace[hidden] { display: none; }
.ws-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.tabs { min-width: 0; display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: thin; }
.tab { display: flex; align-items: center; gap: 2px; padding: 2px 4px 2px 4px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; cursor: pointer; max-width: 260px; }
.tab[data-active="true"] { background: var(--surface); border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.tab .t { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .9rem; padding: 4px 8px; border-radius: 8px; }
.tab .x { padding: 0 6px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; font-size: 1rem; line-height: 1.3; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: #22c55e; } .dot.ended { background: var(--bad); } .dot.connecting { background: #f59e0b; }
.panes { flex: 1; display: grid; gap: 10px; padding: 10px; min-height: 0; }
.pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.pane.focused { border-color: var(--accent); }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; white-space: nowrap; overflow: hidden; border-bottom: 1px solid var(--border); background: var(--surface-2); min-height: 40px; }
.pane-title { flex: 0 1 auto; min-width: 40px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.pane-title[contenteditable="true"] { outline: 2px solid var(--accent); border-radius: 4px; padding: 0 4px; }
.pane-body { flex: 1; min-height: 0; position: relative; background: var(--term-bg, #0b0b0d); padding: 6px 4px 2px 8px; }
.pane-body .xterm { height: 100%; } .pane-body .xterm-viewport { background-color: transparent !important; }
.overlay { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 12px; background: color-mix(in srgb, var(--surface) 88%, transparent); z-index: 5; padding: 20px; }
.usage-chip { white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); font-size: .8rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; font-family: inherit; color: var(--text); }
.usage-chip:hover { border-color: var(--accent); }
.tmux-toggle { width: auto; padding: 6px 16px; border-radius: 999px; font-weight: 700; border: 2px solid var(--accent); background: transparent; color: var(--accent); cursor: pointer; }
.tmux-toggle[aria-checked="true"] { background: var(--accent); color: #fff; }
.usage-box { flex: none; display: grid; gap: 1px; padding: 4px 12px; border-radius: 12px; background: var(--surface-3); font-size: .78rem; line-height: 1.35; white-space: nowrap; }
.usage-box .ub-row { display: flex; align-items: center; gap: 8px; } .usage-box b { min-width: 60px; }
.usage-box .meter.wide { width: 90px; flex: none; } .usage-box .ub-note { font-size: .72rem; opacity: .75; }
.meter { width: 44px; height: 6px; background: var(--border-strong); border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; }
.meter > i { display: block; height: 100%; background: var(--accent); } .meter.hot > i { background: #f59e0b; } .meter.max > i { background: #ef4444; }
.usage-panel { position: absolute; top: 44px; right: 10px; z-index: 30; width: min(340px, 90%); }
.usage-panel .card { padding: 16px; }
.usage-panel .bar { height: 9px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 4px 0 2px; }
.usage-panel .bar > i { display: block; height: 100%; background: var(--accent); } .usage-panel .bar.hot > i { background: #f59e0b; } .usage-panel .bar.max > i { background: #ef4444; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0 0; } .kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 800px) { .panes { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: none !important; grid-auto-rows: minmax(260px, 1fr); } .topbar { flex-wrap: wrap; } }

/* session tab state: working pulses, yellow = asking you, light purple = done unread, red = error; tool logos */
.ssh-logo { width: auto; font: 700 .75rem ui-monospace, monospace; color: var(--accent); }
.tool-logo { width: 16px; height: 16px; flex: none; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tab[data-state="working"] { border-color: var(--accent); background: linear-gradient(100deg, var(--surface-2) 30%, color-mix(in srgb, var(--accent) 45%, var(--surface-2)) 50%, var(--surface-2) 70%) 100% 0 / 300% 100%; animation: tab-wave 1.6s linear infinite; }
.tab[data-state="waiting"] { border-color: #eab308; background: color-mix(in srgb, #eab308 28%, var(--surface-2)); }
.tab[data-state="unread"] { border-color: #a78bfa; background: color-mix(in srgb, #c4b5fd 38%, var(--surface-2)); }
.tab[data-state="error"] { border-color: #ef4444; background: color-mix(in srgb, #ef4444 24%, var(--surface-2)); }
@property --wave { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes pane-wave { to { --wave: 360deg; } }
.pane.working::after { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 2px; pointer-events: none; z-index: 5; background: conic-gradient(from var(--wave), transparent 0 55%, var(--accent) 85%, #fff 100%); -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); animation: pane-wave 5s linear infinite; }
@media (prefers-reduced-motion: reduce) { .pane.working::after { animation: none; background: var(--accent); } }
@keyframes tab-wave { to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .tab[data-state="working"] { animation: none; background: color-mix(in srgb, var(--accent) 28%, var(--surface-2)); } }
.usage-box[data-warn="hot"] { background: color-mix(in srgb, #f59e0b 28%, var(--surface-3)); outline: 1px solid #f59e0b; }
.usage-box[data-warn="max"] { background: color-mix(in srgb, #ef4444 30%, var(--surface-3)); outline: 1px solid #ef4444; }
.usage-box .ub-warn { font-weight: 700; }
.usage-box { position: relative; }
.usage-pop { display: none; position: absolute; top: 100%; right: 0; margin-top: 6px; z-index: 40; width: 340px; white-space: normal; font-size: .9rem; line-height: 1.55; padding: 16px; }
.usage-box:hover .usage-pop, .usage-box:focus-within .usage-pop, .usage-box:focus .usage-pop { display: block; }
.usage-pop .bar { height: 9px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 4px 0 2px; }
.usage-pop .bar > i { display: block; height: 100%; background: var(--accent); } .usage-pop .bar.hot > i { background: #f59e0b; } .usage-pop .bar.max > i { background: #ef4444; }

.ws-bar > :not(.tabs) { flex: none; }
.modal-x { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; padding: 0; font-size: 1.4rem; line-height: 1; }
.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.pane-head[draggable="true"] { cursor: grab; }
.ws-bar { position: relative; }
.hidden-menu { position: absolute; top: 100%; left: 14px; z-index: 40; display: grid; gap: 2px; padding: 6px; min-width: 220px; }
.hidden-menu button { display: flex; align-items: center; gap: 6px; justify-content: flex-start; text-align: left; }
.hidden-btn[data-state="working"], .hidden-menu [data-state="working"] { color: var(--accent); }
.hidden-btn[data-state="waiting"], .hidden-menu [data-state="waiting"] { color: #ca8a04; }
.hidden-btn[data-state="unread"], .hidden-menu [data-state="unread"] { color: #8b5cf6; }
.hidden-btn[data-state="error"], .hidden-menu [data-state="error"] { color: #ef4444; }
.ws-bar { position: relative; }
.hidden-menu { position: absolute; top: 100%; left: 14px; z-index: 40; display: grid; gap: 2px; padding: 6px; min-width: 220px; }
.hidden-menu button { display: flex; align-items: center; gap: 6px; justify-content: flex-start; text-align: left; }
.hidden-btn[data-state="working"], .hidden-menu [data-state="working"] { color: var(--accent); }
.hidden-btn[data-state="waiting"], .hidden-menu [data-state="waiting"] { color: #ca8a04; }
.hidden-btn[data-state="unread"], .hidden-menu [data-state="unread"] { color: #8b5cf6; }
.hidden-btn[data-state="error"], .hidden-menu [data-state="error"] { color: #ef4444; }

/* chat */
.chat-layout { display: grid; grid-template-columns: var(--side-w, 220px) minmax(0, 1fr) 250px; height: 100%; min-height: 0; }
.chat-layout[data-aside="closed"] { grid-template-columns: var(--side-w, 220px) minmax(0, 1fr); }
.chat-layout[data-aside="closed"] .chat-aside { display: none; }
.chat-side { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-right: 1px solid var(--border); overflow-y: auto; background: var(--surface); }
.chat-side { min-height: 0; }
.chat-side a { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-side a:hover { background: var(--surface-2); }
.chat-side a[aria-current="page"] { background: var(--surface-3); font-weight: 700; }
.chat-side .primary-link { background: var(--accent); color: var(--on-accent); font-weight: 700; text-align: center; border-radius: 999px; margin-bottom: 8px; }
.chat-side .primary-link:hover { background: color-mix(in srgb, var(--accent) 86%, black); }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 18px 24px 20px; max-width: 860px; width: 100%; margin: 0 auto; overflow-y: auto; }
.chat-hero { margin: auto 0 18px; text-align: center; }
.chat-thread { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 14px 0; }
.chat-head { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.chat-box { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.chat-box textarea { border: 0; resize: none; box-shadow: none; padding: 4px; background: transparent; }
.chat-box textarea:focus { box-shadow: none; }
.msg.user { align-self: flex-end; max-width: 80%; background: var(--surface-3); border-radius: var(--radius); padding: 8px 14px; }
.msg.user p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant { overflow-wrap: anywhere; }
.chat-status { color: var(--muted); font-size: .9rem; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h2, .md h3, .md h4 { margin: 18px 0 6px; } .md ul, .md ol { margin: 0 0 12px; padding-left: 24px; }
.md code { font: .88em var(--mono); background: var(--surface-3); padding: 1px 5px; border-radius: 6px; }
.md-code { margin: .6em 0; } .md-code pre { margin: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; } .md-code-foot { display: flex; justify-content: space-between; align-items: center; padding: 2px 8px; background: var(--surface-2); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); font-size: .72rem; color: var(--muted, inherit); } .md-copy { padding: 1px 8px; font-size: .72rem; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; } .md pre code { background: none; padding: 0; }
.md sup.cite { color: var(--link); font-weight: 700; font-size: .75em; }
.run-out { margin-top: 12px; max-height: 420px; overflow: auto; border-top: 1px solid var(--border); padding-top: 12px; }
@media (max-width: 900px) { .chat-layout, .chat-layout[data-aside="closed"] { grid-template-columns: 1fr; height: auto; } .chat-aside { padding: 0 16px 16px; } }
@media (max-width: 760px) { .chat-layout { grid-template-columns: 1fr; height: auto; } .chat-side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); } }
.admin-chip { flex: none; white-space: nowrap; padding: 4px 12px; border-radius: 999px; background: var(--surface-3); font-size: .8rem; font-weight: 600; margin-right: 6px; }
.admin-chip:not([hidden]) { display: inline-block; }
.joblog { max-height: 260px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; font: .78rem/1.4 var(--mono); white-space: pre-wrap; }
.versions { max-height: 280px; overflow: auto; } .version { padding: 4px 0; border-bottom: 1px solid var(--border); flex-wrap: nowrap; } .version code { font-family: var(--mono); color: var(--muted); }
dialog:has(.conn), dialog:has(.ce) { width: min(760px, 94vw); max-height: 92vh; overflow: auto; }
dialog:has(.versions) { width: min(720px, 94vw); }
.panes { position: relative; }
.splitter { position: absolute; z-index: 5; background: transparent; touch-action: none; }
.splitter.col { top: 10px; bottom: 10px; width: 10px; cursor: col-resize; } .splitter.row { left: 10px; right: 10px; height: 10px; cursor: row-resize; }
.splitter:hover, .splitter:focus-visible, .panes.resizing .splitter { background: var(--accent); opacity: .55; outline: 0; }
.panes.resizing { user-select: none; } .panes.resizing .pane-body { pointer-events: none; }
@media (max-width: 800px) { .splitter { display: none; } }
.pane.floating { position: absolute; resize: both; box-shadow: 0 10px 30px rgba(0,0,0,.45); min-width: 280px; min-height: 160px; }
.pane.floating .pane-head { cursor: move; touch-action: none; }
@media (max-width: 800px) { .pane.floating { position: relative; left: auto !important; top: auto !important; width: auto !important; height: auto !important; resize: none; } }
.tool-menu { position: fixed; z-index: 100; padding: 3px; width: max-content; max-width: 90vw; } .tool-menu button { width: 100%; text-align: left; padding: 5px 10px; font-size: .85rem; font-weight: 500; border-radius: 8px; }
.admin-chip { position: relative; }
.admin-pop { display: none; position: absolute; top: 100%; left: 0; margin-top: 6px; z-index: 40; width: 360px; white-space: normal; font-weight: 400; font-size: .85rem; line-height: 1.5; padding: 14px; }
.admin-chip:hover .admin-pop, .admin-chip:focus .admin-pop, .admin-chip:focus-within .admin-pop { display: block; }
.admin-user { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 5px 0; border-top: 1px solid var(--border); } .admin-user > :nth-child(3) { grid-column: 1 / -1; font-variant-numeric: tabular-nums; }
.ai-bubble { position: fixed; right: 20px; bottom: 20px; z-index: 50; width: min(380px, calc(100vw - 40px)); display: grid; gap: 10px; padding: 14px; }
.ai-log { max-height: 300px; overflow: auto; display: grid; gap: 8px; align-content: start; }
.ai-msg { padding: 8px 12px; border-radius: 14px; background: var(--surface-2); font-size: .9rem; white-space: pre-wrap; max-width: 92%; }
.ai-msg.me { background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); justify-self: end; } .ai-msg.error { color: var(--bad); background: var(--bad-bg); }

/* chat: projects, files, pickers */
.chat-item { display: flex; align-items: center; gap: 2px; border-radius: var(--radius-sm); } .chat-item:hover { background: var(--surface-2); }
.chat-item a { flex: 1; min-width: 0; } .chat-item button { visibility: hidden; padding: 2px 8px; } .chat-item:hover button, .chat-item:focus-within button { visibility: visible; }
.proj > summary { display: flex; align-items: center; gap: 6px; cursor: pointer; padding-right: 4px; } .proj > summary a { flex: 1; min-width: 0; font-weight: 600; } .proj .chat-item { margin-left: 12px; }
.chat-aside { align-self: start; max-height: 100%; overflow-y: auto; padding: 18px 16px 0 0; display: flex; flex-direction: column; gap: 12px; } /* small floating windows, not a full-height column */
.panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; background: var(--surface); box-shadow: var(--shadow); max-height: 40vh; overflow-y: auto; } .panel > summary { cursor: pointer; font-weight: 700; }
.panel-actions { margin: 8px 0; }
.files { list-style: none; margin: 8px 0 0; padding: 0; } .files li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-top: 1px solid var(--border); } .files a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-note { font-size: .85rem; margin: 8px 0 0; } .pad { padding: 8px; }
.pickers { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 2px 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.pick { display: inline-flex; align-items: center; gap: 4px; margin: 0; padding: 0 2px 0 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; font-size: .78rem; font-weight: 600; color: var(--muted); transition: border-color .12s; }
.pick:hover { border-color: var(--border-strong); } .pick:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.pick select { appearance: none; width: auto; margin: 0; padding: 5px 26px 5px 4px; border: 0; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%238a8a94' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center; color: var(--text); font-size: .85rem; font-weight: 600; cursor: pointer; border-radius: 999px; box-shadow: none; max-width: 190px; text-overflow: ellipsis; }
.pick select:focus { box-shadow: none; } .pick select:disabled { opacity: .55; cursor: not-allowed; }
.pick option { background: var(--surface); color: var(--text); font-weight: 400; }
.proj-card { margin: 14px 0; } .check { display: flex; gap: 12px; align-items: flex-start; } .check input { width: auto; margin-top: 4px; }
.code-editor { font-family: var(--mono); font-size: .85rem; line-height: 1.5; tab-size: 4; white-space: pre; overflow: auto; background: var(--surface-2); }

/* chat sidebar: folding sections, fold-away, drag to resize */
.chat-side { position: relative; overflow: visible; padding: 0; }
.side-top { display: flex; align-items: center; gap: 6px; padding: 14px 14px 6px; } .side-top .primary-link { flex: 1; margin: 0; } .fold { font-size: 1rem; padding: 4px 10px; }
.side-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 14px 14px; display: flex; flex-direction: column; gap: 2px; }
.sec > summary, .proj > summary { list-style: none; } .sec > summary::-webkit-details-marker, .proj > summary::-webkit-details-marker { display: none; }
.sec > summary { display: flex; align-items: center; gap: 6px; margin: 10px 4px 2px; cursor: pointer; color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.sec > summary::before, .proj > summary::before { content: "▸"; display: inline-block; width: 1em; transition: transform .12s; } .sec[open] > summary::before, .proj[open] > summary::before { transform: rotate(90deg); }
.proj > summary::before { color: var(--muted); }
.side-split { position: absolute; top: 0; right: -4px; bottom: 0; width: 8px; cursor: col-resize; z-index: 3; touch-action: none; }
.side-split:hover, .side-split:focus-visible, .chat-layout.resizing .side-split { background: var(--accent); opacity: .5; outline: 0; }
.chat-layout.resizing { user-select: none; cursor: col-resize; }
.chat-layout[data-side="closed"] { grid-template-columns: 52px minmax(0, 1fr) 250px; } .chat-layout[data-side="closed"][data-aside="closed"] { grid-template-columns: 52px minmax(0, 1fr); }
.chat-layout[data-side="closed"] .side-body, .chat-layout[data-side="closed"] .side-split, .chat-layout[data-side="closed"] .primary-link { display: none; } .chat-layout[data-side="closed"] .side-top { justify-content: center; padding: 14px 0; }
@media (max-width: 900px) { .side-split { display: none; } .chat-layout[data-side="closed"], .chat-layout[data-side="closed"][data-aside="closed"] { grid-template-columns: 1fr; } }

/* modern chevrons and quieter dropdowns (override the rules above) */
:root { --panel: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='3'/%3E%3Cpath d='M9 4v16'/%3E%3C/svg%3E"); --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3l5 5-5 5'/%3E%3C/svg%3E"); }
.sec > summary::before, .proj > summary::before { content: ""; width: 12px; height: 12px; background: currentColor; opacity: .7; -webkit-mask: var(--chev) center / contain no-repeat; mask: var(--chev) center / contain no-repeat; flex: none; }
.fold { width: 30px; height: 30px; padding: 0; border-radius: 8px; flex: none; color: var(--muted); }
.fold::before { content: ""; display: block; margin: auto; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--panel) center / contain no-repeat; mask: var(--panel) center / contain no-repeat; }
.fold:hover:not(:disabled) { color: var(--text); }
.pickers { gap: 4px; border-top: 0; margin-top: 0; padding: 2px 0 6px; }
.pick { background: transparent; border-color: transparent; padding: 0 0 0 10px; }
.pick:hover { background: var(--surface-2); border-color: transparent; }
.pick > span { font-weight: 500; opacity: .8; }
.pick select { background-image: none; padding-right: 22px; font-weight: 600; }
.pick::after { content: ""; position: absolute; right: 9px; top: 50%; width: 10px; height: 10px; margin-top: -5px; background: var(--muted); pointer-events: none; -webkit-mask: var(--chev) center / contain no-repeat; mask: var(--chev) center / contain no-repeat; transform: rotate(90deg); }
.pick { position: relative; }

/* Scheduled restarts (auto-pause): the right-hand pane, its icon and popup. */
.ws-body { flex: 1; display: flex; min-height: 0; } .ws-body > .panes { min-width: 0; }
.sched-pane { flex: none; width: 280px; overflow: auto; padding: 10px; border-left: 1px solid var(--border); background: var(--surface); }
.sched-pane.collapsed { width: 26px; padding: 0; overflow: hidden; background: var(--surface-2); }
.sched-strip { display: block; width: 100%; padding: 10px 0; border: 0; border-radius: 0; background: transparent; cursor: pointer; font-size: .95rem; line-height: 1; } .sched-strip:hover, .sched-strip:focus-visible { background: var(--surface-3); }
.sched-item { display: grid; gap: 4px; padding: 8px; margin-bottom: 6px; border-radius: 10px; background: var(--surface-3); }
.sched-menu { display: grid; gap: 8px; width: 270px; padding: 12px; } .sched-menu button { width: auto; text-align: center; }
@media (max-width: 800px) { .sched-pane:not(.collapsed) { display: none; } }

.tip { position: fixed; z-index: 200; max-width: 280px; padding: 7px 11px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: .8rem; font-weight: 500; line-height: 1.4; box-shadow: var(--shadow); pointer-events: none; }

/* admin resource monitor */
.admin-chip.hot { background: var(--bad-bg); color: var(--bad); }
.res-pop { width: 320px; } .res-row { margin: 8px 0; }
.res-bar { height: 8px; margin-top: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.res-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--good); transition: width .4s; } .res-bar > .warn { background: #d97706; } .res-bar > .bad { background: var(--bad); }
.staged { display: flex; flex-wrap: wrap; gap: 6px; } .staged .x { border: 0; background: transparent; padding: 0 0 0 6px; cursor: pointer; color: inherit; }

/* ---- phones: app-style layout (one terminal at a time, bottom-reach controls, no hover-only things) ---- */
.keybar { display: none; }
@media (max-width: 800px) {
  body { font-size: 16px; }
  input, select, textarea { font-size: 16px; } /* stops iOS zooming on focus */
  button { min-height: 40px; }
  /* top bar: brand and controls on one line, the section links scroll on their own row */
  .topbar { flex-wrap: wrap; padding: 8px 12px calc(8px) 12px; gap: 6px; }
  .brand { margin-right: 0; font-size: 1rem; }
  .nav { order: 9; flex: 0 0 100%; display: flex; overflow-x: auto; scrollbar-width: none; gap: 2px; }
  .nav a { white-space: nowrap; padding: 8px 14px; }
  /* usage: only the first row, tap it for the full detail */
  .usage-box .ub-row:nth-child(n+2), .usage-box .ub-note { display: none; }
  .usage-pop { position: fixed; left: 12px; right: 12px; top: auto; width: auto; margin-top: 0; }
  /* Code: tabs on top, one full-height terminal, extra keys pinned under it */
  html, body { overflow-x: hidden; max-width: 100%; }
  .workspace, .ws-body, .ws-bar { min-width: 0; max-width: 100%; }
  .ws-bar { padding: 6px 10px; gap: 6px; }
  .ws-bar { flex-wrap: wrap; } /* tabs get their own full-width row so the buttons can never sit over them */
  .ws-bar > .tabs { flex: 1 1 0; min-width: 0; order: -1; } /* tabs share the row with + New: one bar, more terminal */
  .tab { flex: none; }
  .ws-bar > button { min-height: 36px; padding: 4px 10px; }
  .ws-bar > .primary { margin-left: 0; }
  .row > div:has(> label > .segmented) label { display: flex; align-items: center; gap: 12px; } /* Home: "Tool" label sat flush against its switch */
  .hidden-menu { left: 10px; right: 10px; min-width: 0; }
  .tab .t { padding: 6px 10px; }
  .panes { padding: 0; gap: 0; }
  .pane { border-radius: 0; border-left: 0; border-right: 0; max-width: 100%; }
  .panes { display: block; overflow-y: auto; overflow-x: hidden; scroll-snap-type: y proximity; }
  .panes { background: var(--border-strong); } /* shows through the gaps as a divider band between stacked terminals */
  .panes > .pane:not(.floating) { height: 100%; scroll-snap-align: start; } /* one terminal fills the screen; more stack and snap */
  .panes > .pane:not(.floating):not(:last-of-type) { margin-bottom: 12px; }
  .pane-body { overflow: auto; } /* a phone follows the PC's terminal size and pans sideways */
  .pane-body .xterm { width: max-content; }
  .pane-head { min-height: 36px; padding: 4px 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } /* one swipeable row (title + buttons) instead of two: more terminal */
  .pane-head > * { flex: none; }
  .pane-body { padding: 4px 4px 0 6px; }
  .keybar { display: flex; gap: 6px; overflow-x: auto; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface-2); border-top: 1px solid var(--border); scrollbar-width: none; }
  .keybar button { flex: none; min-width: 48px; font-family: var(--mono); }
  /* Chat: fills the screen; list and files fold away; the box stays at the bottom */
  main { padding: 0; }
  .chat-layout, .chat-layout[data-aside="closed"], .chat-layout[data-side="closed"], .chat-layout[data-side="closed"][data-aside="closed"] { display: flex; flex-direction: column; height: 100%; }
  .chat-side { flex: none; padding: 0; border-right: 0; border-bottom: 1px solid var(--border); flex-direction: column; overflow: visible; }
  .chat-layout .side-top, .chat-layout[data-side="closed"] .side-top { justify-content: space-between; padding: 8px 12px; }
  .chat-layout[data-side="closed"] .primary-link { display: block; }
  /* the open list is a sheet over the conversation (no pushing the box off screen) */
  .chat-side { position: relative; z-index: 6; }
  .chat-layout[data-side="open"] .side-body { display: block; position: absolute; top: 100%; left: 0; right: 0; max-height: 70dvh; overflow-y: auto; padding: 0 12px 12px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 12px 24px rgba(0,0,0,.25); }
  .chat-layout .side-top, .chat-layout[data-side="closed"] .side-top { padding: 6px 12px; }
  .composer-hint { display: none; } /* a phone keyboard has no Shift+Enter */
  .msg.user { max-width: 90%; }
  .chat-layout[data-side="closed"] .side-body { display: none; }
  .chat-main { flex: 1; padding: 10px 12px 0; max-width: none; }
  .chat-box { position: sticky; bottom: 0; margin: 0 -4px calc(8px + env(safe-area-inset-bottom)); }
  .chat-box .pickers { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px; scrollbar-width: none; }
  .chat-box .pick { flex: none; }
  .chat-aside { flex: none; max-height: 40dvh; padding: 8px 12px; border-top: 1px solid var(--border); }
  .chat-layout[data-aside="closed"] .chat-aside { display: none; }
  /* Home and other pages */
  .grid { grid-template-columns: minmax(0, 1fr); }
  .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; } .segmented button { flex: none; white-space: nowrap; padding: 6px 14px; }
  .card:has(> table) { overflow-x: auto; }
  dialog { width: 100vw !important; max-width: 100vw; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; max-height: 92dvh; }
}

/* admin badge: small, same height as the other top-bar controls, everything else in its popup */
.admin-chip.online { padding: 6px 12px; font-size: .8rem; font-weight: 600; margin: 0 6px 0 0; }
.dock-pop { left: auto; right: 0; width: 340px; max-height: 80vh; overflow-y: auto; }
.dock-sys { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }

/* Compact bars: more room for the terminal (phones keep their larger touch targets). */
@media (min-width: 801px) {
  .ws-bar { padding: 3px 8px; gap: 6px; }
  .ws-bar button.small { padding: 2px 8px; font-size: .78rem; }
  .tab { border-radius: 8px; padding: 0 2px; }
  .tab .t { font-size: .8rem; padding: 2px 6px; gap: 5px; }
  .tab .x { font-size: .9rem; line-height: 1.1; padding: 0 4px; }
  .tab .tool-logo { width: 18px; height: 18px; }
  .pane-head { padding: 2px 8px; gap: 6px; min-height: 0; }
  .pane-head .tool-logo { width: 18px; height: 18px; }
  .pane-head .pane-title { font-size: .85rem; }
  .pane-head button.small { padding: 1px 8px; font-size: .75rem; }
  .pane-head .pill { font-size: .68rem; padding: 0 8px; line-height: 1.35; }
  .pane-head .usage-chip { font-size: .75rem; padding: 1px 8px; }
  .panes { padding: 6px; gap: 6px; }
}
.pill-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; flex: none; }
.workspace.popout { height: 100vh; }
.workspace.popout .ws-bar { display: none; }
button.pause-btn { box-sizing: border-box; padding: 0; width: 20px; height: 20px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: .65rem; line-height: 1; opacity: .5; }
button.pause-btn:hover:not(:disabled) { opacity: 1; }
button.pause-btn.on, button.pause-btn.on:hover:not(:disabled) { opacity: 1; background: var(--accent); border-color: var(--accent); color: #fff; }
.usage-pop [role="tab"][aria-selected="true"] { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.profile-menu { left: auto; min-width: 220px; } .profile-menu .pm-who { padding: 4px 12px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; }
.sched-pane.collapsed .icon-btn { width: 100%; height: 30px; border-radius: 0; border: 0; background: transparent; } .sched-pane.collapsed .icon-btn:hover { background: var(--surface-3); }

/* the side rail: always thin; its buttons open floating boxes */
.dock { flex: none; width: 34px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-left: 1px solid var(--border); background: var(--surface); overflow: hidden; }
.dock-btn { position: relative; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: var(--radius-sm); font: 700 1rem var(--font); color: var(--text); }
.dock-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.dock-btn .badge { position: absolute; top: -2px; right: -2px; margin: 0; padding: 0 5px; font-size: .65rem; }
@media (max-width: 800px) { .dock { display: none; } }
.float-win { position: fixed; z-index: 60; display: flex; flex-direction: column; padding: 0; overflow: hidden; min-width: 300px; min-height: 180px; box-shadow: 0 14px 40px rgba(0,0,0,.35); }
.fw-head { display: flex; align-items: center; gap: 4px; padding: 1px 4px 1px 10px; font-size: .8rem; border-bottom: 1px solid var(--border); background: var(--surface-2); cursor: move; touch-action: none; user-select: none; }
.fw-body { flex: 1; min-height: 0; overflow: auto; padding: 12px; }
.float-win .workspace { height: 100%; } .float-win .page { padding: 4px; max-width: none; } .float-win:has(.workspace) .fw-body { padding: 0; display: flex; flex-direction: column; } .float-win .workspace:not([hidden]) { flex: 1; min-height: 0; }
/* the profile drop-down: only as wide as its words */
.profile-menu { width: max-content; min-width: 0; max-width: 240px; padding: 6px; border-radius: 12px; }
.profile-menu button { white-space: nowrap; padding: 7px 12px; border-radius: 8px; font-weight: 500; }
.profile-menu .pm-who { max-width: 220px; white-space: nowrap; }
.dock .icon-btn { width: 30px; height: 30px; font-size: .9rem; }
.mode-icon { flex: none; cursor: help; font-size: .8rem; line-height: 1; color: var(--muted); } .mode-icon.tmux { color: #22c55e; } .mode-icon:hover, .mode-icon:focus-visible { color: var(--text); }

/* layout choices follow the screen: none on phones, up to two on tablets */
@media (max-width: 800px) { .layouts { display: none; } }
@media (max-width: 1100px) { .layouts [data-layout="3"], .layouts [data-layout="4"] { display: none; } }
.ai-body { display: flex; flex-direction: column; gap: 6px; padding: 8px; overflow: hidden; }
.ai-tabs { display: flex; gap: 2px; flex: none; } .ai-tabs [aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
.ai-stage { flex: 1; min-height: 0; overflow: auto; } .ai-thread { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; font-size: .9rem; overflow-wrap: anywhere; } .ai-thread .msg { min-width: 0; } .ai-thread pre, .ai-thread table { max-width: 100%; overflow-x: auto; } .ai-thread img { max-width: 100%; height: auto; } .ai-in { width: 100%; box-sizing: border-box; }
.ai-bar { display: flex; gap: 6px; flex: none; } .ai-model { flex: 1; min-width: 0; margin: 0; padding: 4px 6px; font-size: .8rem; }
.ai-in { flex: none; resize: none; }

/* usage: lives in its own floating box; the details show inline there instead of on hover */
.fw-usage .usage-box { padding: 0; background: none; white-space: normal; font-size: .85rem; outline: 0; }
.fw-usage .usage-box .ub-note { display: block; }
.fw-usage .usage-pop { display: block; position: static; width: auto; margin: 10px 0 0; padding: 12px; box-shadow: none; }
.fw-usage .usage-off { display: none; } .fw-usage .usage-box[hidden] + .usage-off { display: block; }

/* profile: just an initials circle */
.avatar { width: 34px; height: 34px; padding: 0; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-size: .8rem; letter-spacing: .02em; }
.avatar:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, black); border-color: transparent; }

/* usage box: docked under the top bar beside the rail until you float it */
.float-win.docked { right: 38px !important; left: auto !important; top: 40px !important; resize: none; }
.float-win.docked .fw-head { cursor: default; }

/* slimmer top bar (desktop) */
@media (min-width: 801px) {
  .topbar { padding: 3px 10px; gap: 4px; }
  .brand { font-size: .95rem; gap: 7px; margin-right: 8px; } .brand img { width: 20px; height: 20px; border-radius: 6px; }
  .nav a { padding: 3px 10px; font-size: .85rem; }
  .avatar { width: 26px; height: 26px; font-size: .7rem; } .topbar .icon-btn { width: 26px; height: 26px; }
  .admin-chip.online { padding: 2px 10px; font-size: .75rem; }
}

/* floated usage box: only the session limits, as the old top-bar summary showed them */
.usage-win:not(.docked) { min-height: 0; } .usage-win:not(.docked) .usage-pop { display: none; } .usage-win:not(.docked) .fw-body { padding: 8px 12px; }

/* top bar: the two plan-limit bars, side by side, nothing else */
.limits-bar { display: flex; gap: 14px; padding: 2px 10px; font-size: .72rem; }
.limits-bar .meter.wide { width: 70px; }
.limits-bar .ub-row b { min-width: 0; }
@media (max-width: 800px) { .limits-bar .ub-row span:last-child { display: none; } .limits-bar .meter.wide { width: 44px; } }
.limits-bar { cursor: pointer; } .limits-bar:hover { background: var(--surface-3); }
.zoom-reset { min-width: 2.2em; font-variant-numeric: tabular-nums; } .zoom-reset[title^="Zoom is"] { opacity: .55; cursor: default; }
.follow-ask { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; font-size: .85rem; background: var(--surface-2); border-bottom: 1px solid var(--border); } .follow-ask span { flex: 1 1 200px; }
@media (max-width: 800px) { .follow-ask { padding: 4px 8px; gap: 6px; font-size: .78rem; } .follow-ask button { min-height: 28px; padding: 2px 10px; font-size: .78rem; } }

/* chat, Kagi-style: quiet sidebar, centred column, big rounded composer with a toolbar and round send button */
.chat-side { background: var(--surface-2); }
.chat-side .primary-link { border-radius: 12px; }
.chat-item a { font-size: .92rem; } .chat-item a[aria-current="page"] { background: var(--surface-3); }
.chat-main { max-width: 780px; }
.chat-head { border-bottom: 0; }
.msg.assistant { line-height: 1.65; }
.chat-box { border-radius: 22px; padding: 12px 14px 8px; box-shadow: 0 2px 14px rgba(0,0,0,.08); }
.chat-box:focus-within { border-color: var(--accent); }
.chat-box textarea { font-size: 1rem; min-height: 52px; }
.staged:empty { display: none; } .chat-box .staged { margin: 4px 0; }
.composer-bar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.composer-bar .pickers { padding: 0; display: contents; }
.composer-bar > .small { border-radius: 999px; color: var(--muted); }
.send { width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 1.15rem; line-height: 1; flex: none; }
.composer-hint { font-size: .75rem; text-align: center; padding: 4px 0 0; }
.chat-aside { padding-top: 18px; }
.chat-aside .panel { border-radius: 14px; box-shadow: none; background: var(--surface-2); }

.chat-item { position: relative; } .chat-item .chat-menu { position: absolute; right: 4px; top: 100%; z-index: 20; display: flex; flex-direction: column; min-width: 110px; padding: 4px; background: var(--surface); border: 1px solid var(--border, var(--surface-3)); border-radius: var(--radius-sm); box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
.chat-item .chat-menu[hidden] { display: none; } .chat-item .chat-menu button { visibility: visible; text-align: left; }
.chat-item .more[aria-expanded="true"] { visibility: visible; }

.md img { max-width: 100%; max-height: 320px; border-radius: var(--radius-sm); display: block; margin: 8px 0; }
.md-table { overflow-x: auto; margin: 0 0 12px; } .md table { border-collapse: collapse; font-size: .92em; } .md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; } .md th { background: var(--surface-3); }
.sources { list-style: none; margin: 8px 0 0; padding: 0; } .sources a { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; color: inherit; text-decoration: none; overflow-wrap: anywhere; } .sources a:hover span:first-child { text-decoration: underline; }
.sources .meta { display: block; } .sources img, .sources .fav { flex: none; width: 16px; height: 16px; margin-top: 3px; border-radius: 3px; } .sources .fav { background: var(--surface-3); font-size: .65rem; font-weight: 700; display: grid; place-items: center; }
.md-sources { margin: 12px 0 0; border-top: 1px solid var(--border); padding-top: 8px; } .md-sources > summary { cursor: pointer; font-weight: 700; } .md-sources[open] > summary { margin-bottom: 6px; }
.md sup.cite a { color: inherit; text-decoration: none; } .md sup.cite a:hover { text-decoration: underline; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.share-page { max-width: 820px; margin: 0 auto; padding: 24px 16px; } .share-card { padding: 20px 24px; } .share-card h1 { margin-top: 0; font-size: 1.4rem; }
.nt-pane { display: flex; flex-direction: column; gap: 6px; padding: 8px; min-width: 0; min-height: 0; overflow: auto; }
.nt-title { flex: 1; min-width: 0; margin: 0; font-weight: 700; }
.nt-edit { flex: 1; min-height: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.nt-text { height: 100%; resize: none; margin: 0; font-family: var(--mono, ui-monospace, monospace); font-size: .85rem; }
.nt-prev { overflow: auto; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); } .nt-pdf { width: 100%; height: 100%; min-height: 60vh; border: 0; } .nt-prev:has(.nt-pdf) { padding: 0; }
.nt-prev .math.block { overflow-x: auto; }
.nt-bar { display: flex; flex-wrap: wrap; gap: 2px; } .nt-bar button { min-width: 28px; padding: 2px 6px; }
.md blockquote { margin: 0 0 12px; padding: 2px 12px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md li.task { list-style: none; margin-left: -20px; } .md li.task input { width: auto; margin: 0 6px 0 0; } .md li > ul, .md li > ol { margin-bottom: 0; }
.md mark { background: color-mix(in srgb, gold 45%, transparent); color: inherit; padding: 0 2px; } .md del { opacity: .7; }
/* Documents > JupyterLab */
.jl-sec { margin: 0 0 18px; } .jl-sec h4 { margin: 0 0 6px; }
.jl-sec form.row { margin-top: 8px; } .jl-sec form.row input { flex: 1 1 140px; min-width: 0; }
.jl-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
/* A lab fills the whole window below the title bar (the title bar holds its name and buttons). */
.float-win.lab-view .fw-body { position: relative; padding: 0; overflow: hidden; }
.float-win.lab-view .jl-embed { position: absolute; inset: 0; }
.fw-extra { display: contents; }
.float-win:active iframe { pointer-events: none; } /* dragging or resizing the window must not lose the mouse to a frame */
/* Dock / Full for floating windows (floatwin.js): the same box, pinned beside the page or filling it. Rail 38px. */
.float-win.lw-dock, .float-win.lw-full { position: fixed; top: var(--top-h, 33px) !important; bottom: 0 !important; height: auto !important; resize: none; border-radius: 0; box-shadow: none; }
.float-win.lw-dock { right: 38px !important; left: auto !important; width: var(--side-w, 45vw) !important; max-width: none; border-width: 0 0 0 1px; }
.float-win.lw-full { left: 0 !important; right: 38px !important; width: auto !important; max-width: none; }
.float-win.lw-dock .fw-head, .float-win.lw-full .fw-head { cursor: default; }
body.side-docked .app-content { margin-right: var(--side-w, 45vw); }
.lw-split { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 3; touch-action: none; }
.lw-split:hover { background: color-mix(in srgb, var(--accent, #6b8afd) 35%, transparent); }
@media (max-width: 800px) { .float-win.lw-full { right: 0 !important; } }
/* phones: every floating window is a full-width sheet under the top bar (like dialogs), no drag/resize */
@media (max-width: 800px) { .float-win { left: 0 !important; right: 0 !important; top: var(--top-h, 33px) !important; bottom: 0 !important; width: auto !important; height: auto !important; min-width: 0; max-width: none; border-radius: 0; box-shadow: none; resize: none; } .float-win .fw-rs { display: none; } }

/* Session bar in a narrow workspace (data-room is set from the workspace's own width, so docking a panel counts): the layout choices fold into one menu button, the new-session button shortens. */
.layout-menu-btn { display: none; } .layouts .lbl { display: none; }
.workspace[data-room="2"] .layout-menu-btn, .workspace[data-room="1"] .layout-menu-btn { display: inline-flex; align-items: center; }
.workspace[data-room="2"] .layouts, .workspace[data-room="1"] .layouts { display: none; position: absolute; top: 100%; right: 8px; z-index: 40; flex-direction: column; align-items: stretch; gap: 2px; padding: 6px; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.workspace[data-room="2"] .layouts.open, .workspace[data-room="1"] .layouts.open { display: flex; }
.workspace[data-room="2"] .layouts button, .workspace[data-room="1"] .layouts button { display: flex; justify-content: flex-start; gap: 8px; text-align: left; }
.workspace[data-room="2"] .layouts .lbl, .workspace[data-room="1"] .layouts .lbl { display: inline; }
.workspace[data-room="2"] .layouts [data-layout="3"], .workspace[data-room="2"] .layouts [data-layout="4"], .workspace[data-room="1"] .layouts [data-layout="2"], .workspace[data-room="1"] .layouts [data-layout="3"], .workspace[data-room="1"] .layouts [data-layout="4"] { display: none; }
.workspace[data-room="2"] .nl-long, .workspace[data-room="1"] .nl-long { display: none; }
.tabs { flex: 1 1 120px; }
@media (max-width: 800px) { .layout-menu-btn { display: none !important; } }

/* Thin title bars for every floating window: more of the window is the content. */
.fw-head strong { font-size: .8rem; font-weight: 700; }
.fw-head button { padding: 0 8px; min-height: 0; font-size: .75rem; line-height: 1.5; }
.fw-head .fw-extra button { font-size: .85rem; padding: 0 9px; }
/* Resize handles on every edge and corner (floatwin.js); a docked or full window does not use them. */
.fw-rs { position: absolute; z-index: 5; touch-action: none; }
.fw-rs-n, .fw-rs-s { left: 12px; right: 12px; height: 6px; cursor: ns-resize; } .fw-rs-n { top: 0; } .fw-rs-s { bottom: 0; }
.fw-rs-e, .fw-rs-w { top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; } .fw-rs-e { right: 0; } .fw-rs-w { left: 0; }
.fw-rs-ne, .fw-rs-nw, .fw-rs-se, .fw-rs-sw { width: 14px; height: 14px; }
.fw-rs-ne { top: 0; right: 0; cursor: nesw-resize; } .fw-rs-sw { bottom: 0; left: 0; cursor: nesw-resize; } .fw-rs-nw { top: 0; left: 0; cursor: nwse-resize; } .fw-rs-se { bottom: 0; right: 0; cursor: nwse-resize; }
.float-win.docked .fw-rs, .float-win.lw-dock .fw-rs, .float-win.lw-full .fw-rs { display: none; }

/* FTP window: servers on the left, files on the right, a viewer in place of the list */
.ftp { display: flex; gap: 8px; height: 100%; align-items: stretch; } .ftp-side { flex: 0 0 168px; padding: 8px; overflow: auto; }
.ftp-pane { flex: 1; min-width: 0; padding: 8px; overflow: auto; } .ftp-bar { margin: 6px 0; gap: 6px; } .ftp-sel { gap: 6px; margin-left: auto; align-items: center; }
.ftp .table th { text-align: left; font-size: .75rem; color: var(--muted); } .ftp .table td, .ftp .table th { padding: 3px 6px; } .ftp tr.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.ftp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 0; width: 100%; } .ftp-act { white-space: nowrap; text-align: right; } .ftp-act button { padding: 0 7px; }
.ftp input[type="checkbox"] { width: auto; margin: 0; } .ftp-bar .ftp-name { max-width: none; width: auto; }
.ftp-view { max-height: calc(100% - 44px); overflow: auto; } .ftp-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }
.ftp-text { margin: 0; padding: 8px; white-space: pre-wrap; word-break: break-word; font: .8rem/1.45 var(--mono, ui-monospace, monospace); background: var(--surface-2); border-radius: 8px; }
.ftp-picker { max-height: 50vh; overflow: auto; }
.float-win:has(.ftp, .docs-win) .fw-body { padding: 6px; overflow: hidden; }

/* Syntax colours (highlight.js classes), light and dark */
.hljs-comment, .hljs-quote { color: light-dark(#6b7280, #8b95a5); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag, .hljs-meta .hljs-keyword { color: light-dark(#7c3aed, #c4a1ff); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string { color: light-dark(#15803d, #86d9a0); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-variable.constant_ { color: light-dark(#b45309, #f5b971); }
.hljs-title, .hljs-title.function_, .hljs-section, .hljs-selector-id, .hljs-selector-class { color: light-dark(#1d4ed8, #82aaff); }
.hljs-built_in, .hljs-type, .hljs-class .hljs-title, .hljs-title.class_ { color: light-dark(#0e7490, #7fdbca); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-name, .hljs-tag { color: light-dark(#be185d, #f78fb3); }
.hljs-meta, .hljs-link { color: light-dark(#6b7280, #9aa5b4); } .hljs-deletion { color: light-dark(#b91c1c, #ff8a8a); }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }

/* file viewer (fileview.js) */
.fv-body { min-width: min(720px, 86vw); max-height: 70vh; overflow: auto; } .fv-img { max-width: 100%; display: block; margin: 0 auto; }
.fv-code { margin: 0; padding: 10px; background: var(--surface-2); border-radius: 8px; font: .82rem/1.5 var(--mono, ui-monospace, monospace); white-space: pre; overflow: auto; }
.fv-md { padding: 4px 8px; }

/* Chat composer: Plan card and Web search button; tool list; My files tree */
.composer-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 6px 6px; }
.mode-card { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; text-align: left; border-radius: 12px; font-weight: 500; background: var(--surface); border: 1px solid var(--border-strong); }
.mode-card .mc-text { display: grid; line-height: 1.2; } .mode-card small { color: var(--muted); font-weight: 400; font-size: .72rem; } .mode-card.mc-pill { border-radius: 999px; padding: 5px 12px; }
.mode-card[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: var(--accent); }
.tool-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); } .tool-row > :not(.grow) { width: 80px; text-align: center; } .tool-head { font-size: .8rem; color: var(--muted); }
.ft > summary { cursor: pointer; font-weight: 600; padding: 3px 0; } .ft-sub { margin-left: 14px; } .ft-sub > summary { font-weight: 500; font-size: .92rem; }
/* Composer: icon buttons, Search/Plan switch, searchable model picker that opens upward */
.composer-bar .seg-mini button { padding: 4px 12px; font-size: .82rem; }
.mp { position: relative; }
.mp-btn { background: transparent; border: 0; font-weight: 600; font-size: .85rem; padding: 6px 8px; border-radius: 999px; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-menu { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 30; width: min(340px, 86vw); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; display: grid; gap: 6px; }
.mp-menu[hidden] { display: none; }
.mp-list { max-height: 260px; overflow-y: auto; display: grid; gap: 2px; }
.mp-list button, .mp-refresh { text-align: left; background: transparent; border: 0; padding: 8px 10px; border-radius: 8px; font-weight: 500; overflow-wrap: anywhere; }
.mp-list button:hover, .mp-refresh:hover, .mp-list button[aria-selected="true"] { background: var(--surface-2); }
.mp-refresh { border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; }
.composer-bar .seg-mini button[aria-pressed="true"], .composer-bar .mode-card[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.composer-bar .seg-mini button[aria-pressed="false"] { opacity: .65; }
/* source-code notes: a coloured <pre> sits under a transparent textarea with the same metrics */
.nt-code { position: relative; min-height: 0; }
.nt-hl, .nt-over { position: absolute; inset: 0; margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); box-sizing: border-box; font: .85rem/1.45 var(--mono, ui-monospace, monospace); tab-size: 4; white-space: pre; overflow: auto; }
.nt-hl { overflow: hidden; pointer-events: none; } .nt-hl code { font: inherit; }
.nt-over { color: transparent; background: transparent; caret-color: var(--text); resize: none; } .nt-over::selection { background: color-mix(in srgb, Highlight 40%, transparent); }

/* Notes: Joplin's three panes (dark notebooks column, note list, editor) */
.nt-body { display: grid; grid-template-columns: 175px minmax(190px, 260px) minmax(0, 1fr); padding: 0; overflow: hidden; }
.nt-side { display: flex; flex-direction: column; min-height: 0; overflow: auto; padding: 8px 0; background: #2b3036; color: #dfe3e8; }
.nt-sbar { padding: 0 8px 6px; } .nt-sbar button { width: 100%; background: transparent; color: inherit; border-color: #566; }
.nt-shead { margin: 12px 10px 3px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #8c96a3; }
.nt-snote { margin: 2px 10px; font-size: .78rem; color: #8c96a3; }
.nt-srow { display: flex; align-items: center; padding-right: 8px; } .nt-srow[aria-current="true"] { background: #4a5260; } .nt-srow:hover { background: #3a414a; }
.nt-sbtn { flex: 1; min-width: 0; text-align: left; color: inherit; padding: 4px 4px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 0; }
.nt-chev { display: inline-block; width: 1em; color: #8c96a3; } .nt-count { font-size: .72rem; color: #8c96a3; }
.nt-list { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--border); }
.nt-lhead { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 6px 8px 2px; } .nt-lname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; } .nt-lhead select { width: auto; margin: 0; padding: 1px 4px; font-size: .78rem; }
.nt-ltools { padding: 4px 8px; flex-wrap: wrap; } .nt-ltools select { width: auto; margin: 0; padding: 2px 4px; font-size: .8rem; }
.nt-search { padding: 0 8px 6px; } .nt-search input { margin: 0; }
.nt-notes { flex: 1; overflow: auto; border-top: 1px solid var(--border); }
.nt-nrow { display: flex; align-items: center; gap: 6px; padding: 0 8px; border-bottom: 1px solid var(--border); } .nt-nrow:hover { background: var(--surface-2); }
.nt-nrow[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.nt-ntitle { flex: 1; min-width: 0; text-align: left; padding: 8px 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 0; } .nt-ntitle.done { text-decoration: line-through; color: var(--muted); }
.nt-date { flex: none; font-size: .7rem; color: var(--muted); } .nt-chk { width: auto; margin: 0; flex: none; }
.nt-pane { display: flex; flex-direction: column; gap: 6px; padding: 8px; min-width: 0; min-height: 0; overflow: auto; }
.nt-tags { flex-wrap: wrap; gap: 4px; } .nt-taginput { width: 110px; margin: 0; padding: 2px 8px; font-size: .8rem; }
.nt-chip { display: inline-flex; align-items: center; padding: 0 2px 0 9px; border-radius: 999px; background: var(--surface-3); font-size: .78rem; font-weight: 600; } .nt-chip button { padding: 0 6px; border: 0; font-size: .7rem; }
.nt-trashed { white-space: pre-wrap; overflow: auto; font-size: .85rem; }
@media (max-width: 800px) { .nt-body { grid-template-columns: 105px minmax(0, 1fr); grid-template-rows: minmax(0, 38%) minmax(0, 1fr); } .nt-side { grid-row: 1 / 3; } .nt-list { border-right: 0; border-bottom: 1px solid var(--border); } }
.nt-side button.ghost, .nt-side button.ghost:hover:not(:disabled) { color: inherit; background: transparent; border-color: transparent; }
.nt-list .nt-ntitle, .nt-list .nt-ntitle:hover:not(:disabled) { color: var(--text); background: transparent; border-color: transparent; } .nt-list .nt-ntitle.done { color: var(--muted); }
.nt-pane select { width: auto; margin: 0; } .nt-pane .row { gap: 6px; }

.nt-pdfbox { background: var(--surface); display: flex; flex-direction: column; height: 100%; min-height: 60vh; } .nt-pdfbar { background: var(--surface-2); display: flex; gap: 6px; padding: 4px 6px; border-bottom: 1px solid var(--border); } .nt-pdfbar select { width: auto; } .nt-pdfbox .nt-pdf { flex: 1; }
/* Print always on white: light tokens, and the dark-theme PDF inversion off. */
@media print { :root, :root[data-theme="dark"] { color-scheme: light; } body { background: #fff; } }

/* ---- Window chrome: title bars, one maximize/restore button, red close ---- */
.ic { display: inline-block; flex: none; width: 1.15em; height: 1.15em; background: currentColor; -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; vertical-align: -.2em; }
/* A bar you can drag is tinted with the theme colour; a docked or full-size one cannot move, so it stays neutral. */
.fw-head { background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); border-bottom-color: color-mix(in srgb, var(--accent) 38%, var(--border)); cursor: grab; padding-block: 3px; }
.fw-head:active { cursor: grabbing; }
.float-win.docked .fw-head, .float-win.lw-dock .fw-head, .float-win.lw-full .fw-head { background: var(--surface-2); border-bottom-color: var(--border); }
.fw-head .fw-max, .fw-head .fw-close, .modal-max, .modal-x { width: 28px; height: 24px; padding: 0; display: inline-grid; place-items: center; border-radius: 7px; font-size: .95rem; line-height: 1; flex: none; }
.fw-head .fw-close, .modal-x { background: #dc2626; border: 1px solid #b91c1c; color: #fff; }
.fw-head .fw-close:hover:not(:disabled), .modal-x:hover:not(:disabled) { background: #ef4444; border-color: #dc2626; color: #fff; }
.float-win.docked .fw-max { display: none; }
.modal-btns { position: absolute; top: 12px; right: 14px; display: flex; gap: 6px; z-index: 2; }
.modal-x { position: static; }
dialog h2.modal-drag { margin: -24px -24px 16px; padding: 14px 96px 14px 24px; font-size: 1.05rem; background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); border-bottom: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border)); border-radius: var(--radius) var(--radius) 0 0; cursor: grab; }
dialog.max h2.modal-drag { cursor: default; border-radius: 0; background: var(--surface-2); }
dialog.max { inset: 2vh 2vw !important; width: 96vw !important; height: 96vh !important; max-width: none !important; max-height: none !important; margin: 0; resize: none; overflow: auto; }

/* ---- Side rail: coloured icons ---- */
.dock-btn .ic, .dock .icon-btn .ic { width: 19px; height: 19px; vertical-align: 0; }
.dock-btn[aria-pressed="true"] .ic { color: var(--on-accent) !important; }

/* ---- Profile menu ---- */
.profile-menu { width: 288px; max-width: 92vw; padding: 8px; border-radius: 14px; }
.profile-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; font-size: .9rem; font-weight: 500; }
.profile-menu .pm-who { display: flex; align-items: center; gap: 12px; max-width: none; padding: 6px 6px 10px; border-bottom: 0; white-space: normal; }
.profile-menu .pm-who .avatar { width: 44px; height: 44px; font-size: 1rem; flex: none; }
.profile-menu .pm-who strong { display: block; overflow-wrap: anywhere; } .profile-menu .pm-who .meta { overflow-wrap: anywhere; margin-bottom: 2px; }
.pm-head { padding: 10px 10px 4px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-top: 1px solid var(--border); margin-top: 4px; }
.pm-who + .pm-head { border-top: 1px solid var(--border); }
.pm-sep { height: 1px; background: var(--border); margin: 6px 0; }
.switch { position: relative; flex: none; width: 30px; height: 17px; border-radius: 99px; background: var(--border-strong); transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: transform .15s; }
[aria-checked="true"] > .switch { background: var(--accent); } [aria-checked="true"] > .switch::after { transform: translateX(13px); }

/* ---- Online badge and usage lists ---- */
.admin-chip { cursor: pointer; }
.admin-chip.others { background: var(--good-bg); color: var(--good); box-shadow: 0 0 0 1px color-mix(in srgb, var(--good) 45%, transparent); }
dialog:has(.ulist) { width: min(980px, 96vw); }
.ulist { display: flex; flex-direction: column; }
.urow { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(70px, .6fr) minmax(0, 2fr) 120px; gap: 6px 16px; align-items: center; padding: 11px 12px; border-top: 1px solid var(--border); }
.urow.top { background: color-mix(in srgb, #f59e0b 12%, transparent); box-shadow: inset 3px 0 0 #f59e0b; }
.uwho { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; } .uwho .meta { flex-basis: 100%; padding-left: 28px; overflow-wrap: anywhere; }
.urank { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-3); color: var(--muted); font-size: .72rem; font-weight: 700; flex: none; }
.urow.top .urank { background: #f59e0b; color: #1c1100; }
.ubar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; } .ubar i { display: block; height: 100%; background: var(--accent); } .urow.top .ubar i { background: #f59e0b; }
.ustats { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: .82rem; font-variant-numeric: tabular-nums; } .ustats b { font-size: .95rem; }
.spark { width: 120px; height: 32px; display: block; border-bottom: 1px solid var(--border); } .spark rect { fill: var(--accent); } .urow.top .spark rect { fill: #f59e0b; }
.uuse { white-space: nowrap; } .uuse .spark { width: 96px; height: 24px; margin-top: 2px; }
.perms { display: flex; flex-wrap: wrap; gap: 4px 10px; max-width: 230px; } .perm { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: .8rem; font-weight: 500; color: var(--muted); } .perm input { width: auto; margin: 0; }
.help { margin: 0 0 12px; } .help summary { cursor: pointer; color: var(--muted); }
@media (max-width: 760px) { .urow { grid-template-columns: minmax(0, 1fr) 100px; } .urow .ubar { grid-column: 1 / -1; } }

/* ---- Slideable panes (drag the edge, double-click to fold) ---- */
.slide-host { position: relative; }
.slider { position: absolute; width: 10px; z-index: 6; cursor: col-resize; touch-action: none; }
.slider::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .12s; }
.slider:hover::before, .slider:focus-visible::before { background: var(--accent); }
.slider-fold { position: absolute; top: 50%; left: -3px; width: 16px; height: 34px; margin-top: -17px; padding: 0; border-radius: 8px; font-size: .85rem; line-height: 1; opacity: 0; background: var(--surface); border: 1px solid var(--border-strong); color: var(--muted); cursor: pointer; }
.slider:hover .slider-fold, .slider-fold:focus-visible, .slider-fold[aria-expanded="false"] { opacity: 1; }
.slide-host > .folded { min-width: 0; overflow: hidden; padding-left: 0; padding-right: 0; border-width: 0; visibility: hidden; }
.nt-body { grid-template-columns: var(--nt-side, 175px) var(--nt-list, 260px) minmax(0, 1fr); }
.ftp-side { flex: 0 0 var(--ftp-side, 168px); min-width: 0; }
.profile-menu button span:not(.ic):not(.grow) { white-space: normal; text-align: left; }
.page table select { width: auto; min-width: 84px; }
.page table td:first-child { min-width: 190px; }
.perms { max-width: 200px; }

/* slim toolbars: same scale as the top bar and pane headers; phones keep their 40px touch targets */
@media (min-width: 801px) {
  .nt-bar { gap: 1px; } .nt-bar button { min-width: 24px; padding: 1px 5px; font-size: .75rem; }
  .nt-pdfbar { padding: 2px 6px; gap: 4px; } .nt-pdfbar button, .nt-ltools button, .nt-sbar button, .ftp-bar button, .ai-bar button { padding: 1px 8px; font-size: .75rem; }
  .nt-pdfbar select, .ai-model { padding: 1px 4px; font-size: .75rem; }
  .nt-ltools { padding: 2px 8px; gap: 4px; } .nt-lhead { padding: 4px 8px 0; }
  .nt-sbar { padding: 0 8px 4px; }
  .ftp-bar { margin: 3px 0; gap: 4px; } .ftp-pane { padding: 6px 8px; }
  .ai-bar { gap: 4px; }
  .composer-bar { margin-top: 2px; gap: 3px; } .composer-bar .seg-mini button { padding: 2px 10px; font-size: .75rem; } .composer-bar > .small { padding: 2px 8px; font-size: .75rem; }
  .fw-head .fw-extra button { font-size: .75rem; padding: 0 7px; }
}

/* popup unity: a dialog gets the same slim title bar as a floating window, and only its content scrolls (title stays put, no nested scroll bars) */
@media (min-width: 701px) {
  dialog.resizable[open] { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
  dialog.resizable h2.modal-drag { flex: none; margin: 0; padding: 3px 90px 3px 10px; font-size: .8rem; font-weight: 700; line-height: 1.9; border-radius: 0; }
  dialog.resizable .modal-btns { top: 3px; right: 6px; gap: 4px; }
  dialog.resizable[open] > :last-child { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
  dialog.resizable .fv, dialog.resizable .fv-body { max-height: none; }
  dialog.resizable .fv-body { min-width: 0; }
  dialog.max[open] { overflow: hidden; }
  dialog.resizable > :last-child, .fw-body, .fv-body { scrollbar-width: thin; }
}
dialog:has(.fv) { width: min(760px, 94vw); }

/* dialogs open wide enough to show their forms whole; they only scroll when the screen is genuinely too small */
dialog { width: min(640px, 94vw); }
dialog.resizable { max-height: calc(100vh - 24px); }
.bulk { gap: 12px; margin: 6px 0; } .bulk label { gap: 6px; font-weight: 400; margin: 0; } .bulk input, input.bulk-box { width: auto; margin: 0; flex: none; }

/* Connections: a tidy list, the router tucked away, and a small code editor for custom APIs */
.conn-top { align-items: center; margin-bottom: 8px; } .conn-head { margin: 14px 0 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.conn-card { padding: 10px 12px; } .conn-card h3 { margin: 0; font-size: 1rem; } .conn-card .meta { overflow-wrap: anywhere; } .conn-imp { padding: 6px 0; border-bottom: 1px solid var(--border); }
.conn-router { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--border); } .conn-router summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; }
.ce { position: relative; height: 240px; resize: vertical; overflow: hidden; min-height: 100px; }

.fl-top h2 { margin: 0; font-size: 1.05rem; } .fl-h { margin: 16px 0 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fl-step { padding: 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; } .fl-step textarea { width: 100%; } .fl .ce { height: 200px; }

/* Documents (dialog from chat or profile, and the floating box): big and centred, the list scrolls inside, not the window. */
dialog:has(.docs-win) { width: min(1000px, 94vw); height: min(720px, 90vh); }
.docs-win { display: flex; flex-direction: column; height: 100%; min-height: 0; } .docs-win > .segmented { flex: none; margin-bottom: 8px; }
.docs-win > div:not(.segmented):not(.row) { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; } .docs-win .ftp { flex: 1; min-height: 0; height: auto; } .docs-win .ftp-pane { min-height: 0; }
dialog:has(.docs-win) > .docs-win { height: calc(100% - 52px); }

/* Chat sidebar, calmer: tick boxes and "Select all" only appear when you hover a row or start a selection; quiet section headers; a thin guide line under each project. */
.chat-side .side-body { gap: 0; padding: 0 10px 14px; }
.chat-side .sec > summary { margin: 14px 6px 4px; font-size: .7rem; letter-spacing: .08em; font-weight: 600; opacity: .85; }
.chat-side .sec > summary:hover { color: var(--text); }
.chat-side .chat-item { padding: 0 2px 0 6px; border-radius: 8px; min-height: 32px; gap: 4px; }
.chat-side .chat-item a { padding: 6px 4px; border-radius: 6px; font-size: .9rem; }
.chat-side .chat-item a:hover, .chat-side .chat-item a[aria-current="page"] { background: none; }
.chat-side .chat-item:has(a[aria-current="page"]) { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.chat-side .chat-item:has(a[aria-current="page"]) a { font-weight: 600; }
.chat-side .bulk-box { width: 0; opacity: 0; margin: 0; flex: none; transition: width .1s, opacity .1s; cursor: pointer; }
.chat-side .chat-item:hover .bulk-box, .chat-side .bulk-box:focus-visible, .chat-side .bulk-box:checked { width: 14px; opacity: 1; }
.chat-side .bulk { display: none; margin: 2px 6px 4px; padding: 4px 8px; font-size: .78rem; justify-content: space-between; background: var(--surface-3); border-radius: 8px; }
.chat-side :is(.sec, .proj):has(.bulk-box:checked) > .bulk { display: flex; }
.chat-side .bulk[hidden] { display: none !important; }
.chat-side .proj { margin: 2px 0; }
.chat-side .proj > summary { padding: 4px 6px; border-radius: 8px; } .chat-side .proj > summary:hover { background: var(--surface-3); }
.chat-side .proj .chat-item { margin-left: 14px; border-left: 1px solid var(--border); border-radius: 0 8px 8px 0; }
.chat-side .side-top { padding: 14px 10px 8px; }
.chat-side .primary-link { padding: 9px 12px; font-size: .92rem; }
.chat-side .sec > summary .small { opacity: .6; } .chat-side .sec > summary .small:hover { opacity: 1; }
.chat-side .small-note { margin: 2px 8px 6px; font-size: .8rem; }

/* ---- phones, app style: one slim header, content edge to edge, pill composer, round buttons ---- */
@media (max-width: 800px) {
  .topbar { flex-wrap: nowrap; padding: 8px 12px; gap: 8px; }
  .brand { font-size: 0; gap: 0; } .brand img { width: 36px; height: 36px; border-radius: 12px; } /* logo only */
  .nav { order: 0; flex: 1 1 auto; min-width: 0; flex-basis: auto; gap: 4px; }
  .nav a { padding: 8px 14px; background: transparent; }
  .nav a[aria-current="page"] { background: var(--surface-3); color: var(--text); }
  .topbar .limits-bar, .topbar .admin-chip, .topbar .grow { display: none; } /* usage stays in the avatar menu */
  .avatar { flex: none; margin-left: auto; width: 40px; height: 40px; }
  .page { padding: 16px 16px 40px; }
  h1 { font-size: 1.7rem; }
  .card { border-radius: 20px; padding: 16px; box-shadow: none; }
  button, .primary-link { border-radius: 999px; }
  .chat-side .side-top .primary-link { font-size: 1rem; padding: 10px; }
  .chat-main { padding: 6px 16px 0; }
  .chat-thread { font-size: 1.06rem; line-height: 1.6; gap: 18px; }
  .md p { margin: 0 0 14px; }
  .msg.user { border-radius: 22px; }
  .chat-box { margin: 0 -4px calc(10px + env(safe-area-inset-bottom)); border-radius: 28px; padding: 8px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.35); background: var(--surface-2); }
  .chat-box textarea { font-size: 1.05rem; padding: 6px 4px; min-height: 0; }
  .composer-bar { flex-wrap: wrap; gap: 4px; } /* no scrolling here: it would clip the model popup */
  .composer-bar .grow { flex: 1 0 8px; }
  .dock-pop, .usage-pop { max-width: calc(100vw - 24px); }
  .sched-pane { display: none; } /* the schedule strip took a bar under the keys */
}
.fab { display: none; }
@media (max-width: 800px) {
  .fab { display: block; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 15; padding: 12px 22px; font-size: 1.05rem; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
  .page { padding-bottom: 90px; }
  /* sessions read as a plain list, not a stack of boxes */
  .session-card.card { background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 12px 0; }
  .session-card h3 { font-size: 1.05rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grid { gap: 0; }
}
.flash69 { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; pointer-events: none; font: 900 min(60vw, 60vh)/1 system-ui, sans-serif; color: #ef4444; text-shadow: 0 0 40px rgba(0,0,0,.45); animation: flash69 1s ease-in-out infinite alternate; }
@keyframes flash69 { from { opacity: .55; transform: scale(.96); } to { opacity: .95; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .flash69 { animation: none; opacity: .9; } }
@media (max-width: 800px) {
  .profile-menu { right: 12px !important; left: 12px; width: auto; max-width: none; max-height: calc(100dvh - 80px); overflow-y: auto; }
  .profile-menu button { min-height: 44px; }
}
.conn-how { margin-bottom: 10px; } .conn-how summary { cursor: pointer; font-weight: 700; } .conn-how ol { margin: 6px 0; padding-left: 20px; }
.conn-tips { margin: 4px 0 10px; padding-left: 18px; font-size: .85rem; color: var(--muted); } .conn-field { margin: 6px 0; }
.conn-pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .78rem; padding: 8px; border-radius: 8px; background: var(--surface-3); }
.mp-ico { display: none; }
@media (max-width: 800px) {
  .mp { position: static; } /* the popup is sized against the whole chat box */
  .mp-name { display: none; } .mp-ico { display: inline; font-size: 1.15rem; }
  .mp-btn { min-width: 40px; background: var(--surface-3); }
  .mp-menu { left: 0; right: 0; width: auto; bottom: calc(100% + 8px); }
  .mp-list { max-height: 40dvh; }
}
@media (max-width: 800px) {
  .composer-bar .seg-mini button { padding: 4px 9px; font-size: .78rem; min-height: 34px; }
  .composer-bar > .small { padding: 4px 6px; min-width: 32px; }
  .composer-bar .send { margin-left: auto; width: 40px; height: 40px; padding: 0; }
}

/* Automations window: hero + templates, the New automation form and its trigger menu (rounded, app-style; same on desktop and phone) */
.auto h2 { font-size: 1.05rem; } .auto .segmented { margin-bottom: 14px; }
.circ { width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border-strong); font-size: 1.2rem; line-height: 1; } .circ.small { width: 30px; height: 30px; min-height: 0; }
.fw-extra .circ { margin-right: 6px; }
.auto-hero { text-align: center; padding: 20px 8px 14px; } .auto-hero h2 { font: 400 2.1rem/1.1 ui-serif, Georgia, serif; margin: 10px 0 6px; } .auto-hero .big { padding: 12px 26px; font-size: 1.05rem; margin-top: 8px; }
.auto-tiles { display: flex; justify-content: center; align-items: center; gap: 12px; height: 84px; }
.auto-tiles > span { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); color: var(--accent); } .auto-tiles > span:nth-child(2) { transform: translateY(-14px); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 14px; height: auto; background: transparent; border: 1px dashed var(--border-strong); border-radius: var(--radius); font-weight: 400; } .tpl strong { font-size: 1rem; }
.auto-form .fld { display: block; margin: 0 0 18px; } .auto-form .lbl { display: block; font-size: .95rem; font-weight: 600; margin-bottom: 7px; }
.auto-form input:not([type="checkbox"]), .auto-form textarea, .auto-form select { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.auto-form input, .auto-form textarea, .auto-form select { font-weight: 400; }
.auto-form .code-editor { font-family: var(--mono); }
.trig { position: relative; } .trig-add, .trig-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; font-weight: 400; text-align: left; }
.trig-add span { font-size: 1.3rem; line-height: 1; } .trig .meta { margin: 6px 4px 0; }
.trig-edit { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; } .trig-edit input, .trig-edit select { width: auto; padding: 6px 10px; background: var(--surface); border-radius: 10px; } .trig-edit input[type="number"] { width: 5.5em; }
.trig-menu { position: absolute; z-index: 5; left: 0; top: 52px; min-width: 240px; padding: 6px; display: flex; flex-direction: column; border-radius: 20px; box-shadow: 0 14px 40px rgba(0,0,0,.35); }
.trig-menu[hidden] { display: none; } .trig-menu button { display: flex; align-items: center; gap: 12px; justify-content: flex-start; width: 100%; min-height: 44px; border: 0; border-radius: 12px; font-weight: 400; text-align: left; }
.trig-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; font-weight: 700; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.adv { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.adv .arow { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 1rem; } .adv .arow select { width: auto; max-width: 55%; margin: 0; background: transparent; border: 0; padding: 4px 6px; text-align: right; }
.adv .arow input[type="checkbox"] { flex: none; } .adv .apad { padding: 10px 14px 0; }
