/* Termdeck — warm charcoal + ember. Cloned from the Termdeck Design System
   console kit (claude.ai/design): one dark warm-charcoal surface, a single
   ember voice, a green heartbeat for whatever is alive, Plex type. Tokens in
   tokens/; :root maps the app's semantic var names onto the DS so the markup
   and JS below never had to change — only the values. */

@import url("tokens/fonts.css");
@import url("tokens/colors.css");
@import url("tokens/typography.css");
@import url("tokens/spacing.css");
@import url("tokens/effects.css");

:root {
  /* Semantic vars kept by NAME, remapped onto the DS console kit's warm-charcoal
     palette (session-chat.html): sidebar/cards sit a step above the main+
     transcript surface; ember accent; warm stone text ramp. */
  --bg: #140f09;                    /* main + transcript surface (--panel-bg) */
  --panel: #19130b;                 /* sidebar & cards (one step up) */
  --panel-2: #1f1810;               /* raised / hover (--card-2) */
  --border: #2b231a;                /* hairline (--line) */
  --ink: #ece2d2;                   /* --fg */
  --muted: #a89a89;                 /* stone-400 (--fg-mute) */
  --faint: #857866;                 /* --fg-sub */
  --accent-rgb: 234, 127, 60;       /* ember-400 — reads as both text and tint on charcoal */
  --accent: rgb(var(--accent-rgb));
  --accent-dim: #7c3f1e;            /* dim ember for subtle borders */
  --live: #7fbf6a;                  /* warm green, legible on charcoal */
  --err: #ef8878;                   /* warm red, legible on charcoal */
  --mono: var(--font-mono);
  --sans: var(--font-sans);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ---------- sidebar ---------- */

.sidebar {
  width: var(--sidebar-w, 340px);
  min-width: 240px;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

/* account usage-limit widget pinned at the sidebar bottom */
.sidebar-foot {
  flex: none;
  position: relative;
  border-top: 1px solid var(--border);
  padding: 8px 12px 10px;
  font-family: var(--mono);
  font-size: 11px;
  height: var(--limits-h, 160px);
  min-height: 60px;
  max-height: 60vh;
}
.limits-resizer {
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  cursor: row-resize;
  touch-action: none;
  z-index: 10;
}
.limits-resizer:hover,
.limits-resizer:focus-visible {
  background: var(--accent);
  opacity: 0.4;
  outline: none;
}
.limits-content {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* one line per engine when there's no room for bars — full label/pct text,
   never truncated; wraps instead of clipping if the sidebar is narrow */
.limit-engine-condensed { display: flex; align-items: flex-start; gap: 6px; }
.limit-condensed-text { color: var(--muted); white-space: normal; }
.limit-condensed-seg.warn { color: #d98a3b; }
.limit-condensed-seg.hot { color: var(--err); }

/* grid so the label column auto-sizes to the widest label (no truncation) while
   bars stay aligned across rows; rows are display:contents to join the grid */
.limit-engine { display: grid; grid-template-columns: max-content 1fr auto; align-items: center; gap: 5px 8px; }
.limit-engine-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.limit-logo { width: 13px; height: 13px; flex: none; }
.limit-plan { color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; }
.limit-row { display: contents; }
.limit-label { color: var(--faint); white-space: nowrap; }
.limit-strip { display: flex; align-items: center; gap: 2px; height: 5px; min-width: 24px; }
.limit-seg { flex: 1; height: 100%; border-radius: 1.5px; background: #241c13; }
.limit-seg.f { background: var(--ember-500); }
.limit-seg.w { background: var(--gold-400); }
.limit-seg.hot { background: linear-gradient(90deg, var(--ember-500), var(--rose-500)); }
.limit-pct { flex: none; width: 30px; text-align: right; color: var(--muted); }

.sidebar-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -3px;
  width: 6px;
  cursor: col-resize;
  touch-action: none;
  z-index: 10;
}
.sidebar-resizer:hover,
.sidebar-resizer:focus-visible {
  background: var(--accent);
  opacity: 0.4;
  outline: none;
}

.sidebar-head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-mark { color: var(--accent); }

.brand-sub {
  margin: 4px 0 12px;
  color: var(--faint);
  font-size: 12px;
}

#filter {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
}

#filter::placeholder { color: var(--faint); }

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 24px;
}

.notice {
  color: var(--faint);
  font-size: 13px;
  padding: 8px;
}

.live-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 8px 4px;
  color: var(--live);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.live-heading.attention { color: var(--err); }

.project-group { margin-top: 6px; }

.project-group > summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  cursor: pointer;
  list-style: none;
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.project-group > summary::-webkit-details-marker { display: none; }
.project-group > summary::before {
  content: "▸";
  color: var(--faint);
  flex: none;
}
.project-group[open] > summary::before { content: "▾"; }
.project-group > summary:hover { background: var(--panel-2); }

.project-count {
  margin-left: auto;
  color: var(--faint);
  flex: none;
}

.session-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px 7px 22px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.session-row:hover { background: var(--panel-2); }

.session-row.active {
  background: var(--panel-2);
  border-left-color: var(--accent);
}

.session-title-line {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.engine-logo {
  flex: none;
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.session-title {
  display: block;
  min-width: 0;
  flex: 1;
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-row.untitled .session-title { color: var(--faint); font-style: italic; }

.session-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
}

.terminal-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--muted);
  background: currentColor;
  -webkit-mask-image: var(--ic-terminal);
  mask-image: var(--ic-terminal);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

/* "Show more" in project groups and "Show earlier" atop the transcript */
.load-more {
  display: block;
  width: calc(100% - 30px);
  margin: 4px 8px 6px 22px;
  padding: 6px 10px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

.load-more:hover { background: var(--panel-2); }

.transcript .load-more {
  max-width: 900px;
  width: 100%;
  margin: 0 auto 18px;
}

/* the heartbeat */
.live-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
}

.live-dot.busy { animation: heartbeat 1.6s ease-in-out infinite; }
.live-dot.idle { background: var(--faint); }
.live-dot.pin { background: var(--accent); }

.pin-mark {
  flex: none;
  width: 11px;
  height: 11px;
  background: var(--accent);
  -webkit-mask-image: var(--ic-pin);
  mask-image: var(--ic-pin);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

@keyframes heartbeat {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45); }
  50% { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot.busy { animation: none; }
}

/* ---------- main pane ---------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  position: absolute;
  top: 12px;
  right: 18px;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.account-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  min-height: 38px;
  padding: 5px 10px 5px 6px;
  color: var(--ink);
  background: rgba(24, 28, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  backdrop-filter: blur(10px);
}
.account-btn:hover { border-color: var(--accent-dim); }
.account-avatar {
  flex: none;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #15120c;
  background: var(--accent);
  font-weight: 800;
  font-size: 12px;
  background-size: cover;
  background-position: center;
}
.account-avatar.has-image { color: transparent; }
.account-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
.account-menu {
  pointer-events: auto;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 218px;
  padding: 6px;
  background: rgba(24, 28, 34, 0.98);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(12px);
}
.account-menu button {
  width: 100%;
  padding: 9px 10px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.account-menu button:hover { background: var(--panel-2); }
.account-menu #logout-btn { color: var(--err); }

.viewer[hidden] { display: none; } /* .viewer's display:flex otherwise beats the UA [hidden] rule */
.viewer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.viewer-head {
  padding: 14px 280px 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.viewer-head-content {
  position: relative;
  flex: 1;
  min-width: 0;
  padding-right: 38px;
}

.viewer-minimize {
  position: absolute;
  top: 0;
  right: 0;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
}
.viewer-minimize:hover {
  color: var(--ink);
  border-color: var(--accent-dim);
  background: rgba(var(--accent-rgb), 0.12);
}

.viewer-menu-btn {
  display: none;
  flex: none;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
}
.viewer-menu-btn:hover { background: rgba(var(--accent-rgb), 0.18); }

.viewer-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.viewer-title .engine-logo {
  width: 18px;
  height: 18px;
}

.viewer-title-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* always-visible run-state badge */
.status-badge {
  flex: none;
  margin-left: 0;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }

.status-responding, .status-terminal {
  color: #86e29a;
  border-color: #2f6b3a;
  background: rgba(74, 222, 128, 0.1);
}
.status-responding .status-dot, .status-terminal .status-dot { background: var(--live); animation: heartbeat 1.6s ease-in-out infinite; }

.status-paused {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(var(--accent-rgb), 0.12);
}
.status-paused .status-dot { background: var(--accent); animation: heartbeat-amber 1.6s ease-in-out infinite; }

.status-attached { color: var(--live); border-color: #2f6b3a; }
.status-attached .status-dot { background: var(--live); }

.status-idle { color: var(--faint); }
.status-idle .status-dot { background: var(--faint); }

.status-stopped { color: var(--faint); border-color: var(--border); }
.status-stopped .status-dot { background: var(--faint); }

.status-error {
  color: var(--err);
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}
.status-error .status-dot { background: var(--err); }

@media (prefers-reduced-motion: reduce) {
  .status-badge .status-dot { animation: none; }
}

.viewer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 6px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11.5px;
}

.viewer-meta .live-flag { color: var(--live); display: inline-flex; align-items: center; gap: 6px; }
.viewer-meta .live-flag.gone { color: var(--faint); }
.ping-badge {
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  background: rgba(var(--accent-rgb), 0.06);
  white-space: nowrap;
}
.ping-badge.stale { color: var(--faint); background: transparent; }

/* token / context-window strip under the meta line — expandable breakdown */
.ctx-fold { margin-top: 5px; }
.ctx-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11.5px;
  cursor: pointer;
  list-style: none;
}
.ctx-strip::-webkit-details-marker { display: none; }
.ctx-strip:hover .ctx-label { color: var(--ink); }
.ctx-caret { flex: none; color: var(--faint); transition: transform 0.15s ease; display: inline-block; }
.ctx-fold[open] .ctx-caret { transform: rotate(90deg); }
.ctx-label { flex: none; color: var(--muted); }
.ctx-io { flex: none; }
.ctx-cost {
  flex: none;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 0 4px;
  font-weight: 600;
}
.ctx-bar {
  flex: 1;
  min-width: 40px;
  max-width: 220px;
  height: 5px;
  border-radius: 3px;
  background: var(--panel-2);
  overflow: hidden;
}
.ctx-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; }
.ctx-bar-fill.hot { background: var(--err); }

/* expanded breakdown */
.ctx-breakdown {
  margin: 8px 0 2px 16px;
  max-width: 460px;
  font-family: var(--mono);
  font-size: 11px;
}
.ctx-seg-bar {
  display: flex;
  height: 7px;
  border-radius: 4px;
  background: var(--panel-2);
  overflow: hidden;
  margin-bottom: 8px;
}
.ctx-seg { height: 100%; }
.ctx-seg.seg-cached { background: #7a5f3a; }
.ctx-seg.seg-write { background: #a87d45; }
.ctx-seg.seg-fresh { background: var(--accent); }
.ctx-legend { display: flex; flex-direction: column; gap: 3px; }
.ctx-legend-row { display: flex; align-items: center; gap: 8px; }
.ctx-dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.ctx-dot.seg-cached { background: #7a5f3a; }
.ctx-dot.seg-write { background: #a87d45; }
.ctx-dot.seg-fresh { background: var(--accent); }
.ctx-dot.seg-free { background: var(--panel-2); border: 1px solid var(--border); }
.ctx-legend-label { color: var(--muted); }
.ctx-legend-val { margin-left: auto; color: var(--faint); }
.ctx-aside { margin-top: 7px; color: var(--faint); }

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 26px 40px 10px;
  scroll-behavior: auto;
}

.notice-line {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  padding: 8px 0;
}
.loading-line { color: var(--accent); }

/* user turns read as shell prompts; assistant turns read as prose */
.msg { max-width: 980px; margin: 0 auto 10px; }

.msg-user {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  color: var(--accent);
  padding: 8px 12px;
  background: rgba(var(--accent-rgb), 0.06);
  border-left: 2px solid var(--accent-dim);
  border-radius: 0 6px 6px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-user .prompt-mark {
  color: var(--accent);
  font-weight: 700;
  margin-right: 8px;
  user-select: none;
}

.msg-assistant {
  font-size: 15px;
  line-height: 1.6;
}

.msg-time {
  display: block;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
  margin: 0 0 3px 2px;
}

/* markdown body */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0.55em 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1em 0 0.4em; line-height: 1.3; }
.md h1 { font-size: 1.25em; } .md h2 { font-size: 1.15em; } .md h3 { font-size: 1.05em; }
.md ul, .md ol { margin: 0.4em 0; padding-left: 1.4em; }
.md li { margin: 0.15em 0; }
.md code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 4px;
}
.md pre {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
}
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: 0.6em 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 10px; font-size: 0.92em; }
.md blockquote {
  margin: 0.6em 0;
  padding: 2px 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.md a { color: var(--accent); }
.md hr { border: 0; border-top: 1px solid var(--border); }

/* collapsible machinery: tools, thinking, results */
details.fold {
  margin: 5px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  font-family: var(--mono);
  font-size: 12px;
}

details.fold > summary {
  padding: 6px 12px;
  cursor: pointer;
  color: var(--muted);
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: baseline;
  overflow: hidden;
  white-space: nowrap;
}

details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--faint); flex: none; }
details.fold[open] > summary::before { content: "▾"; }
details.fold > summary:hover { color: var(--ink); }

.fold-label { color: var(--ink); font-weight: 600; flex: none; }
.fold-preview { color: var(--faint); overflow: hidden; text-overflow: ellipsis; }

details.fold pre {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 420px;
  overflow-y: auto;
  color: var(--muted);
}

details.fold pre.error { color: var(--err); }
details.thinking > summary .fold-label { color: var(--faint); font-weight: 400; font-style: italic; }

.tool-result-slot:empty { display: none; }
.tool-result-slot .result-tag {
  display: block;
  padding: 4px 12px 0;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.tool-result-slot pre { border-top: 0; }

.command-chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
}

.command-chip .cmd { color: var(--accent); }

.image-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
}

/* Task checklist lines (TaskCreate/TaskUpdate) */
.task-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
  padding: 2px 0;
  color: var(--ink);
}
.task-line .task-icon { flex: none; }
.task-line .task-tag { color: var(--faint); font-size: 11px; }
.task-line .task-subject { flex: 1 1 auto; }
.task-line .task-status {
  flex: none;
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
}
.task-in_progress .task-icon { color: var(--accent); }
.task-completed .task-icon { color: #46a758; }
.task-completed .task-subject { color: var(--muted); text-decoration: line-through; }
.task-cancelled .task-icon,
.task-deleted .task-icon { color: var(--faint); }
.task-cancelled .task-subject,
.task-deleted .task-subject { color: var(--faint); text-decoration: line-through; }

/* Background-agent wake-ups (async Agent task completions/kills) */
.task-notif-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
  padding: 2px 0;
  color: var(--ink);
}
.task-notif-line .task-notif-icon { flex: none; }
.task-notif-line .task-notif-summary { flex: 1 1 auto; color: var(--muted); }
.task-notif-line .task-notif-status {
  flex: none;
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
}
.task-notif-completed .task-notif-icon { color: var(--live); }
.task-notif-stopped .task-notif-icon { color: var(--err); }

/* Rewind checkpoint markers */
.checkpoint-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  padding: 3px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  border-left: 2px solid var(--border);
}
.checkpoint-line .checkpoint-icon { color: var(--muted); }
.checkpoint-line .checkpoint-label { color: var(--muted); }
.checkpoint-line .checkpoint-time { margin-left: auto; }
.checkpoint-restore {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  cursor: pointer;
}
.checkpoint-line .checkpoint-time + .checkpoint-restore { margin-left: 8px; }
.checkpoint-restore:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.checkpoint-restore:disabled { opacity: 0.5; cursor: default; }

/* Edit/Write/MultiEdit diffs */
.diff {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  margin: 4px 0 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.diff-line { display: flex; white-space: pre; }
.diff-gutter {
  flex: none;
  width: 20px;
  text-align: center;
  color: var(--faint);
  user-select: none;
}
.diff-text { flex: 1 1 auto; padding-right: 8px; }
.diff-add { background: rgba(70, 167, 88, 0.14); }
.diff-add .diff-gutter { color: #46a758; }
.diff-del { background: rgba(224, 84, 84, 0.14); }
.diff-del .diff-gutter { color: #e05454; }
.diff-ctx { color: var(--muted); }
.diff-trunc { padding: 2px 8px; color: var(--faint); font-size: 11px; }

.msg-image {
  display: block;
  max-width: min(420px, 100%);
  max-height: 320px;
  width: auto;
  height: auto;
  margin: 6px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  object-fit: contain;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
}
.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 6px;
}

/* Off-canvas drawer controls — hidden on desktop, shown in the mobile query. */
.drawer-toggle { display: none; }
.drawer-backdrop { display: none; }

@media (max-width: 860px) {
  .drawer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 60;
    width: 44px;
    height: 44px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--ink);
    font-size: 18px;
    cursor: pointer;
  }
  body.viewer-active .drawer-toggle { display: none; }

  .viewer-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(var(--sidebar-w, 320px), 92vw);
    min-width: 0;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .app.drawer-open .sidebar { transform: translateX(0); }

  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(0, 0, 0, 0.5);
  }
  .drawer-backdrop[hidden] { display: none; }

  .main { width: 100%; }
  .transcript { padding: 16px 12px 40px; }
  .viewer-head {
    align-items: center;
    padding: 10px 12px;
  }

  /* Touch targets */
  .session-row { min-height: 44px; }
  .perm-btn { min-height: 44px; }
  .send-btn { min-height: 44px; }
  .composer-side select { min-height: 32px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* ================= phase 2: alive & interactive ================= */

.reconnect-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: #7a2e2e;
  color: #fff;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.push-bell {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  opacity: 0.6;
}
.push-bell.on { opacity: 1; }
.push-bell:disabled { opacity: 0.3; cursor: default; }

.new-chat-btn,
.limit-refresh-btn {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
}
.limit-refresh-btn {
  color: var(--muted);
  background: transparent;
  border-color: var(--border);
}
.new-chat-btn:hover,
.limit-refresh-btn:hover:not(:disabled) { background: rgba(var(--accent-rgb), 0.18); }
.limit-refresh-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent-dim);
}
.limit-refresh-btn:disabled { opacity: 0.55; cursor: default; }

@keyframes heartbeat-amber {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45); }
  50% { box-shadow: 0 0 0 5px rgba(var(--accent-rgb), 0); }
}

/* composer */
.composer {
  position: relative;
  border-top: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(20, 22, 27, 0.96), rgba(18, 20, 25, 0.98)),
    var(--panel);
  padding: 6px 16px 8px;
}

.composer-resizer {
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  touch-action: none;
  z-index: 10;
}
.composer-resizer:hover,
.composer-resizer:focus-visible {
  background: var(--accent);
}
@media (max-width: 860px) {
  /* Same centerline as desktop (top:-3px, height:6px → center at 0), just a
     much bigger invisible grab zone — a 6px strip is unhittable by touch. */
  .composer-resizer { top: -22px; height: 44px; }
}

.run-status {
  max-width: 980px;
  margin: 0 auto 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  min-height: 18px;
}

.run-status-label {
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.run-status .status-badge {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.composer-row {
  display: grid;
  grid-template-areas:
    "input input"
    "subagents side";
  grid-template-columns: 1fr auto;
  gap: 6px;
  max-width: 980px;
  margin: 0 auto;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  padding: 12px 14px;
}
.composer-row:focus-within {
  border-color: var(--ember-500);
  box-shadow: 0 0 0 3px rgba(226, 97, 27, 0.18);
}

#composer-input {
  grid-area: input;
  width: 100%;
  resize: none;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.45;
  padding: 7px 0;
  height: var(--composer-input-h, 42px);
  min-height: 42px;
  max-height: 50vh;
}
#composer-input:focus { outline: none; }
#composer-input:disabled { opacity: 0.5; }

/* --- Composer Layout Modes --- */

/* Small mode (height < 60px): Minimal spacing, side buttons on the right, and input cropped in */
.composer.composer-s {
  padding: 4px 16px 6px;
}
.composer.composer-s .composer-row {
  grid-template-areas: "input side";
  grid-template-columns: 1fr auto;
}
.composer.composer-s select {
  display: none !important;
}
.composer.composer-s .subagents {
  display: none !important;
}
.composer.composer-s .composer-side {
  gap: 4px;
}

/* Medium mode (60px <= height < 120px): Standard compact dropdowns and buttons */
.composer.composer-m select {
  display: inline-block;
  height: 22px;
  font-size: 11px;
}
.composer.composer-m .plan-toggle,
.composer.composer-m .attach-btn,
.composer.composer-m .send-btn {
  height: 22px;
  font-size: 11px;
}

/* Large mode (height >= 120px): Larger toolbar controls and comfortable viewing */
.composer.composer-l {
  padding: 8px 16px 10px;
}
.composer.composer-l select {
  display: inline-block;
  height: 28px;
  font-size: 12.5px;
  padding: 0 8px;
}
.composer.composer-l .plan-toggle,
.composer.composer-l .attach-btn,
.composer.composer-l .send-btn {
  height: 28px;
  font-size: 12.5px;
  border-radius: 6px;
}
.composer.composer-l .subagents-summary-btn {
  height: 28px;
  font-size: 12px;
  border-radius: 6px;
  padding: 4px 12px;
}

.composer-side {
  grid-area: side;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.composer-side select {
  height: 22px;
  background: #101216;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 0 4px;
}

/* Plan mode is a workflow toggle, not just a permission level — give it a
   dedicated always-visible pill in the composer that fills in when it's on. */
.plan-toggle {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: #101216;
  border: 1px solid var(--border);
  border-radius: 4px;
  height: 22px;
  padding: 0 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.plan-toggle:hover:not(:disabled) { border-color: var(--accent-dim); }
.plan-toggle:disabled { opacity: 0.5; cursor: default; }
.plan-toggle.active {
  color: #3a1408;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
/* In the new-chat dialog the pill sits under its select, matching its width. */
.nc-row .plan-toggle { width: 100%; margin-top: 6px; height: 28px; }

.attach-btn {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: #101216;
  border: 1px solid var(--border);
  border-radius: 4px;
  height: 22px;
  padding: 0 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.attach-btn:hover:not(:disabled) { border-color: var(--accent-dim); color: var(--ink); }
.attach-btn:disabled { opacity: 0.5; cursor: default; }

.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.cmd-palette {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 8px;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
}
.cmd-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
}
.cmd-item.active { background: rgba(var(--accent-rgb), 0.16); }
.cmd-item .cmd-name { color: var(--accent); }
.attach-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-remove {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  padding: 0;
  font-size: 14px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.send-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: #3a1408;
  background: var(--accent);
  border: 0;
  border-radius: 4px;
  height: 22px;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.send-btn:hover { filter: brightness(1.1); }
.send-btn.stop { background: var(--err); color: #1a0d0d; }
.send-btn:disabled { opacity: 0.5; cursor: default; }

.ticker {
  max-width: 980px;
  margin: 0 auto 3px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ticker::after {
  content: '…';
  animation: ticker-dots 1.4s steps(4, end) infinite;
}
@keyframes ticker-dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}
@media (prefers-reduced-motion: reduce) {
  .ticker::after { animation: none; }
}

.queued-notice, .viewonly-note {
  max-width: 980px;
  margin: 0 auto 3px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.viewonly-note { color: var(--faint); }
.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  margin-left: 8px;
  text-decoration: underline;
}

/* Sub-agents: a view-only status strip left of the composer input. */
.subagents {
  display: flex;
  align-items: center;
}
.subagents-summary-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  cursor: pointer;
  height: 22px;
  transition: border-color 0.12s, transform 0.12s;
  box-sizing: border-box;
  white-space: nowrap;
}
.subagents-summary-btn:hover {
  border-color: var(--accent-dim);
  transform: translateY(-0.5px);
}
.sa-pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--live);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.7);
  animation: sa-pulse 1.4s infinite cubic-bezier(0.66, 0, 0, 1);
  flex: 0 0 auto;
}
@keyframes sa-pulse {
  to {
    box-shadow: 0 0 0 6px rgba(63, 185, 80, 0);
  }
}

/* Modal styling for the subagents list */
.subagents-list-dialog {
  width: min(400px, calc(100vw - 28px));
  max-height: min(500px, calc(100vh - 28px));
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  padding: 16px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
}
.subagents-list-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.sa-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}
.subagents-list-dialog .subagent-chip {
  width: 100%;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
}
.subagent-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left-width: 2px;
  border-radius: 4px;
  padding: 3px 6px;
  font-family: var(--mono);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.12s, transform 0.12s;
}
.subagent-chip:hover { border-color: var(--accent-dim); transform: translateX(1px); }
.subagent-chip.running { border-left-color: var(--live); }
.subagent-chip.error { border-left-color: var(--err); }
.subagent-chip.done { opacity: 0.72; }
.subagent-chip.done .sa-title { color: var(--muted); }

/* Status icon: spinner while running, check when done, cross on error. */
.sa-icon {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
}
.sa-icon.running {
  border: 1.5px solid var(--accent-dim);
  border-top-color: var(--live);
  border-radius: 50%;
  animation: sa-spin 0.8s linear infinite;
}
.sa-icon.done::before { content: '✓'; color: var(--live); }
.sa-icon.error::before { content: '✕'; color: var(--err); }
@keyframes sa-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .sa-icon.running { animation: none; border-top-color: var(--accent-dim); }
}
.sa-text { display: flex; flex-direction: column; min-width: 0; }
.sa-title {
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sa-sub {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subagent-dialog {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  max-width: 640px;
  width: calc(100vw - 32px);
  font-family: var(--mono);
}
.subagent-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.sa-dlg-head { display: flex; align-items: center; gap: 10px; }
.sa-dlg-title { margin: 0; font-size: 15px; flex: 1; }
.sa-dlg-close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}
.sa-dlg-close:hover { color: var(--ink); }
.sa-dlg-meta { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
.sa-dlg-label {
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 4px;
}
.sa-dlg-pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 30vh;
  overflow: auto;
}
.sa-dlg-md { font-size: 13px; max-height: 40vh; overflow: auto; }
.sa-dlg-empty { color: var(--faint); font-size: 12px; }
.sa-dlg-transcript {
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
  font-size: 13px;
}
.sa-dlg-transcript .msg { margin: 0 0 12px; }
.sa-dlg-transcript .msg:last-child { margin-bottom: 0; }

/* permission cards */
.permission-area {
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  padding: 0 24px;
}

.perm-card {
  border: 1px solid var(--accent-dim);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: rgba(var(--accent-rgb), 0.06);
  padding: 10px 14px;
  margin: 8px 0;
  font-family: var(--mono);
  font-size: 12.5px;
}

.perm-head { display: flex; gap: 10px; align-items: baseline; overflow: hidden; }
.perm-tool { color: var(--accent); font-weight: 700; flex: none; }
.perm-preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.perm-plan { margin-top: 10px; max-height: 360px; overflow-y: auto; }

.perm-actions { display: flex; gap: 8px; margin-top: 8px; }
.perm-btn {
  font-family: var(--mono);
  font-size: 12px;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink);
}
.perm-btn.allow { background: var(--accent); color: #16130d; border-color: var(--accent); font-weight: 600; }
.perm-btn.allow-always:hover, .perm-btn.allow:hover { filter: brightness(1.1); }
.perm-btn.deny { color: var(--err); border-color: #5a2e2e; }
.perm-btn.deny:hover { background: #2a1a1a; }
.perm-countdown { margin-top: 6px; color: var(--faint); font-size: 11px; }

.perm-question { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.perm-q-header { color: var(--accent); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.perm-q-text { color: var(--ink); margin-bottom: 2px; }
.perm-q-opt {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 7px 10px;
}
.perm-q-opt:hover { border-color: var(--accent-dim); }
.perm-q-opt:has(input:checked) { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }
.perm-q-opt input { margin-top: 1px; flex: none; accent-color: var(--accent); }

/* DS forms — Checkbox / Radio: 18px box, ember fill on check (cards/forms.card.html) */
.perm-q-opt input[type="checkbox"],
.perm-q-opt input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px;
  background: #120d08; border: 1.5px solid var(--border);
  cursor: pointer; display: inline-grid; place-content: center;
  transition: background var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard);
}
.perm-q-opt input[type="checkbox"] { border-radius: var(--radius-xs); }
.perm-q-opt input[type="radio"] { border-radius: 999px; }
.perm-q-opt input[type="checkbox"]:checked,
.perm-q-opt input[type="radio"]:checked { border-color: var(--ember-500); }
.perm-q-opt input[type="checkbox"]:checked {
  background: var(--ember-500) center/12px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 6.2 5 8.5 9.5 3.5' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.perm-q-opt input[type="radio"]:checked::before {
  content: ''; width: 9px; height: 9px; border-radius: 999px; background: var(--ember-500);
}
.perm-q-opt input:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.28); }
.perm-q-opt-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.perm-q-opt-label { color: var(--ink); }
.perm-q-opt-desc { color: var(--muted); font-size: 11px; line-height: 1.4; }
.perm-q-input {
  font-family: var(--mono);
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  padding: 5px 8px;
}
.perm-q-input:focus { outline: none; border-color: var(--accent-dim); }
.perm-q-other { width: 100%; box-sizing: border-box; margin-top: 2px; }

/* streaming */
.streaming-bubble .msg-assistant { opacity: 0.96; }
.streaming-text > p:last-child::after,
.streaming-text > ul:last-child > li:last-child::after,
.streaming-text > ol:last-child > li:last-child::after,
.streaming-text > pre:last-child::after,
.streaming-text > blockquote:last-child > p:last-child::after,
.streaming-text:not(:has(*))::after {
  content: '▋';
  color: var(--accent);
  animation: cursor-blink 1s steps(2) infinite;
  margin-left: 2px;
  display: inline-block;
  vertical-align: bottom;
}
@keyframes cursor-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .streaming-text > p:last-child::after,
  .streaming-text > ul:last-child > li:last-child::after,
  .streaming-text > ol:last-child > li:last-child::after,
  .streaming-text > pre:last-child::after,
  .streaming-text > blockquote:last-child > p:last-child::after,
  .streaming-text:not(:has(*))::after { animation: none; }
}

.stream-tool {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  margin: 8px 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.stream-tool-name { color: var(--ink); font-weight: 600; }

.cost-chip { color: var(--faint); }
.error-line { color: var(--err); }

/* new chat dialog */
.new-chat-dialog {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px 18px;
  width: min(560px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
}
.new-chat-dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
.new-chat-dialog[open] { animation: nc-in 0.16s ease-out; }
@keyframes nc-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
}
@media (prefers-reduced-motion: reduce) {
  .new-chat-dialog[open] { animation: none; }
}
.new-chat-dialog h2 { margin: 0 0 14px; font-size: 16px; }
.new-chat-dialog label {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  margin: 10px 0 4px;
}
.new-chat-dialog input,
.new-chat-dialog textarea,
.new-chat-dialog select {
  display: block;
  width: 100%;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 10px;
  box-sizing: border-box;
}

.nc-cwd-combo {
  position: relative;
  margin-top: 4px;
}

.nc-cwd-combo input {
  margin-top: 0;
  padding-right: 40px;
}
.nc-cwd-combo input.invalid {
  border-color: var(--err);
  box-shadow: 0 0 0 1px var(--err);
}

.nc-cwd-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 34px;
  background: none;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0 5px 5px 0;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
}
.nc-cwd-toggle:hover,
.nc-cwd-toggle[aria-expanded="true"] {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

.nc-cwd-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 176px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}
.nc-cwd-menu[hidden] { display: none; }

.nc-cwd-option {
  display: block;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12.5px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nc-cwd-option:hover,
.nc-cwd-option.active {
  background: var(--panel-2);
  color: var(--ink);
}

/* right-click / long-press context menu */
.ctx-menu {
  position: fixed;
  z-index: 200; /* above the auth overlay (100) */
  min-width: 216px;
  max-width: 320px;
  padding: 6px;
  background:
    linear-gradient(180deg, rgba(31, 24, 16, 0.98), rgba(20, 15, 9, 0.98));
  border: 1px solid rgba(168, 154, 137, 0.16);
  border-radius: 12px;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(255, 255, 255, 0.025) inset;
  backdrop-filter: blur(16px);
  animation: ctx-in 0.14s var(--ease-out);
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 8px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d8cab8;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
  transition:
    background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}
.ctx-item:hover,
.ctx-item:focus,
.ctx-item[aria-expanded="true"] {
  background: rgba(var(--accent-rgb), 0.13);
  color: var(--ink);
  outline: none;
}
.ctx-item:active:not(:disabled) {
  transform: scale(0.985);
  background: rgba(var(--accent-rgb), 0.18);
}
.ctx-item:focus-visible { box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.38) inset; }
.ctx-item:disabled {
  color: rgba(216, 202, 184, 0.38);
  cursor: default;
}
.ctx-item:disabled:hover {
  background: transparent;
  color: rgba(216, 202, 184, 0.38);
  transform: none;
}
.ctx-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  min-width: 16px;
  color: var(--faint);
  text-align: center;
}
.ctx-item:hover .ctx-icon,
.ctx-item:focus .ctx-icon,
.ctx-item[aria-expanded="true"] .ctx-icon { color: var(--ember-300); }
/* Scoped to .ctx-item (menu rows) — "ctx-" is also used by the header's
   token/context-WINDOW strip (.ctx-fold/.ctx-strip/.ctx-label et al in
   main.js), an unrelated, unscoped .ctx-label there. A bare rule here would
   win the cascade and stretch that strip's label full-width too. */
.ctx-item .ctx-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-arrow { flex: none; color: var(--faint); font-size: 10px; }
.ctx-danger,
.ctx-danger .ctx-icon { color: var(--err); }
.ctx-danger:hover,
.ctx-danger:focus,
.ctx-danger[aria-expanded="true"] {
  background: rgba(220, 74, 55, 0.14);
  color: var(--err);
}
.ctx-danger:active:not(:disabled) { background: rgba(220, 74, 55, 0.2); }
.ctx-danger:hover .ctx-icon,
.ctx-danger:focus .ctx-icon,
.ctx-danger[aria-expanded="true"] .ctx-icon { color: var(--err); }
.ctx-sep { height: 1px; margin: 5px 8px; background: rgba(168, 154, 137, 0.14); }
.ctx-check { flex: none; color: var(--accent); font-size: 12px; }
@keyframes ctx-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .ctx-menu { animation: none; } }

/* ---- Dropdown skin: native <select> shown as a trigger + .ctx-menu -------
   (mock "Dropdown menu" component). The <select> itself is visually hidden
   but stays in the DOM as the real control — see public/js/dropdown.js.
   Both sit in the same grid cell so the select's *existing* per-surface CSS
   (composer's #model-select, .settings-body select, .field select, etc. —
   different heights/widths in every context) sizes the cell, and the trigger
   just fills it — no need to re-declare that sizing per surface. */
.dd-wrap { position: relative; display: inline-grid; }
.dd-native { grid-area: 1 / 1 / 2 / 2; visibility: hidden; pointer-events: none; }
.dd-trigger {
  grid-area: 1 / 1 / 2 / 2;
  display: inline-flex; align-items: center; gap: 6px;
  width: 100%; height: 100%; padding: 0 10px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--ink); font-family: var(--mono); font-size: 12.5px; cursor: pointer;
}
.dd-trigger:hover, .dd-trigger[aria-expanded="true"] { border-color: var(--accent-dim); color: var(--accent); }
.dd-trigger:disabled { opacity: 0.5; cursor: default; }
.dd-trigger-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-trigger-caret { flex: none; color: var(--faint); font-size: 11px; transition: transform 0.15s ease; }
.dd-trigger[aria-expanded="true"] .dd-trigger-caret { transform: rotate(180deg); color: var(--accent); }
.dd-menu { min-width: 160px; }

/* archived sessions — dimmed, and a footer toggle to reveal them */
.session-row.archived { opacity: 0.5; }
.archived-toggle {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--faint);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
}
.archived-toggle:hover { background: var(--panel-2); color: var(--muted); }

/* engine picker — terminal tabs, not a dropdown */
.nc-engine { display: flex; gap: 6px; margin: 12px 0 2px; }
.nc-engine label {
  flex: 1;
  margin: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 0;
  cursor: pointer;
}
.nc-engine input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.nc-engine label:has(input:checked) {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(var(--accent-rgb), 0.08);
}
.nc-engine label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* first message — a prompt line, the amber voice */
.nc-prompt { position: relative; }
.nc-prompt::after {
  content: '❯';
  position: absolute;
  left: 11px;
  top: 26px; /* textarea offset in label + border + padding: first text line */
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  pointer-events: none;
}
.nc-prompt textarea {
  padding-left: 27px;
  resize: vertical;
  min-height: 84px;
}
.nc-prompt textarea:focus { border-color: var(--accent-dim); outline: none; }

.nc-row { display: flex; gap: 12px; flex-wrap: wrap; }
.nc-row label { flex: 1 1 130px; }
.nc-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.nc-actions button[type="button"] {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
}
.nc-error {
  color: var(--err);
  font-family: var(--mono);
  font-size: 12px;
  margin: 0 auto 0 0;
  min-width: 0;
}

/* ================= phase 3: multi-host ================= */

.host-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 4px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.host-head.host-down { color: var(--err); }

.host-name { font-weight: 600; }

.host-badge {
  font-size: 10px;
  color: var(--err);
  border: 1px solid var(--err);
  border-radius: 3px;
  padding: 0 4px;
  letter-spacing: 0;
  text-transform: none;
}

.host-chip {
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 0 4px;
}
/* Sidebar session rows: push the host chip to the bottom-right corner of the
   card, away from the rest of the meta line (time/size/project). */
.session-meta .host-chip { margin-left: auto; }

/* ================= phase 3: auth ================= */

.auth-overlay[hidden] { display: none; }

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, 90vw);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.auth-form .brand { font-size: 18px; }

.auth-hint { margin: 0; color: var(--muted); font-size: 13px; }

.auth-form input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  padding: 8px 10px;
}

.auth-error { color: var(--err); font-family: var(--mono); font-size: 12px; margin: 0; }

/* ================= phase 9: fleet board ================= */

.brand-home {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  text-align: left;
}

.board[hidden] { display: none; }
.board {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
}

.terminals[hidden] { display: none; }
.terminals {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
@media (max-width: 860px) {
  #nav-terminals { display: none; } /* desktop-only feature; render() also bails to a notice */
  .terminals { padding: calc(64px + var(--safe-top)) 12px 24px; } /* clears the fixed drawer-toggle/account-btn, matches .board */
}

/* ---------- terminals: left rail ---------- */
.term-rail {
  width: 260px;
  flex: none;
  overflow-y: auto;
  padding: 8px;
  border-right: 1px solid var(--border);
}
.term-rail-heading {
  margin: 10px 4px 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.term-rail-row { cursor: grab; }
.term-rail-row:active { cursor: grabbing; }
.term-rail-oncanvas { color: var(--accent); margin-left: auto; }

/* ---------- terminals: canvas + windows ---------- */
.term-canvas {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

.term-arrange-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  padding: 6px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.term-arrange-btn:hover { color: var(--ink); border-color: var(--accent-dim); }

.term-win {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  overflow: auto;
  resize: both;
}
.term-win.needs-approval {
  border-color: rgba(234, 127, 60, 0.85);
  box-shadow: 0 0 0 1px rgba(234, 127, 60, 0.35), 0 16px 40px rgba(0, 0, 0, 0.32);
}
.term-win-flash { animation: term-win-flash 0.6s ease-out; }
@keyframes term-win-flash {
  0%, 40% { box-shadow: 0 0 0 2px var(--accent); }
  100% { box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28); }
}
.term-win-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 6px 8px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  cursor: grab;
}
.term-win-head:active { cursor: grabbing; }
.term-win-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--ink);
}
.term-win-max,
.term-win-perm,
.term-win-close {
  flex: none;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.term-win-max:hover,
.term-win-close:hover { background: rgba(var(--accent-rgb), 0.18); color: var(--ink); }
.term-win-perm {
  min-width: 20px;
  padding: 0 6px;
  background: rgba(234, 127, 60, 0.18);
  color: #f0a15f;
  font-size: 11px;
  font-weight: 700;
}
.term-win-perm:hover { background: rgba(234, 127, 60, 0.28); color: #ffd2a8; }
.term-win-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12px;
}
/* condensed: mini windows run ~340px wide, so shrink the same block styles the
   main transcript uses rather than inventing a parallel set of mark-up rules */
.term-win-body .msg { max-width: none; margin: 0 0 6px; }
.term-win-body .msg-user { font-size: 12px; padding: 5px 8px; }
.term-win-body .msg-assistant { font-size: 12px; line-height: 1.45; }
.term-win-body details.fold { font-size: 11px; margin: 3px 0; }
.term-win-body details.fold pre { padding: 6px 8px; max-height: 160px; }
.term-win-body .msg-image { max-height: 120px; margin: 4px 0; }

.term-tail {
  flex: none;
  margin: 0 8px 6px;
  padding: 5px 7px;
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: var(--radius-sm);
  background: rgba(var(--accent-rgb), 0.07);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.term-win-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 4px 8px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
}
.term-win-foot-meta { display: flex; gap: 8px; }
.term-view-chip,
.term-ticker {
  flex: none;
  max-width: 44%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.term-view-chip {
  color: #f0a15f;
  border: 1px solid rgba(234, 127, 60, 0.35);
  border-radius: 999px;
  padding: 1px 6px;
  background: rgba(234, 127, 60, 0.08);
}
.term-ticker { color: var(--muted); }
.term-win-offline-note { display: none; }
.term-win.term-win-offline .term-win-offline-note {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 29px 0 0 0; /* below the title bar */
  background: rgba(0, 0, 0, 0.55);
  color: var(--err);
  font-family: var(--mono);
  font-size: 12px;
}

.term-notice {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 6px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

::view-transition-old(term-zoom),
::view-transition-new(term-zoom) {
  animation-duration: 180ms;
  animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.board-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.board-mark { font-family: var(--mono); color: var(--accent-dim); font-size: 22px; }
.board-title { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: 0.01em; }
.board-sub { color: var(--muted); font-size: 13px; font-family: var(--mono); }
.board-down { color: var(--err); font-size: 13px; margin: 8px 0 0; }

.board-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 22px 0 10px;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.board-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}
.board-card:hover { background: var(--panel-2); border-color: var(--accent-dim); }
.board-card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.board-card-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}
.board-badge-label { text-transform: none; letter-spacing: 0; }
.board-card-path {
  color: var(--faint);
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-more { color: var(--faint); font-size: 12px; margin: 10px 0 0; }
.board-empty { color: var(--muted); text-align: center; margin-top: 60px; }

.board-heading.attention { color: var(--err); }
.live-dot.attention { background: var(--err); animation: heartbeat-red 1.6s ease-in-out infinite; }
.board-card.needs-approval { border-color: rgba(239,136,120,0.48); background: rgba(220,74,55,0.08); }
.board-card.needs-approval:hover { background: rgba(220,74,55,0.14); }
@media (prefers-reduced-motion: reduce) { .live-dot.attention { animation: none; } }

@keyframes heartbeat-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,136,120,0.45); }
  50% { box-shadow: 0 0 0 5px rgba(239,136,120,0); }
}

/* a #…?req= deep link lands here and flashes the target approval card */
.perm-flash { animation: perm-flash 2s ease-out; }
@keyframes perm-flash {
  0%, 30% { box-shadow: 0 0 0 2px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------- sidebar page links ---------- */
.sidebar-links { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); }
.sidebar-links:empty { display: none; }
.sidebar-link {
  flex: 1; padding: 7px 10px; font: inherit; font-size: 13px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.sidebar-link:hover { color: var(--ink); border-color: var(--accent-dim); }

/* ---------- Settings / Connect pages ---------- */
.page { overflow-y: auto; padding: 68px 24px 24px; max-width: 860px; width: 100%; margin: 0 auto; }
.page-title { font-size: 20px; margin: 0 0 16px; color: var(--ink); }
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.account-hero {
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  border-radius: 18px;
  background:
    radial-gradient(circle at 16% 0%, rgba(var(--accent-rgb), 0.18), transparent 34%),
    linear-gradient(135deg, rgba(26, 31, 38, 0.96), rgba(20, 22, 27, 0.98));
}
.account-hero .page-title { margin-bottom: 8px; font-size: 26px; letter-spacing: -0.02em; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 16px;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.account-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}
.account-card h2 { grid-column: 1 / -1; }
.profile-row {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}
.profile-avatar {
  flex: none;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #15120c;
  background: linear-gradient(135deg, var(--accent), #f4c06f);
  font-size: 20px;
  font-weight: 900;
  background-size: cover;
  background-position: center;
}
.profile-avatar.has-image { color: transparent; }
.profile-info { min-width: 0; }
.profile-name {
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}
.card h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 12px; }
.card .muted { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.field { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.field-label { flex: none; width: 110px; color: var(--muted); font-size: 13px; }
.field select, .page input, .add-grid input {
  flex: 1; padding: 7px 10px; font: inherit; color: var(--ink);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
}
.page .row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.btn {
  padding: 7px 14px; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
}
.btn:hover { border-color: var(--accent-dim); }
.btn.primary { background: var(--accent); color: #14161b; border-color: var(--accent); }
.btn.danger { color: var(--err); border-color: var(--border); }
.btn.danger:hover { border-color: var(--err); }
.btn:disabled { opacity: 0.5; cursor: default; }
.page .msg { font-size: 13px; margin: 8px 0 0; }
.page .msg.err { color: var(--err); }
.page .msg.ok { color: var(--live); }

.device-list, .machine-list { display: flex; flex-direction: column; gap: 8px; }
.device-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
}
.device-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.device-name { color: var(--ink); font-size: 14px; }
.device-url { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.dot.up { background: var(--live); }
.dot.down { background: var(--err); }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.machines-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  background:
    radial-gradient(circle at 8% 0%, rgba(74, 222, 128, 0.12), transparent 34%),
    linear-gradient(145deg, rgba(26, 31, 38, 0.98), rgba(19, 22, 27, 0.98));
}
.machines-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.12), transparent 38%);
}
.machines-card > * { position: relative; }
.machines-card .card-head {
  align-items: center;
  text-transform: none;
}
.machines-title {
  color: var(--ink);
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -0.01em;
}
.machines-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.machine-summary {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  color: var(--live);
  background: rgba(74, 222, 128, 0.09);
  border: 1px solid rgba(74, 222, 128, 0.22);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}
.cloud-machine-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 13px;
  background: rgba(14, 17, 22, 0.54);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.cloud-machine-row:hover {
  transform: translateY(-1px);
  border-color: var(--accent-dim);
  background: rgba(14, 17, 22, 0.76);
}
.cloud-machine-row.online { border-left: 2px solid var(--live); }
.cloud-machine-row.offline { border-left: 2px solid var(--faint); }
.upd {
  flex: 1 0 100%;
  margin-top: 12px;
}
.upd-track {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  position: relative;
}
.upd-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--acc);
  transition: width 0.5s ease;
}
.upd-fill.ok { background: var(--ok); }
.upd-fill.err { background: var(--danger); }
.upd-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--mut);
  margin-top: 6px;
}
.upd-track.busy::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.13), transparent);
  animation: upd-sheen 1.2s linear infinite;
}
@keyframes upd-sheen {
  to { transform: translateX(100%); }
}
.machine-dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 28px));
  overflow: auto;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}
.machine-dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
.machine-dialog h2 { margin: 0 0 8px; }
.machine-dialog input {
  width: 100%;
  margin: 6px 0 4px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
}
.dialog-actions { justify-content: flex-end; margin-top: 14px; }
.token-box {
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--accent);
  border-color: var(--accent-dim);
}
.install-block {
  margin-top: 12px;
  padding: 11px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.install-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}
.install-block pre {
  margin: 0 0 8px;
  white-space: pre-wrap;
  word-break: break-all;
}
.uninstall-fold {
  margin-top: 12px;
  color: var(--muted);
}
.uninstall-fold summary { cursor: pointer; }

.settings-modal {
  width: min(860px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
}
.settings-modal::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(3px);
}
.settings-shell {
  display: flex;
  flex-direction: column;
  min-height: min(620px, calc(100vh - 48px));
}
.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.settings-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  letter-spacing: -0.01em;
}
.settings-head .muted {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.settings-close {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.settings-close:hover { color: var(--ink); border-color: var(--accent-dim); }
.settings-body {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  min-height: 0;
  flex: 1;
}
.settings-nav {
  padding: 12px;
  border-right: 1px solid var(--border);
  background: rgba(14, 17, 22, 0.38);
}
.settings-nav-btn {
  width: 100%;
  padding: 9px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  text-align: left;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.settings-nav-btn:hover { color: var(--ink); background: var(--panel-2); }
.settings-nav-btn.active {
  color: var(--ink);
  background: rgba(var(--accent-rgb), 0.12);
}
.settings-panels {
  min-width: 0;
  overflow: auto;
  padding: 16px;
}
.settings-panel .card:last-child { margin-bottom: 0; }
@media (max-width: 520px) { .add-grid { grid-template-columns: 1fr; } .field { flex-wrap: wrap; } }

/* ---------- phone layout ---------- */
@media (max-width: 860px) {
  html,
  body {
    overflow: hidden;
  }

  button,
  input,
  select,
  textarea,
  summary {
    touch-action: manipulation;
  }

  .drawer-toggle {
    top: calc(8px + var(--safe-top));
    left: 10px;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  }

  .sidebar {
    width: min(var(--sidebar-w, 340px), 88vw);
    box-shadow: 18px 0 42px rgba(0, 0, 0, 0.42);
  }

  .sidebar-head {
    padding: calc(12px + var(--safe-top)) 12px 10px;
  }

  .topbar {
    top: calc(8px + var(--safe-top));
    right: 10px;
  }

  .account-btn {
    min-height: 42px;
    max-width: 46vw;
  }

  .account-label {
    display: none;
  }

  .account-menu {
    min-width: min(250px, calc(100vw - 20px));
  }

  .brand-row {
    gap: 10px;
    align-items: flex-start;
  }

  .brand-home {
    min-height: 40px;
    font-size: 16px;
  }

  .brand-actions {
    gap: 6px;
  }

  .push-bell,
  .new-chat-btn,
  .limit-refresh-btn,
  .sidebar-link {
    min-height: 40px;
  }

  .new-chat-btn,
  .limit-refresh-btn {
    padding: 6px 10px;
    white-space: nowrap;
  }

  #filter {
    min-height: 42px;
    font-size: 16px;
  }

  .session-list {
    padding: 8px 8px 14px;
  }

  .project-group > summary {
    min-height: 42px;
    align-items: center;
    padding: 8px;
  }

  .session-row {
    min-height: 50px;
    padding: 10px 10px 10px 18px;
    border-radius: 8px;
  }

  .session-title {
    font-size: 14px;
  }

  .session-meta {
    flex-wrap: wrap;
    gap: 4px 8px;
    line-height: 1.35;
  }

  .load-more {
    min-height: 42px;
    width: calc(100% - 18px);
    margin-left: 10px;
  }

  .sidebar-links {
    padding: 8px;
  }

  .sidebar-foot {
    max-height: 36vh;
    padding-bottom: calc(10px + var(--safe-bottom));
  }

  .sidebar-resizer {
    display: none;
  }

  .viewer-head {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: calc(8px + var(--safe-top)) 10px 9px;
  }

  .viewer-menu-btn {
    width: 44px;
    min-height: 44px;
    align-self: start;
    border-radius: 12px;
    padding: 0;
    font-size: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--accent);
    cursor: pointer;
  }
  .viewer-menu-btn::before {
    content: "☰";
    font-size: 20px;
  }

  .viewer-head-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 44px;
    padding-top: 1px;
    padding-right: 50px;
  }

  .viewer-title {
    flex-wrap: wrap;
    gap: 5px 7px;
    font-size: 14px;
    line-height: 1.25;
  }

  .viewer-title .engine-logo {
    width: 16px;
    height: 16px;
  }

  .status-badge {
    margin-left: 0;
    padding: 4px 8px;
    font-size: 10.5px;
    line-height: 1.1;
  }

  .viewer-meta,
  .ctx-strip {
    gap: 5px 10px;
    font-size: 11px;
  }

  .ctx-strip {
    flex-wrap: wrap;
  }

  .ctx-bar {
    flex-basis: 100%;
    max-width: none;
  }

  .ctx-breakdown {
    margin-left: 0;
    max-width: none;
  }

  .transcript {
    padding: 12px 10px 16px;
  }

  .msg {
    margin-bottom: 12px;
  }

  .msg-user {
    padding: 8px 10px;
    font-size: 15.5px;
  }

  .msg-assistant {
    font-size: 15px;
    line-height: 1.55;
  }

  .md pre,
  details.fold pre {
    font-size: 12px;
  }

  details.fold > summary {
    min-height: 42px;
    white-space: normal;
    align-items: flex-start;
  }

  .fold-preview {
    white-space: normal;
  }

  .permission-area {
    padding: 0 10px;
  }

  .perm-card {
    padding: 10px 12px;
  }

  .perm-head {
    flex-direction: column;
    gap: 4px;
    align-items: stretch;
  }

  .perm-preview {
    white-space: normal;
  }

  .perm-actions {
    flex-wrap: wrap;
  }

  .perm-btn {
    flex: 1 1 130px;
    min-height: 44px;
  }

  .composer {
    padding: 6px 8px calc(7px + var(--safe-bottom));
  }

  .composer-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 6px !important;
  }

  .subagents {
    display: flex !important;
    width: 100% !important;
    margin-bottom: 2px !important;
  }

  .subagents-summary-btn {
    width: 100% !important;
    justify-content: center !important;
    height: 32px !important;
    font-size: 12px !important;
    border-radius: 4px !important;
  }

  #composer-input {
    width: 100%;
    min-height: 54px;
    max-height: 25vh;
    font-size: 16px;
    padding: 8px 0;
  }



  .composer-side {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .composer-side select {
    min-width: 0;
    height: 32px !important;
    min-height: 32px !important;
    width: 100% !important;
    max-width: none !important;
    font-size: 12px !important;
    padding: 4px 6px !important;
    box-sizing: border-box !important;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }

  #mode-select,
  #send-btn {
    grid-column: auto;
  }

  .send-btn,
  .attach-btn,
  .plan-toggle {
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 4px !important;
    padding: 4px 6px !important;
    font-size: 12px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
  }

  /* Small mode on mobile: horizontal row layout with cropped input */
  .composer.composer-s .composer-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px;
  }
  .composer.composer-s #composer-input {
    flex: 1;
    width: auto !important;
    min-height: 38px !important;
    height: var(--composer-input-h, 42px) !important;
    max-height: 58px !important;
    font-size: 15px;
    padding: 6px 8px;
  }
  .composer.composer-s .subagents {
    display: none !important;
  }
  .composer.composer-s .composer-side {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 4px;
    margin-top: 0 !important;
  }
  .composer.composer-s .composer-side select {
    display: none !important;
  }
  .composer.composer-s .plan-toggle,
  .composer.composer-s .attach-btn,
  .composer.composer-s .send-btn {
    height: 30px !important;
    min-height: 30px !important;
    font-size: 11px !important;
    padding: 0 8px !important;
    border-radius: 4px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .run-status,
  .ticker,
  .queued-notice,
  .viewonly-note {
    white-space: normal;
    line-height: 1.25;
  }

  .run-status {
    flex-wrap: wrap;
    margin-bottom: 3px;
  }

  .board {
    padding: calc(64px + var(--safe-top)) 12px 24px;
  }

  .board-head {
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
  }

  .board-title {
    font-size: 21px;
  }

  .board-sub {
    flex-basis: 100%;
    line-height: 1.4;
  }

  .board-heading {
    margin-top: 18px;
  }

  .board-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .board-card {
    min-height: 74px;
    padding: 12px;
    border-radius: 10px;
  }

  .board-card-title {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .board-card-path {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .page {
    max-width: none;
    padding: calc(64px + var(--safe-top)) 12px 24px;
  }

  .card {
    padding: 14px;
  }

  .account-hero {
    padding: 18px 16px;
    border-radius: 15px;
  }

  .account-card {
    grid-template-columns: 1fr;
  }

  .account-actions {
    justify-content: stretch;
  }

  .account-actions .btn {
    flex: 1 1 150px;
  }

  .settings-modal {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
    border-radius: 16px;
  }

  .settings-shell {
    min-height: min(620px, calc(100vh - 20px));
  }

  .settings-head {
    padding: 15px;
  }

  .settings-body {
    display: flex;
    flex-direction: column;
  }

  .settings-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .settings-nav-btn {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .settings-panels {
    padding: 12px;
  }

  .machines-card .card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .machines-actions {
    justify-content: stretch;
  }

  .machines-actions .btn,
  .machine-summary {
    flex: 1 1 auto;
    justify-content: center;
  }

  .cloud-machine-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .cloud-machine-row .device-meta {
    flex-basis: calc(100% - 24px);
  }

  .field {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .field-label {
    width: auto;
  }

  .field select,
  .page input,
  .add-grid input,
  .btn {
    min-height: 44px;
    font-size: 16px;
  }

  .page .row,
  .device-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .device-url {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .new-chat-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    padding: 16px;
  }

  .new-chat-dialog input,
  .new-chat-dialog textarea,
  .new-chat-dialog select {
    min-height: 44px;
    font-size: 16px;
  }

  .nc-engine {
    flex-wrap: wrap;
  }

  .nc-engine label {
    flex: 1 1 112px;
    min-height: 42px;
  }

  .nc-row {
    gap: 8px;
  }

  .nc-row label {
    flex-basis: 100%;
  }

  .nc-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .nc-error {
    margin-right: 0;
  }

  .nc-actions button[type="button"],
  .nc-actions .send-btn {
    min-height: 44px;
    width: 100%;
  }
}

@media (max-width: 420px) {
  .sidebar {
    width: 90vw;
  }

  .brand-row {
    flex-direction: column;
  }

  .brand-actions {
    width: 100%;
  }

  .new-chat-btn,
  .limit-refresh-btn {
    flex: 1;
  }

  .viewer-head {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
  }

  .viewer-menu-btn {
    font-size: 0;
    width: 42px;
    padding: 0;
  }

  .viewer-menu-btn::before {
    content: "☰";
    font-size: 18px;
  }

  .composer-side {
    grid-template-columns: 1fr;
  }

  #mode-select,
  #send-btn {
    grid-column: auto;
  }
}

/* ============================================================================
   DS LAYER — Termdeck Design System console kit, cloned onto Termdeck's own
   selectors. Appended last and carefully specificity-matched (composer controls
   are targeted by #id to beat the .composer-s/m/l rules) so nothing silently
   loses. Icon glyphs are inline SVG data-URIs (lucide). Delete this block to
   revert. Values verbatim from ui_kits/console/{session-chat,component-sheet}.
   ============================================================================ */

:root {
  /* recolorable icon masks (background:currentColor fills them) */
  --ic-chevron-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
  --ic-terminal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 17 6-6-6-6'/%3E%3Cpath d='M12 19h8'/%3E%3C/svg%3E");
  --ic-coins: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='M18.09 10.37A6 6 0 1 1 10.34 18'/%3E%3Cpath d='M7 6h1v4'/%3E%3Cpath d='m16.71 13.88.7.71-2.82 2.82'/%3E%3C/svg%3E");
  --ic-server: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='20' height='8' x='2' y='2' rx='2'/%3E%3Crect width='20' height='8' x='2' y='14' rx='2'/%3E%3Cpath d='M6 6h.01'/%3E%3Cpath d='M6 18h.01'/%3E%3C/svg%3E");
  --ic-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='3' rx='2' ry='2'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-3.09-3.09a2 2 0 0 0-2.82 0L6 21'/%3E%3C/svg%3E");
  --ic-paperclip: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m16 6-8.41 8.41a2 2 0 0 0 2.83 2.83L18.83 8.83a4 4 0 1 0-5.66-5.66L4.76 11.59a6 6 0 1 0 8.48 8.48L21 12.3'/%3E%3C/svg%3E");
  --ic-pin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 17v5'/%3E%3Cpath d='M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z'/%3E%3C/svg%3E");
}

/* ---- Motion: heartbeat is a ping (expanding ring behind a solid dot) ------ */
@keyframes heartbeat {
  0%   { transform: scale(1);   opacity: 0.55; }
  70%  { transform: scale(2.6); opacity: 0; }
  100% { opacity: 0; }
}
.live-dot, .status-dot { position: relative; }
/* neutralise element-level animations; the ping lives on ::after */
.live-dot.busy, .live-dot.attention,
.status-responding .status-dot, .status-terminal .status-dot,
.status-attached .status-dot, .status-error .status-dot,
.status-paused .status-dot { animation: none; }
.live-dot.busy::after, .live-dot.attention::after,
.status-responding .status-dot::after, .status-terminal .status-dot::after,
.status-attached .status-dot::after, .status-error .status-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 999px;
  background: inherit; animation: heartbeat 1.6s var(--ease-out) infinite;
}

/* ---- Buttons -------------------------------------------------------------- */
.send-btn, #send-btn {
  height: 32px; padding: 0 13px; border-radius: var(--radius-md);
  background: var(--ember-500); color: #fff; border: 1px solid transparent;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600; gap: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: background var(--duration-fast) var(--ease-standard),
              transform var(--duration-fast) var(--ease-standard);
}
.send-btn:hover:not(:disabled), #send-btn:hover:not(:disabled) { background: var(--ember-400); filter: none; }
.send-btn:active:not(:disabled), #send-btn:active:not(:disabled) { transform: translateY(0.5px); background: var(--ember-600); }
.send-btn.stop, #send-btn.stop { background: var(--red-500); color: #fff; }
.send-btn.stop:hover:not(:disabled), #send-btn.stop:hover:not(:disabled) { background: var(--red-600); }
.send-btn:disabled, #send-btn:disabled { opacity: 0.55; cursor: default; transform: none; filter: none; }

.new-chat-btn,
.limit-refresh-btn {
  height: 30px; padding: 0 11px; border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-weight: 600;
}
.new-chat-btn { background: var(--panel-2); color: var(--ink); }
.limit-refresh-btn { background: transparent; color: var(--muted); }
.new-chat-btn:hover:not(:disabled) { background: var(--panel-2); border-color: var(--ember-500); color: #fff; }
.limit-refresh-btn:hover:not(:disabled) { background: var(--panel-2); border-color: var(--ember-500); color: var(--ink); }

.attach-btn, #attach-btn, .plan-toggle, #plan-toggle {
  height: 30px; border-radius: var(--radius-md);
  transition: background var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}
.attach-btn, #attach-btn { border: 1px solid transparent; background: transparent; color: var(--muted); gap: 6px; }
.attach-btn::before, #attach-btn::before {
  content: ''; width: 14px; height: 14px; flex: none; background: currentColor;
  -webkit-mask: var(--ic-paperclip) center/contain no-repeat;
  mask: var(--ic-paperclip) center/contain no-repeat;
}
.attach-btn:hover:not(:disabled), #attach-btn:hover:not(:disabled) { background: var(--panel-2); border-color: transparent; color: var(--ink); }
.plan-toggle, #plan-toggle { border: 1px solid var(--border); background: transparent; color: var(--ink); }
.plan-toggle.active, #plan-toggle.active { background: rgba(var(--accent-rgb), 0.14); border-color: var(--accent-dim); color: var(--accent); }

.link-btn { color: var(--ember-400); }
.link-btn:hover:not(:disabled) { color: var(--ember-300); text-decoration: underline; }

/* secondary / ghost buttons across the app share the DS radius */
.viewer-menu-btn, .account-btn, .settings-nav-btn, .checkpoint-restore,
.nc-actions button, .archived-toggle, .nc-cwd-toggle, .subagents-summary-btn,
.machines-actions .btn, .machines-card .btn, .machine-list .btn,
.account-actions .btn { border-radius: var(--radius-md); }

/* icon buttons — 30px square, scale on press */
.settings-close, .push-bell {
  width: 30px; height: 30px; padding: 0; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
}
.settings-close:active:not(:disabled), .push-bell:active:not(:disabled) { transform: scale(0.94); }

/* ---- Status badges: 999px pill, mono, tinted bg + 1px border -------------- */
.status-badge {
  height: 26px; padding: 0 11px 0 9px; border-radius: var(--radius-pill);
  border: 1px solid; font-family: var(--font-mono); font-size: 11.5px;
  font-weight: 600; gap: 7px; letter-spacing: 0.01em; background: transparent;
  display: inline-flex; align-items: center;
}
.status-dot { width: 8px; height: 8px; border-radius: 999px; }
.status-responding, .status-terminal { color: #86c46e; background: rgba(74,157,63,0.12); border-color: rgba(74,157,63,0.35); }
.status-responding .status-dot, .status-terminal .status-dot { background: #4a9d3f; }
.status-attached { color: var(--ember-300); background: rgba(234,127,60,0.13); border-color: rgba(234,127,60,0.38); }
.status-attached .status-dot { background: var(--ember-400); }
.status-paused { color: var(--gold-300); background: rgba(239,180,45,0.12); border-color: rgba(239,180,45,0.34); }
.status-paused .status-dot { background: var(--gold-400); }
.status-idle { color: var(--muted); background: rgba(168,154,137,0.08); border-color: #3a3126; }
.status-idle .status-dot { background: var(--faint); }
.status-stopped { color: #c2b39d; background: rgba(120,109,94,0.1); border-color: #40362a; }
.status-stopped .status-dot { background: #79695a; }
.status-error { color: #ef8878; background: rgba(220,74,55,0.12); border-color: rgba(220,74,55,0.4); }
.status-error .status-dot { background: var(--red-500); }

/* ---- Chips: inline-flex, 24px, 7px radius, mono, leading icon ------------- */
.command-chip, .cost-chip, .host-chip, .host-badge, .image-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: 7px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  color: var(--muted); background: #241c13; border: 1px solid var(--border);
  vertical-align: middle;
}
.command-chip::before, .cost-chip::before, .host-chip::before, .host-badge::before, .image-chip::before {
  content: ''; width: 12px; height: 12px; flex: none; background: currentColor;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.command-chip { color: var(--gold-300); }
.command-chip::before { -webkit-mask-image: var(--ic-terminal); mask-image: var(--ic-terminal); }
.command-chip .cmd { color: var(--gold-300); }
.host-chip, .host-badge { color: var(--ember-300); }
.host-chip::before, .host-badge::before { -webkit-mask-image: var(--ic-server); mask-image: var(--ic-server); }
.image-chip::before { -webkit-mask-image: var(--ic-image); mask-image: var(--ic-image); }

/* cost chip is a centred .notice-line block today — make it a pill */
.notice-line.cost-chip {
  display: flex; width: fit-content; margin: 6px auto; color: #86c46e;
}
.notice-line.cost-chip::before { -webkit-mask-image: var(--ic-coins); mask-image: var(--ic-coins); }

/* composer image attachment: DS preview tile + remove */
.composer-attachments .attach-thumb-wrap {
  position: relative; width: 58px; height: 58px; flex: none;
}
.composer-attachments .attach-thumb {
  width: 58px; height: 58px; padding: 0; border-radius: 8px;
  border: 1px solid var(--border); background: #120d08; overflow: hidden;
  cursor: zoom-in; display: block;
}
.composer-attachments .attach-thumb:hover {
  border-color: var(--ember-500);
  box-shadow: 0 0 0 3px rgba(226, 97, 27, 0.12);
}
.composer-attachments .attach-thumb::before {
  content: ''; position: absolute; left: 4px; bottom: 4px; width: 17px; height: 17px;
  border-radius: 5px; background: rgba(15, 11, 6, 0.72); backdrop-filter: blur(4px);
}
.composer-attachments .attach-thumb::after {
  content: ''; position: absolute; left: 7px; bottom: 7px; width: 11px; height: 11px;
  background: #fff;
  -webkit-mask: var(--ic-image) center/contain no-repeat;
  mask: var(--ic-image) center/contain no-repeat;
}
.composer-attachments .attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.composer-attachments .attach-remove {
  color: #fff; background: rgba(15, 11, 6, 0.72); border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(4px);
}
.composer-attachments .attach-remove:hover { color: #fff; background: var(--red-500); }

/* ---- Tool cards: 10px, dark, mono header, DS chevron --------------------- */
details.fold, .stream-tool { border-radius: 10px; border: 1px solid var(--border); background: #191308; }
details.fold > summary { display: flex; align-items: center; gap: 9px; }
.fold-label, .stream-tool-name { color: var(--ember-300); font-weight: 600; }
.fold-preview, .stream-tool-tail { color: var(--muted); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: ''; width: 12px; height: 12px; flex: none; background: var(--muted);
  color: transparent; font-size: 0;
  -webkit-mask: var(--ic-chevron-right) center/contain no-repeat;
  mask: var(--ic-chevron-right) center/contain no-repeat;
  transition: transform var(--duration-fast) var(--ease-standard);
}
details.fold[open] > summary::before { content: ''; transform: rotate(90deg); }
.tool-result-slot .result-tag { color: var(--faint); }
.md code {
  font-family: var(--font-mono); font-size: 0.86em; background: #241c13;
  color: var(--gold-300); padding: 1.5px 6px; border-radius: 5px; border: 1px solid #2f2517;
}
.md pre { border-radius: 10px; border: 1px solid var(--border); background: #120d08; }

/* ---- Cards: 12px, hover lift + soft shadow ------------------------------- */
.board-card, .account-card, .machines-card, .perm-card, .card { border-radius: var(--radius-lg); }
.board-card {
  transition: border-color var(--duration-base) var(--ease-standard),
              transform var(--duration-base) var(--ease-standard),
              box-shadow var(--duration-base) var(--ease-standard);
}
.board-card:hover {
  border-color: #4a3a26; transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}
.board-card:hover:not(.needs-approval) { background: var(--panel); }
.board-card.needs-approval:hover { border-color: rgba(239,136,120,0.58); }
.perm-card { border-left: 3px solid var(--ember-500); }

/* ---- Inputs: 8px radius, sunken bg, 3px ember focus ring ------------------ */
/* #composer-input is excluded: it's borderless, its enclosing .composer-row owns the card + focus ring. */
#filter, .nc-cwd-combo input, .auth-form input,
.machine-dialog input, .perm-q-input, .perm-q-other,
.new-chat-dialog input, .new-chat-dialog textarea, .new-chat-dialog select,
.nc-prompt textarea {
  border-radius: var(--radius-md); background: #120d08; border: 1px solid var(--border);
  transition: border-color var(--duration-fast) var(--ease-standard),
              box-shadow var(--duration-fast) var(--ease-standard);
}
#filter:focus, .nc-cwd-combo input:focus,
.auth-form input:focus, .machine-dialog input:focus, .perm-q-input:focus,
.new-chat-dialog input:focus, .new-chat-dialog textarea:focus,
.new-chat-dialog select:focus, .nc-prompt textarea:focus {
  outline: none; border-color: var(--ember-500);
  box-shadow: 0 0 0 3px rgba(226, 97, 27, 0.18);
}

/* ---- Composer pickers as DS selchips (native <select>, id beats modes) ---- */
#model-select, #effort-select, #mode-select {
  -webkit-appearance: none; appearance: none;
  height: 30px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background-color: var(--panel);
  color: var(--muted); font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  padding: 0 26px 0 28px; background-repeat: no-repeat, no-repeat;
  background-position: left 9px center, right 9px center;
  background-size: 13px 13px, 11px 11px;
}
#model-select:hover, #effort-select:hover, #mode-select:hover { border-color: #4a3a26; color: var(--ink); }
#model-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ea7f3c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.9 15.5 8.5 14 2.4 12.4a.5.5 0 0 1 0-1L8.5 9.9 10 3.9a.5.5 0 0 1 1 0l1.5 6 6.1 1.6a.5.5 0 0 1 0 1L13.5 14 12 20a.5.5 0 0 1-1 0z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23857866' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
#effort-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a89a89' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 14 4-4'/%3E%3Cpath d='M3.34 19a10 10 0 1 1 17.32 0'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23857866' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
#mode-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a89a89' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23857866' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ---- Progress: pill track, ember fill, gradient when hot ------------------ */
.ctx-bar { border-radius: var(--radius-pill); background: #241c13; }
.ctx-bar-fill { border-radius: var(--radius-pill); background: var(--ember-500); }
.ctx-bar-fill.hot { background: linear-gradient(90deg, var(--ember-500), var(--rose-500)); }
.ctx-seg.seg-cached { background: #7a5f3a; }
.ctx-seg.seg-write { background: var(--gold-400); }
.ctx-seg.seg-fresh { background: var(--ember-500); }

/* ---- Sidebar rows + groups ----------------------------------------------- */
.session-row { border-radius: 9px; border: 1px solid transparent; }
.session-row:hover { background: var(--panel-2); }
.session-row.active { background: rgba(var(--accent-rgb), 0.10); border-color: var(--accent-dim); }
.project-group > summary { border-radius: 9px; }
.project-group > summary::before,
.host-marker,
.ctx-caret,
.dd-trigger-caret {
  content: ''; width: 12px; height: 12px; flex: none; color: var(--faint);
  background: currentColor; font-size: 0; line-height: 0;
  -webkit-mask: var(--ic-chevron-right) center/contain no-repeat;
  mask: var(--ic-chevron-right) center/contain no-repeat;
  transition: transform var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}
.project-group[open] > summary::before,
.host-group[open] > .host-head .host-marker,
.ctx-fold[open] .ctx-caret { transform: rotate(90deg); }
.dd-trigger-caret { transform: rotate(90deg); }
.dd-trigger[aria-expanded="true"] .dd-trigger-caret { transform: rotate(-90deg); color: var(--accent); }
.dd-trigger:disabled:hover { border-color: var(--border); color: var(--ink); }
/* ---- Menus + dialogs: rounded, layered shadow ---------------------------- */
.account-menu, .nc-cwd-menu {
  border-radius: 11px; box-shadow: 0 20px 44px rgba(0,0,0,0.5);
}
.account-menu button, .nc-cwd-option { border-radius: 8px; }
.ctx-has-submenu { padding-right: 8px; }
.ctx-arrow {
  width: 12px; height: 12px; font-size: 0; color: var(--faint);
  background: currentColor;
  -webkit-mask: var(--ic-chevron-right) center/contain no-repeat;
  mask: var(--ic-chevron-right) center/contain no-repeat;
}
.ctx-item[aria-expanded="true"] .ctx-arrow,
.ctx-item:hover .ctx-arrow,
.ctx-item:focus .ctx-arrow { color: var(--ember-300); }
.ctx-danger[aria-expanded="true"] .ctx-arrow,
.ctx-danger:hover .ctx-arrow,
.ctx-danger:focus .ctx-arrow { color: var(--err); }
.new-chat-dialog, .subagent-dialog, .machine-dialog, .settings-shell,
.subagents-list-dialog { border-radius: var(--radius-xl); box-shadow: 0 24px 50px rgba(0,0,0,0.55); }

/* ---- Permission actions: primary ember / danger red ---------------------- */
.perm-btn { border-radius: var(--radius-md); }
.perm-btn.allow { background: var(--ember-500); color: #fff; border-color: transparent; }
.perm-btn.allow:hover { background: var(--ember-400); filter: none; }
.perm-btn.deny { color: var(--red-500); border-color: rgba(220,74,55,0.4); }
.perm-btn.deny:hover { background: rgba(220,74,55,0.12); }

/* ---- Gradient app-icon tiles (built by appTile() in engines.js) ---------- */
.app-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  color: #fff; border-radius: var(--radius-sm);
}
.board-card .app-tile { width: 26px; height: 26px; }
.session-title-line .app-tile { width: 18px; height: 18px; border-radius: 5px; }
.app-tile svg { width: 58%; height: 58%; }
.app-tile.tile-ember { background: linear-gradient(135deg, var(--ember-400), var(--ember-600)); }
.app-tile.tile-gold { background: linear-gradient(135deg, var(--gold-400), var(--gold-500)); color: #3a1408; }
.app-tile.tile-rose { background: linear-gradient(135deg, var(--rose-400), var(--rose-600)); }

/* ---- Display type + misc ------------------------------------------------- */
.board-title, .new-chat-dialog h2, .settings-head h2, .sa-dlg-title,
.machine-dialog h2, .viewer-title-text, .account-card h2, .machines-title,
.auth-form .brand {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em;
}
.brand { font-family: var(--font-display); }
.brand-mark { color: var(--ember-400); }
.reconnect-banner { border-radius: 10px; }
.account-avatar, .profile-avatar { background: var(--gradient-brand); }

/* ---- Reduced motion: kill the pings + spinners --------------------------- */
@media (prefers-reduced-motion: reduce) {
  .live-dot::after, .status-dot::after, .sa-pulse-dot,
  .sa-icon.running::before, .ticker::after, .subagents-summary-btn .sa-pulse-dot {
    animation: none !important;
  }
}

/* ---- Mobile: keep DS radius on the composer (beats the !important block) -- */
@media (max-width: 720px) {
  #send-btn, #attach-btn, #plan-toggle,
  #model-select, #effort-select, #mode-select { border-radius: var(--radius-md) !important; }
  .composer-row { border-radius: var(--radius-lg) !important; }
  .status-badge { border-radius: var(--radius-pill) !important; }
}

/* ---- Settings modal → DS (full-height nav + pane) ------------------------ */
:root {
  --ic-settings: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 7h-9'/%3E%3Cpath d='M14 17H5'/%3E%3Ccircle cx='17' cy='17' r='3'/%3E%3Ccircle cx='7' cy='7' r='3'/%3E%3C/svg%3E");
  --ic-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
  --ic-layout: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='18' x='3' y='3' rx='2'/%3E%3Cpath d='M9 3v18'/%3E%3Cpath d='M3 9h18'/%3E%3C/svg%3E");
  --ic-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E");
  --ic-bell: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9'/%3E%3Cpath d='M10.3 21a1.94 1.94 0 0 0 3.4 0'/%3E%3C/svg%3E");
  --ic-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E");
}
.settings-shell {
  display: flex; flex-direction: row; padding: 0; overflow: hidden;
  width: min(860px, 94vw); height: min(620px, 88vh); max-width: 94vw;
  background: #140f09; border: 1px solid #362b1e;
}
.settings-nav {
  width: 224px; flex: none; background: #17120b; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 0; margin: 0;
}
.settings-nav-head { padding: 20px 18px 14px; }
.settings-nav-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; color: #fff; }
.settings-nav-sub { font-size: 12.5px; color: var(--faint); margin-top: 3px; }
.settings-nav-list { flex: 1; overflow: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 11px; border: 1px solid transparent; border-radius: 9px; background: transparent;
  color: var(--muted); font-family: var(--font-sans); font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.settings-nav-btn::before {
  content: ''; width: 17px; height: 17px; flex: none; background: var(--faint);
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.settings-nav-btn:hover { background: #1c150d; color: var(--ink); }
.settings-nav-btn.active { background: #241a10; border-color: #3a2a18; color: #fff; font-weight: 600; }
.settings-nav-btn.active::before { background: var(--ember-400); }
.settings-nav-btn[data-section="general"]::before { -webkit-mask-image: var(--ic-settings); mask-image: var(--ic-settings); }
.settings-nav-btn[data-section="account"]::before { -webkit-mask-image: var(--ic-user); mask-image: var(--ic-user); }
.settings-nav-btn[data-section="layout"]::before { -webkit-mask-image: var(--ic-layout); mask-image: var(--ic-layout); }
.settings-nav-btn[data-section="notifications"]::before { -webkit-mask-image: var(--ic-bell); mask-image: var(--ic-bell); }
.settings-nav-btn[data-section="chats"]::before { -webkit-mask-image: var(--ic-chat); mask-image: var(--ic-chat); }
.settings-pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.settings-head {
  display: flex; align-items: center; gap: 12px; margin: 0;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border);
}
.settings-head h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: #fff; }
.settings-head-sp { flex: 1; }
.settings-close {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.settings-close::before {
  content: ''; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: var(--ic-x) center/contain no-repeat; mask: var(--ic-x) center/contain no-repeat;
}
.settings-close:hover { background: #241c13; color: #fff; }
.settings-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 22px 20px; display: block; }
/* Termdeck's setting cards read as DS groups */
.settings-panel .card {
  border: none; background: transparent; border-radius: 0; margin: 0; padding: 16px 0;
  border-bottom: 1px solid #221b13; box-shadow: none;
}
.settings-panel .card:last-child { border-bottom: none; }
.settings-panel .card > h2 {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin: 0 0 12px;
}
.settings-body input[type="text"], .settings-body input[type="search"],
.settings-body input[type="number"], .settings-body input:not([type]), .settings-body select {
  height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: #120d08; color: var(--ink); font-family: var(--font-mono); font-size: 12.5px;
}
.settings-body .field select { max-width: 220px; }
@media (max-width: 860px) {
  .settings-shell { flex-direction: column; height: min(620px, 88vh); }
  .settings-nav {
    width: auto; flex: none; flex-direction: row; align-items: center;
    overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .settings-nav-head { display: none; }
  .settings-nav-list { flex-direction: row; padding: 8px 10px; }
  .settings-nav-btn { flex: none; white-space: nowrap; }
  .settings-pane { min-height: 0; }
  .settings-body .field select { max-width: none; }
}
.settings-body input:focus, .settings-body select:focus {
  outline: none; border-color: var(--ember-500); box-shadow: 0 0 0 3px rgba(226,97,27,0.18);
}

/* ---- Board card meta → DS mini status pill ------------------------------- */
.board-status {
  display: inline-flex; align-items: center; gap: 6px; height: 20px;
  padding: 0 8px 0 7px; border-radius: 999px; border: 1px solid;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
}
.board-status .live-dot { width: 7px; height: 7px; }
.board-status .terminal-marker { width: 12px; height: 12px; color: currentColor; }
.board-status.busy { color: #86c46e; background: rgba(74,157,63,0.12); border-color: rgba(74,157,63,0.35); }
.board-status.idle { color: var(--muted); background: rgba(168,154,137,0.08); border-color: #3a3126; }
.board-status.done { color: var(--gold-300); background: rgba(239,180,45,0.12); border-color: rgba(239,180,45,0.34); }
.board-status.error { color: #ef8878; background: rgba(220,74,55,0.12); border-color: rgba(220,74,55,0.4); }
.board-badge-label { text-transform: none; letter-spacing: 0; }

/* ---- Sidebar meta rows: mono/faint, DS spacing --------------------------- */
.session-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }

/* ==== Overlays + transcript + account → DS ================================= */
:root {
  --ic-logout: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' x2='9' y1='12' y2='12'/%3E%3C/svg%3E");
}

/* ---- Account menu: leading icons (CSS-only, by id) ----------------------- */
.account-menu button { display: flex; align-items: center; gap: 9px; }
.account-menu button::before {
  content: ''; width: 15px; height: 15px; flex: none; background: var(--faint);
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.account-menu button:hover::before { background: var(--ember-400); }
#nav-account::before  { -webkit-mask-image: var(--ic-user);     mask-image: var(--ic-user); }
#nav-settings::before { -webkit-mask-image: var(--ic-settings); mask-image: var(--ic-settings); }
#logout-btn::before   { -webkit-mask-image: var(--ic-logout);   mask-image: var(--ic-logout); background: var(--err); }
#logout-btn:hover::before { background: var(--err); }

/* ---- Context menu items keep their icon slot, DS sizing ------------------ */
.ctx-icon { width: 16px; }

/* ---- Reconnect banner: gold tint + spinner ------------------------------ */
.reconnect-banner {
  display: flex; align-items: center; gap: 11px;
  color: var(--gold-300); background: rgba(214,138,18,0.1);
  border: 1px solid rgba(214,138,18,0.34); border-radius: 10px;
}
.reconnect-banner[hidden] { display: none; }
.reconnect-banner::before {
  content: ''; width: 15px; height: 15px; flex: none; border-radius: 999px;
  border: 2px solid rgba(239,180,45,0.3); border-top-color: var(--gold-400);
  animation: sa-spin 0.8s linear infinite;
}

/* ---- Auth overlay: gradient prompt-glyph tile --------------------------- */
.auth-form .brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-md);
  background: var(--gradient-brand); color: #fff; font-weight: 700; margin-right: 4px;
}

/* ---- Account avatar: gradient circle ------------------------------------ */
.account-avatar {
  border-radius: 999px; background: var(--gradient-brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---- Machines rows ------------------------------------------------------ */
.cloud-machine-row { border-radius: 10px; border: 1px solid var(--border); }

/* ---- Transcript: warm-tune diff + task colours to DS green/red ----------- */
.diff-add { background: rgba(74,157,63,0.14); }
.diff-add .diff-gutter { color: #86c46e; }
.diff-del { background: rgba(220,74,55,0.14); }
.diff-del .diff-gutter { color: #ef8878; }
.task-completed .task-icon { color: #86c46e; }
.error-line { color: #ef8878; }

@media (prefers-reduced-motion: reduce) {
  .reconnect-banner::before { animation: none; }
}

/* ---- Settings: Notifications / Chats / Layout (Settings modal) ---------- */
.check-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; cursor: pointer; line-height: 1.4;
}
.check-row input[type="checkbox"] {
  flex: none; appearance: none; width: 42px; height: 24px; margin: 0;
  border: none; border-radius: 999px; background: var(--panel-2);
  position: relative; cursor: pointer; transition: background 0.15s ease;
}
.check-row input[type="checkbox"]::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: left 0.15s ease;
}
.check-row input[type="checkbox"]:checked { background: var(--accent); }
.check-row input[type="checkbox"]:checked::before { left: 21px; }
.check-row input[type="checkbox"]:disabled { cursor: default; opacity: 0.5; }
.check-row input[type="checkbox"]:disabled + span { color: var(--faint); }

.perm-state { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--muted); }

/* ---- Layout prefs: sidebar density -------------------------------------- */
body[data-density="compact"] .session-row { padding: 3px 8px 3px 22px; }
body[data-density="compact"] .session-title { font-size: 12.5px; }
body[data-density="compact"] .session-meta { font-size: 10.5px; }

/* ---- Layout prefs: transcript width ------------------------------------- */
body[data-transcript-width="narrow"] .transcript .msg { max-width: 720px; }
body[data-transcript-width="full"] .transcript .msg { max-width: none; }

/* ---- Layout prefs: board card size -------------------------------------- */
#board[data-card-size="small"] .board-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
#board[data-card-size="small"] .board-card { padding: 8px 10px; gap: 5px; }
#board[data-card-size="small"] .board-card-path { display: none; }
#board[data-card-size="large"] .board-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
#board[data-card-size="large"] .board-card { padding: 16px 18px; gap: 10px; }

/* ---- Composer footer: stable across resized heights and viewport widths --- */
:root { --composer-max: 980px; }

.composer {
  padding: 8px 16px calc(10px + var(--safe-bottom));
  overflow-x: clip;
}

.composer > .run-status,
.composer > .ticker,
.composer > .queued-notice,
.composer > .viewonly-note,
.composer > .composer-attachments,
.composer > .cmd-palette,
.composer > .composer-row {
  width: 100%;
  max-width: var(--composer-max);
  margin-left: auto;
  margin-right: auto;
}

.composer > .composer-attachments {
  align-items: center;
  margin-bottom: 8px;
}

.composer-row {
  grid-template-areas:
    "input input"
    "subagents side";
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  gap: 8px 10px;
  align-items: end;
  min-width: 0;
  position: relative;
}

#composer-input {
  min-width: 0;
  height: clamp(42px, var(--composer-input-h, 42px), 50vh);
  overflow-y: auto;
}

.composer-side {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.composer-side #attach-btn {
  margin-left: auto;
}

.composer-settings-btn {
  display: none;
}

.composer-side .dd-wrap {
  flex: 0 1 auto;
  min-width: 0;
  max-width: none;
}

.composer-side .dd-native {
  grid-area: 1 / 1 / 2 / 2 !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
}

.composer-side .dd-wrap-model-select { width: 154px; }
.composer-side .dd-wrap-effort-select { width: 154px; }
.composer-side .dd-wrap-mode-select { width: 196px; }

.composer-side .dd-trigger {
  min-width: 0;
  height: 100%;
}

.composer-side .dd-trigger-label {
  min-width: 0;
}

.composer.composer-s {
  padding: 5px 12px calc(6px + var(--safe-bottom));
}

.composer.composer-s .composer-row {
  display: grid !important;
  grid-template-areas: "input side" !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 8px 10px;
}

.composer.composer-s .subagents,
.composer.composer-s .composer-side .dd-wrap {
  display: none !important;
}

.composer.composer-s .composer-side {
  grid-area: side !important;
  grid-column: auto !important;
  display: flex !important;
  flex: none;
  width: auto !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 4px !important;
  margin: 0 !important;
}

.composer.composer-s #attach-btn {
  margin-left: 0 !important;
}

.composer.composer-s .composer-settings-btn {
  display: inline-flex !important;
  width: 32px !important;
  min-width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0 !important;
}

.composer.composer-s .composer-settings-btn::before {
  content: '';
  width: 15px;
  height: 15px;
  background: currentColor;
  -webkit-mask: var(--ic-settings) center/contain no-repeat;
  mask: var(--ic-settings) center/contain no-repeat;
}

.composer.composer-s .composer-settings-btn:hover,
.composer.composer-s.composer-settings-open .composer-settings-btn {
  background: var(--panel-2);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.composer.composer-s.composer-settings-open .composer-resizer {
  pointer-events: none;
}

.composer.composer-s.composer-settings-open .composer-row {
  --compact-settings-card-w: min(292px, calc(100vw - 28px));
  --compact-settings-field-w: min(268px, calc(100vw - 52px));
}

.composer.composer-s.composer-settings-open .composer-row::before {
  content: '';
  position: absolute;
  left: auto;
  right: 0;
  bottom: calc(100% + 8px);
  width: var(--compact-settings-card-w);
  height: 132px;
  border: 1px solid rgba(168, 154, 137, 0.18);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(31, 24, 16, 0.98), rgba(16, 12, 8, 0.98));
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(14px);
  pointer-events: none;
  z-index: 30;
}

.composer.composer-s.composer-settings-open .composer-side .dd-wrap {
  display: grid !important;
  position: absolute;
  left: auto;
  right: 12px;
  width: var(--compact-settings-field-w) !important;
  height: 32px !important;
  z-index: 31;
}

.composer.composer-s.composer-settings-open .composer-side .dd-wrap-model-select {
  bottom: calc(100% + 96px);
}

.composer.composer-s.composer-settings-open .composer-side .dd-wrap-effort-select {
  bottom: calc(100% + 58px);
}

.composer.composer-s.composer-settings-open .composer-side .dd-wrap-mode-select {
  grid-column: span 1 / auto !important;
  left: auto;
  right: 12px;
  bottom: calc(100% + 20px);
}

.composer.composer-s #composer-input {
  min-height: 38px !important;
  height: clamp(38px, var(--composer-input-h, 42px), 58px) !important;
  max-height: 58px !important;
  padding: 6px 0 !important;
}

.composer.composer-s #attach-btn,
.composer.composer-s #plan-toggle {
  width: 32px !important;
  min-width: 32px !important;
  padding: 0 !important;
  font-size: 0 !important;
}

.composer.composer-s #plan-toggle::before {
  content: "◐";
  font-size: 13px;
  line-height: 1;
}

.composer.composer-s #send-btn {
  min-width: 54px !important;
}

.composer.composer-m .composer-side .dd-wrap-model-select { width: 144px; }
.composer.composer-m .composer-side .dd-wrap-effort-select { width: 148px; }
.composer.composer-m .composer-side .dd-wrap-mode-select { width: 184px; }

.composer.composer-l .composer-row {
  gap: 10px 12px;
  padding: 14px 16px;
}

.composer.composer-l .composer-side .dd-wrap-model-select { width: 166px; }
.composer.composer-l .composer-side .dd-wrap-effort-select { width: 166px; }
.composer.composer-l .composer-side .dd-wrap-mode-select { width: 210px; }

@media (max-width: 900px) {
  /* the "prompt": the message textarea itself — 16px is desktop-sized here.
     !important: a later unconditional #composer-input rule also sets 16px. */
  #composer-input { font-size: 14px !important; }

  .composer-row {
    display: grid !important;
    grid-template-areas:
      "input"
      "subagents"
      "side" !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
  }

  .composer-side {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .composer.composer-s .composer-side {
    grid-area: side !important;
    grid-column: auto !important;
    display: flex !important;
    width: auto !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 4px !important;
  }

  .composer-side #attach-btn {
    margin-left: 0 !important;
  }

  .composer-side .dd-wrap,
  .composer-side #attach-btn,
  .composer-side #plan-toggle,
  .composer-side #send-btn {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .composer-side .dd-wrap-model-select,
  .composer-side .dd-wrap-effort-select,
  .composer-side .dd-wrap-mode-select {
    grid-column: span 2;
  }

  .composer-side #attach-btn,
  .composer-side #plan-toggle,
  .composer-side #send-btn {
    grid-column: span 2;
  }

  .composer-side .dd-trigger,
  .composer-side #attach-btn,
  .composer-side #plan-toggle,
  .composer-side #send-btn {
    height: 32px !important;
    min-height: 32px !important;
  }
}

@media (max-width: 720px) {
  .composer {
    padding: 6px 8px calc(8px + var(--safe-bottom));
  }

  .composer-row {
    padding: 10px;
  }

  #composer-input {
    min-height: 48px;
    max-height: 30vh;
  }

  .composer.composer-s .composer-row {
    grid-template-areas: "input side" !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
  }

  .composer.composer-s #attach-btn,
  .composer.composer-s #plan-toggle,
  .composer.composer-s #send-btn {
    height: 32px !important;
    min-height: 32px !important;
  }
}

@media (max-width: 520px) {
  .composer-side {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Model + Thinking pair up (short labels); Permission mode keeps its own
     full row (its labels — "ask permissions", "bypass all" — run longer);
     Attach + Plan pair up; Send stays full-width as the primary action. */
  .composer-side .dd-wrap-mode-select,
  .composer-side #send-btn {
    grid-column: 1 / -1;
  }

  .composer-side .dd-wrap-model-select,
  .composer-side .dd-wrap-effort-select,
  .composer-side #attach-btn,
  .composer-side #plan-toggle {
    grid-column: span 1;
  }

  .composer.composer-s .composer-side {
    display: flex !important;
  }
}

/* ---- Readability pass: reserve mono for code/data, use sans for UI prose --- */
:root {
  --muted: #b8aa99;
  --faint: #9b8d7b;
  --font-display: var(--font-sans);
  --mono: var(--font-sans);
  --sans: var(--font-sans);
}

html,
body {
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

#filter,
.project-group > summary,
.session-title,
.session-meta,
.viewer-meta,
.run-status,
.ticker,
.queued-notice,
.viewonly-note,
.composer-side .dd-trigger,
.attach-btn,
.plan-toggle,
.send-btn,
.status-badge,
.row-tag,
.ctx-item,
.account-menu button,
.nc-cwd-option,
.settings-nav-btn,
.field-label,
.page .msg,
.card .muted {
  font-family: var(--font-sans);
  letter-spacing: 0;
}

.session-title {
  font-size: 14px;
  line-height: 1.35;
}

.session-meta,
.viewer-meta,
.queued-notice,
.viewonly-note,
.ticker {
  font-size: 12.5px;
  line-height: 1.45;
}

.msg-user,
.msg-assistant,
.md,
#composer-input {
  font-family: var(--font-sans);
}

.msg-user {
  font-size: 15.5px;
  line-height: 1.58;
}

.msg-assistant,
.md {
  font-size: 16px;
  line-height: 1.7;
}

#composer-input {
  font-size: 16px;
  line-height: 1.55;
}

.composer-side .dd-trigger,
.attach-btn,
.plan-toggle,
.send-btn,
.ctx-item,
.account-menu button {
  font-size: 13px;
  font-weight: 500;
}

.status-badge,
.command-chip,
.cost-chip,
.host-chip,
.host-badge,
.image-chip {
  font-size: 12px;
}

button,
input,
textarea,
select,
dialog,
.brand,
.board-title,
.settings-nav-title,
.settings-head h2,
.new-chat-dialog h2,
.sa-dlg-title,
.machine-dialog h2,
.viewer-title-text,
.account-card h2,
.machines-title,
.settings-panel .card > h2,
.settings-body input[type="text"],
.settings-body input[type="search"],
.settings-body input[type="number"],
.settings-body input:not([type]),
.settings-body select,
.board-status,
.limit-plan,
.run-status-label,
.perm-card,
.perm-btn,
.perm-q-header,
.task-line,
.task-notif-line,
.checkpoint-line,
.nc-engine label,
.nc-prompt::after,
.host-head,
.host-badge,
.board-sub,
.field input,
.field select,
.device-row,
.machine-list,
.cloud-machine-row {
  font-family: var(--font-sans);
}

.msg-user .prompt-mark,
.terminal-marker,
code,
pre,
kbd,
samp,
.md code,
.md pre,
.md pre code,
details.fold pre,
.tool-result-slot pre,
.diff-code,
.token-box,
.command-chip,
.cost-chip,
.host-chip,
.host-badge,
.image-chip,
.device-url,
.ctx-breakdown,
.limit-engine,
.limit-engine-condensed,
.limit-label,
.limit-pct,
.ctx-strip,
.ctx-cost,
.ctx-io,
.ctx-legend-val {
  font-family: var(--font-mono);
}

/* ============================================================================
   THEME — Black / white dashboard with restrained Termdeck green
   Black, near-black, white, and neutral grays carry the UI. Brand green is used
   only for identity, primary action, selection, focus, and live/healthy state.
   ============================================================================ */

:root {
  --brand-green: #6de95c;
  --brand-green-rgb: 109, 233, 92;
  --brand-green-soft: rgba(var(--brand-green-rgb), 0.12);
  --brand-green-faint: rgba(var(--brand-green-rgb), 0.07);
  --brand-green-line: rgba(var(--brand-green-rgb), 0.38);

  --bg: #000000;
  --panel: #0b0b0b;
  --panel-2: #151515;
  --panel-3: #1f1f1f;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.22);
  --ink: #ffffff;
  --muted: #d2d2d2;
  --faint: #8f8f8f;
  --accent-rgb: var(--brand-green-rgb);
  --accent: var(--brand-green);
  --accent-dim: var(--brand-green-line);
  --live: var(--brand-green);
  --err: #ff6b63;

  --ember-300: var(--brand-green);
  --ember-400: var(--brand-green);
  --ember-500: var(--brand-green);
  --ember-600: #4fd63d;
  --gold-300: #dcdcdc;
  --gold-400: #b8b8b8;
  --gold-500: #909090;
  --rose-400: #a0a0a0;
  --rose-500: #7a7a7a;
  --red-500: var(--err);
  --red-600: #e8554f;
  --green-500: var(--brand-green);
  --green-600: #4fd63d;
  --gradient-brand: linear-gradient(135deg, var(--brand-green) 0%, #ffffff 100%);
  --gradient-brand-soft: linear-gradient(135deg, rgba(var(--brand-green-rgb), 0.16), rgba(255, 255, 255, 0.04));
  --gradient-ink: linear-gradient(180deg, #101010 0%, #000000 100%);
  --focus-ring: 0 0 0 3px rgba(var(--brand-green-rgb), 0.28);
  color-scheme: dark;
}

html,
body,
.app,
.main,
.transcript,
.term-canvas,
.auth-overlay {
  background: var(--bg);
  color: var(--ink);
}

::selection {
  background: var(--brand-green);
  color: #000;
}

:focus-visible {
  outline-color: var(--brand-green);
}

*::-webkit-scrollbar-thumb {
  background: #4a4a4a;
}

*::-webkit-scrollbar-thumb:hover {
  background: #6a6a6a;
}

/* Shell and navigation */
.sidebar,
.viewer-head,
.composer,
.account-menu,
.ctx-menu,
.new-chat-dialog,
.subagent-dialog,
.subagents-list-dialog,
.machine-dialog,
.settings-modal,
.settings-shell,
.auth-form,
.card,
.board-card,
.term-win,
.term-rail,
.cmd-palette,
details.fold,
.stream-tool {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--border);
}

.sidebar,
.viewer-head,
.composer,
.sidebar-foot,
.sidebar-links,
.term-rail,
.term-win-head,
.term-win-foot,
.settings-head,
.settings-nav,
.settings-panel .card,
.account-menu,
.ctx-sep {
  border-color: var(--border);
}

.sidebar {
  border-right-color: var(--border);
}

.sidebar-head,
.term-win-head,
.settings-nav,
.settings-nav-list,
.account-menu,
.ctx-menu,
.cmd-palette,
.nc-cwd-menu {
  background: #080808;
}

.brand-mark,
.brand-home:hover,
.board-mark,
.eyebrow,
.loading-line,
.md a,
.link-btn,
.term-rail-oncanvas,
.token-box,
.ctx-check,
.dd-trigger[aria-expanded="true"],
.dd-trigger[aria-expanded="true"] .dd-trigger-caret,
.nc-cwd-toggle:hover,
.nc-cwd-toggle[aria-expanded="true"],
.nc-prompt::after {
  color: var(--brand-green);
}

.brand-mark,
.auth-form .brand-mark,
.account-avatar,
.profile-avatar {
  background: var(--brand-green);
  color: #000;
}

.brand .brand-mark,
.brand-home .brand-mark,
.board-mark {
  background: transparent;
  color: var(--brand-green);
}

.notice,
.brand-sub,
.session-meta,
.viewer-meta,
.ctx-strip,
.fold-preview,
.device-url,
.muted,
.card .muted,
.settings-head .muted,
.settings-nav-sub,
.board-sub,
.board-card-meta,
.board-card-path,
.board-more,
.board-empty,
.queued-notice,
.viewonly-note,
.perm-preview,
.perm-countdown,
.perm-q-opt-desc,
.sa-sub,
.sa-dlg-meta,
.sa-dlg-empty,
.host-head,
.limit-label,
.limit-plan,
.limit-pct,
.ctx-legend-label,
.ctx-legend-val,
.ctx-aside {
  color: var(--faint);
}

.viewer-title,
.viewer-title-text,
.session-title,
.fold-label,
.stream-tool-name,
.settings-nav-title,
.settings-head h2,
.page-title,
.board-title,
.board-card-title,
.machines-title,
.profile-name,
.device-name,
.term-win-title,
.perm-q-text,
.sa-title {
  color: var(--ink);
}

/* Inputs, dropdowns, and focus rings */
#filter,
.new-chat-dialog input,
.new-chat-dialog textarea,
.new-chat-dialog select,
.auth-form input,
.machine-dialog input,
.settings-body input[type="text"],
.settings-body input[type="search"],
.settings-body input[type="number"],
.settings-body input:not([type]),
.settings-body select,
.field select,
.page input,
.add-grid input,
.perm-q-input,
.perm-q-other,
.dd-trigger,
#model-select,
#effort-select,
#mode-select,
.composer-side select {
  background-color: #050505;
  color: var(--ink);
  border-color: var(--border);
}

#filter::placeholder,
#composer-input::placeholder,
.new-chat-dialog textarea::placeholder,
.new-chat-dialog input::placeholder,
.auth-form input::placeholder {
  color: #727272;
}

#filter:focus,
.nc-cwd-combo input:focus,
.auth-form input:focus,
.machine-dialog input:focus,
.perm-q-input:focus,
.new-chat-dialog input:focus,
.new-chat-dialog textarea:focus,
.new-chat-dialog select:focus,
.nc-prompt textarea:focus,
.settings-body input:focus,
.settings-body select:focus,
.composer-row:focus-within {
  border-color: var(--brand-green);
  box-shadow: var(--focus-ring);
}

.dd-trigger:hover,
#model-select:hover,
#effort-select:hover,
#mode-select:hover,
.viewer-minimize:hover,
.sidebar-link:hover,
.term-arrange-btn:hover,
.checkpoint-restore:hover:not(:disabled),
.btn:hover,
.account-btn:hover,
.settings-close:hover,
.attach-btn:hover:not(:disabled),
.plan-toggle:hover:not(:disabled),
.perm-q-opt:hover,
.subagent-chip:hover,
.subagents-summary-btn:hover,
.board-card:hover,
.cloud-machine-row:hover,
.new-chat-btn:hover:not(:disabled),
.limit-refresh-btn:hover:not(:disabled) {
  border-color: var(--brand-green-line);
}

/* Primary and secondary actions */
.send-btn,
#send-btn,
.btn.primary,
.perm-btn.allow,
.new-chat-btn,
button.primary,
.machine-summary,
.plan-toggle.active,
#plan-toggle.active,
.nc-engine label:has(input:checked),
.check-row input[type="checkbox"]:checked {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: #000;
}

.send-btn:hover:not(:disabled),
#send-btn:hover:not(:disabled),
.btn.primary:hover,
.perm-btn.allow:hover,
button.primary:hover {
  background: #8cf77d;
  border-color: #8cf77d;
  color: #000;
  filter: none;
}

.send-btn.stop,
#send-btn.stop,
.perm-btn.deny:hover,
.composer-attachments .attach-remove:hover {
  background: var(--err);
  border-color: var(--err);
  color: #000;
}

.btn,
.perm-btn,
.attach-btn,
.plan-toggle,
.sidebar-link,
.term-arrange-btn,
.checkpoint-restore,
.account-btn,
.settings-close,
.viewer-minimize,
.limit-refresh-btn,
.nc-actions button[type="button"] {
  background: var(--panel-2);
  color: var(--ink);
  border-color: var(--border);
}

.btn.danger,
.perm-btn.deny,
.account-menu #logout-btn,
.ctx-danger,
.ctx-danger .ctx-icon,
.page .msg.err,
.nc-error,
.auth-error,
.error-line,
.board-down,
.host-head.host-down,
.host-badge,
.dot.down {
  color: var(--err);
}

/* Sidebar, board, and active states */
.session-row,
.project-group > summary,
.sidebar-link,
.board-card,
.cloud-machine-row,
.device-row,
.term-win,
.composer-row,
.perm-card,
.subagent-chip,
.subagents-summary-btn,
.command-chip,
.cost-chip,
.host-chip,
.host-badge,
.image-chip,
.board-status {
  border-color: var(--border);
}

.session-row:hover,
.project-group > summary:hover,
.load-more:hover,
.archived-toggle:hover,
.account-menu button:hover,
.nc-cwd-option:hover,
.nc-cwd-option.active,
.ctx-item:hover,
.ctx-item:focus,
.ctx-item[aria-expanded="true"],
.settings-nav-btn:hover,
.cmd-item.active,
.perm-q-opt,
.device-row,
.cloud-machine-row,
.term-tail,
.status-idle,
.status-stopped {
  background: var(--panel-2);
}

.session-row.active,
.settings-nav-btn.active,
.board-card:hover:not(.needs-approval),
.nc-engine label:has(input:checked) {
  background: var(--brand-green-soft);
  border-color: var(--brand-green-line);
  color: var(--ink);
}

.session-row.active {
  border-left-color: var(--brand-green);
}

.settings-nav-btn.active::before,
.account-menu button:hover::before,
.ctx-item:hover .ctx-icon,
.ctx-item:focus .ctx-icon,
.ctx-item[aria-expanded="true"] .ctx-icon,
.ctx-item:hover .ctx-arrow,
.ctx-item:focus .ctx-arrow,
.ctx-item[aria-expanded="true"] .ctx-arrow {
  background: var(--brand-green);
  color: var(--brand-green);
}

.pin-mark,
.live-dot.pin {
  background: var(--brand-green);
}

.board-card:hover {
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(var(--brand-green-rgb), 0.08);
}

.board-card.needs-approval,
.perm-card,
.term-win.needs-approval {
  background: var(--brand-green-faint);
  border-color: var(--brand-green-line);
}

.perm-card,
.subagents-summary-btn {
  border-left-color: var(--brand-green);
}

/* Status, chips, and progress */
.live-dot,
.dot.up,
.dot.on,
.sa-pulse-dot,
.status-responding .status-dot,
.status-terminal .status-dot,
.status-attached .status-dot,
.board-status.busy .live-dot,
.task-in_progress .task-icon,
.task-completed .task-icon,
.task-notif-completed .task-notif-icon {
  background: var(--brand-green);
  color: var(--brand-green);
}

.live-heading,
.viewer-meta .live-flag,
.status-responding,
.status-terminal,
.status-attached,
.board-status.busy,
.machine-summary,
.page .msg.ok,
.cost-chip,
.notice-line.cost-chip {
  color: var(--brand-green);
}

.status-responding,
.status-terminal,
.status-attached,
.board-status.busy,
.machine-summary,
.live-heading {
  background: var(--brand-green-soft);
  border-color: var(--brand-green-line);
}

.status-paused,
.board-status.done,
.ping-badge,
.ctx-cost,
.command-chip,
.host-chip,
.image-chip {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border);
}

.status-idle,
.status-stopped,
.board-status.idle {
  color: var(--faint);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
}

.status-error,
.board-status.error,
.live-heading.attention,
.live-dot.attention,
.task-notif-stopped .task-notif-icon {
  color: var(--err);
  border-color: rgba(255, 107, 99, 0.42);
}

.status-error,
.board-status.error {
  background: rgba(255, 107, 99, 0.12);
}

.status-error .status-dot,
.board-status.error .live-dot,
.live-dot.attention {
  background: var(--err);
}

.ctx-bar,
.ctx-seg-bar,
.limit-strip,
.upd-track {
  background: #202020;
}

.ctx-bar-fill,
.ctx-seg.seg-fresh,
.limit-seg.f,
.upd-fill,
.upd-fill.ok {
  background: var(--brand-green);
}

.ctx-bar-fill.hot,
.limit-seg.hot,
.upd-fill.err {
  background: var(--err);
}

.ctx-seg.seg-cached,
.ctx-dot.seg-cached,
.limit-seg {
  background: #3a3a3a;
}

.ctx-seg.seg-write,
.ctx-dot.seg-write,
.limit-seg.w {
  background: #777777;
}

.ctx-dot.seg-fresh,
.ctx-dot.seg-free {
  background: var(--brand-green);
}

/* Transcript, markdown, tools, and code */
.msg-user {
  color: var(--brand-green);
  background: var(--brand-green-faint);
  border-left-color: var(--brand-green);
}

.msg-user .prompt-mark,
.streaming-text > p:last-child::after,
.streaming-text > ul:last-child > li:last-child::after,
.streaming-text > ol:last-child > li:last-child::after,
.streaming-text > pre:last-child::after,
.streaming-text > blockquote:last-child > p:last-child::after,
.streaming-text:not(:has(*))::after,
.ticker,
.perm-tool,
.perm-q-header,
.cmd-item .cmd-name,
.command-chip .cmd,
.sa-dlg-label,
.fold-label,
.stream-tool-name {
  color: var(--brand-green);
}

.md code,
.command-chip,
.cost-chip,
.host-chip,
.host-badge,
.image-chip {
  background: #111111;
  border-color: var(--border);
}

.md code,
.md pre code,
.command-chip .cmd {
  color: var(--ink);
}

.md pre,
details.fold pre,
.diff,
.sa-dlg-pre,
.sa-dlg-transcript,
.blk.result,
pre {
  background: #050505;
  border-color: var(--border);
  color: var(--ink);
}

details.fold,
.stream-tool {
  background: #0a0a0a;
}

.diff-add {
  background: rgba(var(--brand-green-rgb), 0.14);
}

.diff-add .diff-gutter {
  color: var(--brand-green);
}

.diff-del {
  background: rgba(255, 107, 99, 0.14);
}

.diff-del .diff-gutter {
  color: var(--err);
}

/* Composer and compact settings */
.composer {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.94), rgba(0, 0, 0, 0.98)),
    var(--bg);
}

.composer-row {
  background: #070707;
  border-color: var(--border);
}

#composer-input {
  color: var(--ink);
}

.composer.composer-s.composer-settings-open .composer-row::before {
  background: linear-gradient(180deg, rgba(15, 15, 15, 0.98), rgba(0, 0, 0, 0.98));
  border-color: var(--border);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.composer.composer-s .composer-settings-btn:hover,
.composer.composer-s.composer-settings-open .composer-settings-btn {
  background: var(--brand-green-soft);
  border-color: var(--brand-green-line);
  color: var(--brand-green);
}

/* Dialogs, menus, auth, and account surfaces */
.account-hero,
.machines-card {
  background:
    radial-gradient(circle at 14% 0%, rgba(var(--brand-green-rgb), 0.14), transparent 34%),
    linear-gradient(135deg, #101010, #050505);
  border-color: var(--brand-green-line);
}

.account-btn,
.account-menu,
.ctx-menu,
.new-chat-dialog,
.machine-dialog,
.settings-shell,
.subagent-dialog,
.subagents-list-dialog,
.auth-form {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}

.account-btn,
.account-menu,
.ctx-menu {
  background: rgba(8, 8, 8, 0.96);
}

.ctx-danger:hover,
.ctx-danger:focus,
.ctx-danger[aria-expanded="true"] {
  background: rgba(255, 107, 99, 0.12);
  color: var(--err);
}

.reconnect-banner {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
}

.reconnect-banner::before {
  border-color: rgba(255, 255, 255, 0.24);
  border-top-color: var(--brand-green);
}

/* Terminals */
.term-win-head,
.term-win-foot,
.term-tail,
.term-notice,
.term-arrange-btn {
  background: var(--panel-2);
}

.term-win-perm,
.term-view-chip {
  color: var(--brand-green);
  background: var(--brand-green-soft);
  border-color: var(--brand-green-line);
}

.term-win-perm:hover {
  color: #000;
  background: var(--brand-green);
}

.term-win-max:hover,
.term-win-close:hover {
  background: var(--brand-green-soft);
  color: var(--ink);
}

/* Green versions of SVG select icons that previously encoded ember. */
#model-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236de95c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.9 15.5 8.5 14 2.4 12.4a.5.5 0 0 1 0-1L8.5 9.9 10 3.9a.5.5 0 0 1 1 0l1.5 6 6.1 1.6a.5.5 0 0 1 0 1L13.5 14 12 20a.5.5 0 0 1-1 0z'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f8f8f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

#effort-select,
#mode-select {
  background-image:
    linear-gradient(transparent, transparent),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f8f8f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Engine tiles stay useful without introducing extra brand hues. */
.app-tile.tile-ember,
.app-tile.tile-gold,
.app-tile.tile-rose {
  background: var(--brand-green);
  color: #000;
}

@media (max-width: 860px) {
  .drawer-toggle,
  .viewer-menu-btn {
    background: var(--panel-2);
    border-color: var(--border);
    color: var(--brand-green);
  }

  .drawer-backdrop {
    background: rgba(0, 0, 0, 0.72);
  }
}

/* Final edge-case cleanup for controls that used hardcoded warm warnings. */
.auth-form .brand .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-right: 4px;
  border-radius: var(--radius-md);
  background: var(--brand-green);
  color: #000;
}

.limit-condensed-seg.warn {
  color: var(--faint);
}

.limit-condensed-seg.hot {
  color: var(--err);
}

.perm-q-opt input[type="checkbox"],
.perm-q-opt input[type="radio"] {
  background: #050505;
  border-color: var(--border);
}

.perm-q-opt input[type="checkbox"]:checked,
.perm-q-opt input[type="radio"]:checked {
  border-color: var(--brand-green);
}

.perm-q-opt input[type="checkbox"]:checked {
  background-color: var(--brand-green);
}

.perm-q-opt input[type="radio"]:checked::before {
  background: var(--brand-green);
}

.session-row {
  margin: 3px 0;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
}

.session-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Active chat: no selected fill, just a minimal left rail beside the title. */
.session-row.active {
  background: transparent;
  border-left-color: var(--brand-green);
  border-left-width: 2px;
}

.session-row.active:hover {
  background: var(--panel-2);
}
