*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #03070a;
  --surface:       #060e14;
  --surface-2:     #0a1820;
  --border:        #0d1f2d;
  --border-mid:    #1a3548;
  --muted:         #215060;
  --text:          #e8f6fa;
  --text-dim:      #3d6878;
  --text-mid:      #8abccc;

  --user-bg:       rgba(0, 40, 35, 0.82);
  --user-text:     #5de0c0;
  --user-border:   rgba(93, 224, 192, 0.18);

  --bot-text:      #b8e8f4;
  --bot-bg:        rgba(0, 18, 24, 0.82);
  --bot-border:    rgba(0, 196, 212, 0.08);
  --bot-rail:      rgba(0, 196, 212, 0.45);
  --bot-rail-glow: rgba(0, 196, 212, 0.05);

  --accent:        #00c4d4;
  --accent-bright: #22e8f8;
  --accent-glow:   rgba(0, 196, 212, 0.25);
  --accent-dim:    rgba(0, 196, 212, 0.06);

  --error:         #e06030;
  --error-bg:      rgba(224, 96, 48, 0.07);
  --error-border:  rgba(224, 96, 48, 0.16);

  --warn:          #c4843a;
  --green:         #39e8a0;
  --green-glow:    rgba(57, 232, 160, 0.2);

  --log-debug:     #3d6878;
  --log-info:      #5ba0b8;
  --log-warn:      #c4843a;
  --log-error:     #e06030;

  --font-ui:   'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;
  --radius:    8px;
}

html, body { height: 100%; overscroll-behavior: none; }

/* Background lives on html so canvas at z-index:-2 (root stacking context) is visible */
html { background: var(--bg); }


#void-canvas {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
}

body {
  font-family: var(--font-ui);
  background: transparent;
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    /* Primary heat bloom — orange-red energy rising from below */
    radial-gradient(ellipse 85% 50% at 50% 108%, rgba(220,80,20,0.18)  0%, rgba(180,40,10,0.06) 45%, transparent 70%),
    /* Secondary — yellow-white hot centre bleeding up */
    radial-gradient(ellipse 40% 30% at 50% 112%, rgba(255,200,80,0.12) 0%, transparent 55%),
    /* Left flank — deep red structural mass */
    radial-gradient(ellipse 38% 55% at -6% 65%,  rgba(180,30,10,0.08)  0%, transparent 55%),
    /* Right edge — violet/purple deep energy */
    radial-gradient(ellipse 30% 40% at 108% 40%, rgba(140,0,200,0.06)  0%, transparent 50%),
    /* Upper — cold cyan, entity structure above frame */
    radial-gradient(ellipse 50% 28% at 50% -8%,  rgba(0,80,100,0.10)   0%, transparent 60%),
    /* Deep void floor */
    radial-gradient(ellipse 100% 55% at 50% 130%, rgba(60,10,5,0.35)   0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  top: 51px;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(0,196,212,0.2) 30%, rgba(0,196,212,0.4) 50%, rgba(0,196,212,0.2) 70%, transparent 100%);
  pointer-events: none;
  z-index: 9;
}

/* ─── Header ─── */
header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 3, 5, 0.88);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
}

header.streaming::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: streamPulse 1.5s ease-in-out infinite;
  z-index: 11;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.logo-mark {
  width: 22px; height: 22px; flex-shrink: 0; color: var(--accent);
  animation: entityNotice 4s ease-in-out infinite;
}

.logo-mark.noticing {
  filter: drop-shadow(0 0 16px rgba(0,196,212,0.95)) !important;
  animation: none !important;
  transition: filter 0.08s;
}

.logo-name {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
}

.logo-divider { width: 1px; height: 14px; background: var(--border-mid); margin: 0 0.2rem; }

.logo-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
  transition: opacity 0.2s;
}

/* ─── Nav ─── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-link {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover { color: var(--text-mid); background: rgba(0, 196, 212, 0.05); }
.nav-link.active {
  color: var(--accent);
  text-shadow: 0 0 14px rgba(0,196,212,0.5);
  background: none;
}


/* ─── Header end group ─── */
.header-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Logout button ─── */
.logout-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.logout-btn:hover { color: var(--error); background: var(--error-bg); }

/* ─── Status pill ─── */
.status-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0;
  background: none;
  border: none;
}

.header-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.4s, box-shadow 0.4s;
  flex-shrink: 0;
}

.header-dot.connected {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0,196,212,0.5);
  animation: signalPulse 2.5s ease-out infinite;
}

.header-dot.disconnected {
  background: var(--error);
  box-shadow: 0 0 6px rgba(224,96,48,0.4);
}

#status-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ─── Panel system ─── */
.panel {
  display: none;
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
  min-height: 0;
}

#panel-chat.active {
  display: flex;
  flex-direction: column;
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
}
#panel-config.active  { display: flex; overflow: hidden; background: rgba(0,3,5,0.72); }

/* ─── Chat: messages ─── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 3px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.message {
  display: flex;
  flex-direction: column;
  padding: 0.9rem 1.75rem;
  gap: 0.4rem;
  animation: msgIn 0.24s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes entityMaterialize {
  0%   { opacity: 0; filter: blur(4px); transform: translateY(4px); }
  100% { opacity: 1; filter: blur(0);   transform: translateY(0); }
}

@keyframes terminalScanIn {
  0%   { opacity: 0; transform: translateX(-8px); }
  60%  { opacity: 0.7; transform: translateX(1px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes voidPulse {
  0%, 100% { opacity: 0.1; transform: scale(0.7); }
  50%       { opacity: 0.9; transform: scale(1.3); }
}

@keyframes entityNotice {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(0,196,212,0.3)); }
  50%       { filter: drop-shadow(0 0 12px rgba(0,196,212,0.8)); }
}

@keyframes signalPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,196,212,0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(0,196,212,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,196,212,0); }
}

@keyframes streamPulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1.0; }
}

@keyframes incomingShimmer {
  0%   { background: transparent; }
  20%  { background: rgba(0,196,212,0.03); }
  100% { background: transparent; }
}

.message.user    { align-items: flex-end; }
.message.assistant,
.message.error   { align-items: flex-start; }

.message-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
}

.bubble-body { display: block; }

.message.user .message-label      { color: rgba(93, 224, 192, 0.35); }
.message.assistant .message-label { color: rgba(0, 196, 212, 0.4); }

.message.user .message-label::before      { content: '👤 '; }
.message.assistant .message-label::before { content: '🤖 '; }

.bubble {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 300;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: min(660px, 82%);
}

.message.user {
  animation: terminalScanIn 0.3s cubic-bezier(0.16,1,0.3,1) both;
}

.message.user .bubble {
  color: var(--user-text);
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  border-radius: 16px 16px 4px 16px;
  padding: 0.7rem 1rem;
  font-weight: 400;
  font-size: 0.84rem;
}

.message.assistant {
  animation: entityMaterialize 0.45s cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes entityPower {
  0%   { box-shadow: 0 0 12px rgba(0,196,212,0.28),  0 0 40px rgba(0,196,212,0.07),  0 0 80px rgba(0,196,212,0.03); }
  18%  { box-shadow: 0 0 16px rgba(0,196,212,0.32),  0 0 50px rgba(180,60,220,0.06), 0 0 90px rgba(0,196,212,0.02); }
  35%  { box-shadow: 0 0 10px rgba(220,140,0,0.22),  0 0 38px rgba(0,196,212,0.10),  0 0 70px rgba(220,80,0,0.04); }
  52%  { box-shadow: 0 0 18px rgba(0,196,212,0.30),  0 0 55px rgba(0,196,212,0.06),  0 0 85px rgba(150,0,200,0.03); }
  70%  { box-shadow: 0 0 14px rgba(200,30,60,0.18),  0 0 45px rgba(0,196,212,0.08),  0 0 75px rgba(0,196,212,0.03); }
  85%  { box-shadow: 0 0 20px rgba(150,60,220,0.20), 0 0 48px rgba(0,196,212,0.09),  0 0 80px rgba(220,140,0,0.03); }
  100% { box-shadow: 0 0 12px rgba(0,196,212,0.28),  0 0 40px rgba(0,196,212,0.07),  0 0 80px rgba(0,196,212,0.03); }
}

.message.assistant .bubble {
  color: var(--bot-text);
  padding: 0.85rem 1.1rem;
  background: var(--bot-bg);
  border-left: 2px solid var(--bot-rail);
  border-top: 1px solid rgba(0,196,212,0.07);
  border-right: 1px solid rgba(0,196,212,0.04);
  border-bottom: 1px solid rgba(0,196,212,0.04);
  border-radius: 4px 14px 14px 14px;
  font-weight: 300;
  font-size: 0.875rem;
  line-height: 1.8;
  min-height: 44px;
  animation: entityPower 6s ease-in-out infinite;
}

.message.error .bubble {
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-size: 0.82rem;
}

.tool-indicator {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.4rem 0;
}

.dots-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

#messages.receiving {
  animation: incomingShimmer 0.7s ease both;
}

.dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: voidPulse 1.8s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: 0.3s; background: var(--accent); }
.dot:nth-child(3) { animation-delay: 0.6s; }

/* ─── Chat: usage bar ─── */
.chat-dock {
  margin: 0 1rem 1rem;
  border-radius: 12px;
  background: rgba(3, 7, 12, 0.72);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(0, 196, 212, 0.09);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(0, 196, 212, 0.04);
  flex-shrink: 0;
  overflow: hidden;
}

/* ─── Observe: costs table ─── */
.costs-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-mid);
}

.costs-table th {
  text-align: left;
  padding: 0.4rem 0.75rem;
  color: var(--text-dim);
  font-weight: normal;
  border-bottom: 1px solid rgba(0, 196, 212, 0.1);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.65rem;
}

.costs-table td {
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.costs-table td:first-child { color: var(--accent); opacity: 0.85; }
.costs-table td:nth-child(2) { color: var(--text-mid); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.costs-table td:nth-child(3),
.costs-table td:nth-child(4),
.costs-table td:nth-child(5) { text-align: right; }
.costs-table td:last-child { text-align: right; color: var(--text-bright); }

.costs-table tfoot td {
  border-top: 1px solid rgba(0, 196, 212, 0.15);
  border-bottom: none;
  color: var(--text-bright);
  font-weight: bold;
  padding-top: 0.5rem;
}

/* ─── Chat: input area ─── */
.input-area {
  padding: 0.85rem 1.25rem 1rem;
  background: transparent;
  flex-shrink: 0;
}

#chat-form {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
}

textarea {
  flex: 1;
  padding: 0.8rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.6;
  resize: none;
  outline: none;
  min-height: 46px;
  max-height: 150px;
  overflow-y: auto;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

textarea:focus {
  border-color: rgba(0,196,212,0.4);
  box-shadow:
    0 0 0 1px rgba(0,196,212,0.12),
    0 0 20px rgba(0,196,212,0.06),
    inset 0 0 15px rgba(0,196,212,0.02);
  background: rgba(6, 14, 20, 0.95);
}

textarea::placeholder { color: var(--muted); font-weight: 300; }
textarea:disabled { opacity: 0.3; cursor: not-allowed; }
textarea::-webkit-scrollbar { width: 3px; }
textarea::-webkit-scrollbar-track { background: transparent; }
textarea::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 2px; }

button[type="submit"] {
  width: 46px; height: 46px;
  flex-shrink: 0;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #051018;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
  box-shadow: 0 2px 14px var(--accent-glow);
}

button[type="submit"]:hover:not(:disabled) {
  background: var(--accent-bright);
  box-shadow: 0 2px 22px rgba(196, 149, 56, 0.45);
  transform: translateY(-1px);
}

button[type="submit"]:active:not(:disabled) { transform: translateY(0); box-shadow: 0 1px 8px var(--accent-glow); }
button[type="submit"]:disabled { background: var(--muted); box-shadow: none; opacity: 0.45; cursor: not-allowed; }
button[type="submit"] svg { pointer-events: none; }

/* ─── Attach / mic buttons ─── */

#attach-btn,
#mic-btn {
  width: 36px; height: 36px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
  margin-bottom: 5px;
}

#attach-btn:hover,
#mic-btn:hover {
  border-color: rgba(54, 184, 204, 0.4);
  color: var(--accent);
}

#mic-btn.recording {
  border-color: rgba(224, 96, 48, 0.65);
  color: var(--error);
  animation: recordPulse 1.2s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 0 0   rgba(224, 96, 48, 0.45); }
  50%       { box-shadow: 0 0 0 6px rgba(224, 96, 48, 0);    }
}

/* ─── Audio preview (in the shared media strip) ─── */

.audio-preview-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 60px;
}

.audio-preview-player {
  height: 32px;
  width: 220px;
  accent-color: var(--accent);
  border-radius: calc(var(--radius) - 2px);
  outline: none;
}

/* ─── PDF preview (in the shared media strip) ─── */

.pdf-preview-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 36px;
  padding: 0 0.6rem;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.72rem;
  max-width: 200px;
}

.pdf-preview-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: var(--accent);
}

.pdf-preview-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-remove {
  position: static !important;
  top: auto !important;
  right: auto !important;
  margin-left: 0.25rem;
  flex-shrink: 0;
}

/* ─── Image previews strip ─── */

.image-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.image-previews.hidden { display: none; }

.image-thumb-wrap {
  position: relative;
  display: inline-flex;
}

.image-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border-mid);
}

.image-thumb-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.image-thumb-remove:hover { color: var(--text); }

/* ─── Images in message bubbles ─── */

.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.message-image {
  max-width: 180px;
  max-height: 180px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid rgba(255,255,255,0.08);
}

.message-audio {
  display: block;
  width: 260px;
  margin-top: 0.45rem;
  accent-color: var(--accent);
  outline: none;
}

.message-pdf-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.4rem;
  padding: 0.25rem 0.55rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 220px;
}

.message-pdf-chip svg { flex-shrink: 0; color: var(--accent); }
.message-pdf-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.input-hint {
  margin-top: 0.45rem;
  font-size: 0.62rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  padding-left: 0.1rem;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  pointer-events: none;
  user-select: none;
  padding: 2rem;
  animation: emptyFade 0.6s ease both;
}

@keyframes emptyFade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.empty-state svg { opacity: 0.35; color: var(--accent); }

.empty-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.empty-sub {
  font-size: 0.68rem;
  color: var(--text-dim);
  opacity: 0.5;
  font-family: var(--font-mono);
  font-weight: 300;
}

.empty-sub::after { content: '_'; animation: blink 1.1s step-end infinite; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ─── Config panel ─── */
#panel-config.active { flex-direction: column; }

.config-bar {
  display: flex;
  align-items: stretch;
  height: 42px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 21, 32, 0.55);
  flex-shrink: 0;
  padding: 0 1.25rem 0 0;
}

.config-subtabs {
  display: flex;
  align-items: stretch;
}

.config-subtab {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 1rem;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: color 0.15s, border-color 0.15s;
  position: relative;
  top: 1px;
}

.config-subtab:hover { color: var(--text-mid); }
.config-subtab.active { color: var(--accent); border-bottom-color: var(--accent); }

.config-content {
  flex: 1;
  overflow-y: auto;
}

#config-form {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  padding: 2rem 2.5rem;
  max-width: 540px;
}

.config-pane {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}

.config-pane.active { display: flex; }

.pane-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.pane-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}

.pane-sub {
  font-size: 0.66rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 300;
}

.field { display: flex; flex-direction: column; gap: 0.45rem; }

.field-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-mid);
  letter-spacing: 0.04em;
}

.field-hint {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-weight: 300;
}

.field textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 90px;
}

.field textarea:focus {
  border-color: rgba(54, 184, 204, 0.35);
  box-shadow: 0 0 0 3px rgba(54, 184, 204, 0.07);
}

.field textarea::placeholder { color: var(--muted); font-weight: 300; }

.field input[type="text"],
.field input[type="number"],
.field select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 400;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.field input:focus,
.field select:focus {
  border-color: rgba(54, 184, 204, 0.35);
  box-shadow: 0 0 0 3px rgba(54, 184, 204, 0.07);
}

.field input::placeholder { color: var(--muted); }

.field select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233d6878' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.2rem;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--muted);
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: var(--text-mid);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-track { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); background: #051018; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.btn-save {
  padding: 0.65rem 1.5rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #051018;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 2px 14px var(--accent-glow);
}

.btn-save:hover { background: var(--accent-bright); box-shadow: 0 2px 22px rgba(54, 184, 204, 0.4); transform: translateY(-1px); }
.btn-save:active { transform: translateY(0); }

.btn-reset {
  padding: 0.65rem 1.2rem;
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-reset:hover { border-color: var(--text-dim); color: var(--text-mid); }

.save-status {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 300;
  color: var(--green);
  opacity: 0;
  transition: opacity 0.3s;
  margin-left: auto;
}

.save-status.visible { opacity: 1; }

.save-error {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 300;
  color: var(--error);
  opacity: 0;
  transition: opacity 0.3s;
  margin-left: auto;
}

.save-error.visible { opacity: 1; }

/* ─── Observe panel ─── */

#panel-observe.active { display: flex; flex-direction: column; background: rgba(0,3,5,0.72); }

.obs-bar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  height: 42px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 21, 32, 0.55);
  flex-shrink: 0;
  padding: 0 1.25rem 0 0;
}

.obs-subtabs {
  display: flex;
  align-items: stretch;
}

.obs-subtab {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 1rem;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: color 0.15s, border-color 0.15s;
  position: relative;
  top: 1px;
}

.obs-subtab:hover { color: var(--text-mid); }
.obs-subtab.active { color: var(--accent); border-bottom-color: var(--accent); }

.obs-bar-end {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.metrics-summary {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.summary-stat {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 0.35rem;
}

.summary-val {
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
}

.summary-key {
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.obs-log-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ─── Subpanels ─── */

.obs-subpanel {
  display: none;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.obs-subpanel.active { display: flex; flex-direction: column; }

/* ─── Metrics layout ─── */

.metrics-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.tree-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.detail-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Actor tree ─── */

#actor-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
}

#actor-tree::-webkit-scrollbar { width: 3px; }
#actor-tree::-webkit-scrollbar-track { background: transparent; }
#actor-tree::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.27rem 0.65rem 0.27rem 0;
  padding-right: 0.65rem;
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}

.tree-row:hover { background: rgba(54, 184, 204, 0.04); }
.tree-row.selected { background: rgba(54, 184, 204, 0.1); }
.tree-row.selected .tree-label { color: var(--accent-bright); }

.tree-chevron {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.12s;
}

.tree-row:hover .tree-chevron { color: var(--text-mid); }

.tree-spacer { width: 14px; flex-shrink: 0; }

.tree-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tree-dot.running { background: var(--green); box-shadow: 0 0 4px var(--green-glow); }
.tree-dot.stopped { background: var(--muted); }
.tree-dot.error   { background: var(--error); }
.tree-dot-empty   { width: 5px; flex-shrink: 0; }

.tree-label {
  font-size: 0.75rem;
  font-weight: 400;
  font-family: var(--font-mono);
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.tree-msg-count {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ─── Actor detail ─── */

#actor-detail {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#actor-detail::-webkit-scrollbar { width: 3px; }
#actor-detail::-webkit-scrollbar-track { background: transparent; }
#actor-detail::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0.75rem;
  flex-shrink: 0;
}

.detail-path {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 0.2rem;
}

.crumb {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.crumb.active {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.crumb-sep {
  font-size: 0.78rem;
  color: var(--border-mid);
  padding: 0 0.08rem;
}

.detail-divider {
  height: 1px;
  background: var(--border);
  margin: 0.1rem 1.5rem 1.25rem;
  flex-shrink: 0;
}

.detail-section-label {
  font-size: 0.57rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 1rem 1.5rem 0.55rem;
  flex-shrink: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  margin: 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.detail-grid.three { grid-template-columns: repeat(3, 1fr); }

.detail-stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  transition: background 0.12s;
}

.detail-stat:hover { background: var(--surface-2); }
.detail-stat.error { background: var(--error-bg); }

.ds-val {
  font-size: 1.55rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-mid);
  line-height: 1;
}

.ds-val.sm   { font-size: 1.05rem; }
.ds-val.error { color: var(--error); }

.ds-unit {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-weight: 400;
}

.ds-key {
  font-size: 0.57rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.detail-state {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 300;
  line-height: 1.6;
  color: var(--text-mid);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 1.5rem 1rem;
  padding: 0.85rem 1rem;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-all;
  flex-shrink: 0;
}

/* ─── Log subpanel ─── */

#log-stream {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
  font-family: var(--font-mono);
  font-size: 0.775rem;
  font-weight: 300;
}

#log-stream::-webkit-scrollbar { width: 3px; }
#log-stream::-webkit-scrollbar-track { background: transparent; }
#log-stream::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.log-count { font-size: 0.62rem; font-family: var(--font-mono); color: var(--text-dim); }

.btn-clear {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font-ui);
}

.btn-clear:hover { color: var(--text-mid); border-color: var(--text-dim); }

.log-entry {
  display: grid;
  grid-template-columns: 80px 42px 1fr;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.2rem 1.5rem;
  transition: background 0.1s;
  animation: logIn 0.15s ease both;
}

.log-entry:hover { background: rgba(255,255,255,0.025); }

@keyframes logIn {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

.log-ts { color: var(--text-dim); font-size: 0.72rem; letter-spacing: -0.02em; white-space: nowrap; }

.log-level {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 0.1rem 0;
  border-radius: 3px;
}

.log-level.debug { color: var(--log-debug); }
.log-level.info  { color: var(--log-info); }
.log-level.warn  { color: var(--log-warn); }
.log-level.error { color: var(--log-error); }

.log-body { line-height: 1.5; }
.log-source { color: var(--accent); margin-right: 0.4rem; font-size: 0.72rem; }
.log-msg.debug { color: var(--log-debug); }
.log-msg.info  { color: var(--text); }
.log-msg.warn  { color: var(--log-warn); }
.log-msg.error { color: var(--log-error); }

.log-data { display: block; margin-top: 0.1rem; color: var(--text-dim); font-size: 0.7rem; }

/* ─── Actor status badge ─── */

.actor-status {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.actor-status.running { color: var(--green); background: rgba(69, 196, 154, 0.1); }
.actor-status.stopped { color: var(--text-dim); background: rgba(255,255,255,0.04); }
.actor-status.error   { color: var(--error); background: rgba(201, 95, 82, 0.1); }

/* ─── Topics subpanel ─── */

#topic-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
}

#topic-list::-webkit-scrollbar { width: 3px; }
#topic-list::-webkit-scrollbar-track { background: transparent; }
#topic-list::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.topic-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.27rem 1rem;
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}

.topic-row:hover { background: rgba(54, 184, 204, 0.04); }
.topic-row[data-has-subs="false"] { cursor: default; }

.topic-name {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.topic-sub-count {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 1ch;
  text-align: right;
}

.topic-children {
  border-left: 1px solid var(--border);
  margin-left: 2.1rem;
}

.topic-children .topic-row {
  padding-left: 0.8rem;
}

.topic-subscribers {
  border-left: 1px solid var(--border);
  margin-left: 2.1rem;
}

.topic-sub-row {
  padding: 0.2rem 0.75rem;
}

.topic-sub-name {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--accent);
}

.topic-chevron {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.12s;
}

.topic-row:hover .topic-chevron { color: var(--text-mid); }

/* ─── Tools panel ─── */

#tools-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

#tools-list::-webkit-scrollbar { width: 3px; }
#tools-list::-webkit-scrollbar-track { background: transparent; }
#tools-list::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.tool-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.12s;
}

.tool-row:hover { background: rgba(54, 184, 204, 0.04); }

.tool-name {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 160px;
}

.tool-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ─── Empty panel ─── */

.empty-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  pointer-events: none;
  user-select: none;
  padding: 2rem;
}

.empty-panel svg { opacity: 0.1; color: var(--accent); }

.empty-panel span {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 300;
  color: var(--text-dim);
}

.empty-panel span::after { content: '_'; animation: blink 1.1s step-end infinite; }

/* ─── Chat: searching indicator ─── */

.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-style: italic;
  opacity: 0.85;
  margin-bottom: 0.4rem;
  padding: 0.18rem 0.55rem;
  background: rgba(0, 196, 212, 0.07);
  border: 1px solid rgba(0, 196, 212, 0.18);
  border-radius: 6px;
}

.tool-badge::before {
  content: '⚙';
  font-style: normal;
  font-size: 0.65rem;
  opacity: 0.7;
  animation: streamPulse 1.4s ease-in-out infinite;
}

/* ─── Chat: sources ─── */

.sources {
  margin-top: 0.6rem;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.sources-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  padding: 0.15rem 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.15s;
}

.sources-toggle::before {
  content: '▶';
  font-size: 0.5rem;
  transition: transform 0.15s;
}

.sources-toggle.open::before { transform: rotate(90deg); }

.sources-toggle:hover { color: var(--text-mid); }

.sources-list {
  display: none;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.sources-list.open { display: flex; }

.source-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-left: 2px solid var(--border-mid);
  transition: border-color 0.15s;
}

.source-item:hover { border-left-color: var(--accent); }

.source-title {
  font-size: 0.72rem;
  color: var(--text-mid);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-snippet {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Markdown body ─── */

.md {
  line-height: 1.8;
  white-space: normal;
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
}
.md > *:first-child { margin-top: 0; }
.md p { margin-bottom: 0.82em; }
.md p:last-child { margin-bottom: 0; }

.md h1, .md h2, .md h3 {
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-bright);
  margin: 1.4em 0 0.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}
.md h1 { font-size: 1.1em; }
.md h2 { font-size: 0.97em; }
.md h3 { font-size: 0.88em; border-bottom: none; color: var(--text-mid); }

.md ul, .md ol { padding-left: 1.4em; margin: 0 0 0.75em; }
.md li { margin: 0; padding: 0; }
.md li + li { margin-top: 0.97em; }
.md li p { margin: 0 !important; }
.md li > ul, .md li > ol { margin: 0.35em 0 0; }
.md ul ul, .md ol ul, .md ul ol, .md ol ol { margin-bottom: 0; }
.md ul li::marker { color: var(--accent); }

.md blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.1em 0 0.1em 1em;
  margin: 0.8em 0;
  color: var(--text-mid);
  font-style: italic;
}

.md a { color: var(--accent-bright); text-decoration: none; border-bottom: 1px solid var(--accent-dim); }
.md a:hover { border-color: var(--accent); }

.md strong { color: var(--text); font-weight: 700; }
.md em { color: var(--text-mid); }

.md hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }

.md img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
  margin: 0.5em 0;
}

/* Inline code */
.md code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  padding: 0.12em 0.4em;
  color: var(--accent-bright);
}

/* ─── Code blocks ─── */

.code-block {
  margin: 0.9em 0;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}
.code-block:first-child { margin-top: 0; }
.code-block:last-child { margin-bottom: 0; }

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.38rem 0.85rem;
  background: rgba(22, 46, 63, 0.55);
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.copy-btn {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  transition: color 0.14s, border-color 0.14s;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent-dim); }

.code-block pre {
  margin: 0;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  background: transparent !important;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}

.code-block pre::-webkit-scrollbar { height: 4px; }
.code-block pre::-webkit-scrollbar-track { background: transparent; }
.code-block pre::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
.code-block pre::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.code-block pre code {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  line-height: 1.62;
  background: none !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0;
  color: inherit;
}

/* Neutralize hljs ocean background — use our surface instead */
.hljs { background: transparent !important; }

/* ─── Markdown tables ─── */

.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.9em 0;
  font-size: 0.84em;
}
.md th {
  background: var(--surface-2);
  color: var(--text-mid);
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.45em 0.8em;
  border: 1px solid var(--border-mid);
  text-align: left;
}
.md td {
  padding: 0.4em 0.8em;
  border: 1px solid var(--border);
  color: var(--text);
}
.md tr:nth-child(even) td { background: rgba(16, 36, 52, 0.35); }

/* ─── Traces ─── */

#obs-traces {
  overflow-y: auto;
}

#obs-traces-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
}

.trace-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.trace-item.wf-live {
  border-color: var(--accent);
}

.trace-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.trace-id   { color: var(--text-dim); }
.trace-dur  { color: var(--accent); margin-left: auto; }

.trace-live-badge {
  color: var(--accent);
  font-size: 0.62rem;
  padding: 1px 5px;
  border: 1px solid var(--accent-glow);
  border-radius: 3px;
  animation: wf-pulse-text 1.2s ease-in-out infinite;
}

@keyframes wf-pulse-text {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.trace-waterfall {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0.3rem 0;
}

.waterfall-row {
  display: grid;
  grid-template-columns: 150px 1fr 44px;
  align-items: center;
  gap: 0.5rem;
  padding: 2px 0.6rem 2px 0;
  font-family: var(--font-mono);
  font-size: 0.67rem;
}

.waterfall-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.wf-actor { color: var(--text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-op    { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.waterfall-track {
  position: relative;
  height: 12px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.waterfall-bar {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
}

.waterfall-bar.op-request        { background: var(--accent-dim);              border: 1px solid var(--accent);                    }
.waterfall-bar.op-react            { background: rgba(139,92,246,0.15);          border: 1px solid rgba(139,92,246,0.45);            }
.waterfall-bar.op-llm-call        { background: rgba(139,92,246,0.2);           border: 1px solid rgba(139,92,246,0.55);            }
.waterfall-bar.op-llm-response    { background: rgba(139,92,246,0.2);           border: 1px solid rgba(139,92,246,0.55);            }
.waterfall-bar.op-llm-synthesize  { background: rgba(168,85,247,0.2);           border: 1px solid rgba(168,85,247,0.55);            }
.waterfall-bar.op-tool-invoke     { background: rgba(245,158,11,0.18);          border: 1px solid rgba(245,158,11,0.5);             }
.waterfall-bar.op-brave-search    { background: rgba(245,158,11,0.18);          border: 1px solid rgba(245,158,11,0.5);             }

.waterfall-bar.wf-active { animation: wf-pulse-bar 1s ease-in-out infinite; }
.waterfall-bar.wf-error  { background: var(--error-bg) !important; border-color: var(--error) !important; }

@keyframes wf-pulse-bar {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.waterfall-dur {
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
}

/* ─── Reasoning section ─── */

.reasoning {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.78rem;
}

.reasoning summary {
  padding: 5px 10px;
  cursor: pointer;
  color: var(--text-dim);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.reasoning summary::-webkit-details-marker { display: none; }

.reasoning summary::before {
  content: '▶';
  font-size: 0.55em;
  opacity: 0.6;
  transition: transform 0.15s ease;
}

.reasoning[open] summary::before {
  transform: rotate(90deg);
}

.reasoning[open] summary {
  border-bottom: 1px solid var(--border);
}

.reasoning-content {
  padding: 10px 12px;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.55;
  opacity: 0.8;
}

/* ─── Knowledge graph ─── */

#memory-graph {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#memory-graph svg {
  display: block;
  width: 100%;
  height: 100%;
}

.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text);
  max-width: 260px;
  z-index: 10;
  line-height: 1.5;
}

.graph-tooltip strong {
  display: block;
  color: var(--accent);
  margin-bottom: 4px;
  font-size: 0.72rem;
}

.graph-tooltip pre {
  margin: 0;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-all;
}

.obs-memory-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
