:root {
  --bg: #0b0d10;
  --surface: #12161b;
  --surface-2: #171c22;
  --border: #232a33;
  --text: #e6e8eb;
  --text-dim: #9aa4af;
  --accent: #6aa9ff;
  --accent-dim: #2b4970;
  --ok: #4caf82;
  --warn: #d8a64a;
  --err: #e06b6b;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface);
  height: 44px;
}
.brand { font-weight: 600; letter-spacing: 0.01em; }
.status { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }

/* --- agent activity indicators ---
   One dot per in-flight agent task (turn, tool call, voice session).
   Lifecycle: starting (red flash) → working (orange blink) → done (green hold) → fade out. */
.agent-indicators {
  display: flex; align-items: center; gap: 6px;
  height: 100%; padding: 0 4px;
  overflow: hidden;
}
.agent-indicators:empty { padding: 0; }
.agent-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-dim);
  flex: 0 0 auto;
  transition: transform 180ms ease, opacity 180ms ease, background-color 120ms ease;
  transform-origin: center;
  animation: agent-dot-in 160ms ease-out;
}
@keyframes agent-dot-in { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.agent-dot.starting { background: var(--err); box-shadow: 0 0 6px rgba(224, 107, 107, 0.5); }
.agent-dot.working  { background: var(--warn); animation: agent-dot-blink 0.9s ease-in-out infinite; }
.agent-dot.done     { background: var(--ok); box-shadow: 0 0 6px rgba(76, 175, 130, 0.55); }
.agent-dot.error    { background: var(--err); }
.agent-dot.leaving  { transform: scale(0); opacity: 0; }
@keyframes agent-dot-blink {
  0%, 100% { opacity: 1;   box-shadow: 0 0 5px rgba(216, 166, 74, 0.45); }
  50%      { opacity: 0.35; box-shadow: 0 0 0 rgba(216, 166, 74, 0); }
}

.btn-ghost {
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent-dim); }
.btn-ghost.danger { color: var(--err); border-color: rgba(224, 107, 107, 0.3); }
.btn-ghost.danger:hover { border-color: var(--err); background: rgba(224, 107, 107, 0.1); }

/* --- auth modal --- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
}
/* Unconditional display: flex above beats the [hidden] attribute. Re-hide. */
.modal[hidden] { display: none; }
.modal__sheet {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px 22px; min-width: 360px; max-width: 440px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.modal__sheet h2 { margin: 0 0 8px; font-size: 16px; }
.modal__hint { margin: 0 0 14px; color: var(--text-dim); font-size: 12px; line-height: 1.5; }
.modal__error {
  background: rgba(224, 107, 107, 0.1); border: 1px solid var(--err); color: var(--err);
  padding: 6px 10px; border-radius: 6px; font-size: 12px; margin-bottom: 10px;
}
.modal form { display: flex; flex-direction: column; gap: 8px; }
.modal input[type="password"] {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; font: inherit;
}
.modal input[type="password"]:focus { outline: none; border-color: var(--accent); }
.modal__row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.modal button.primary {
  background: var(--accent); color: #0b0d10; border: none; padding: 8px 14px;
  border-radius: 6px; cursor: pointer; font-weight: 600;
}

/* --- dashboard switcher + sharing controls in topbar --- */
.dash-switch { display: flex; align-items: center; gap: 6px; }
.dash-switch select {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; font-family: var(--sans);
  max-width: 220px;
}
.dash-switch select:focus { outline: none; border-color: var(--accent); }

.view-badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--warn); border: 1px solid var(--warn); border-radius: 4px;
  padding: 2px 6px; background: rgba(216, 166, 74, 0.1);
}
body.view-only .pane--chat .msg--user { opacity: 0.85; }

.share-popover {
  position: absolute; right: 12px; top: 52px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; gap: 6px; min-width: 360px;
}
.share-popover[hidden] { display: none; }

/* --- toasts --- */
.toast-host {
  position: fixed; bottom: 16px; right: 16px; z-index: 30;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px 8px 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex; align-items: center; gap: 10px; font-size: 12px;
  color: var(--text); min-width: 240px; max-width: 420px;
  pointer-events: auto;
  animation: toast-in 180ms ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast__action {
  color: var(--accent); text-decoration: none; font-weight: 600;
  border: 1px solid var(--accent-dim); border-radius: 5px; padding: 2px 8px;
}
.toast__action:hover { background: rgba(106, 169, 255, 0.12); }
.toast__close {
  background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px;
}
.toast__close:hover { color: var(--text); }
.share-popover__row { display: flex; gap: 6px; }
.share-popover__row input {
  flex: 1; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px;
  font-family: var(--mono); font-size: 12px;
}
.share-popover__hint { color: var(--text-dim); font-size: 11px; }

/* --- wires panel --- */
.wires-panel {
  position: absolute; right: 12px; top: 52px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; min-width: 460px; max-width: 640px;
  max-height: 70vh;
}
.wires-panel[hidden] { display: none; }
.wires-panel__header {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.wires-panel__title { font-weight: 600; font-size: 13px; }
.wires-panel__hint { color: var(--text-dim); font-size: 11px; flex: 1; }
.wires-list { overflow-y: auto; padding: 6px 0; }
.wires-list:empty::after {
  content: "No wires on this dashboard yet."; color: var(--text-dim);
  font-size: 12px; padding: 14px; display: block; text-align: center;
}
.wire-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12px;
}
.wire-row:last-child { border-bottom: none; }
.wire-row__heads {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.wire-row__title { font-weight: 600; }
.wire-row__arrow { color: var(--text-dim); }
.wire-row__instr { color: var(--text-dim); font-style: italic; }
.wire-row__meta { color: var(--text-dim); font-size: 11px; }
.wire-row__transform {
  display: inline-block; background: rgba(106,169,255,0.08);
  border: 1px solid var(--accent-dim); color: var(--accent);
  border-radius: 4px; padding: 0 6px; font-size: 10px;
  font-family: var(--mono);
}
.wire-row__delete {
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 8px; cursor: pointer; font-size: 11px;
  align-self: start;
}
.wire-row__delete:hover { color: var(--err); border-color: var(--err); }
.wire-row.is-recently-fired {
  background: rgba(106,169,255,0.06);
  transition: background 800ms ease;
}

/* Wire-from button on window header + wiring-mode chrome */
.window__btn--wire { cursor: pointer; }
.window__btn--wire.is-wire-source { color: var(--accent); }
body.is-wiring .window { cursor: crosshair; }
body.is-wiring .window__header { background: rgba(106,169,255,0.08); }
.window--wire-source { outline: 2px dashed var(--accent); }
.window__wire-badge {
  display: inline-block; min-width: 14px; padding: 0 4px;
  font-size: 10px; line-height: 14px; text-align: center;
  background: rgba(106,169,255,0.18); color: var(--accent);
  border-radius: 7px; margin-left: 2px;
}
.window__wire-badge[hidden] { display: none; }

.grid {
  display: grid;
  grid-template-columns: var(--pane-left-w, 360px) 1fr var(--pane-right-w, 380px);
  transition: grid-template-columns 220ms ease;
  height: calc(100vh - 44px);
  min-height: 0;
}
.grid[data-left="closed"] { --pane-left-w: 0px; }
.grid[data-right="closed"] { --pane-right-w: 0px; }

.pane {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--border);
  overflow: hidden;  /* clip content while the column animates to/from 0 */
}
.pane:last-child { border-right: none; }
.pane__header {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface);
  min-height: 40px;
}
.pane__title { font-weight: 600; font-size: 13px; }
.pane__sub { color: var(--text-dim); font-size: 12px; margin-left: auto; }

/* --- chat pane --- */
.mic {
  margin-left: auto;
  position: relative;  /* anchor for the VU halo */
  --mic-level: 0;      /* 0..1, set by VoiceClient.onMicLevel */
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 18px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; font-size: 12px; user-select: none;
}
.mic:hover { border-color: var(--accent-dim); }
.mic.active { background: var(--err); border-color: var(--err); color: white; }
/* VU halo: a soft ring around the mic button whose intensity tracks
   the current mic RMS. Visible only when listening — when idle/closed
   the level is forced to 0 by VoiceClient.stop(). Lets the user see
   "yes my voice is reaching the mic" before the model says anything. */
.mic.active::before {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 22px;
  pointer-events: none;
  box-shadow: 0 0 calc(var(--mic-level) * 18px) calc(var(--mic-level) * 4px)
              rgba(255, 220, 220, 0.75);
  opacity: var(--mic-level);
  transition: opacity 60ms linear, box-shadow 60ms linear;
}
/* When muted, the halo turns warm yellow so the user sees "mic is
   picking me up but I'm muted" — different from "mic dead". */
.mic.active.mic--muted::before {
  box-shadow: 0 0 calc(var(--mic-level) * 18px) calc(var(--mic-level) * 4px)
              rgba(255, 220, 120, 0.75);
}

.mute-btn { padding: 4px 10px; border-radius: 18px; font-size: 12px; }
.mute-btn:not([hidden]) { margin-left: auto; }
.mute-btn.muted { background: var(--warn); border-color: var(--warn); color: #1a1200; }
.mute-btn:not([hidden]) + .mic { margin-left: 8px; }
.mic__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.mic.active .mic__dot { background: white; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.live-transcript {
  min-height: 28px;
  padding: 6px 12px; font-size: 13px; color: var(--text-dim);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  font-style: italic;
}
.live-transcript:empty::before { content: "— no live transcript —"; color: var(--text-dim); opacity: 0.5; }

.chat-log {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 92%; padding: 8px 10px; border-radius: 10px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.msg--user { align-self: flex-end; background: var(--accent-dim); color: white; }
.msg--asst { align-self: flex-start; background: var(--surface-2); }
.msg--tool { align-self: flex-start; font-family: var(--mono); font-size: 12px; color: var(--text-dim); background: transparent; padding: 2px 10px; }

.text-form {
  display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); background: var(--surface);
}
.text-form input {
  flex: 1; padding: 8px 10px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font: inherit;
}
.text-form input:focus { outline: none; border-color: var(--accent); }
.text-form button {
  padding: 8px 14px; border-radius: 6px; border: none; cursor: pointer;
  background: var(--accent); color: #0b0d10; font-weight: 600;
}

/* --- canvas (floating windows) --- */
.canvas-shell {
  flex: 1; min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.canvas-scroll {
  flex: 1; min-height: 0; min-width: 0;
  position: relative; overflow: auto;
}
.canvas-workspace {
  position: relative;
  /* JS sets explicit width/height to enclose every window's bounds. */
  min-width: 100%; min-height: 100%;
}
.canvas-taskbar {
  display: flex; gap: 6px; padding: 6px 8px;
  background: var(--surface-2); border-top: 1px solid var(--border);
  overflow-x: auto; flex-wrap: nowrap;
  flex-shrink: 0;
}
.canvas-taskbar[hidden] { display: none; }
.canvas-taskbar__chip {
  display: inline-flex; gap: 6px; align-items: center;
  padding: 4px 10px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font: inherit; font-size: 12px;
  cursor: pointer; white-space: nowrap;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.canvas-taskbar__chip:hover { border-color: var(--accent); }
.canvas-taskbar__chip__title {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px;
}

.window {
  position: absolute;
  left: 0; top: 0;
  /* x/y/w/h via inline style for cheap drag. */
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  animation: winpop 0.18s ease-out;
}
.window--focused {
  border-color: var(--accent);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.window--maximized {
  /* Fill the canvas-scroll viewport, not the workspace. position:sticky pins
     it to the visible scroll area so scrolling the workspace doesn't hide it. */
  position: sticky !important;
  inset: 0 !important;
  width: auto !important; height: auto !important;
  z-index: 9000 !important;
  border-radius: 0;
}
.window--minimized { display: none !important; }
@keyframes winpop { from { opacity: 0; } to { opacity: 1; } }
.window--resizing { transition: none; }
.window__header {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  cursor: grab; user-select: none; flex-shrink: 0;
}
.window__header.dragging { cursor: grabbing; }
.window__title { font-weight: 600; font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.window__status {
  font-size: 10px; padding: 2px 6px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--accent-dim); color: var(--text);
}
.window__status.done { background: var(--ok); color: #07150e; }
.window__status.error { background: var(--err); color: white; }
.window__status.filling::after { content: " •"; animation: dots 1s infinite; }
@keyframes dots { 50% { opacity: 0.3; } }

/* Agent-presence + state indicator. Always present on every window
   header. Outline-only = no agent (passive window). Filled = agent;
   color encodes state. Hover tooltip carries the full status text. */
.window__agent-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  display: inline-block;
  border: 1px solid transparent; background: transparent;
}
.window__agent-dot.is-no-agent {
  background: transparent;
  border-color: var(--text-faint, #66707a);
  opacity: 0.55;
}
.window__agent-dot.is-pending {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 4px rgba(106, 169, 255, 0.5);
}
.window__agent-dot.is-running {
  background: var(--ok);
  border-color: var(--ok);
  box-shadow: 0 0 6px rgba(76, 175, 130, 0.7);
  animation: agentdot-pulse 1.8s ease-in-out infinite;
}
.window__agent-dot.is-interrupted {
  background: var(--warn);
  border-color: var(--warn);
}
.window__agent-dot.is-errored {
  background: var(--err);
  border-color: var(--err);
  box-shadow: 0 0 5px rgba(224, 107, 107, 0.6);
}
.window__agent-dot.is-terminal {
  background: var(--text-dim);
  border-color: var(--text-dim);
  opacity: 0.55;
}
@keyframes agentdot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.88); }
}
.window__btns { display: flex; gap: 2px; flex-shrink: 0; align-items: center; }
.window__btn {
  background: transparent; color: var(--text-dim); border: none; cursor: pointer;
  width: 26px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  font-family: inherit; font-size: 13px; line-height: 1;
  padding: 0;
  transition: background 80ms ease, color 80ms ease;
}
.window__btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.window__btn--close:hover { background: var(--err); color: #fff; }
.window__btn--max { font-size: 12px; }
.window__btn--min { font-size: 18px; padding-bottom: 4px; }
.window__btn--close { font-size: 16px; }
.window__btn--focus { font-size: 13px; opacity: 0.55; }
.window__btn--focus:hover { opacity: 1; }
.window__btn--focus.is-active {
  opacity: 1;
  background: rgba(110, 168, 254, 0.18);
  color: var(--text);
}
.window--voice-focus {
  outline: 2px solid rgba(110, 168, 254, 0.7);
  outline-offset: -2px;
  box-shadow: 0 0 0 4px rgba(110, 168, 254, 0.12);
}
.window__body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px; font-size: 13px; line-height: 1.5; }
.window__resize {
  position: absolute; right: 0; bottom: 0; z-index: 3;
  width: 18px; height: 18px; cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 0 45%, rgba(230, 232, 235, 0.45) 45% 52%, transparent 52% 100%),
    linear-gradient(135deg, transparent 0 62%, rgba(230, 232, 235, 0.7) 62% 69%, transparent 69% 100%);
}
.window--maximized .window__resize { display: none; }
.window__resize:hover { filter: brightness(1.15); }
body.is-resizing-window { user-select: none; cursor: nwse-resize; }
body.is-dragging-window { user-select: none; cursor: grabbing; }
body.is-dragging-window iframe { pointer-events: none; }
body.is-resizing-window iframe { pointer-events: none; }
.window__body h1, .window__body h2, .window__body h3 { margin: 8px 0 4px; }
.window__body p { margin: 6px 0; }
.window__body ul, .window__body ol { margin: 6px 0; padding-left: 22px; }
.window__body pre { background: var(--surface-2); padding: 8px; border-radius: 6px; overflow-x: auto; font-family: var(--mono); font-size: 12px; }
.window__body code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.window__body pre code { background: transparent; padding: 0; }
.window__body table { border-collapse: collapse; width: 100%; margin: 6px 0; }
.window__body th, .window__body td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.window__body th { background: var(--surface-2); }

/* --- media types --- */
.w-media { margin: 0; display: flex; flex-direction: column; gap: 6px; height: 100%; min-height: 0; }
.w-media img, .w-media video { width: 100%; height: 100%; min-height: 0; border-radius: 6px; background: #000; object-fit: contain; }
.w-media audio { width: 100%; }
.w-media figcaption { color: var(--text-dim); font-size: 12px; text-align: center; }

.w-video-wrap { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 6px; overflow: hidden; }
.w-video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.w-video { width: 100%; height: 100%; background: #000; border-radius: 6px; object-fit: contain; }

.w-iframe { width: 100%; height: 100%; min-height: 260px; border: none; background: #fff; border-radius: 6px; }
.window__body > .w-iframe { height: 100%; min-height: 280px; }

.w-empty { color: var(--text-dim); font-style: italic; padding: 16px; text-align: center; }
.w-err { color: var(--err); font-size: 12px; padding: 8px; }

.w-chart-wrap { position: relative; width: 100%; height: 100%; min-height: 240px; }
.w-chart-wrap canvas { width: 100% !important; height: 100% !important; }
.rich-text { margin-bottom: 8px; }
.rich-text p:last-child { margin-bottom: 0; }

/* --- terminal kind (run_bash, code_with_claude) --- */
.w-term { display: flex; flex-direction: column; height: 100%; min-height: 180px; }
.w-term__head {
  display: flex; gap: 12px; align-items: baseline;
  padding: 4px 8px; border-bottom: 1px solid var(--border);
  background: #0a0d11; border-radius: 4px 4px 0 0;
  font-family: var(--mono); font-size: 11px;
}
.w-term__cmd { color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.w-term__cwd { color: var(--text-dim); white-space: nowrap; }
.w-term__out {
  flex: 1; margin: 0; padding: 8px 10px;
  background: #07090c; color: #c9d1d9;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.4;
  overflow-y: auto; min-height: 0;
  white-space: pre-wrap; word-wrap: break-word;
  border-radius: 0 0 4px 4px;
}
.window:has(.w-term) { min-height: 260px; }

/* --- assistant kind (window agents — phase 3) --- */
.w-asst { display: flex; flex-direction: column; height: 100%; min-height: 200px; }
.w-asst__badges {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 6px 8px; border-bottom: 1px solid var(--border);
  background: #0a0d11; border-radius: 4px 4px 0 0;
  font-family: var(--mono); font-size: 10px;
}
.w-asst__badge {
  padding: 2px 6px; border-radius: 3px;
  background: #1a1f25; color: var(--text-dim);
  border: 1px solid var(--border); white-space: nowrap;
}
.w-asst__badge--profile { color: var(--accent); border-color: var(--accent); }
.w-asst__badge--model { color: #a8b3c0; }
.w-asst__badge--status { font-weight: 600; }
.w-asst__badge--status.is-live {
  color: #6ad07f; border-color: #2c6f3a; background: #0e1a12;
}
.w-asst__badge--status.is-warn {
  color: #f0c674; border-color: #6f5a2c; background: #1a160e;
}
.w-asst__badge--status.is-idle { color: var(--text-dim); }
.w-asst__badge--listen {
  color: #c194ff; border-color: #4a3870; background: #15101e;
}
.w-asst__transcript {
  flex: 1; margin: 0; padding: 8px 10px;
  background: #07090c; color: #c9d1d9;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.4;
  overflow-y: auto; min-height: 0;
  white-space: pre-wrap; word-wrap: break-word;
}
.w-asst__form {
  display: flex; gap: 4px;
  padding: 6px; border-top: 1px solid var(--border); background: #0a0d11;
}
.w-asst__input {
  flex: 1; padding: 6px 8px;
  background: #07090c; color: var(--text); border: 1px solid var(--border);
  border-radius: 3px; font-family: var(--mono); font-size: 12px;
}
.w-asst__input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.w-asst__input:disabled { opacity: 0.5; cursor: progress; }
.w-asst__send {
  padding: 6px 12px;
  background: var(--accent); color: #07090c; border: 0;
  border-radius: 3px; font-weight: 600; font-size: 12px; cursor: pointer;
}
.w-asst__send:hover { opacity: 0.9; }
.w-asst__actions {
  padding: 4px 6px; border-top: 1px solid var(--border);
  background: #0a0d11; display: flex; gap: 4px; justify-content: flex-end;
}
.w-asst__actions:empty { display: none; }
.w-asst__btn {
  padding: 3px 10px; font-size: 11px; cursor: pointer;
  background: #1a1f25; color: var(--text); border: 1px solid var(--border);
  border-radius: 3px;
}
.w-asst__btn:hover { background: #252b32; }
.w-asst__btn--cancel { color: #f08080; border-color: #553030; }
.w-asst__btn--resume { color: #6ad07f; border-color: #2c6f3a; }
.window:has(.w-asst) { min-height: 320px; }

/* --- feed kind (RSS / Atom) --- */
.w-feed { list-style: none; margin: 0; padding: 0; }
.w-feed__item {
  padding: 8px 2px; border-bottom: 1px solid var(--border);
}
.w-feed__item:last-child { border-bottom: none; }
.w-feed__title { font-weight: 600; font-size: 13px; line-height: 1.3; }
.w-feed__title a { color: var(--accent); text-decoration: none; }
.w-feed__title a:hover { text-decoration: underline; }
.w-feed__meta { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.w-feed__summary { color: var(--text); opacity: 0.85; font-size: 12px; margin-top: 4px; line-height: 1.4; }
.w-feed__footer { color: var(--text-dim); font-size: 10px; margin-top: 8px; text-align: right; }

/* --- email kind (gmail_get_message) --- */
.email-card {
  display: flex; flex-direction: column;
  /* `flex: 1` + `min-width: 0` lets the card track both axes when the
     window resizes — the parent .window__body is a flex container
     (see the :has rule below), so a bare height:100% only stretches
     vertically and the inner iframe/list never reflows on widen. */
  flex: 1; min-width: 0; min-height: 0;
  background: var(--surface); color: var(--text);
  font-family: var(--sans);
}
.email-header {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.email-subject {
  font-size: 15px; font-weight: 600; line-height: 1.3;
  color: var(--text); margin-bottom: 6px;
  word-break: break-word;
}
.email-meta {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; font-size: 12px; color: var(--text-dim);
}
.email-addrs { flex: 1; min-width: 0; }
.email-from, .email-to, .email-cc {
  line-height: 1.45; word-break: break-word;
}
.email-from { color: var(--text); }
.email-meta__label {
  color: var(--text-dim); font-weight: 500; margin-right: 2px;
}
.email-date {
  color: var(--text-dim); font-size: 11px; white-space: nowrap;
  flex-shrink: 0; padding-top: 2px;
}
.email-body {
  flex: 1; min-height: 0; overflow: auto;
  background: var(--bg);
}
.email-iframe {
  width: 100%; height: 100%; min-height: 200px;
  border: 0; background: #ffffff;
  display: block;
}
.email-body-text {
  margin: 0; padding: 10px 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.email-attachments {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.email-attachment-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px; color: var(--text);
  max-width: 220px;
}
.email-attachment-chip__icon { flex-shrink: 0; }
.email-attachment-chip__name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.email-attachment-chip__size { color: var(--text-dim); flex-shrink: 0; }
.window:has(.email-card) { min-height: 280px; }
.window:has(.email-card) .window__body { padding: 0; display: flex; }

/* --- email toolbar (Reply / Reply All / Delete / Send / Discard) --- */
.email-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.email-tool-btn {
  font: inherit; cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}
.email-tool-btn:hover:not(:disabled) { background: var(--surface-2); }
.email-tool-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.email-tool-btn--primary {
  background: var(--accent, #2b6cb0); color: #fff; border-color: transparent;
}
.email-tool-btn--primary:hover:not(:disabled) { filter: brightness(1.1); }
.email-tool-btn--danger {
  background: transparent; color: #c0392b; border-color: #c0392b;
}
.email-tool-btn--danger:hover:not(:disabled) { background: rgba(192,57,43,0.08); }
.email-tool-btn--ghost { background: transparent; }

/* --- email delete confirmation strip --- */
.email-delete-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: rgba(192,57,43,0.08);
  border-bottom: 1px solid rgba(192,57,43,0.4);
  font-size: 12px; color: var(--text);
}
.email-delete-strip span { flex: 1; min-width: 0; }

/* --- email compose form --- */
.email-compose {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px;
  flex: 1; min-height: 0; overflow: auto;
}
.email-compose.is-sending { opacity: 0.6; pointer-events: none; }
.email-compose__row {
  display: grid; grid-template-columns: 64px 1fr; gap: 8px;
  align-items: start;
}
.email-compose__row[data-field="body"] { flex: 1; min-height: 160px; }
.email-compose__label {
  color: var(--text-dim); font-size: 12px;
  padding-top: 6px; text-align: right;
}
.email-compose__input {
  width: 100%; box-sizing: border-box;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font: inherit; font-size: 13px;
  padding: 5px 8px; resize: vertical;
}
.email-compose__input:focus { outline: 2px solid var(--accent, #2b6cb0); outline-offset: -1px; }
.email-compose textarea.email-compose__input { min-height: 140px; font-family: var(--mono); }
.email-compose__error {
  color: #c0392b; font-size: 12px;
  padding: 4px 0;
}
.email-sent-note {
  padding: 16px; color: var(--text-dim); font-size: 13px; text-align: center;
}

/* --- email window in list view (gmail-style rows) --- */
.email-card--list { /* shares .email-card flex column */ }
.email-list-header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
}
.email-list-query { font-weight: 600; color: var(--text); }
.email-list-count { color: var(--text-dim); }
.email-list-rows {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; flex-direction: column;
}
.email-list-empty {
  padding: 24px 12px; color: var(--text-dim); text-align: center; font-size: 13px;
}
.email-list-row {
  display: grid; grid-template-columns: 10px 160px 1fr 64px;
  align-items: center; gap: 10px;
  padding: 6px 12px;
  border: 0; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text);
  font: inherit; font-size: 13px; text-align: left;
  cursor: pointer;
  min-height: 30px;
}
.email-list-row:hover { background: var(--surface-2); }
.email-list-row.is-loading { opacity: 0.5; cursor: wait; }
.email-list-row__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent;
}
.email-list-row.is-unread .email-list-row__dot { background: #2b6cb0; }
.email-list-row.is-unread .email-list-row__sender,
.email-list-row.is-unread .email-list-row__subject { font-weight: 700; color: var(--text); }
.email-list-row__sender {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.email-list-row__body {
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.email-list-row__subject { color: var(--text); }
.email-list-row__sep { color: var(--text-dim); }
.email-list-row__snippet { color: var(--text-dim); }
.email-list-row__date {
  color: var(--text-dim); font-size: 11px; white-space: nowrap;
  text-align: right; justify-self: end;
}

/* --- calendar kind (calendar_list_events / calendar_refresh) --- */
.calendar-card {
  display: flex; flex-direction: column;
  flex: 1; min-width: 0; min-height: 0;
  background: var(--surface); color: var(--text);
  font-family: var(--sans);
}
.calendar-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.calendar-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.calendar-chip {
  font: inherit; cursor: pointer;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); font-size: 11px;
}
.calendar-chip:hover { color: var(--text); border-color: var(--accent); }
.calendar-chip.is-active {
  background: var(--accent); border-color: var(--accent);
  color: var(--bg);
}
.calendar-chip:disabled { opacity: 0.6; cursor: progress; }
.calendar-toolbar__right {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-dim);
}
.calendar-count { white-space: nowrap; }
.calendar-refresh {
  font: inherit; cursor: pointer;
  width: 22px; height: 22px;
  border-radius: 4px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 13px; line-height: 1; padding: 0;
}
.calendar-refresh:hover { border-color: var(--accent); color: var(--accent); }
.calendar-refresh:disabled { opacity: 0.5; cursor: progress; }
.calendar-body {
  flex: 1; min-height: 0; overflow: auto;
  padding: 4px 0;
}
.calendar-empty {
  padding: 24px 12px; text-align: center;
  color: var(--text-dim); font-size: 12px;
}
.calendar-day { padding: 4px 0; }
.calendar-day__header {
  padding: 8px 12px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-dim);
}
.calendar-event {
  display: grid; grid-template-columns: 90px 1fr;
  gap: 10px; padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-size: 12px; line-height: 1.4;
  color: inherit; text-decoration: none;
}
.calendar-event:hover { background: var(--surface-2); }
.calendar-event__time {
  font-family: var(--mono); color: var(--text-dim);
  font-size: 11px; white-space: nowrap;
  padding-top: 1px;
}
.calendar-event.is-all-day .calendar-event__time {
  color: var(--accent); font-weight: 600;
}
.calendar-event__meta { min-width: 0; }
.calendar-event__title {
  font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis;
  word-break: break-word;
}
.calendar-event__location,
.calendar-event__attendees {
  font-size: 11px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 2px;
}
.window:has(.calendar-card) { min-height: 240px; }
.window:has(.calendar-card) .window__body { padding: 0; display: flex; }

/* --- map kind (maps_geocode / directions / search_places / static_map) --- */
.map-card {
  display: flex; flex-direction: row;
  flex: 1; min-width: 0; min-height: 0;
  background: var(--surface); color: var(--text);
  font-family: var(--sans);
}
.map-canvas {
  flex: 1; min-width: 0; min-height: 0;
  position: relative; background: var(--surface-2);
}
.map-canvas > div { width: 100%; height: 100%; }
.map-fallback {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.map-info { font-size: 12px; color: #1f2328; }
.map-error {
  position: absolute; left: 8px; bottom: 8px;
  padding: 4px 8px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.6); color: #fff;
  font-size: 11px;
}
.map-panel {
  width: 220px; flex: 0 0 220px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow: auto;
  display: flex; flex-direction: column;
  font-size: 12px;
}
.map-panel__head {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.map-panel__route {
  font-weight: 600; color: var(--text); font-size: 12px;
  word-break: break-word; line-height: 1.3;
}
.map-panel__summary {
  margin-top: 3px; color: var(--text-dim); font-size: 11px;
}
.map-panel__steps {
  margin: 0; padding: 6px 10px 12px 26px;
  color: var(--text); list-style: decimal;
}
.map-panel__steps li { padding: 4px 0; border-bottom: 1px dotted var(--border); }
.map-panel__steps li:last-child { border-bottom: 0; }
.map-step__instr { line-height: 1.35; }
.map-step__meta { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.map-panel__places {
  margin: 0; padding: 4px 10px 12px 10px;
  list-style: none; counter-reset: place;
}
.map-panel__places li {
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.map-panel__places li:last-child { border-bottom: 0; }
.map-place__name { font-weight: 600; color: var(--text); line-height: 1.3; }
.map-place__addr { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.map-place__meta { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.window:has(.map-card) { min-height: 260px; }
.window:has(.map-card) .window__body { padding: 0; display: flex; }
/* Narrow windows: stack the side panel under the map. */
@container (max-width: 480px) {
  .map-card { flex-direction: column; }
  .map-panel { width: 100%; flex: 0 0 auto; max-height: 40%; border-left: 0; border-top: 1px solid var(--border); }
}

/* --- live terminal (make_terminal_window, xterm.js) --- */
.w-xterm { width: 100%; height: 100%; min-height: 280px; background: #07090c; padding: 6px 4px 2px; box-sizing: border-box; }
.w-xterm .xterm { height: 100%; }
.w-xterm .xterm-viewport { background: #07090c !important; }
.window:has(.w-xterm) { min-height: 320px; }
/* Ensure the body fills so xterm's fit addon has real pixels to measure. */
.window:has(.w-xterm) .window__body { padding: 0; display: flex; }

/* --- activity log --- */
.log {
  flex: 1; overflow-y: auto; padding: 6px 10px;
  font-family: var(--mono); font-size: 11px; line-height: 1.4;
}
.log__line { padding: 1px 0; color: var(--text-dim); border-bottom: 1px dotted transparent; }
.log__line .t { color: var(--text); opacity: 0.5; margin-right: 6px; }
.log__line.log__line--info { color: var(--text-dim); }
.log__line.log__line--warn { color: var(--warn); }
.log__line.log__line--error { color: var(--err); }
.log__line.log__line--user { color: var(--accent); }
.log__line.log__line--asst { color: var(--text); }
.log__line.log__line--tool { color: #b08cff; }
.log__line.log__line--window { color: var(--ok); }

/* settings_group window kind — same controls as /settings.html, inline */
.w-settings { padding: 0.5rem 0.6rem; display: flex; flex-direction: column; gap: 0.2rem; }
.w-settings__row {
  display: grid; grid-template-columns: 1fr auto;
  gap: 0.4rem 0.8rem; align-items: start;
  padding: 0.55rem 0; border-top: 1px solid var(--border, #2a2a2a);
}
/* Routines and other full-width widgets break out of the 1fr/auto grid. */
.w-settings__row:has(.w-routines-host) {
  grid-template-columns: 1fr;
}
.w-settings__row:first-child { border-top: 0; }
.w-settings__name { font-weight: 500; }
.w-settings__help { font-size: 0.82rem; opacity: 0.65; margin-top: 0.2rem; }
.w-settings__default { font-size: 0.78rem; opacity: 0.55; margin-top: 0.2rem; }
.w-settings__default code { font-family: var(--mono, ui-monospace, monospace); background: rgba(255,255,255,0.06); padding: 0 0.3rem; border-radius: 3px; }
.w-settings__key { font-size: 0.74rem; opacity: 0.4; margin-top: 0.15rem; font-family: var(--mono, ui-monospace, monospace); }
.w-settings__value { display: flex; gap: 0.4rem; align-items: center; }
.w-settings__value select, .w-settings__value input[type="text"] {
  background: var(--surface, #1a1a1a); color: inherit;
  border: 1px solid var(--border, #333); border-radius: 4px;
  padding: 0.32rem 0.5rem; min-width: 200px; font: inherit;
}
.w-settings__status { font-size: 0.78rem; opacity: 0.65; min-width: 4em; }
.w-settings__status.saved { color: var(--ok, #4caf82); opacity: 1; }
.w-settings__status.error { color: var(--err, #d8554a); opacity: 1; }
.w-settings__connector-summary { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.w-settings__connector-account { font-size: 0.85rem; opacity: 0.85; }
.w-settings__connector-buttons { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.w-settings__value:has(.w-settings__connector-summary) { flex-direction: column; align-items: flex-end; }

/* gbrain endpoint widget */
.w-brain-host { width: 100%; flex: 1; }
.w-brain { display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.w-brain__list { display: flex; flex-direction: column; gap: 0.5rem; }
.w-brain__card { background: var(--surface, #1a1a1a); border: 1px solid var(--border, #333);
  border-radius: 6px; padding: 0.6rem 0.7rem; }
.w-brain__head { display: flex; gap: 0.5rem; align-items: center; justify-content: space-between; }
.w-brain__title { font-weight: 600; }
.w-brain__url { font-size: 0.82rem; opacity: 0.78; margin-top: 0.25rem;
  font-family: var(--mono, ui-monospace, monospace); word-break: break-all; }
.w-brain__meta { font-size: 0.78rem; opacity: 0.65; margin-top: 0.3rem; }
.w-brain__actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.w-brain__form { display: flex; flex-direction: column; gap: 0.5rem;
  background: var(--surface, #1a1a1a); border: 1px dashed var(--border, #333);
  border-radius: 6px; padding: 0.6rem 0.7rem; }
.w-brain__runner { border-color: var(--accent, #79c); }
.w-brain__runner code { background: var(--input-bg, #0f0f1a); padding: 1px 4px;
  border-radius: 3px; font-size: 0.85em; }
.w-brain__logs { max-height: 220px; overflow: auto; margin-top: 0.5rem;
  font-family: var(--mono, ui-monospace, monospace); font-size: 0.78rem;
  background: #0f0f0f; border: 1px solid var(--border, #333);
  border-radius: 4px; padding: 0.5rem; white-space: pre-wrap; word-break: break-all; }
.w-brain__field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.82rem; }
.w-brain__field input { width: 100%; box-sizing: border-box; }
.w-settings__value:has(.w-brain-host) { flex-direction: column; align-items: stretch; }

/* routines widget */
.w-routines-host { width: 100%; flex: 1; }
.w-routines { display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.w-routines__status { font-size: 0.85rem; opacity: 0.7; }
.w-routines__status.error { color: var(--err); }
.w-routines__list { display: flex; flex-direction: column; gap: 0.4rem; }
.w-routines__empty { font-size: 0.88rem; opacity: 0.7; padding: 0.4rem 0; }
.w-routine { background: var(--surface, #1a1a1a); border: 1px solid var(--border, #333);
  border-radius: 6px; padding: 0.6rem 0.7rem; }
.w-routine--off { opacity: 0.55; }
.w-routine__header { display: flex; flex-direction: column; gap: 0.2rem; }
.w-routine__title { font-weight: 600; }
.w-routine__meta { font-size: 0.78rem; opacity: 0.75; }
.w-routine__meta code { font-size: 0.85em; opacity: 0.9; }
.w-routine__last--ok { color: var(--ok, #4caf82); }
.w-routine__last--error { color: var(--err, #d8554a); }
.w-routine__last--running { color: var(--accent, #79c); }
.w-routine__prompt { font-size: 0.86rem; opacity: 0.8; margin: 0.4rem 0;
  white-space: pre-wrap; word-break: break-word; }
.w-routine__buttons { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.w-routine__drawer { margin-top: 0.6rem; padding-top: 0.6rem;
  border-top: 1px solid var(--border, #2a2a2a); font-size: 0.85rem; }
.w-routine__runs { display: flex; flex-direction: column; gap: 0.3rem; }
.w-routine-run { background: var(--bg-2, #141414); border-radius: 4px;
  padding: 0.4rem 0.55rem; }
.w-routine-run--error .w-routine-run__status { color: var(--err); }
.w-routine-run--ok .w-routine-run__status { color: var(--ok); }
.w-routine-run__head { font-size: 0.82rem; }
.w-routine-run__body { margin-top: 0.4rem; padding-top: 0.4rem;
  border-top: 1px dashed var(--border, #2a2a2a); }
.w-routine-run__error { color: var(--err); margin-bottom: 0.3rem; }
.w-routine-run__final { font-style: italic; opacity: 0.85; margin-bottom: 0.3rem;
  white-space: pre-wrap; }
.w-routine-run__windows { font-size: 0.8rem; opacity: 0.75; margin-bottom: 0.3rem; }
.w-routine-run__log ul { list-style: none; padding-left: 0; margin: 0;
  font-family: var(--mono, ui-monospace, monospace); font-size: 0.78rem; }
.w-routine-run__log-entry { padding: 0.15rem 0; opacity: 0.9; }
.w-routine-run__log-entry .t { opacity: 0.5; margin-right: 0.4em; }
.w-routine-run__log-entry .error { color: var(--err); }
.w-routines__create { display: flex; flex-direction: column; gap: 0.35rem;
  background: var(--surface, #1a1a1a); border: 1px dashed var(--border, #333);
  border-radius: 6px; padding: 0.55rem 0.7rem; }
.w-routines__create h4 { margin: 0 0 0.3rem; font-size: 0.9rem; opacity: 0.85; }
.w-routines__create input, .w-routines__create textarea {
  background: var(--bg-2, #141414); color: inherit;
  border: 1px solid var(--border, #333); border-radius: 4px;
  padding: 0.32rem 0.5rem; font: inherit; font-size: 0.85rem;
}
.w-routines__create textarea { font-family: var(--mono, ui-monospace, monospace); }
.w-routines__create-actions { display: flex; gap: 0.5rem; align-items: center; }
.w-routines__create-status { font-size: 0.78rem; opacity: 0.7; }

/* --- stock kind (yfinance-backed compact stock card) --- */
.window:has(.w-stock) { min-height: 320px; }
.window:has(.w-stock) .window__body { padding: 10px 14px; display: flex; flex-direction: column; }
.w-stock {
  display: flex; flex-direction: column; gap: 6px; height: 100%; min-height: 0;
}
.w-stock__head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.w-stock__sym { font-weight: 700; font-size: 14px; letter-spacing: 0.02em; }
.w-stock__name {
  color: var(--text-dim); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.w-stock__exch { color: var(--text-dim); font-size: 11px; }
.w-stock__price-row {
  display: flex; align-items: baseline; gap: 8px;
}
.w-stock__price { font-size: 28px; font-weight: 500; letter-spacing: -0.5px; }
.w-stock__currency { color: var(--text-dim); font-size: 11px; }
.w-stock__change { font-size: 13px; }
.w-stock__change.up { color: #81c995; }
.w-stock__change.down { color: #f28b82; }
.w-stock__after {
  color: var(--text-dim); font-size: 11px; margin-top: -2px;
}
.w-stock__after .delta.up { color: #81c995; }
.w-stock__after .delta.down { color: #f28b82; }
.w-stock__as-of { color: var(--text-dim); font-size: 11px; }
.w-stock__ranges {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border);
  margin: 4px 0 0; flex-wrap: wrap;
}
.w-stock__range {
  background: none; border: none; color: var(--text-dim);
  padding: 4px 8px; font: inherit; font-size: 11px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.w-stock__range:hover { color: var(--text); }
.w-stock__range.active { color: var(--accent); border-bottom-color: var(--accent); }
.w-stock__chart {
  position: relative; flex: 1; min-height: 120px; margin-top: 4px;
}
.w-stock__chart canvas { width: 100% !important; height: 100% !important; }
.w-stock__chart-status {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 11px; pointer-events: none;
}
.w-stock__stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px;
  border-top: 1px solid var(--border); padding-top: 6px; margin-top: 4px;
  font-size: 11px;
}
.w-stock__stat { display: flex; justify-content: space-between; padding: 2px 0; }
.w-stock__stat .k { color: var(--text-dim); }
.w-stock__stat .v { color: var(--text); }

/* --- mobile fallback (presentation only — desktop geometry is preserved) --- */
@media (max-width: 640px) {
  #canvas-workspace { width: auto !important; height: auto !important; padding: 8px; }
  .window {
    position: static !important;
    width: auto !important; height: auto !important;
    margin-bottom: 12px;
    box-shadow: none;
  }
  .window--minimized { display: none !important; }
  .window--maximized { position: static !important; }
  .window__btn--min, .window__btn--max, .window__resize { display: none !important; }
  .canvas-taskbar { display: none !important; }
  .window__header { cursor: default; }
  #auto-arrange { display: none; }
}

/* System dashboard (Settings): pure CSS grid, all chrome locked. The
   windows are system-managed and must not be deletable, draggable, or
   resizable — losing one wipes a settings category. */
body.system-dash #canvas-workspace {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px; padding: 12px;
  align-content: start;
  width: auto !important; height: auto !important;
}
body.system-dash .window {
  position: static !important;
  width: auto !important; height: auto !important;
  min-height: 260px; max-height: 70vh;
  z-index: auto !important;
  box-shadow: none;
  animation: none;
}
body.system-dash .window--minimized,
body.system-dash .window--maximized {
  position: static !important;
  inset: auto !important;
}
body.system-dash .window--minimized { display: flex !important; }
body.system-dash .window--focused {
  border-color: var(--border);
  box-shadow: none;
}
body.system-dash .window__btn--min,
body.system-dash .window__btn--max,
body.system-dash .window__btn--close,
body.system-dash .window__resize { display: none !important; }
body.system-dash .window__header { cursor: default; }
body.system-dash #auto-arrange { display: none; }
body.system-dash .canvas-taskbar { display: none !important; }

/* View-only dashboards: hide window chrome the visitor can't actuate. */
body.view-only .window__btn--min,
body.view-only .window__btn--max,
body.view-only .window__btn--close,
body.view-only .window__resize,
body.view-only #auto-arrange { display: none; }
body.view-only .window__header { cursor: default; }

/* ---------------------------------------------------------------------
 * Standalone /settings page
 * --------------------------------------------------------------------- */
body.settings-page { background: var(--bg); color: var(--text); }
body.settings-page .topbar { gap: 0.6rem; }
body.settings-page .topbar .brand { letter-spacing: 0.02em; }

.settings-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 880px);
  gap: 1.5rem;
  padding: 1.2rem 1.5rem 3rem;
  max-width: 1140px;
  margin: 0 auto;
  align-items: start;
}
.settings-sidebar {
  position: sticky; top: 1rem;
  display: flex; flex-direction: column;
  gap: 0.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
}
.settings-nav__link {
  display: block;
  padding: 0.45rem 0.7rem;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 5px;
  font-size: 0.92rem;
}
.settings-nav__link:hover { background: var(--surface-2); color: var(--text); }
.settings-nav__link.active { background: var(--accent-dim); color: var(--text); }

.settings-main { display: flex; flex-direction: column; gap: 1.4rem; min-width: 0; }
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.settings-section__head {
  padding: 0.9rem 1rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.settings-section__head h2 {
  margin: 0; font-size: 1.05rem; letter-spacing: 0.01em;
}
.settings-section__hint { margin: 0.3rem 0 0; font-size: 0.85rem; opacity: 0.7; }
.settings-section__body { padding: 0.4rem 1rem 0.9rem; }

.settings-flash {
  padding: 0.55rem 0.8rem;
  border-radius: 6px;
  font-size: 0.88rem;
  margin-bottom: 0.6rem;
}
.settings-flash--ok    { background: #16361f; color: #b6e6c7; }
.settings-flash--info  { background: #1a2530; color: #cbd5e1; }
.settings-flash--error { background: #3a1d1d; color: #f0b5b5; }

/* Prompt editor */
.settings-prompt {
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}
.settings-prompt:first-child { border-top: 0; }
.settings-prompt__head {
  display: flex; gap: 0.6rem; align-items: baseline; justify-content: space-between;
}
.settings-prompt__title { font-weight: 600; }
.settings-prompt__source {
  font-size: 0.78rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.05em;
}
.settings-prompt__textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg);
  color: inherit;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  margin-top: 0.4rem;
  resize: vertical;
}
.settings-prompt__meta {
  display: flex; justify-content: flex-end;
  font-size: 0.78rem; opacity: 0.65;
  margin-top: 0.2rem;
}
.settings-prompt__counter.over { color: var(--err); opacity: 1; }
.settings-prompt__actions {
  display: flex; gap: 0.5rem; align-items: center;
  margin-top: 0.5rem;
}
.settings-prompt__actions .primary {
  background: var(--accent); color: #06121f; border: 0;
  padding: 0.4rem 0.9rem; border-radius: 5px; cursor: pointer;
  font-weight: 600;
}
.settings-prompt__actions .primary:hover { filter: brightness(1.05); }
.settings-prompt__preview { margin-top: 0.7rem; }
.settings-prompt__preview summary {
  cursor: pointer; font-size: 0.85rem; opacity: 0.75;
  list-style: revert;
}
.settings-prompt__preview-pre {
  margin-top: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.55rem 0.7rem;
  max-height: 320px;
  overflow: auto;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.85;
}

/* Settings page reuses the existing .modal / .modal__sheet styles defined
 * earlier in this file. No additional modal rules needed. */

/* ---------------------------------------------------------------------
 * /features — capabilities & roadmap page
 * --------------------------------------------------------------------- */
body.features-page { background: var(--bg); color: var(--text); }

.features-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.6rem 1.5rem 4rem;
}

.features-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.6rem;
}
.features-hero h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  letter-spacing: 0.01em;
}
.features-hero p { margin: 0.4rem 0; line-height: 1.55; opacity: 0.85; }
.features-hero a { color: var(--accent); text-decoration: none; }
.features-hero a:hover { text-decoration: underline; }
.features-hero__nav {
  margin-top: 0.9rem !important;
  font-size: 0.95rem;
}
.features-hero__nav span { opacity: 0.45; }

.features-section {
  margin-top: 2rem;
}
.features-section h2 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}
.features-section__hint {
  margin: 0 0 1rem;
  opacity: 0.7;
  font-size: 0.92rem;
}
.features-section--upcoming {
  position: relative;
}
.features-section--upcoming h2::before {
  content: "★ ";
  color: var(--warn);
  margin-right: 0.2rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 0.9rem;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.95rem 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.feature-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1.02rem;
  letter-spacing: 0.005em;
}
.feature-card p {
  margin: 0;
  line-height: 1.5;
  font-size: 0.92rem;
  opacity: 0.88;
}
.feature-card ul {
  margin: 0.2rem 0 0 1.05rem;
  padding: 0;
  font-size: 0.88rem;
  opacity: 0.82;
  line-height: 1.5;
}
.feature-card li { margin: 0.15rem 0; }
.feature-card code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 0.83em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.feature-card a {
  color: var(--accent);
  text-decoration: none;
}
.feature-card a:hover { text-decoration: underline; }
.feature-card__manage {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.75;
}

.feature-card--upcoming {
  background: linear-gradient(0deg, rgba(216, 166, 74, 0.04), rgba(216, 166, 74, 0.04)),
              var(--surface);
  border-color: rgba(216, 166, 74, 0.35);
}
.feature-card--upcoming h3::before {
  content: "→ ";
  color: var(--warn);
  margin-right: 0.15rem;
  opacity: 0.85;
}

.features-footer {
  margin-top: 2.5rem;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.55;
}
.features-footer a { color: var(--text-dim); }

/* ---- kanban board (new /features layout) ---------------------------- */

body.features-page .features-shell { max-width: 1600px; }

.features-topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 0.7rem;
  align-items: start;
  margin-top: 1.2rem;
}
@media (max-width: 1100px) {
  .kanban-board { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}

.kanban-loading, .kanban-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  opacity: 0.7;
}
.kanban-error { color: var(--err, #d66); }

.kanban-column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 240px;
  padding: 0.55rem 0.55rem 0.7rem;
}

.kanban-column__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.15rem 0.35rem 0.45rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.kanban-column__header h2 {
  margin: 0;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
}
.kanban-column__count {
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 1.5em;
  text-align: center;
  opacity: 0.7;
}
.kanban-column__add-btn {
  width: 22px;
  height: 22px;
  margin-left: 0.35rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim, #999);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kanban-column__add-btn:hover {
  border-color: var(--accent, #5db1e0);
  color: var(--accent, #5db1e0);
  background: rgba(93, 177, 224, 0.08);
}

/* Per-column accent colours */
.kanban-column.is-idea       { border-top: 3px solid #6c8eaf; }
.kanban-column.is-upcoming   { border-top: 3px solid var(--warn, #d8a64a); }
.kanban-column.is-progress   { border-top: 3px solid var(--accent, #5db1e0); }
.kanban-column.is-blocked    { border-top: 3px solid #c46969; }
.kanban-column.is-done       { border-top: 3px solid #6cae72; }

.kanban-column__cards {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 60px;
  padding: 0.1rem;
  border-radius: 6px;
  transition: background 0.1s ease;
}
.kanban-column__cards.is-drop-target {
  background: rgba(93, 177, 224, 0.08);
  outline: 1px dashed var(--accent, #5db1e0);
}

.kanban-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  user-select: none;
  transition: transform 0.05s ease, border-color 0.1s ease;
}
.kanban-card:hover {
  border-color: var(--accent, #5db1e0);
  transform: translateY(-1px);
}
.kanban-card.is-dragging { opacity: 0.5; }
.kanban-card h3 {
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
  letter-spacing: 0.005em;
}
.kanban-card__preview {
  font-size: 0.8rem;
  line-height: 1.4;
  opacity: 0.78;
  max-height: 5.2em;
  overflow: hidden;
  position: relative;
}
.kanban-card__preview p { margin: 0; }
.kanban-card__preview code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 3px;
  font-size: 0.78rem;
}

.kanban-card__stage {
  display: inline-block;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
  margin: 0.1rem 0 0.3rem;
  letter-spacing: 0.01em;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  opacity: 0.85;
}
.kanban-card__stage.is-running {
  border-color: var(--accent, #5db1e0);
  background: rgba(93, 177, 224, 0.12);
  color: var(--accent, #5db1e0);
  animation: kanban-stage-pulse 1.4s ease-in-out infinite;
}
.kanban-card__stage.is-success {
  border-color: rgba(108, 174, 114, 0.5);
  background: rgba(108, 174, 114, 0.12);
  color: #6cae72;
}
.kanban-card__stage.is-error {
  border-color: rgba(196, 105, 105, 0.5);
  background: rgba(196, 105, 105, 0.12);
  color: #c46969;
}
@keyframes kanban-stage-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.kanban-column__add {
  margin-top: 0.5rem;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--text-dim, #999);
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
}
.kanban-column__add:hover {
  border-color: var(--accent, #5db1e0);
  color: var(--text);
}

/* ---- card edit modal ----------------------------------------------- */

.card-modal {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 680px;
  width: 92vw;
}
.card-modal::backdrop { background: rgba(0, 0, 0, 0.55); }

#card-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1rem 1.2rem 1.1rem;
}

.card-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}
.card-modal__header h2 {
  margin: 0;
  font-size: 1.05rem;
}
.card-modal__close {
  background: transparent;
  border: 0;
  font-size: 1.4rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}
.card-modal__close:hover { background: var(--bg); }

.card-modal__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.card-modal__field span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.65;
}
.card-modal__field input,
.card-modal__field textarea,
.card-modal__field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  font: inherit;
}
.card-modal__field textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88rem;
  line-height: 1.45;
}

.card-modal__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
}
.card-modal__spacer { flex: 1; }
.card-modal .btn-danger {
  background: transparent;
  border: 1px solid #c46969;
  color: #c46969;
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font: inherit;
}
.card-modal .btn-danger:hover { background: rgba(196, 105, 105, 0.1); }
.card-modal .btn-primary {
  background: var(--accent, #5db1e0);
  border: 1px solid var(--accent, #5db1e0);
  color: #fff;
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  font: inherit;
}
.card-modal .btn-primary:hover { filter: brightness(1.1); }
.card-modal .btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font: inherit;
}
.card-modal .btn-ghost:hover { background: var(--bg); }
