/* ============================================================
   AI Dev Environment — dashboard styles
   Railway × terminal · dark · purple accent · mobile-first
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* base palette — overridden per style-direction below */
  --bg:        #0a0a0f;
  --bg-grad:   #0d0d15;
  --surface:   #14141d;
  --surface-2: #1a1a26;
  --raised:    #1e1e2b;
  --border:    rgba(255,255,255,.07);
  --border-2:  rgba(255,255,255,.12);
  --text:      #ecedf3;
  --text-dim:  #9a9bb0;
  --text-mute: #5e5f73;

  --accent:    #a07cff;            /* set by tweak */
  --accent-2:  color-mix(in oklab, var(--accent) 70%, #fff 30%);
  --accent-dim: color-mix(in oklab, var(--accent) 16%, transparent);
  --accent-line: color-mix(in oklab, var(--accent) 38%, transparent);
  --accent-glow: color-mix(in oklab, var(--accent) 45%, transparent);

  --ok:    #43d18a;
  --ok-dim: color-mix(in oklab, var(--ok) 16%, transparent);
  --warn:  #f5b948;
  --warn-dim: color-mix(in oklab, var(--warn) 16%, transparent);
  --err:   #fb6f6f;
  --err-dim: color-mix(in oklab, var(--err) 16%, transparent);
  --info:  #4aa8ff;

  --radius: 10px;                  /* set by tweak */
  --radius-sm: max(4px, calc(var(--radius) - 4px));
  --radius-xs: max(3px, calc(var(--radius) - 6px));

  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;

  /* density-driven */
  --pad: 13px;
  --gap: 10px;
  --fs:  13px;
  --glow: 1;
}

/* ---------- density ---------- */
[data-density="compact"] { --pad: 12px; --gap: 9px;  --fs: 13px; }
[data-density="cozy"]    { --pad: 16px; --gap: 13px; --fs: 14px; }

/* ---------- style direction: terminal ---------- */
[data-style="terminal"] {
  --radius: 4px;
  --surface:   #0e0e14;
  --surface-2: #13131b;
  --raised:    #181820;
  --border:    rgba(255,255,255,.09);
  --border-2:  rgba(255,255,255,.16);
  --glow: 0;
}
/* ---------- style direction: saas ---------- */
[data-style="saas"] {
  --radius: 14px;
  --surface:   #15151f;
  --surface-2: #1c1c29;
  --raised:    #22222f;
  --border:    rgba(255,255,255,.06);
  --glow: 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* full-viewport stage: centered phone column on desktop */
.stage {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(120% 70% at 50% -10%, color-mix(in oklab, var(--accent) 9%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-grad), var(--bg) 30%);
}

.app {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
}
@media (max-width: 480px) { .app { border-left: 0; border-right: 0; } }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 11px var(--pad);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar .logo {
  width: 26px; height: 26px; border-radius: var(--radius-xs);
  display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(140deg, var(--accent), color-mix(in oklab, var(--accent) 55%, #000));
  color: #0a0a0f; font-family: var(--mono); font-weight: 700; font-size: 14px;
  box-shadow: 0 0 calc(14px * var(--glow)) var(--accent-glow);
}
.topbar .host { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar .host b { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.topbar .host span {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .conn {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; color: var(--text-dim);
  padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
}
.conn .led {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 8px var(--ok);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* section nav (jump pills) */
.nav {
  position: sticky; top: 49px; z-index: 20;
  display: flex; gap: 6px; padding: 9px var(--pad);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav button {
  flex: 0 0 auto; appearance: none; cursor: pointer;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--text-dim); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 11px; transition: .15s;
}
.nav button:hover { color: var(--text); border-color: var(--border-2); }
.nav button[data-active="1"] {
  color: var(--accent-2); background: var(--accent-dim);
  border-color: var(--accent-line);
}

/* ============================================================
   Section scaffold
   ============================================================ */
.scroll { flex: 1; }
section.block { padding: 18px var(--pad) 6px; scroll-margin-top: 96px; }
.sec-head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 12px;
}
.sec-head h2 {
  margin: 0; font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--text-mute);
}
.sec-head .rule { flex: 1; height: 1px; background: var(--border); }
.sec-head .meta {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-mute);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ============================================================
   Server status
   ============================================================ */
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap);
}
.stat {
  padding: var(--pad);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px;
}
.stat .top { display: flex; align-items: center; justify-content: space-between; }
.stat .label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-mute);
}
.stat .ico { color: var(--text-mute); display: grid; place-items: center; }
.stat .val {
  font-family: var(--mono); font-weight: 600; font-size: 25px; letter-spacing: -.02em;
  line-height: 1; color: var(--text); font-variant-numeric: tabular-nums;
}
.stat .val small { font-size: 13px; color: var(--text-dim); font-weight: 500; margin-left: 2px; }
.stat .sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); }

/* progress bar */
.bar { height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 calc(8px * var(--glow)) var(--accent-glow);
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.bar.warn > i { background: linear-gradient(90deg, var(--warn), #ffd98a); box-shadow: none; }
.bar.err  > i { background: linear-gradient(90deg, var(--err), #ff9d9d); box-shadow: none; }

/* sparkline */
.spark { width: 100%; height: 30px; display: block; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark path.fill { fill: var(--accent-dim); stroke: none; }

/* ring */
.ring { width: 46px; height: 46px; flex-shrink: 0; }
.ring circle { fill: none; stroke-width: 5; }
.ring .track { stroke: var(--surface-2); }
.ring .prog { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.4,0,.2,1); filter: drop-shadow(0 0 calc(4px*var(--glow)) var(--accent-glow)); }
.ring-stat { flex-direction: row; align-items: center; gap: 12px; }
.ring-stat .col { display: flex; flex-direction: column; gap: 5px; }

/* ============================================================
   Projects
   ============================================================ */
.proj-list { display: flex; flex-direction: column; gap: var(--gap); }
.proj {
  padding: var(--pad);
  display: flex; flex-direction: column; gap: 11px;
  transition: border-color .2s;
}
.proj:hover { border-color: var(--border-2); }
.proj .row1 { display: flex; align-items: flex-start; gap: 10px; }
.proj .pmark {
  width: 30px; height: 30px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: grid; place-items: center; font-family: var(--mono); font-weight: 700;
  font-size: 13px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
}
.proj .pinfo { min-width: 0; flex: 1; }
.proj .pname { font-weight: 600; font-size: 14px; letter-spacing: -.01em; }
.proj .pdomain {
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  display: flex; align-items: center; gap: 5px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.proj .pdomain a { color: var(--text-dim); text-decoration: none; }
.proj .pdomain a:hover { color: var(--accent-2); }

/* status pill */
.pill {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px; border: 1px solid transparent;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill.running { color: var(--ok);   background: var(--ok-dim);   border-color: color-mix(in oklab,var(--ok) 30%,transparent); }
.pill.running .dot { background: var(--ok); box-shadow: 0 0 7px var(--ok); animation: pulse 2s infinite; }
.pill.stopped { color: var(--text-mute); background: var(--surface-2); border-color: var(--border); }
.pill.stopped .dot { background: var(--text-mute); }
.pill.starting, .pill.stopping { color: var(--warn); background: var(--warn-dim); border-color: color-mix(in oklab,var(--warn) 30%,transparent); }
.pill.starting .dot, .pill.stopping .dot { background: var(--warn); animation: pulse 1s infinite; }

/* project metric strip */
.pmetrics {
  display: flex; flex-wrap: wrap; gap: 5px 14px; font-family: var(--mono);
  font-size: 10.5px; color: var(--text-mute);
}
.pmetrics span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.pmetrics b { color: var(--text-dim); font-weight: 600; }

/* action buttons */
.actions { display: flex; gap: 7px; }
.btn {
  appearance: none; cursor: pointer; font-family: var(--mono);
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 7px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--text); transition: .15s; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--text-mute); background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary {
  background: var(--accent); border-color: transparent; color: #0a0a0f;
  box-shadow: 0 0 calc(14px*var(--glow)) var(--accent-glow);
}
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--err); border-color: color-mix(in oklab,var(--err) 28%,transparent); background: var(--err-dim); }
.btn.danger:hover { background: color-mix(in oklab,var(--err) 22%,transparent); }
.btn.ghost { background: transparent; }
.btn .ld { width: 12px; height: 12px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* logs drawer */
.logs {
  border-top: 1px solid var(--border);
  margin: 0 calc(var(--pad) * -1) calc(var(--pad) * -1);
  padding: 11px var(--pad) var(--pad);
  background: var(--bg);
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: var(--mono); font-size: 11px; line-height: 1.65;
  max-height: 190px; overflow-y: auto;
}
.logs .ln { display: flex; gap: 9px; white-space: pre-wrap; word-break: break-word; }
.logs .ts { color: var(--text-mute); flex-shrink: 0; }
.logs .lv-info { color: var(--text-dim); }
.logs .lv-ok   { color: var(--ok); }
.logs .lv-warn { color: var(--warn); }
.logs .lv-err  { color: var(--err); }
.logs .lv-sys  { color: var(--accent-2); }

/* ============================================================
   AI Chat
   ============================================================ */
.chat { display: flex; flex-direction: column; overflow: hidden; }
.chat-thread {
  display: flex; flex-direction: column; gap: 12px;
  padding: var(--pad); max-height: 460px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.msg { display: flex; flex-direction: column; gap: 5px; max-width: 86%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.ai   { align-self: flex-start; align-items: flex-start; }
.msg .who {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-mute);
  display: flex; align-items: center; gap: 5px;
}
.msg .bubble {
  padding: 9px 12px; border-radius: var(--radius);
  font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .bubble {
  background: var(--accent); color: #0a0a0f; font-weight: 450;
  border-bottom-right-radius: var(--radius-xs);
}
.msg.ai .bubble {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-bottom-left-radius: var(--radius-xs);
}
.msg.ai .bubble p { margin: 0 0 7px; }
.msg.ai .bubble p:last-child { margin-bottom: 0; }
.msg.ai .bubble code.inline {
  font-family: var(--mono); font-size: 12px; background: var(--bg);
  padding: 1px 5px; border-radius: 4px; color: var(--accent-2);
  border: 1px solid var(--border);
}

/* code / command block */
.code {
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; margin: 7px 0;
  width: 100%;
}
.code .chead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute);
}
.code .copy {
  appearance: none; cursor: pointer; background: transparent; border: 0;
  color: var(--text-mute); font-family: var(--mono); font-size: 10px;
  display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 4px;
}
.code .copy:hover { color: var(--accent-2); }
.code pre { margin: 0; padding: 10px 12px; overflow-x: auto; color: #d7d8e6; }
.code .prompt { color: var(--accent); }
.code .out { color: var(--text-dim); }

/* typing indicator */
.typing { display: inline-flex; gap: 4px; padding: 11px 13px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-mute);
  animation: blink 1.2s infinite both;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.3;transform:translateY(0)} 40%{opacity:1;transform:translateY(-3px)} }

/* composer */
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: var(--pad); border-top: 1px solid var(--border);
  background: var(--surface);
}
.composer .field {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); padding: 0 4px 0 11px;
  transition: border-color .15s;
}
.composer .field:focus-within { border-color: var(--accent-line); }
.composer .field .glyph { color: var(--accent); font-family: var(--mono); font-size: 13px; }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent;
  color: var(--text); font-family: var(--sans); font-size: 13.5px;
  padding: 11px 4px; max-height: 110px; line-height: 1.4;
}
.composer textarea::placeholder { color: var(--text-mute); }
.send {
  appearance: none; cursor: pointer; flex-shrink: 0;
  width: 38px; height: 38px; border-radius: var(--radius-sm); border: 0;
  background: var(--accent); color: #0a0a0f; display: grid; place-items: center;
  box-shadow: 0 0 calc(14px*var(--glow)) var(--accent-glow); transition: .15s;
}
.send:hover { background: var(--accent-2); }
.send:disabled { opacity: .4; cursor: default; box-shadow: none; }

.suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 var(--pad) var(--pad); }
.suggest button {
  appearance: none; cursor: pointer; font-family: var(--mono); font-size: 10.5px;
  color: var(--text-dim); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; transition: .15s;
}
.suggest button:hover { color: var(--accent-2); border-color: var(--accent-line); }

/* ============================================================
   Task queue
   ============================================================ */
.task-list { display: flex; flex-direction: column; }
.task {
  display: flex; align-items: center; gap: 11px;
  padding: 11px var(--pad);
  border-bottom: 1px solid var(--border);
}
.task:last-child { border-bottom: 0; }
.task:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.task .ticon {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; position: relative;
}
.task .tbody { flex: 1; min-width: 0; }
.task .tname { font-size: 13px; font-weight: 500; letter-spacing: -.01em; }
.task .tsub {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-mute);
  margin-top: 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
}
.task .tsub span { white-space: nowrap; }
.task .tprog { height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.task .tprog > i { display: block; height: 100%; background: linear-gradient(90deg,var(--accent),var(--accent-2)); transition: width .4s linear; }
.task .tstatus {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; flex-shrink: 0;
}

.t-queued   .ticon { background: var(--surface-2); color: var(--text-mute); border: 1px solid var(--border-2); }
.t-queued   .tstatus { color: var(--text-mute); }
.t-running  .ticon { background: var(--accent-dim); color: var(--accent); }
.t-running  .tstatus { color: var(--accent-2); }
.t-running  .ring-spin { position:absolute; inset:0; }
.t-completed .ticon { background: var(--ok-dim); color: var(--ok); }
.t-completed .tstatus { color: var(--ok); }
.t-failed   .ticon { background: var(--err-dim); color: var(--err); }
.t-failed   .tstatus { color: var(--err); }

.task-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px var(--pad); border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 10.5px; color: var(--text-mute);
}
.task-foot .counts { display: flex; gap: 12px; }
.task-foot .counts b { color: var(--text-dim); }

/* task elapsed time */
.t-elapsed {
  font-family: var(--mono); font-size: 9px; color: var(--accent-line);
}

/* kill button */
.task-kill {
  appearance: none; cursor: pointer; border: 1px solid var(--err-dim);
  background: transparent; color: var(--err); border-radius: 4px;
  font-size: 10px; width: 22px; height: 22px;
  display: grid; place-items: center; transition: .15s; flex-shrink: 0;
}
.task-kill:hover { background: var(--err-dim); }
.task-kill:disabled { opacity: .4; cursor: default; }
/* delete (✕) button — dimmer than kill */
.task-del { border-color: var(--border); color: var(--text-dim); }
.task-del:hover { background: var(--surface-2); color: var(--text); }

/* task clear buttons in header */
.task-clear-btns { display: flex; gap: 4px; margin-left: 4px; }
.btn.sm { padding: 2px 8px; font-size: 10px; height: auto; }
.btn.danger-hover:hover { border-color: var(--err-dim); color: var(--err); background: var(--err-dim); }

footer.foot {
  padding: 22px var(--pad) 30px; text-align: center;
  font-family: var(--mono); font-size: 10px; color: var(--text-mute);
  letter-spacing: .04em;
}

/* entrance — transform-only so content stays visible even if the
   animation timeline is throttled (never gate opacity on a keyframe) */
@keyframes rise { from { transform: translateY(7px); } to { transform: none; } }
.rise { animation: rise .35s cubic-bezier(.2,.7,.3,1) both; }

/* file download link */
.file-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  width: fit-content;
}
.file-link:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }

/* tabs / screens */
.screen { display: none; }
.screen.show { display: block; animation: screenIn .28s cubic-bezier(.2,.7,.3,1); }
@keyframes screenIn { from { transform: translateY(6px); } to { transform: none; } }

/* file upload button */
.upload-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 0.5rem;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: border-color .15s, color .15s;
}
.upload-btn:hover { border-color: var(--accent); color: var(--accent); }

/* markdown rendered content */
.md-bubble { padding: 10px 14px !important; }
.md-body { font-size: 13.5px; line-height: 1.6; color: var(--text); }
.md-body p { margin: 0 0 8px; }
.md-body p:last-child { margin-bottom: 0; }
.md-body h1,.md-body h2,.md-body h3 {
  font-family: var(--mono); font-weight: 600; margin: 12px 0 6px;
  color: var(--text); letter-spacing: -.01em;
}
.md-body h1 { font-size: 15px; }
.md-body h2 { font-size: 13px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.md-body h3 { font-size: 12px; color: var(--text-dim); }
.md-body ul, .md-body ol { margin: 6px 0 8px 18px; padding: 0; }
.md-body li { margin-bottom: 3px; }
.md-body code {
  font-family: var(--mono); font-size: 12px; background: var(--bg);
  padding: 1px 5px; border-radius: 4px; color: var(--accent-2);
  border: 1px solid var(--border);
}
.md-body pre {
  margin: 8px 0; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg); border: 1px solid var(--border);
}
.md-body pre .chead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-mute); font-family: var(--mono);
}
.md-body pre code {
  display: block; padding: 10px 12px; overflow-x: auto;
  color: #d7d8e6; background: transparent; border: none;
  font-size: 12px; line-height: 1.6;
}
.md-body table {
  border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12.5px;
}
.md-body th {
  background: var(--surface-2); color: var(--text-dim);
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .06em; padding: 6px 10px; text-align: left;
  border: 1px solid var(--border);
}
.md-body td {
  padding: 6px 10px; border: 1px solid var(--border); color: var(--text);
  vertical-align: top;
}
.md-body tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.md-body blockquote {
  border-left: 3px solid var(--accent-line); margin: 8px 0;
  padding: 4px 12px; color: var(--text-dim); font-style: italic;
}
.md-body a { color: var(--accent-2); text-decoration: none; }
.md-body a:hover { text-decoration: underline; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.md-body strong { color: var(--text); font-weight: 600; }

/* elapsed time in chat bubbles */
.elapsed {
  font-family: var(--mono); font-size: 9px; color: var(--accent-line);
  background: rgba(160,124,255,.08); border-radius: 4px; padding: 1px 5px;
  animation: pulse-elapsed 1.5s ease-in-out infinite;
}
.elapsed.done {
  color: var(--text-mute); background: transparent; animation: none;
}
@keyframes pulse-elapsed { 0%,100%{opacity:.6} 50%{opacity:1} }

/* log panel — separate block below chat card */
.log-panel-outer {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}
.log-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; cursor: pointer; user-select: none;
  transition: background .15s;
}
.log-head:hover { background: var(--surface-2); }
.log-title {
  font-family: var(--mono); font-size: 10px; color: var(--text-mute);
  display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .08em;
}
.log-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.log-dot.idle { background: var(--border-2); }
.log-dot.running { background: var(--accent-2); animation: pulse-elapsed 1s ease-in-out infinite; }
.log-dot.done { background: var(--ok); }
.log-dot.fail { background: var(--err); }
.log-toggle {
  font-family: var(--mono); font-size: 10px; color: var(--text-mute);
  letter-spacing: .05em;
}
.log-body {
  margin: 0; padding: 10px 14px;
  font-family: var(--mono); font-size: 11px; line-height: 1.6;
  color: #a0a8c0; white-space: pre-wrap; word-wrap: break-word;
  max-height: 260px; overflow-y: auto;
  border-top: 1px solid var(--border);
}
.log-body::-webkit-scrollbar { width: 4px; }
.log-body::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* clear chat button */
.clear-chat {
  appearance: none; cursor: pointer; background: transparent; border: 0;
  color: var(--text-mute); font-size: 11px; padding: 2px 6px;
  border-radius: 4px; transition: .15s; margin-left: auto;
}
.clear-chat:hover { color: var(--text); background: var(--surface-2); }
