/* RDM dashboard — dark/light themes, three-panel layout. */

:root {
  --bg: #0f1218;
  --bg-panel: #151a23;
  --bg-raised: #1c2330;
  --bg-hover: #222b3b;
  --border: #2a3444;
  --text: #e6ebf2;
  --muted: #8a97ab;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.16);
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --purple: #a78bfa;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-theme="light"] {
  --bg: #f3f5f9;
  --bg-panel: #ffffff;
  --bg-raised: #f6f8fc;
  --bg-hover: #e9eef7;
  --border: #dde4ef;
  --text: #1a2233;
  --muted: #5c6b84;
  --accent: #2f6bff;
  --accent-soft: rgba(47, 107, 255, 0.12);
  --shadow: 0 8px 24px rgba(30, 45, 80, 0.12);
}

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

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: var(--text); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }

/* ── topbar ─────────────────────────────────────────────── */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; }
.brand-sub { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; }
.global-search { flex: 1; max-width: 420px; }
.global-search input, .panel input, .modal input, .modal textarea, .modal select {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.global-search input:focus, .panel input:focus, .modal input:focus, .modal textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); display: inline-block; }
.dot.ok { background: var(--green); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--bg-raised); border: 1px solid var(--border); color: var(--muted); }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 15px;
  border-radius: 8px;
  padding: 6px 9px;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--bg-hover); }

/* ── layout ─────────────────────────────────────────────── */
.layout { display: flex; height: calc(100vh - 52px); position: relative; }
.panel { background: var(--bg-panel); display: flex; flex-direction: column; min-width: 0; }
/* Flex order places the drag handles between the panels: left | ∥ | center | ∥ | right */
.panel.left { order: 0; width: 260px; border-right: 1px solid var(--border); transition: width 0.2s ease, margin-left 0.2s ease; }
#resizer-left { order: 1; }
.panel.center { order: 2; flex: 1; overflow: auto; background: var(--bg); }
#resizer-right { order: 3; }
.panel.right { order: 4; width: 380px; border-left: 1px solid var(--border); transition: width 0.2s ease, margin-right 0.2s ease; }
.panel.collapsed { display: none; }
.resizer { flex: 0 0 5px; width: 5px; cursor: col-resize; background: transparent; transition: background 0.15s ease; z-index: 5; }
.resizer:hover, .resizer.dragging { background: var(--accent); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.panel-foot { padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; }

/* ── buttons ────────────────────────────────────────────── */
.btn {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.12); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── project list ───────────────────────────────────────── */
.sys-item {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; border-left: 3px solid transparent;
  transition: background 0.12s ease;
}
.sys-item:hover { background: var(--bg-hover); }
.sys-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.sys-icon { font-size: 15px; }
.list { flex: 1; overflow-y: auto; padding: 8px; }
.proj-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; margin-bottom: 2px;
  border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease;
}
.proj-item:hover { background: var(--bg-hover); }
.proj-item.active { background: var(--accent-soft); border-color: var(--accent); }
.proj-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-meta { font-size: 11px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.stopped { background: var(--muted); }
.status-dot.broken, .status-dot.unknown { background: var(--yellow); }

/* ── center ─────────────────────────────────────────────── */
.empty { height: 100%; display: flex; align-items: center; justify-content: center; }
.empty-box { text-align: center; color: var(--muted); }
.empty-icon { font-size: 46px; margin-bottom: 10px; }
.project-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px 10px; }
.project-head h1 { margin: 0 0 4px; font-size: 21px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tabs { display: flex; gap: 2px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.tabs button {
  background: none; border: none; color: var(--muted);
  padding: 10px 14px; font-size: 13px; font-weight: 600;
  border-bottom: 2px solid transparent; transition: color 0.15s ease;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab { padding: 18px 22px; display: none; animation: fadein 0.2s ease; }
.tab.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.card .value { font-size: 17px; font-weight: 650; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-all; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
tr { cursor: pointer; transition: background 0.1s ease; }
tbody tr:hover { background: var(--bg-hover); }
td.mono, .mono { font-family: var(--mono); font-size: 12px; }
.prompt-cell { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill.completed { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.pill.running, .pill.starting { background: rgba(79, 140, 255, 0.15); color: var(--accent); }
.pill.queued { background: rgba(138, 151, 171, 0.18); color: var(--muted); }
.pill.failed { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.pill.cancelled, .pill.interrupted { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }
.pill.waiting_for_approval { background: rgba(167, 139, 250, 0.18); color: var(--purple); }

/* ── screens ────────────────────────────────────────────── */
.screens-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.screen-card {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: zoom-in; transition: transform 0.12s ease, border-color 0.12s ease;
}
.screen-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.screen-card img { width: 100%; display: block; aspect-ratio: 16/10; object-fit: cover; background: #000; }
.screen-card .cap { padding: 7px 10px; font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* ── system page ────────────────────────────────────────── */
.checks { display: flex; flex-direction: column; gap: 6px; }
.check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 8px;
}
.check-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.check-dot.ok { background: var(--green); }
.check-dot.warn { background: var(--yellow); }
.check-dot.fail { background: var(--red); }
.check-name { font-family: var(--mono); font-size: 12px; min-width: 120px; }
.check-detail { font-size: 12px; }
.bar {
  height: 8px; border-radius: 5px; background: var(--bg-raised);
  border: 1px solid var(--border); overflow: hidden; margin: 8px 0 6px;
}
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.5s ease; }
.bar > i.warn { background: var(--yellow); }
.cores { display: flex; gap: 3px; align-items: flex-end; height: 26px; margin-top: 8px; }
.core {
  flex: 1; max-width: 12px; height: 100%;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 3px;
  display: flex; align-items: flex-end; overflow: hidden;
}
.core > i { display: block; width: 100%; background: var(--accent); transition: height 0.5s ease; }
.disks { display: flex; flex-direction: column; gap: 8px; }
.disk-row { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.disk-row .disk-path { min-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── config page ───────────────────────────────────────── */
.cfg-note { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.cfg-group h3 {
  margin: 4px 0 6px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--accent);
}
.cfg-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--border);
}
.cfg-row input { width: 170px; }
.cfg-row input[type="checkbox"] { width: auto; }
.cfg-row.secret input { border-color: var(--yellow); }
.cfg-count { font-size: 12px; color: var(--yellow); font-family: var(--mono); margin-right: auto; }
#cfg-body { max-height: 62vh; overflow-y: auto; padding: 2px; }
.files { display: flex; gap: 14px; min-height: 420px; }
.files-nav { width: 300px; flex-shrink: 0; min-width: 0; }
.files-view { flex: 1; min-width: 0; }
.files-crumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; font-size: 12px; }
.crumb { color: var(--accent); cursor: pointer; }
.crumb:hover { text-decoration: underline; }
.file-entries { max-height: 520px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel); }
.file-entry { display: flex; gap: 8px; align-items: center; padding: 7px 10px; cursor: pointer; font-size: 13px; }
.file-entry:hover { background: var(--bg-hover); }
.file-entry .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-entry .fsize { margin-left: auto; font-size: 11px; color: var(--muted); flex-shrink: 0; }
.files-view-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px 8px 0 0; background: var(--bg-panel);
}
.files-content {
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 8px 8px; padding: 14px;
  max-height: 560px; overflow: auto; background: var(--bg-panel);
}
.files-content.md { line-height: 1.6; }
.files-content.code pre {
  margin: 0; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-word;
}
.files-content.md pre {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; overflow-x: auto;
}

/* ── chat ───────────────────────────────────────────────── */
#chat-messages { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; }
#chat-context { padding: 6px 14px; font-size: 11px; border-bottom: 1px solid var(--border); }

/* Composer: tabs attach to the box's top border; Send/Template/Expand sit
   inside the box at the bottom-right corner. */
#chat-composer { padding: 10px 12px 12px; border-top: 1px solid var(--border); }
#chat-modes {
  display: flex; align-items: flex-end; gap: 2px;
  padding: 0 2px; border-top: 0; margin-bottom: -1px;
}
#chat-modes[hidden] { display: none; }
.mode-tab {
  flex: 0 0 auto; background: transparent; border: 1px solid var(--border);
  border-bottom: 0; color: var(--muted); border-radius: 10px 10px 0 0;
  padding: 7px 14px; font-size: 12.5px; font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap; cursor: pointer;
}
.mode-tab:hover { color: var(--text); background: var(--bg-hover); }
/* The active tab flows into the composer box (same fill, no divider). */
.mode-tab.active {
  color: var(--accent); background: var(--bg-raised);
  border-color: var(--border); position: relative;
}
.mode-tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
#chat-composer-box {
  position: relative; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: 0 12px 12px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* No tabs (system view) → fully rounded box. */
#chat-modes[hidden] + #chat-composer-box { border-radius: 12px; }
#chat-composer-box:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
#chat-input {
  display: block; width: 100%; resize: none; background: transparent;
  border: 0; outline: none; min-height: 86px; max-height: 300px;
  padding: 13px 14px 50px; font-size: 13px; line-height: 1.5;
  color: var(--text);
}
#chat-input::placeholder { color: var(--muted); }
/* Bottom-right tool cluster inside the composer box. */
#composer-tools {
  position: absolute; right: 8px; bottom: 8px;
  display: flex; gap: 6px; align-items: center;
}
.tool-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font-size: 15px; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.tool-btn[hidden] { display: none; }
.tool-btn:hover { background: var(--bg-hover); color: var(--text); }
.send-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); border: 0; border-radius: 9px;
  color: #fff; font-size: 17px; cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.send-btn:hover { opacity: 0.92; }
.send-btn:active { transform: scale(0.94); }
.send-btn:disabled { opacity: 0.4; cursor: default; }
/* Stop sits at the bottom-left of the composer, out of the tools' way. */
#chat-stop { position: absolute; left: 10px; bottom: 10px; }

/* Template popover: opens upward from the ⚡ button. */
.qa-wrap { position: relative; }
.qa-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 30;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.35); min-width: 210px; overflow: hidden;
  display: flex; flex-direction: column; max-height: 60vh; overflow-y: auto;
}
/* The hidden attribute must beat display:flex — without this the menu is
   always visible. */
.qa-menu[hidden] { display: none; }
.qa-item {
  background: none; border: 0; color: var(--text); text-align: left;
  padding: 9px 14px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.qa-item:hover { background: var(--bg-hover); }
.qa-item.sys { color: var(--ok, #2e9e5b); }
.qa-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Full-page input mode: the panel becomes one big editor. */
.panel.right.input-full #chat-messages,
.panel.right.input-full #chat-modes,
.panel.right.input-full #chat-context { display: none; }
.panel.right.input-full #chat-composer { flex: 1; display: flex; flex-direction: column; padding: 8px; }
.panel.right.input-full #chat-composer-box { flex: 1; border-radius: 12px; }
.panel.right.input-full #chat-input {
  flex: 1; max-height: none; height: 100%; min-height: 0;
  font-family: var(--mono); font-size: 13px;
}

/* ── banners (container-attach, secrets info) ─────────── */
.banner {
  display: flex; flex-direction: column; gap: 2px;
  border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 13px;
}
.banner.warn { background: color-mix(in srgb, var(--warn, #b8860b) 14%, transparent); border: 1px solid color-mix(in srgb, var(--warn, #b8860b) 45%, transparent); }
.banner.info { background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.banner .input { background: var(--bg-raised); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 12px; }

/* ── secrets tab ───────────────────────────────────────── */
.sec-row {
  display: grid; grid-template-columns: 170px 1fr auto; gap: 8px;
  align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border);
}
.sec-row:last-child { border-bottom: 0; }
.sec-row textarea { min-height: 70px; }
.sec-label { font-size: 12.5px; color: var(--text); }
.sec-label .ok { color: var(--ok, #2e9e5b); font-size: 11px; }
.sec-clear { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.sec-row input[type="text"], .sec-row input[type="password"], .sec-row textarea, .sec-row select {
  background: var(--bg-raised); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font-size: 12.5px; width: 100%;
}
.env-row { grid-template-columns: 160px 1fr auto; }
.env-row input[readonly] { opacity: 0.75; }

/* ── conversation history modal ────────────────────────── */
.hist-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; background: var(--bg-raised);
}
.hist-main { flex: 1; min-width: 0; }
.hist-title {
  font-weight: 600; font-size: 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.hist-meta { font-size: 11.5px; margin-top: 2px; }
.hist-actions { display: flex; gap: 6px; align-items: center; }

/* ── chat buttons editor ───────────────────────────────── */
.act-row {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; background: var(--bg-raised);
}

/* ── activity/audit log ────────────────────────────────── */
.audit-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.audit-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.audit-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.audit-table tr:last-child td { border-bottom: 0; }
.audit-table tr.audit-group td { color: var(--muted); }
.pill.audit { background: var(--accent-soft, rgba(99,102,241,0.14)); color: var(--accent); }
.pill.muted { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.pill.actor { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.pill.actor.sys { color: var(--muted); }
.act-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.act-label { font-weight: 600; font-size: 13px; flex: 1; }
.act-kind {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 2px 7px; border-radius: 20px; border: 1px solid var(--border); color: var(--muted);
}
.act-kind.input { color: var(--accent); border-color: var(--accent); }
.act-kind.system { color: var(--ok, #2e9e5b); border-color: var(--ok, #2e9e5b); }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 13px; line-height: 1.55; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
.msg.agent { align-self: flex-start; background: var(--bg-raised); border: 1px solid var(--border); border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.msg.error { align-self: flex-start; background: rgba(248,113,113,0.1); border: 1px solid var(--red); color: var(--red); }
.msg pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; overflow-x: auto; font-family: var(--mono); font-size: 12px;
  position: relative; margin: 6px 0;
}
.msg code { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.msg.user code { background: rgba(255,255,255,0.2); }
.msg pre code { background: none; padding: 0; }
.copy-btn {
  position: absolute; top: 6px; right: 6px; font-size: 11px; padding: 2px 8px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 6px; color: var(--muted);
}
.copy-btn:hover { color: var(--text); }
.chat-empty { color: var(--muted); text-align: center; margin-top: 38%; font-size: 13px; line-height: 1.7; padding: 0 18px; }
.msg .steps { margin-top: 8px; font-size: 12px; }
.msg .steps summary { cursor: pointer; color: var(--muted); user-select: none; }
.msg .step {
  border-left: 2px solid var(--border); padding: 4px 8px; margin-top: 6px;
  background: var(--bg); border-radius: 0 6px 6px 0;
}
.msg .step .ok { color: var(--green); }
.msg .step .bad { color: var(--red); }
.msg .step-text {
  white-space: pre-wrap; word-break: break-word; font-family: var(--mono);
  font-size: 11px; color: var(--muted); max-height: 90px; overflow: auto;
}
.msg.thinking { opacity: 0.55; animation: pulse 1.2s ease infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.8; } }

/* ── modal / viewer / toasts ────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(5, 8, 14, 0.62);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  animation: fadein 0.15s ease;
}
.modal-box {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; min-width: 360px; max-width: 90vw; max-height: 84vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-box h2 { margin: 0 0 10px; font-size: 16px; }
.modal-box label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#viewer img { max-width: 92vw; max-height: 90vh; border-radius: 8px; box-shadow: var(--shadow); }
.viewer-close { position: absolute; top: 18px; right: 22px; font-size: 18px; background: var(--bg-raised); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 10px; }
#login-overlay .modal-box { max-width: 380px; }

#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--bg-raised); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow);
  animation: slidein 0.2s ease; max-width: 380px;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ── scrollbars ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 1080px) {
  .panel.right { width: 320px; }
}
@media (max-width: 860px) {
  .panel.left, .panel.right { position: absolute; top: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow); }
  .panel.left { left: 0; }
  .panel.right { right: 0; }
  .resizer { display: none; }
  .brand-sub { display: none; }
}
