/* ---------- tokens ----------
   One light palette everywhere. The code editor panel is the single exception:
   it re-declares the same tokens dark, so its whole subtree flips without any
   parallel stylesheet.                                                       */
:root {
  color-scheme: light;

  --bg: #ffffff;
  --chrome: #dee1e6;          /* tab strip / window frame */
  --toolbar: #ffffff;         /* toolbar + active tab */
  --surface: #f7f7f8;
  --surface-2: #ffffff;
  --surface-3: #ebebef;
  --border: #e0e0e4;
  --hover: #00000010;
  --hover-strong: #0000001a;

  --text: #1f2328;
  --text-dim: #5d6169;
  --text-faint: #8b8f96;

  --accent: #0b7a5e;
  --accent-soft: rgba(11, 122, 94, 0.12);
  --danger: #b42318;
  --warn: #b26b00;

  --code-bg: #f7f8fa;
  --omni-bg: #f1f3f4;
  --editor-bg: #1e1e1e;
  --scroll: #00000026;
  --scroll-hover: #0000003d;

  --err-bg: #fff4f3;
  --err-border: #f3c9c4;
  --err-text: #96231b;
  --stream-err: #b42318;

  /* survey */
  --s-bg: #ffffff;
  --s-text: #1f2328;
  --s-muted: #57606a;
  --s-faint: #8b949e;
  --s-line: #d8dde3;
  --s-line-soft: #eaeef2;
  --s-accent: #0b7a5e;
  --s-accent-hover: #096850;
  --s-error: #b42318;
  --s-error-bg: #fff8f7;
  --s-input-bg: #ffffff;
  --s-code-bg: #f3f5f7;

  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --sidebar-w: 260px;
  --tabstrip-h: 38px;
  --toolbar-h: 44px;
  --tab-curve: 12px;
  --split: 50%;
}

/* The editor panel keeps a dark shell so code reads like code. */
.panel[data-panel="ide"] {
  color-scheme: dark;
  /* Re-resolve `color` here: inheritance passes the computed value, so without
     this, text with no colour of its own keeps the light theme's near-black
     and disappears against the dark panel. */
  color: var(--text);

  --bg: #1e1e1e;
  --surface: #202020;
  --surface-2: #262626;
  --surface-3: #333333;
  --border: #333336;
  --hover: #ffffff12;
  --hover-strong: #ffffff26;

  --text: #e6e6e6;
  --text-dim: #a0a0a0;
  --text-faint: #767676;

  --accent: #10a37f;
  --accent-soft: rgba(16, 163, 127, 0.16);
  --danger: #f2555a;
  --warn: #e5a03a;

  --code-bg: #161616;
  --scroll: #ffffff1f;
  --scroll-hover: #ffffff33;
  --stream-err: #ff8f92;
}

* { box-sizing: border-box; }

/* The hidden attribute must beat our display rules (display:grid/flex/block
   otherwise silently override the UA stylesheet's [hidden] { display: none }). */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }
kbd {
  font-family: var(--mono); font-size: 10px; background: var(--surface-3);
  border-radius: 4px; padding: 1px 4px; color: var(--text-dim);
}

/* ---------- browser chrome ---------- */
.chrome { background: var(--chrome); user-select: none; }

.titlebar {
  height: var(--tabstrip-h);
  display: flex;
  align-items: flex-end;
  padding-left: 12px;
}

/* macOS window buttons, decorative */
.traffic { display: flex; gap: 8px; align-items: center; height: 100%; padding: 8px 14px 0 0; }
.light { width: 12px; height: 12px; border-radius: 50%; }
.light.close { background: #ff5f57; }
.light.min { background: #febc2e; }
.light.max { background: #28c840; }

.tabstrip { display: flex; align-items: flex-end; height: 100%; flex: 1; min-width: 0; position: relative; }

/* Chrome's tab: rounded top, and concave "shoulders" that flare into the strip.
   Each shoulder is a small box whose huge box-shadow is clipped to it, so the
   shadow fills everything outside the rounded corner - an inverted radius. */
.tab {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  height: 30px;
  flex: 0 1 210px;
  min-width: 54px;
  padding: 0 8px 0 12px;
  margin-bottom: 0;
  border: none;
  background: transparent;
  color: var(--text-faint);
  border-radius: var(--tab-curve) var(--tab-curve) 0 0;
  font-size: 12.5px;
  transition: background .1s ease, color .1s ease;
}
.tab:hover { background: var(--hover); color: var(--text-dim); }

.tab.active {
  background: var(--toolbar);
  color: var(--text);
  z-index: 2;
}
.tab.active::before,
.tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: var(--tab-curve);
  height: var(--tab-curve);
  box-shadow: 0 0 0 40px var(--toolbar);
  clip-path: inset(0 0 0 0);
}
.tab.active::before { left: calc(-1 * var(--tab-curve)); border-bottom-right-radius: var(--tab-curve); }
.tab.active::after { right: calc(-1 * var(--tab-curve)); border-bottom-left-radius: var(--tab-curve); }

/* Hairline separator between inactive neighbours, hidden next to an active tab. */
.tab:not(.active) + .tab:not(.active)::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 1px;
  background: var(--hover);
}
.tab:hover + .tab::before, .tab:hover::before { background: transparent !important; }

.favicon {
  flex: none;
  width: 16px; height: 16px; border-radius: 4px;
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700; color: #06231b;
}
.favicon.chat { display: grid; height: 16px; background: #2b8a3e; color: #fff; }
.favicon.ide { display: grid; height: 16px; background: #7048e8; color: #fff; }
.favicon.example { background: #1c7ed6; color: #fff; }
.favicon.task { background: #e8590c; color: #fff; }
.favicon.web { background: var(--surface-3); color: var(--text-dim); }
#language.is-unset { color: var(--text-faint); }

.tab-title {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden;
  text-align: left;
  mask-image: linear-gradient(to right, #000 calc(100% - 14px), transparent);
}

.tab-close {
  flex: none;
  display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  color: var(--text-dim);
  opacity: 0;
}
.tab:hover .tab-close, .tab.active .tab-close { opacity: 1; }
.tab-close:hover { background: var(--hover-strong); color: var(--text); }
.tabstrip.single .tab-close { display: none; }

.new-tab {
  flex: none;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  margin: 0 0 1px 6px;
  border: none; background: transparent;
  color: var(--text-dim); border-radius: 50%;
}
.new-tab:hover { background: var(--hover); color: var(--text); }
.new-tab[hidden] { display: none; }
.tab.web .tab-title { font-family: var(--sans); }

.tab-menu {
  position: absolute;
  top: calc(100% + 2px); left: 0;
  z-index: 40;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  min-width: 190px;
  box-shadow: 0 12px 32px #00000030;
}
.tab-menu[hidden] { display: none; }
.tab-menu button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 9px;
  border: none; background: transparent;
  border-radius: 7px; font-size: 13px; text-align: left;
}
.tab-menu button:hover { background: var(--surface-3); }

/* toolbar */
.toolbar {
  height: var(--toolbar-h);
  background: var(--toolbar);
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  position: relative;
}

.nav-btns { display: flex; gap: 2px; }
.nav-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border: none; background: transparent;
  color: var(--text-dim); border-radius: 50%;
}
.nav-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.nav-btn:disabled { color: var(--text-faint); opacity: .45; cursor: default; }

.omnibox {
  flex: 1;
  display: flex; align-items: center; gap: 9px;
  height: 30px;
  padding: 0 14px;
  margin: 0 6px;
  background: var(--omni-bg);
  border-radius: 15px;
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
}
.omnibox .lock { flex: none; color: var(--text-faint); }
.omnibox .url { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.omnibox .url[hidden] { display: none; }

/* The same omnibox, editable, when a web tab is in front. */
.omni-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
}
.omni-input[hidden] { display: none; }
.omni-input::placeholder { color: var(--text-faint); font-family: var(--sans); }
.omnibox .path { color: var(--text); }

.toolbar-actions { display: flex; align-items: center; gap: 2px; position: relative; }
.menu-pop {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  z-index: 40;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  min-width: 270px;
  box-shadow: 0 12px 32px #00000030;
}
.menu-pop[hidden] { display: none; }
.menu-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; font-size: 12.5px; color: var(--text-dim);
}
.menu-row span { flex: 1; }

/* Remove split: only while split, with its label so it is found. */
.unsplit-btn { display: inline-flex; align-items: center; width: auto; gap: 6px; padding: 0 10px; font: inherit; font-size: 12.5px; color: var(--text-dim); }
.unsplit-btn[hidden] { display: none; }

/* Dragging a tab onto the viewport: the half it will take lights up. Frames
   would swallow the drag, so they ignore the pointer meanwhile. */
.viewport { position: relative; }
.drop-hint { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 30; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 16%, transparent); border: 2px dashed var(--accent); border-radius: 8px; }
.drop-hint[hidden] { display: none; }
body.tab-dragging iframe { pointer-events: none; }

/* ---------- viewport + split ---------- */
.viewport {
  height: calc(100% - var(--tabstrip-h) - var(--toolbar-h));
  display: flex;
  background: var(--bg);
}

.panel { display: none; height: 100%; min-width: 0; background: var(--bg); }
.panel.active { display: block; flex: 1 1 auto; }

/* Split view: any two panels side by side, the left one sized by --split. */
.viewport.split .panel.active { flex: 1 1 auto; min-width: 280px; }
.viewport.split .panel.active.pane-left { flex: 0 0 var(--split); }

.vgutter {
  flex: none;
  width: 6px;
  background: var(--chrome);
  cursor: col-resize;
  position: relative;
}
.vgutter[hidden] { display: none; }
.vgutter::after {
  content: "";
  position: absolute; inset: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.vgutter:hover, .vgutter.dragging { background: var(--surface-3); }
body.col-resizing { cursor: col-resize; }
body.col-resizing * { user-select: none; pointer-events: none; }

.blank-state {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--text-faint);
}
.blank-state h2 { font-size: 17px; font-weight: 500; color: var(--text-dim); margin: 0; }
.blank-state[hidden] { display: none; }

/* ---------- chat ---------- */
.chat { display: flex; height: 100%; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition: margin-left .18s ease;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

.sidebar-head { display: flex; gap: 6px; padding: 10px; align-items: center; }
.new-chat {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  transition: background .12s ease;
}
.new-chat:hover { background: var(--surface-2); }

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: none; background: transparent; border-radius: 8px;
  color: var(--text-dim);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.conv-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.conv-group-label {
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: var(--text-faint); padding: 10px 8px 6px; text-transform: uppercase;
}
.conv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.conv {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 8px 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
}
.conv:hover { background: var(--surface-2); color: var(--text); }
.conv.active { background: var(--surface-3); color: var(--text); }
.conv-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-del {
  border: none; background: transparent; color: var(--text-faint);
  opacity: 0; padding: 2px 4px; border-radius: 6px; line-height: 1;
}
.conv:hover .conv-del, .conv.active .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); background: var(--hover); }
.conv-empty { padding: 8px 10px; font-size: 13px; color: var(--text-faint); }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }
.who { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-dim); padding: 4px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4b8f7d);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: #06231b;
}

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.show-sidebar { position: absolute; top: 10px; left: 10px; z-index: 5; }

.messages { flex: 1; overflow-y: auto; scroll-behavior: smooth; }

.empty-state {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 0 24px;
}
.empty-state h1 { font-size: 28px; font-weight: 500; margin: 0; }
.empty-state p { color: var(--text-faint); font-size: 14px; margin: 0; }

.msg { padding: 18px 24px; }
.msg-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 16px; }

.msg.user .msg-inner { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--surface-3);
  padding: 10px 16px;
  border-radius: 20px;
  max-width: 75%;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.assistant .role-badge {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-3);
  display: grid; place-items: center; margin-top: 2px;
}
.msg.assistant .role-badge svg { display: block; }
.msg.assistant .bubble { min-width: 0; flex: 1; line-height: 1.65; }

.bubble > *:first-child { margin-top: 0; }
.bubble > *:last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 12px; }
.bubble h1, .bubble h2, .bubble h3 { margin: 18px 0 8px; line-height: 1.3; }
.bubble h1 { font-size: 20px; } .bubble h2 { font-size: 18px; } .bubble h3 { font-size: 16px; }
.bubble ul, .bubble ol { margin: 0 0 12px; padding-left: 22px; }
.bubble li { margin: 4px 0; }
.bubble a { color: #2f7ed8; }
.bubble code {
  font-family: var(--mono); font-size: .87em;
  background: var(--surface-3); padding: 2px 5px; border-radius: 5px;
}
.bubble blockquote {
  margin: 0 0 12px; padding-left: 12px;
  border-left: 3px solid var(--surface-3); color: var(--text-dim);
}

.codeblock {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
}
.codeblock-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 6px 12px;
  background: var(--surface-2);
  font-size: 11px; color: var(--text-faint);
  font-family: var(--mono);
}
.copy-btn {
  border: none; background: transparent; color: var(--text-faint);
  font-size: 11px; padding: 3px 7px; border-radius: 6px;
}
.copy-btn:hover { background: var(--hover); color: var(--text); }
.codeblock pre {
  margin: 0; padding: 12px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
}
.codeblock code { background: none; padding: 0; font-size: inherit; }

.cursor {
  display: inline-block; width: 7px; height: 15px;
  background: var(--text); vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite; margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Before the reply's first words arrive. */
.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 14px; }
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  animation: thinking 1.2s ease-in-out infinite;
}
.thinking-dots i:nth-child(2) { animation-delay: .15s; }
.thinking-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes thinking { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .thinking-dots i { animation: none; opacity: .6; } }

.msg.error .bubble {
  border: 1px solid var(--err-border); background: var(--err-bg);
  color: var(--err-text); border-radius: 10px; padding: 10px 14px; font-size: 14px;
}

/* composer */
.composer-wrap { padding: 0 24px 14px; }
.composer {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 8px 8px 8px 18px;
}
.composer:focus-within { border-color: #444; }
.composer textarea {
  flex: 1; resize: none; border: none; outline: none;
  background: transparent; color: var(--text);
  font-family: inherit; font-size: 15px; line-height: 1.5;
  max-height: 200px; padding: 8px 0;
}
.composer textarea::placeholder { color: var(--text-faint); }
.send {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: none; background: var(--text); color: var(--bg);
  display: grid; place-items: center;
}
.send:disabled { background: var(--surface-3); color: var(--text-faint); cursor: not-allowed; }
.stop-square { width: 11px; height: 11px; border-radius: 2px; background: currentColor; }
.disclaimer { text-align: center; font-size: 11px; color: var(--text-faint); margin: 8px 0 0; }

/* ---------- ide ---------- */
.ide { height: 100%; display: flex; flex-direction: column; background: var(--editor-bg); }

.ide-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.file-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 7px;
  background: var(--surface-3); font-size: 13px; font-family: var(--mono);
}
.file-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #6c8cff; }

#language {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 9px; font-size: 13px; outline: none;
}

.run {
  display: flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff; border: none;
  padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 500;
}
.run:hover { background: #0e8f70; }
.run:disabled { opacity: .55; cursor: default; }

.ghost {
  background: transparent; border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 11px; font-size: 13px; color: var(--text-dim);
}
.ghost:hover { background: var(--surface-2); color: var(--text); }
.ghost.small { padding: 3px 9px; font-size: 12px; }
.ghost.icon-only { display: grid; place-items: center; padding: 5px 8px; }

.run-kind { display: flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.run-kind[hidden] { display: none; }
.run-kind button {
  background: transparent; border: none; padding: 6px 11px; font-size: 13px; color: var(--text-dim);
}
.run-kind button + button { border-left: 1px solid var(--border); }
.run-kind button:hover { background: var(--surface-2); color: var(--text); }
.run-kind button[aria-checked="true"] { background: var(--surface-3); color: var(--text); font-weight: 600; }

.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.runtime-badge { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

/* ---------- ide shell: explorer | editor ---------- */
.ide-main { flex: 1; display: flex; min-height: 0; }

.explorer {
  flex: none;
  width: 210px;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}
.explorer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 6px 6px 12px;
}
.explorer-title {
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-faint);
}
.explorer-actions { display: flex; gap: 1px; }
.explorer-btn {
  display: grid; place-items: center;
  width: 24px; height: 24px;
  border: none; background: transparent;
  color: var(--text-dim); border-radius: 5px;
}
.explorer-btn:hover { background: var(--hover); color: var(--text); }

.tree { flex: 1; overflow: auto; padding-bottom: 10px; }

.row {
  display: flex; align-items: center; gap: 6px;
  height: 23px;
  padding: 0 8px 0 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.row:hover { background: var(--hover); }
.row.active { background: var(--hover-strong); color: var(--text); }
.row.selected { background: var(--hover); color: var(--text); }
.row.drop-target {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* One guide per level of nesting - the only reliable cue that a file sits
   inside the folder above it rather than beside it. */
.row-guides { display: flex; flex: none; align-self: stretch; }
.guide {
  width: 16px;
  border-left: 1px solid var(--border);
  margin-right: 0;
}
.row-name { overflow: hidden; text-overflow: ellipsis; }
.row-icon { flex: none; }
.row-indent { width: 12px; flex: none; }
.row-badge {
  flex: none;
  font-size: 8.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 4px; border-radius: 3px;
}
.row-input { height: 26px; }

.tree-input {
  width: calc(100% - 16px);
  background: var(--surface-3);
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 5px;
  outline: none;
}

.explorer-gutter {
  flex: none;
  width: 4px;
  cursor: col-resize;
  background: var(--border);
}
.explorer-gutter:hover { background: var(--accent); }

.editor-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- open editor tabs ---------- */
.file-tabs {
  flex: none;
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.file-tabs::-webkit-scrollbar { display: none; }
.file-tabs[hidden] { display: none; }

.file-tab {
  display: flex; align-items: center; gap: 7px;
  padding: 0 8px 0 11px;
  height: 33px;
  border-right: 1px solid var(--border);
  border-top: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  max-width: 210px;
  cursor: pointer;
}
.file-tab:hover { color: var(--text-dim); }
.file-tab.active {
  background: var(--bg);
  border-top-color: var(--accent);
  color: var(--text);
}
.file-name { overflow: hidden; text-overflow: ellipsis; }
.file-badge {
  flex: none;
  font-family: var(--sans);
  font-size: 8.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 4px; border-radius: 3px;
}
.file-close {
  flex: none;
  display: grid; place-items: center;
  width: 17px; height: 17px;
  border-radius: 4px;
  font-size: 10px;
  opacity: 0;
}
.file-tab:hover .file-close, .file-tab.active .file-close { opacity: .7; }
.file-close:hover { background: var(--hover-strong); opacity: 1; }

/* ---------- context menu ---------- */
.ctx-menu {
  position: fixed;
  z-index: 400;
  min-width: 160px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 10px 28px rgba(0,0,0,.4);
  color: var(--text);
}
.ctx-menu[hidden] { display: none; }
.ctx-menu button {
  display: block; width: 100%;
  padding: 6px 10px;
  border: none; background: transparent;
  border-radius: 5px;
  color: var(--text);
  font-size: 12.5px; text-align: left;
}
.ctx-menu button:hover:not(:disabled) { background: var(--accent); color: #fff; }
.ctx-menu button:disabled { color: var(--text-faint); cursor: default; }

/* ---------- status bar ---------- */
.status-bar {
  flex: none;
  display: flex; align-items: center; gap: 16px;
  height: 24px;
  padding: 0 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
}
.status-spacer { flex: 1; }

.ide-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-host { flex: 1; min-height: 80px; position: relative; }
#editor { position: absolute; inset: 0; }

/* A CSV opens as a table over the editor, with a switch back to the text. */
.csv-view { position: absolute; inset: 0; overflow: auto; background: var(--bg); color: var(--text);
            font: 12px/1.5 ui-monospace, Menlo, monospace; z-index: 2; }
.csv-view[hidden], .csv-toggle[hidden] { display: none; }
.csv-meta { padding: 8px 12px; color: var(--text-dim); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.csv-view table { border-collapse: collapse; min-width: 100%; }
.csv-view th, .csv-view td { border: 1px solid var(--border); padding: 3px 8px; white-space: nowrap; text-align: left; }
.csv-view thead th { position: sticky; top: 0; background: var(--surface-3); z-index: 1; }
.csv-view tbody th { color: var(--text-faint); font-weight: normal; background: var(--surface); }
.csv-view tbody tr:hover td { background: var(--hover); }
.csv-toggle { position: absolute; top: 6px; right: 18px; z-index: 3; font: 12px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
              padding: 3px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2);
              color: var(--text); cursor: pointer; }
.csv-toggle:hover { background: var(--surface-3); }

.gutter { height: 6px; background: var(--surface); cursor: row-resize; flex: none; }
.gutter:hover, .gutter.dragging { background: var(--surface-3); }

/* Output beside the editor instead of beneath it. */
.ide-body.vertical { flex-direction: row; }
.ide-body.vertical .gutter { height: auto; width: 6px; cursor: col-resize; }
.ide-body.vertical .io-panel {
  height: auto;
  width: 360px;
  min-width: 160px;
  border-top: none;
  border-left: 1px solid var(--border);
}
.ide-body.vertical .editor-host { min-width: 160px; }
body.row-resizing { cursor: row-resize; }
body.row-resizing * { user-select: none; pointer-events: none; }

.io-panel {
  height: 220px; flex: none; min-height: 90px;
  display: flex; flex-direction: column;
  background: var(--surface); border-top: 1px solid var(--border);
}
.io-tabs {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-bottom: 1px solid var(--border);
}
.io-tab {
  background: transparent; border: none; color: var(--text-faint);
  font-size: 12px; padding: 4px 10px; border-radius: 6px;
}
.io-tab:hover { color: var(--text); }
.io-tab.active { background: var(--surface-3); color: var(--text); }
.io-status { margin-left: auto; font-size: 11.5px; font-family: var(--mono); color: var(--text-faint); }
.io-status .ok { color: var(--accent); }
.io-status .bad { color: var(--danger); }

.io-view { display: none; flex: 1; min-height: 0; }
.io-view.active { display: block; }

.console {
  margin: 0; height: 100%; overflow: auto; padding: 10px 14px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.console .muted { color: var(--text-faint); }
.console .err { color: var(--stream-err); }
.console .meta { color: var(--text-faint); }
.console .label { color: var(--warn); }
.console .warn { color: var(--warn); }


.stdin {
  width: 100%; height: 100%; resize: none; border: none; outline: none;
  background: transparent; color: var(--text); padding: 10px 14px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
}

.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid #ffffff44; border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--hover); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 720px) {
  .sidebar { position: absolute; z-index: 10; height: 100%; }
  .tab { min-width: 110px; }
}

/* A playground placeholder file: its lines blurred, with what will be there on top. */
.editor-host { position: relative; }
.editor-host.is-placeholder #editor { filter: blur(5px); pointer-events: none; user-select: none; }
.placeholder-cover { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 24px; text-align: center; font: 600 15px var(--sans); color: var(--text); background: color-mix(in srgb, var(--bg) 35%, transparent); }
.placeholder-cover[hidden] { display: none; }

/* ---------- the assistant's steps and edits (chat.js, ide.js) ---------- */
/* What the agent did, between what it said: one line per tool call. */
.agent-steps { margin: 4px 0 12px; padding: 6px 10px; border: 1px solid #e3e5e8; border-radius: 10px; background: #f8f9fa; font-size: 13px; }
.agent-step { display: flex; align-items: baseline; gap: 6px; padding: 2px 0; color: #3d434a; }
.agent-step-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #1a7f37; transform: translateY(-1px); }
.agent-step.is-error .agent-step-dot { background: #cf222e; }
.agent-step-label { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.agent-step-detail { color: #6e7781; overflow-wrap: anywhere; }
.agent-count { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.agent-count.add { color: #1a7f37; }
.agent-count.del { color: #cf222e; }
/* The lines the agent changed last, in the editor. */
.monaco-editor .agent-changed-line { background: rgba(46, 160, 67, 0.16); }
.monaco-editor .agent-changed-gutter { background: #2ea043; width: 3px !important; margin-left: 3px; }
.monaco-editor .agent-removed-gutter { border-top: 2px solid #f85149; width: 10px !important; margin-left: 3px; }

/* ---------- pictures in the chat (researcher accounts; chat.js) ---------- */
