﻿/* ═══════════════════════════════════════════════════════════════
   JARVIS — 3-mode UI
   idle  : fullscreen dark orb + clock + settings drawer
   voice : grid bg + HUD corners + orb + frosted chat panel
   code  : fullscreen log panel + mini orb corner
   ═══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;
  --bg:     #03030a;
  --panel:  #0b101d;
  --panel2: #101829;
  --line:   rgba(255,176,72,0.18);
  --text:   #f2f0ff;
  --muted:  #8a9bb4;
  --cyan:   #41e7ff;
  --green:  #78e08f;
  --amber:  #ffad42;
  --violet: #a855f7;
  --hot:    #ff6f3c;
  --red:    #ff6b6b;
  --shadow: rgba(0,0,0,0.65);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 47% 38%, rgba(255,173,66,0.10), transparent 28%),
    radial-gradient(circle at 64% 46%, rgba(65,231,255,0.08), transparent 32%),
    radial-gradient(circle at 35% 56%, rgba(168,85,247,0.11), transparent 34%),
    var(--bg);
  color: var(--text);
}

button, textarea, select { font: inherit; }
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,176,72,0.08), rgba(65,231,255,0.035));
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
button:hover:not(:disabled) {
  border-color: rgba(255,176,72,0.55);
  box-shadow: 0 0 14px rgba(255,176,72,0.13), 0 0 24px rgba(65,231,255,0.08);
}
button:disabled { cursor: not-allowed; opacity: 0.4; }

.ghost {
  min-height: 28px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  background: transparent;
  border-color: transparent;
}
.ghost:hover { border-color: rgba(255,176,72,0.35); color: var(--text); }

.eyebrow, .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

/* STATUS PILL */
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 0.82rem;
  background: rgba(11,16,29,0.58);
  backdrop-filter: blur(8px);
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 10px var(--green); flex-shrink: 0;
}

/* ═══ HUD CORNER DECORATIONS ═══════════════════════════════════ */
.hud {
  position: absolute;
  width: 28px; height: 28px;
  pointer-events: none;
  z-index: 5;
  display: block;
}
.hud-tl { top: 18px; left: 18px; border-top: 1.5px solid rgba(255,176,72,0.5); border-left: 1.5px solid rgba(65,231,255,0.44); }
.hud-tr { top: 18px; right: 18px; border-top: 1.5px solid rgba(255,176,72,0.5); border-right: 1.5px solid rgba(65,231,255,0.44); }
.hud-bl { bottom: 18px; left: 18px; border-bottom: 1.5px solid rgba(65,231,255,0.44); border-left: 1.5px solid rgba(255,176,72,0.5); }
.hud-br { bottom: 18px; right: 18px; border-bottom: 1.5px solid rgba(65,231,255,0.44); border-right: 1.5px solid rgba(255,176,72,0.5); }

/* ═══ IDLE SCREEN ═══════════════════════════════════════════════ */
.idle-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
html[data-mode="idle"] .idle-screen {
  opacity: 1;
  pointer-events: all;
}

.idle-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  user-select: none;
}

/* Idle orb */
.idle-orb-wrap {
  position: relative;
  width: clamp(180px, 28vmin, 300px);
  aspect-ratio: 1;
  cursor: pointer;
}

.idle-ring {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.ir1 {
  inset: 0;
  border: 1.5px solid rgba(70,217,232,0.4);
  animation: idleRing 3.5s ease-in-out infinite;
}
.ir2 {
  inset: -16%;
  border: 1px solid rgba(70,217,232,0.12);
  animation: idleRing 3.5s ease-in-out infinite 0.7s;
}
@keyframes idleRing {
  0%, 100% { transform: scale(1);    opacity: 0.45; }
  50%       { transform: scale(1.03); opacity: 0.9; }
}

.idle-orb {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%,
    rgba(255,255,255,0.16) 0%,
    rgba(70,217,232,0.10) 18%,
    rgba(8,22,34,0.92) 48%,
    rgba(4,10,18,0.98) 70%
  );
  border: 1px solid rgba(70,217,232,0.24);
  box-shadow:
    0 0 48px rgba(70,217,232,0.22),
    0 0 110px rgba(70,217,232,0.08),
    inset 0 0 42px rgba(70,217,232,0.07),
    inset -18px -24px 54px rgba(0,0,0,0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: idleOrbPulse 4s ease-in-out infinite;
  transition: box-shadow 0.4s, border-color 0.4s;
}
.idle-orb:hover {
  box-shadow:
    0 0 65px rgba(70,217,232,0.28),
    0 0 120px rgba(70,217,232,0.12),
    inset 0 0 40px rgba(70,217,232,0.08);
  border-color: rgba(70,217,232,0.5);
}
.idle-orb-inner {
  position: absolute;
  inset: 0; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.20) 0%, transparent 24%),
    radial-gradient(circle at 62% 68%, rgba(70,217,232,0.08) 0%, transparent 52%);
  pointer-events: none;
}
.idle-lbl {
  position: relative; z-index: 1;
  font-size: clamp(0.75rem, 1.8vmin, 1rem);
  font-weight: 800;
  letter-spacing: 0.28em;
  color: rgba(190,240,255,0.82);
  text-shadow: 0 0 18px rgba(70,217,232,0.65);
}
@keyframes idleOrbPulse {
  0%, 100% { box-shadow: 0 0 45px rgba(70,217,232,0.18), 0 0 90px rgba(70,217,232,0.07), inset 0 0 32px rgba(70,217,232,0.05); }
  50%       { box-shadow: 0 0 65px rgba(70,217,232,0.28), 0 0 130px rgba(70,217,232,0.10), inset 0 0 42px rgba(70,217,232,0.08); }
}

/* Idle orb state variants */
.idle-orb.listening {
  background: radial-gradient(circle at 38% 32%, rgba(15,55,25,0.98) 0%, rgba(4,14,8,0.99) 60%);
  border-color: rgba(120,224,143,0.4);
  animation: idleOrbPulse 1.2s ease-in-out infinite;
}
.idle-orb.thinking { animation: idleThink 2s linear infinite; }
.idle-orb.speaking {
  background: radial-gradient(circle at 38% 32%, rgba(65,35,8,0.98) 0%, rgba(18,8,3,0.99) 60%);
  border-color: rgba(243,189,77,0.4);
}
@keyframes idleThink { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }

/* Clock */
.idle-clock {
  font-size: clamp(2.2rem, 7vmin, 5rem);
  font-weight: 200;
  letter-spacing: 0.05em;
  color: rgba(190,240,255,0.75);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 40px rgba(70,217,232,0.25);
  line-height: 1;
}
.idle-date {
  margin: -12px 0 0;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.65;
}

/* Idle start button */
.idle-actions { display: flex; gap: 12px; justify-content: center; }
.idle-start {
  min-height: 46px;
  padding: 0 32px;
  border: 1px solid rgba(70,217,232,0.45);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(70,217,232,0.2), rgba(120,224,143,0.1));
  color: rgba(200,245,255,0.92);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.25s;
  box-shadow: 0 0 24px rgba(70,217,232,0.15);
}
.idle-start:hover {
  border-color: rgba(70,217,232,0.8);
  background: linear-gradient(135deg, rgba(70,217,232,0.32), rgba(120,224,143,0.18));
  box-shadow: 0 0 40px rgba(70,217,232,0.28);
  transform: translateY(-1px);
}
.idle-start:active { transform: translateY(0); }

/* Settings gear FAB */
.idle-gear {
  position: absolute;
  top: 22px; right: 22px;
  width: 44px; min-height: 44px;
  padding: 0;
  border: 1px solid rgba(70,217,232,0.2);
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
  z-index: 10;
  transition: all 0.25s;
}
.idle-gear:hover {
  border-color: rgba(70,217,232,0.55);
  color: var(--cyan);
  background: rgba(70,217,232,0.08);
  box-shadow: 0 0 20px rgba(70,217,232,0.2);
}

/* ═══ SETTINGS BACKDROP ═════════════════════════════════════════ */
.settings-bdrop {
  position: fixed; inset: 0;
  z-index: 44;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
html.settings-open .settings-bdrop {
  opacity: 1; pointer-events: all;
}

/* ═══ MAIN SHELL ════════════════════════════════════════════════ */
.shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.95fr);
  grid-template-rows: auto 1fr;
  gap: 14px;
  width: min(1380px, calc(100vw - 28px));
  height: calc(100vh - 28px);
  margin: 14px auto;
}

/* IDLE MODE — shell is a right-side settings drawer */
html[data-mode="idle"] .shell {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(460px, 92vw);
  height: 100vh;
  margin: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px 20px;
  background:
    radial-gradient(circle at 0% 20%, rgba(255,176,72,0.08), transparent 36%),
    radial-gradient(circle at 100% 52%, rgba(65,231,255,0.07), transparent 42%),
    rgba(8, 10, 20, 0.97);
  backdrop-filter: blur(28px);
  border-left: 1px solid rgba(255,176,72,0.16);
  box-shadow: -24px 0 80px rgba(0,0,0,0.7);
  border-radius: 0;
  z-index: 45;
  transform: translateX(100%);
  transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}
html[data-mode="idle"].settings-open .shell {
  transform: translateX(0);
}
html[data-mode="idle"] .command-deck,
html[data-mode="idle"] .log-panel {
  display: none;
}
html[data-mode="idle"] .side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: none;
  background: none;
  box-shadow: none;
  padding: 0;
  overflow: visible;
  min-height: 0;
}

/* Settings drawer close header */
.settings-drawer-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: rgba(8,16,26,0.98);
  z-index: 1;
}
html[data-mode="idle"] .settings-drawer-head {
  display: flex;
}

/* VOICE MODE — hide shell */
html[data-mode="voice"] .shell {
  opacity: 0;
  pointer-events: none;
}

/* Agent overlay — keep terminal visible while Jarvis delegates code work */
html.agent-running:not([data-mode="code"]) .shell {
  position: fixed;
  right: 18px;
  bottom: 18px;
  left: auto;
  top: auto;
  width: min(760px, calc(100vw - 36px));
  height: min(48vh, 520px);
  min-height: 260px;
  margin: 0;
  display: block;
  opacity: 1;
  pointer-events: none;
  z-index: 70;
  background: none;
  border: none;
  box-shadow: none;
}
html.agent-running:not([data-mode="code"]) .settings-drawer-head,
html.agent-running:not([data-mode="code"]) .command-deck,
html.agent-running:not([data-mode="code"]) .side-panel,
html.agent-running:not([data-mode="code"]) .log-panel {
  display: none;
}
html.agent-running:not([data-mode="code"]) .term-panel {
  display: flex;
  height: 100%;
  min-height: 0;
  pointer-events: auto;
  border-color: rgba(70,217,232,0.38);
  box-shadow: 0 18px 70px rgba(0,0,0,0.72), 0 0 28px rgba(70,217,232,0.11);
}
html.agent-running .term-head .model-picker {
  display: block;
}

/* CODE MODE — two-column: terminal left, log right */
html[data-mode="code"] .shell {
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100%;
  max-width: none;
  height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  padding: 12px 14px;
  gap: 14px;
  background: none;
  border: none;
  box-shadow: none;
  z-index: 2;
}
html[data-mode="code"] .settings-drawer-head,
html[data-mode="code"] .command-deck,
html[data-mode="code"] .side-panel {
  display: none;
}
html[data-mode="code"] .term-panel {
  display: flex;
  min-height: 0;
}
html[data-mode="code"] .log-panel {
  min-height: 0;
  width: auto;
  border-radius: 12px;
}

/* ═══ TERMINAL PANEL ════════════════════════════════════════════ */
.term-panel {
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(14,18,32,0.96), rgba(5,8,15,0.94)),
    radial-gradient(circle at 18% 0%, rgba(255,176,72,0.09), transparent 42%);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 50px var(--shadow);
}
.term-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-dim);
  flex-shrink: 0;
}
.term-dots { display: flex; align-items: center; gap: 5px; }
.tdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.tdot-r { background: #ff5f56; }
.tdot-y { background: #ffbd2e; }
.tdot-g { background: #27c93f; }
.term-title { flex: 1; }
.term-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: #c8d8e0;
}
.term-body::-webkit-scrollbar { width: 4px; }
.term-body::-webkit-scrollbar-thumb { background: rgba(70,217,232,0.2); border-radius: 2px; }

/* Terminal entry types */
.t-entry { white-space: pre-wrap; word-break: break-all; }
.t-start { color: #46d9e8; font-style: italic; margin-bottom: 10px; font-size: 12px; }
.t-cmd { color: #e8f4ff; margin-top: 10px; }
.t-cmd::before { content: "❯ "; color: #27c93f; font-weight: 700; }
.t-out { color: #8ab4a0; margin-left: 2ch; font-size: 11.5px; }
.t-err { color: #ff6b6b; margin-left: 2ch; }
.t-result { color: #27c93f; margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(39,201,63,0.18); }
.t-done { color: #5a7080; font-style: italic; }

/* Panel base styles */
.command-deck, .side-panel, .log-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(16,24,41,0.88), rgba(7,10,19,0.84)),
    radial-gradient(circle at 0% 0%, rgba(255,176,72,0.08), transparent 38%),
    radial-gradient(circle at 100% 100%, rgba(65,231,255,0.06), transparent 42%);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 50px var(--shadow), inset 0 1px 0 rgba(255,255,255,0.035);
}

.command-deck {
  grid-column: 1; grid-row: 1;
  display: flex; flex-direction: column;
  min-height: 480px; padding: 20px; gap: 14px;
}
.side-panel {
  grid-column: 1; grid-row: 2;
  display: flex; flex-direction: column;
  gap: 10px; padding: 14px;
  min-height: 0; overflow: auto;
}
.log-panel {
  grid-column: 2; grid-row: 1 / -1;
}

/* ── Topbar ── */
.topbar, .block-title, .system-row, .confirm-actions {
  display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
}
h1 {
  margin: 2px 0 0;
  font-size: clamp(2rem, 5.5vw, 4.5rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff6e8 0%, #41e7ff 45%, #ffad42 78%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Orb panel (in code command-deck — hidden in code mode anyway) ── */
.orb-panel {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(160px, 0.85fr) minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
}
.jarvis-orb {
  position: relative;
  width: min(280px, 52vw);
  aspect-ratio: 1;
  margin: auto;
  border-radius: 50%;
}
.ring, .core { position: absolute; inset: 0; border-radius: 50%; }
.ring-one {
  border: 1.5px solid rgba(70,217,232,0.45);
  box-shadow: inset 0 0 20px rgba(70,217,232,0.12), 0 0 36px rgba(70,217,232,0.1);
  animation: pulse 3s ease-in-out infinite;
}
.ring-two {
  inset: 10%;
  border: 1px dashed rgba(238,247,248,0.2);
  animation: spin 16s linear infinite;
}
.core {
  inset: 28%;
  background: radial-gradient(circle, #efffff 0%, #46d9e8 30%, rgba(70,217,232,0.06) 70%);
  box-shadow: 0 0 46px rgba(70,217,232,0.5);
}
.jarvis-orb.listening .ring-one { animation-duration: 0.9s; border-color: rgba(120,224,143,0.75); }
.jarvis-orb.thinking .ring-two  { animation-duration: 2s; }
.jarvis-orb.speaking .ring-one  { animation-duration: 1.4s; border-color: rgba(243,189,77,0.65); }
@keyframes pulse { 0%,100%{transform:scale(0.97);opacity:0.7} 50%{transform:scale(1.03);opacity:1} }
@keyframes spin  { to{transform:rotate(360deg)} }

.voice-readout {
  min-height: 140px; padding: 16px;
  border-left: 1px solid var(--line);
}
#transcript {
  margin: 8px 0 0;
  font-size: clamp(1rem, 2.3vw, 1.7rem);
  line-height: 1.3;
}

/* ── Controls ── */
.controls { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.primary {
  background: linear-gradient(135deg, rgba(65,231,255,0.22), rgba(255,176,72,0.18));
  border-color: rgba(255,176,72,0.48);
}
.composer { display: grid; grid-template-columns: 1fr 90px; gap: 8px; }
textarea {
  width: 100%; resize: vertical;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px;
  background: rgba(4,6,14,0.58); color: var(--text);
}
select {
  width: 100%; min-height: 38px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px;
  background: rgba(4,6,14,0.58); color: var(--text);
}

/* ── Side panel blocks ── */
.panel-block {
  padding: 12px;
  border: 1px solid rgba(70,217,232,0.1);
  border-radius: 10px;
  background: rgba(15,29,42,0.65);
}
.block-title { margin-bottom: 10px; font-weight: 700; font-size: 0.9rem; }
#brainBadge  { color: var(--cyan); font-weight: 600; font-size: 0.85rem; }
.segmented { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; }
.segmented button { min-width: 0; font-size: 0.82rem; min-height: 36px; }
.segmented .active {
  background: rgba(70,217,232,0.14);
  border-color: rgba(70,217,232,0.55);
}
.active-toggle {
  background: rgba(120,224,143,0.12);
  border-color: rgba(120,224,143,0.5);
}
.code-mode-btn { width: 100%; margin-top: 8px; }
.code-mode-btn.code-mode-on {
  background: rgba(243,189,77,0.14);
  border-color: rgba(243,189,77,0.55);
  color: var(--amber);
}
.code-mode-hint { margin: 5px 0 0; color: var(--muted); font-size: 0.74rem; line-height: 1.35; }

/* Credit widget */
.credit-block .block-title { margin-bottom: 8px; }
.credit-model { font-size: 0.72rem; color: var(--cyan); opacity: 0.7; font-weight: 500; letter-spacing: 0.03em; }
.credit-rows { display: flex; flex-direction: column; gap: 4px; }
.credit-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.8rem;
}
.credit-row span { color: var(--muted); }
.credit-row strong { color: var(--text); font-weight: 600; font-size: 0.8rem; }
.credit-cost strong { color: var(--amber); }

/* Agent propose */
.agent-propose { border-color: rgba(243,189,77,0.35); background: rgba(243,189,77,0.06); }
.agent-propose .role { color: var(--amber); }
.propose-actions { display: flex; gap: 8px; margin-top: 8px; }
.propose-go {
  min-height: 32px; padding: 0 14px;
  border: 1px solid rgba(120,224,143,0.55); border-radius: 8px;
  background: rgba(120,224,143,0.13); color: var(--text); cursor: pointer;
}
.propose-cancel {
  min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: rgba(255,255,255,0.03); color: var(--muted); cursor: pointer;
}
.tool-message { border-color: rgba(70,217,232,0.18); background: rgba(70,217,232,0.04); }
.tool-message .role { color: var(--cyan); }
.tool-message p { font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; color: #b8dce5; }

/* Memory */
.memory-list {
  display: grid; gap: 5px; max-height: 170px;
  margin: 0; padding: 0; overflow: auto; list-style: none;
}
.memory-list li {
  display: flex; align-items: flex-start; gap: 8px; justify-content: space-between;
  padding: 6px 9px;
  border: 1px solid rgba(120,224,143,0.14); border-radius: 8px;
  background: rgba(120,224,143,0.04); font-size: 0.82rem; line-height: 1.35;
}
.memory-list li.memory-empty {
  border-color: rgba(70,217,232,0.08); background: rgba(0,0,0,0.12); color: var(--muted);
}
.memory-text { flex: 1; }
.memory-del {
  flex: 0 0 auto; min-height: 20px; width: 20px; padding: 0;
  border: 1px solid rgba(255,107,107,0.28); border-radius: 6px;
  background: rgba(255,107,107,0.06); color: var(--red); font-size: 0.85rem; cursor: pointer;
}
.memory-del:hover { background: rgba(255,107,107,0.16); }
.memory-actions { display: inline-flex; gap: 5px; }

/* Systems */
.system-list { display: grid; gap: 7px; }
.system-row {
  min-height: 34px; padding: 6px 0;
  border-bottom: 1px solid rgba(70,217,232,0.08);
}
.system-row:last-child { border-bottom: 0; }
.system-row span { color: var(--muted); }
.system-row strong { text-align: right; font-size: 0.87rem; }
.mic-control {
  display: grid; grid-template-columns: 1fr auto;
  gap: 7px; align-items: end; padding: 7px 0 4px;
}
.mic-control label { grid-column: 1 / -1; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; }
.wake-meter-wrap { display: grid; gap: 6px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: rgba(0,0,0,0.18); }
.wake-meter-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 0.79rem; }
.wake-meter-label strong { color: var(--cyan); }
.wake-meter { height: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: rgba(0,0,0,0.22); }
.wake-meter-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--cyan), var(--amber)); transition: width 80ms linear; }
.wake-hint { min-height: 28px; margin: 6px 0 0; color: var(--muted); font-size: 0.79rem; line-height: 1.35; }
.confirmation { border-color: rgba(243,189,77,0.32); }
.confirmation p:last-child { margin: 5px 0 10px; }

/* ── Log panel ── */
.log-panel { display: flex; flex-direction: column; gap: 12px; padding: 14px; min-height: 0; }
.chat-section, .activity-section { display: flex; min-height: 0; flex-direction: column; }
.chat-section { flex: 1.8; }
.activity-section { flex: 1; padding-top: 12px; border-top: 1px solid var(--line); }
.messages, .activity {
  flex: 1; display: flex; min-height: 0; flex-direction: column;
  gap: 9px; overflow: auto; padding-right: 5px;
}

.message {
  max-width: 88%;
  display: grid; gap: 4px; padding: 10px 13px;
  border: 1px solid rgba(70,217,232,0.09); border-radius: 14px;
  background: rgba(255,255,255,0.025);
}
.message .role { color: var(--muted); font-size: 0.69rem; letter-spacing: 0.04em; text-transform: uppercase; }
.message p { margin: 0; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.message.from-user {
  align-self: flex-end;
  border-color: rgba(70,217,232,0.3); border-bottom-right-radius: 4px;
  background: linear-gradient(135deg, rgba(70,217,232,0.14), rgba(70,217,232,0.04));
}
.message.from-user .role  { color: var(--cyan); }
.message.from-jarvis       { align-self: flex-start; border-bottom-left-radius: 4px; }
.message.from-jarvis .role { color: var(--green); }
.activity .message { max-width: 100%; border-radius: 8px; background: rgba(0,0,0,0.18); }
.activity .message .role { color: var(--muted); }
.action-message { border-color: rgba(243,189,77,0.22) !important; background: rgba(243,189,77,0.04) !important; }
.action-message .role { color: var(--amber) !important; }
.message pre {
  max-width: 100%; margin: 0; overflow: auto; white-space: pre-wrap; word-break: break-word;
  color: #f0d890; font: 0.82rem/1.45 ui-monospace, Consolas, monospace;
}

/* ═══ VOICE OVERLAY ═════════════════════════════════════════════ */
.vo {
  position: fixed; inset: 0; z-index: 50;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: "header" "stage";
  /* dot grid embedded in background */
  background:
    radial-gradient(circle, rgba(255,176,72,0.08) 1.5px, transparent 1.5px) 0 0 / 38px 38px,
    radial-gradient(ellipse 70% 52% at 50% 34%, rgba(255,126,54,0.13) 0%, transparent 64%),
    radial-gradient(ellipse 78% 55% at 50% 38%, rgba(31,210,238,0.12) 0%, transparent 68%),
    radial-gradient(ellipse 64% 44% at 50% 100%, rgba(168,85,247,0.12) 0%, transparent 62%),
    #03030a;
  opacity: 0; pointer-events: none;
  transition: opacity 0.45s ease;
}
html[data-mode="voice"] .vo { opacity: 1; pointer-events: all; }

/* ── vo header ── */
.vo-header {
  grid-area: header;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid rgba(255,176,72,0.10);
  background: linear-gradient(180deg, rgba(3,3,10,0.72), rgba(3,3,10,0));
  position: relative; z-index: 2;
}
.vo-eyebrow {
  margin: 0;
  font-size: 0.66rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.vo-name {
  font-size: clamp(1.5rem, 3.5vw, 2.5rem);
  font-weight: 800; letter-spacing: 0.12em;
  background: linear-gradient(135deg, #fff5df 0%, #41e7ff 48%, #ffad42 78%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 18px rgba(65,231,255,0.34)) drop-shadow(0 0 14px rgba(255,176,72,0.20));
}

/* ── vo stage ── */
.vo-stage {
  grid-area: stage;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 38px; padding: 20px;
  position: relative; z-index: 2;
}

/* Large orb */
.vo-orb-wrap {
  position: relative;
  width: clamp(200px, 32vw, 390px);
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
}
.vo-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255,176,72,0.18);
  animation: voRingBreath 2.8s ease-in-out infinite;
  box-shadow: inset 0 0 22px rgba(255,176,72,0.035);
}
.vo-r1 { inset: 0;    animation-delay: 0s; }
.vo-r2 { inset: -12%; animation-delay: 0.45s; border-color: rgba(65,231,255,0.10); }
.vo-r3 { inset: -26%; animation-delay: 0.9s;  border-color: rgba(168,85,247,0.07); }
@keyframes voRingBreath {
  0%, 100% { transform: scale(1);    opacity: 0.55; }
  50%       { transform: scale(1.04); opacity: 1; }
}

.vo-canvas {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  width: 210%; height: 210%;
  pointer-events: none;
  z-index: 4;
}

.vo-orb {
  position: absolute; inset: -2%;
  border-radius: 50%;
  z-index: 1;
  overflow: hidden;
  background:
    radial-gradient(circle at 42% 38%, rgba(255,255,255,0.58) 0 4%, rgba(255,177,82,0.32) 8%, transparent 22%),
    radial-gradient(circle at 61% 48%, rgba(76,231,255,0.38) 0 4%, transparent 18%),
    radial-gradient(circle at 50% 50%, rgba(255,178,84,0.18) 0 18%, rgba(31,210,238,0.13) 34%, rgba(124,58,237,0.16) 52%, rgba(8,10,20,0.18) 73%, transparent 84%);
  border: 1px solid rgba(255,186,96,0.22);
  box-shadow:
    0 0 58px rgba(168,85,247,0.28),
    0 0 132px rgba(70,217,232,0.11),
    inset 0 0 54px rgba(168,85,247,0.12),
    inset -18px -22px 58px rgba(0,0,0,0.30);
  animation: voOrbBreath 3s ease-in-out infinite;
  backdrop-filter: blur(1px);
}
.vo-orb::before,
.vo-orb::after {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  pointer-events: none;
}
.vo-orb::before {
  inset: 1%;
  border: 1px solid rgba(255,190,100,0.10);
  box-shadow:
    inset 0 0 48px rgba(255,180,76,0.16),
    inset 0 0 86px rgba(46,221,255,0.10),
    0 0 42px rgba(255,180,76,0.12);
  opacity: 0.92;
}
.vo-orb::after {
  inset: 7%;
  background:
    conic-gradient(from 210deg,
      transparent 0deg,
      rgba(255,184,84,0.26) 28deg,
      rgba(255,255,255,0.52) 46deg,
      rgba(34,211,238,0.30) 70deg,
      transparent 118deg,
      rgba(255,136,58,0.20) 176deg,
      rgba(70,217,232,0.20) 220deg,
      transparent 270deg);
  filter: blur(4px);
  opacity: 0.72;
  transform: rotate(-18deg) scaleX(1.28) scaleY(0.58);
}
.vo-orb-inner {
  position: absolute; inset: 18%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, rgba(255,255,255,0.24) 0%, transparent 33%),
    radial-gradient(circle, rgba(168,85,247,0.16) 0%, transparent 68%);
  animation: voOrbBreath 3s ease-in-out infinite 0.5s;
  opacity: 0.72;
}
@keyframes voOrbBreath {
  0%, 100% { transform: scale(1); box-shadow: 0 0 58px rgba(168,85,247,0.28), 0 0 132px rgba(70,217,232,0.11), inset 0 0 54px rgba(168,85,247,0.12), inset -18px -22px 58px rgba(0,0,0,0.30); }
  50%       { transform: scale(1.025); box-shadow: 0 0 78px rgba(168,85,247,0.38), 0 0 170px rgba(70,217,232,0.17), inset 0 0 62px rgba(168,85,247,0.18), inset -18px -22px 58px rgba(0,0,0,0.30); }
}
/* Orb state variants */
html[data-mode="voice"] .vo-orb.listening {
  background:
    radial-gradient(circle at 42% 38%, rgba(255,255,255,0.60) 0 4%, rgba(255,177,82,0.34) 8%, transparent 22%),
    radial-gradient(circle at 61% 48%, rgba(76,231,255,0.40) 0 4%, transparent 18%),
    radial-gradient(circle at 50% 50%, rgba(255,178,84,0.20) 0 18%, rgba(224,64,251,0.14) 32%, rgba(31,210,238,0.14) 48%, rgba(8,10,20,0.18) 73%, transparent 84%);
  border-color: rgba(255,184,84,0.30);
  box-shadow: 0 0 76px rgba(255,174,76,0.24), 0 0 160px rgba(46,221,255,0.14), inset 0 0 58px rgba(224,64,251,0.12);
  animation: voOrbBreathFast 1s ease-in-out infinite;
}
html[data-mode="voice"] .vo-orb.thinking { animation: voOrbSpin 2s linear infinite; }
html[data-mode="voice"] .vo-orb.speaking {
  background: radial-gradient(circle at 40% 35%,
    rgba(255,255,255,0.30) 0%, rgba(185,255,220,0.18) 9%,
    rgba(0,255,136,0.12) 28%, rgba(5,55,34,0.22) 55%, transparent 78%
  );
  border-color: rgba(0,255,136,0.24);
  box-shadow: 0 0 72px rgba(0,255,136,0.30), 0 0 150px rgba(0,255,136,0.13), inset 0 0 52px rgba(0,255,136,0.09);
}
@keyframes voOrbBreathFast { 0%,100%{transform:scale(0.98)} 50%{transform:scale(1.06)} }
@keyframes voOrbSpin { 0%{filter:hue-rotate(0deg)} 100%{filter:hue-rotate(360deg)} }

/* Info */
.vo-info {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  width: min(620px, 86vw);
  margin-top: 20px;
}
.vo-transcript {
  margin: 0;
  width: 100%;
  font-size: clamp(0.9rem, 1.25vw, 1.08rem);
  font-weight: 650;
  color: rgba(220,232,255,0.94);
  line-height: 1.55;
  min-height: 3.4em;
  padding: 13px 18px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(70,217,232,0.20);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(22,28,44,0.64), rgba(8,12,22,0.38)),
    radial-gradient(circle at 50% 0%, rgba(70,217,232,0.10), transparent 58%);
  box-shadow:
    0 12px 34px rgba(0,0,0,0.22),
    inset 0 1px 0 rgba(255,255,255,0.05);
  text-wrap: balance;
}
.vo-state-text {
  margin: 0;
  font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--cyan); opacity: 0.66;
  font-weight: 800;
}

/* Buttons */
.vo-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.vo-btn {
  min-height: 40px; padding: 0 20px;
  border: 1px solid rgba(70,217,232,0.25);
  border-radius: 22px;
  background: rgba(70,217,232,0.05);
  color: var(--text); cursor: pointer; font-size: 0.88rem;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}
.vo-btn:hover {
  border-color: rgba(70,217,232,0.65);
  background: rgba(70,217,232,0.1);
  box-shadow: 0 0 18px rgba(70,217,232,0.18);
}
.vo-primary {
  background: linear-gradient(135deg, rgba(70,217,232,0.28), rgba(120,224,143,0.14));
  border-color: rgba(70,217,232,0.55);
}
.vo-code-btn.code-on {
  background: rgba(243,189,77,0.12);
  border-color: rgba(243,189,77,0.55);
  color: var(--amber);
}

/* ── Voice chat panel — 인페이지 패널로 교체됐으므로 숨김 ── */
.vo-chat { display: none; }

/* ═══ IN-PAGE CHAT PANEL ═════════════════════════════════════════ */
.chat-panel {
  position: fixed;
  right: -460px;
  bottom: 24px;
  width: 400px;
  height: 580px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,.7), 0 0 0 1px rgba(70,217,232,.08);
  display: flex;
  flex-direction: column;
  transition: right .32s cubic-bezier(.4,0,.2,1);
  z-index: 9000;
  overflow: hidden;
}
.chat-panel.open { right: 24px; }

.cp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: .06em;
  flex-shrink: 0;
}
.cp-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.cp-msgs::-webkit-scrollbar { width: 4px; }
.cp-msgs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

.cp-msg {
  max-width: 84%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.55;
  word-break: break-word;
}
.cp-msg.jarvis {
  background: var(--panel2);
  color: var(--text);
  align-self: flex-start;
  border: 1px solid var(--line);
}
.cp-msg.user {
  background: rgba(70,217,232,.18);
  color: var(--cyan);
  align-self: flex-end;
  border: 1px solid rgba(70,217,232,.25);
}

.cp-footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--panel2);
}
.cp-input {
  flex: 1;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  padding: 8px 10px;
  font-family: inherit;
  line-height: 1.4;
  min-height: 36px;
  max-height: 90px;
  overflow-y: auto;
}
.cp-input:focus { outline: none; border-color: rgba(70,217,232,.5); }
.cp-send {
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
  flex-shrink: 0;
  letter-spacing: .04em;
}
.cp-send:hover { filter: brightness(1.15); }

/* ═══ CODE AGENT TERMINAL PANEL (left overlay) ═════════════════ */
.agent-terminal-panel {
  position: fixed;
  left: -640px;
  top: 72px;
  bottom: 24px;
  width: min(600px, calc(100vw - 48px));
  background: rgba(4, 8, 14, 0.97);
  border: 1px solid rgba(70,217,232,.22);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,.72), 0 0 0 1px rgba(70,217,232,.07);
  display: flex;
  flex-direction: column;
  transition: left .28s cubic-bezier(.4,0,.2,1);
  z-index: 8800;
  overflow: hidden;
}
.agent-terminal-panel.open { left: 24px; }
.agent-terminal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(70,217,232,.14);
  background: rgba(8,16,26,.96);
  flex-shrink: 0;
}
.agent-terminal-title {
  flex: 1;
  min-width: 0;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-terminal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, Monaco, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: #c8d8e0;
}
.agent-terminal-body::-webkit-scrollbar { width: 4px; }
.agent-terminal-body::-webkit-scrollbar-thumb { background: rgba(70,217,232,.22); border-radius: 2px; }

/* ═══ TRADER PANEL (KIS Trader 대시보드 팝업) ═════════════════════ */
.trader-panel {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: min(620px, 94vw);
  height: min(840px, 88vh);
  background: #0d1117;
  border: 1px solid rgba(70,217,232,.15);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,.7), 0 0 0 1px rgba(70,217,232,.06);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(-100% - 48px)); /* 닫힘: 화면 왼쪽 밖으로 (너비 반응형이라 transform으로 숨김) */
  transition: transform .32s cubic-bezier(.4,0,.2,1);
  z-index: 8900;
  overflow: hidden;
}
.trader-panel.open { transform: translateX(0); }

.tp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(70,217,232,.1);
  font-size: 0.8rem;
  font-weight: 700;
  color: #e6b800;
  letter-spacing: .05em;
  flex-shrink: 0;
  background: #161b22;
}
.tp-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tp-ext {
  color: var(--muted);
  font-size: 1rem;
  text-decoration: none;
  line-height: 1;
  opacity: 0.6;
  transition: opacity .2s;
}
.tp-ext:hover { opacity: 1; }
.trader-panel iframe {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
  background: #0d1117;
}

.vo-trader-btn {
  background: rgba(230,184,0,.08) !important;
  border-color: rgba(230,184,0,.35) !important;
  color: #e6b800 !important;
}
.vo-trader-btn:hover {
  background: rgba(230,184,0,.18) !important;
  box-shadow: 0 0 14px rgba(230,184,0,.2) !important;
}

/* ── Agent toast (popup-blocked fallback) ── */
.agent-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--panel);
  border: 1px solid rgba(70,217,232,.4);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10000;
  box-shadow: 0 4px 32px rgba(70,217,232,.15), 0 8px 24px rgba(0,0,0,.6);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  font-size: 0.82rem;
  color: var(--text);
  max-width: 500px;
  pointer-events: all;
}
.agent-toast.show { transform: translateX(-50%) translateY(0); }
.agent-toast-icon { font-size: 1.4rem; flex-shrink: 0; }
.agent-toast-msg { flex: 1; line-height: 1.45; }
.agent-toast-msg strong { color: var(--cyan); display: block; margin-bottom: 2px; }
.agent-toast-btn {
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  letter-spacing: .04em;
}
.agent-toast-btn:hover { filter: brightness(1.15); }

.vo-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 0.82rem;
  margin-bottom: 10px; padding-bottom: 9px;
  border-bottom: 1px solid rgba(70,217,232,0.1);
  color: var(--muted); letter-spacing: 0.07em; text-transform: uppercase;
}
.vo-msgs {
  flex: 1; overflow: auto;
  display: flex; flex-direction: column;
  gap: 9px; padding-right: 3px;
}

/* ═══ MINI ORB (code mode) ══════════════════════════════════════ */
.mini-orb {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 60;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; cursor: pointer;
  opacity: 0; pointer-events: none;
  transform: scale(0.4) translateY(20px);
  transition: opacity 0.42s, transform 0.48s cubic-bezier(0.34, 1.56, 0.64, 1);
}
html[data-mode="code"] .mini-orb {
  opacity: 1; pointer-events: all;
  transform: scale(1) translateY(0);
}
.mini-wrap { position: relative; width: 72px; height: 72px; }
.mini-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid rgba(70,217,232,0.42);
  animation: miniPulse 2.2s ease-in-out infinite;
}
.mini-core {
  position: absolute; inset: 13%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 30%, rgba(255,255,255,0.72) 0%, transparent 18%),
    radial-gradient(circle, rgba(70,217,232,0.32) 0%, rgba(8,20,32,0.92) 48%, rgba(70,217,232,0.08) 76%);
  border: 1px solid rgba(70,217,232,0.34);
  box-shadow: 0 0 24px rgba(70,217,232,0.56), 0 0 54px rgba(70,217,232,0.20), inset -8px -10px 20px rgba(0,0,0,0.34);
  animation: miniBreath 3s ease-in-out infinite;
  transition: background 0.38s, box-shadow 0.38s;
}
.mini-core.listening {
  background:
    radial-gradient(circle at 36% 30%, rgba(255,255,255,0.72) 0%, transparent 18%),
    radial-gradient(circle, rgba(224,64,251,0.34) 0%, rgba(26,8,34,0.92) 48%, rgba(224,64,251,0.08) 76%);
  border-color: rgba(224,64,251,0.38);
  box-shadow: 0 0 24px rgba(224,64,251,0.56), 0 0 54px rgba(224,64,251,0.20), inset -8px -10px 20px rgba(0,0,0,0.34);
}
.mini-core.thinking { animation: miniBreath 0.75s ease-in-out infinite; }
.mini-core.speaking {
  background:
    radial-gradient(circle at 36% 30%, rgba(255,255,255,0.72) 0%, transparent 18%),
    radial-gradient(circle, rgba(0,255,136,0.32) 0%, rgba(5,35,24,0.92) 48%, rgba(0,255,136,0.08) 76%);
  border-color: rgba(0,255,136,0.38);
  box-shadow: 0 0 24px rgba(0,255,136,0.54), 0 0 54px rgba(0,255,136,0.20), inset -8px -10px 20px rgba(0,0,0,0.34);
}
.mini-lbl { font-size: 0.62rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
@keyframes miniPulse { 0%,100%{transform:scale(1);opacity:0.5} 50%{transform:scale(1.12);opacity:1} }
@keyframes miniBreath { 0%,100%{transform:scale(1)} 50%{transform:scale(1.06)} }

/* ═══ GLOBAL FLOATING CHAT BAR ══════════════════════════════════ */
/* 음성 모드에서 gchat 바 숨김 — 팝업 채팅창으로 대체 */
html[data-mode="voice"] .gchat { display: none; }

.gchat {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(660px, calc(100vw - 48px));
  z-index: 70;
  transition: opacity 0.3s, transform 0.3s;
}

.gchat-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 16px;
  background:
    linear-gradient(180deg, rgba(16,20,34,0.88), rgba(5,7,15,0.82)),
    radial-gradient(circle at 8% 0%, rgba(255,176,72,0.10), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(65,231,255,0.07), transparent 42%);
  backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255,176,72,0.22);
  border-radius: 18px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.6),
    0 0 0 1px rgba(65,231,255,0.055),
    inset 0 1px 0 rgba(255,255,255,0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gchat-inner:focus-within {
  border-color: rgba(255,176,72,0.55);
  box-shadow:
    0 8px 40px rgba(0,0,0,0.65),
    0 0 28px rgba(255,176,72,0.13),
    0 0 34px rgba(65,231,255,0.08),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

.gchat-input {
  flex: 1;
  min-height: 24px;
  max-height: 140px;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  outline: none;
  overflow-y: auto;
  padding: 0;
}
.gchat-input::placeholder { color: var(--muted); opacity: 0.7; }

.gchat-send {
  flex-shrink: 0;
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid rgba(255,176,72,0.36);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,176,72,0.15), rgba(65,231,255,0.09));
  color: #ffd59c;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.gchat-send:hover {
  background: linear-gradient(135deg, rgba(255,176,72,0.25), rgba(65,231,255,0.16));
  border-color: rgba(255,176,72,0.72);
  box-shadow: 0 0 16px rgba(255,176,72,0.25), 0 0 22px rgba(65,231,255,0.12);
}
.gchat-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ─ Model picker (코드모드 터미널 헤더에만 표시) ─ */
.model-picker {
  display: none; /* 기본 숨김 — 코드모드에서만 노출 */
  flex-shrink: 0;
  height: 26px;
  padding: 0 8px;
  min-width: 110px;
  border: 1px solid rgba(255,176,72,0.20);
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, color 0.2s;
  text-transform: none;
}
.model-picker:hover, .model-picker:focus { border-color: rgba(255,176,72,0.55); color: var(--text); }
.model-picker option { background: #0b101d; }
html[data-mode="code"] .term-head .model-picker { display: block; }

/* ─ Image preview strip above gchat ─ */
.gchat-img-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin-bottom: 6px;
  background: rgba(8, 16, 26, 0.9);
  border: 1px solid rgba(70,217,232,0.28);
  border-radius: 12px;
  backdrop-filter: blur(16px);
}
.gchat-img-preview img {
  width: 52px; height: 52px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(70,217,232,0.2);
}
.gchat-img-label { flex: 1; font-size: 0.82rem; color: var(--muted); }
.gchat-img-remove {
  font-size: 1rem;
  color: var(--muted);
  padding: 2px 6px;
  min-height: 24px;
}
.gchat-img-remove:hover { color: var(--red); }

/* ─ Code mode: gchat anchored to bottom of right panel ─ */
html[data-mode="code"] .gchat {
  left: calc(50% + 7px);
  right: 14px;
  width: auto;
  transform: none;
  bottom: 14px;
}
html[data-mode="code"] .log-panel { padding-bottom: 80px; }
html[data-mode="code"] .activity-section { flex: 0.35 !important; }

/* ─ Orb cursor: clickable during processing ─ */
#voOrb { cursor: default; transition: cursor 0.1s; }
#voOrb.listening, #voOrb.thinking, #voOrb.speaking { cursor: pointer; }
#miniOrb { cursor: pointer; }

/* ═══ VO HEADER RIGHT ═══════════════════════════════════════════ */
.vo-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ═══ BRAIN 3D CANVAS OVERLAY ════════════════════════════════════ */
.brain-canvas {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 190%; height: 190%;
  pointer-events: none;
  z-index: 2;
}

/* ═══ BRAIN PIPELINE ════════════════════════════════════════════ */
.brain-pipeline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 4px 12px;
}

.bp-step {
  min-width: 34px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(70,217,232,0.15);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 7px;
  opacity: 0.3;
  transition: all 0.32s;
}
.bp-step[data-step="stt"]   { --sc: #e040fb; }
.bp-step[data-step="llm"]   { --sc: #7c6af7; }
.bp-step[data-step="claudeapi"] { --sc: #d97757; }
.bp-step[data-step="web"]   { --sc: #00d4ff; }
.bp-step[data-step="db"]    { --sc: #00bcd4; }
.bp-step[data-step="agent"] { --sc: #ffaa00; }
.bp-step[data-step="agent"][data-provider="codex"] { --sc: #27c93f; }
.bp-step[data-step="agent"][data-provider="claude"] { --sc: #ffaa00; }
.bp-step[data-step="tts"]   { --sc: #00ff88; }

.bp-step.active {
  opacity: 1;
  color: var(--sc);
  border-color: var(--sc);
}
.bp-step.active[data-step="stt"]   { box-shadow: 0 0 10px #e040fb55; }
.bp-step.active[data-step="llm"]   { box-shadow: 0 0 10px #7c6af755; }
.bp-step.active[data-step="claudeapi"] { box-shadow: 0 0 10px #d9775766; }
.bp-step.active[data-step="web"]   { box-shadow: 0 0 10px #00d4ff55; }
.bp-step.active[data-step="db"]    { box-shadow: 0 0 10px #00bcd455; }
.bp-step.active[data-step="agent"] { box-shadow: 0 0 10px #ffaa0055; }
.bp-step.active[data-step="agent"][data-provider="codex"] { box-shadow: 0 0 10px #27c93f66; }
.bp-step.active[data-step="tts"]   { box-shadow: 0 0 10px #00ff8855; }

.bp-tools-grp {
  display: flex;
  gap: 4px;
}

.bp-conn {
  flex-shrink: 0;
  width: 14px;
  height: 2px;
  background: rgba(70,217,232,0.14);
  border-radius: 1px;
  position: relative;
  overflow: hidden;
}
.brain-pipeline.processing .bp-conn::after,
.brain-pipeline.speaking .bp-conn::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 8px;
  border-radius: 1px;
  background: rgba(70,217,232,0.8);
  animation: bpFlow 1.1s linear infinite;
}
.brain-pipeline.speaking .bp-conn::after {
  background: rgba(120,224,143,0.8);
  animation-duration: 1.5s;
}
@keyframes bpFlow {
  0%   { transform: translateX(-8px); }
  100% { transform: translateX(14px); }
}

/* ═══ DEBUG PANEL ════════════════════════════════════════════════ */
.dbg-toggle-btn {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(70,217,232,0.2);
  border-radius: 6px;
  background: rgba(70,217,232,0.04);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.2s;
}
.dbg-toggle-btn:hover,
.dbg-toggle-btn.active {
  border-color: rgba(70,217,232,0.55);
  color: var(--cyan);
  background: rgba(70,217,232,0.1);
  box-shadow: 0 0 14px rgba(70,217,232,0.15);
}

.dbg-panel {
  position: absolute;
  top: 64px;
  left: 24px;
  width: 300px;
  max-height: 380px;
  z-index: 20;
  border: 1px solid rgba(70,217,232,0.22);
  border-radius: 12px;
  background: rgba(3, 8, 16, 0.93);
  backdrop-filter: blur(28px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.65);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.dbg-panel.visible { display: flex; }

.dbg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(70,217,232,0.1);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
  flex-shrink: 0;
}

.dbg-body {
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
}
.dbg-empty { color: var(--muted); font-size: 0.72rem; font-style: italic; }

.dbg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}
.dbg-row > span:first-child {
  min-width: 52px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding-top: 1px;
}
.dbg-row strong  { color: var(--text); font-size: 0.74rem; }
.dbg-row em      { color: var(--muted); font-style: normal; word-break: break-word; font-size: 0.72rem; }
.dbg-active { color: var(--cyan) !important; }
.dbg-badge {
  font-size: 0.66rem; font-weight: 700;
  padding: 1px 7px; border-radius: 4px;
  letter-spacing: 0.05em;
}
.dbg-set  { background: rgba(120,224,143,0.16); color: var(--green); border: 1px solid rgba(120,224,143,0.38); }
.dbg-null { background: rgba(255,107,107,0.1);  color: var(--red);   border: 1px solid rgba(255,107,107,0.28); }
.dbg-ts { color: rgba(90,136,152,0.5); font-size: 0.61rem; text-align: right; margin-top: 2px; }

/* ═══ RESPONSIVE ════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
    width: min(100vw - 16px, 700px);
    height: auto; min-height: calc(100vh - 16px);
    margin: 8px auto;
  }
  .command-deck,.side-panel,.log-panel { grid-column: 1; grid-row: auto; }
  .messages,.activity { max-height: 42vh; }
  .command-deck { min-height: auto; padding: 14px; }
  .orb-panel,.composer,.controls { grid-template-columns: 1fr; }
  .voice-readout { border-left: 0; border-top: 1px solid var(--line); }
  .vo { grid-template-columns: 1fr; grid-template-rows: auto 1fr; grid-template-areas:"header""stage"; }
  .vo-orb-wrap { width: clamp(170px, 50vw, 300px); }
}

/* Persistent chat copy controls */
.message-copy {
  appearance: none;
  justify-self: end;
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: var(--muted);
  font: 700 0.66rem/1.2 inherit;
  cursor: pointer;
  opacity: 0.7;
}
.message-copy:hover { color: var(--cyan); opacity: 1; }
.message-copy.copied { color: var(--green); opacity: 1; }
.message.from-jarvis .message-copy { justify-self: start; }
.cp-msg { display: grid; gap: 5px; }
.cp-msg-text { white-space: pre-wrap; word-break: break-word; }
.cp-msg.user .message-copy { justify-self: end; }

/* ═══ APP-MODE (Tauri 데스크탑 전용) ════════════════════════════
   대화 중: voice overlay 숨기고 vo-chat을 풀스크린 채팅창으로 전환
   ═══════════════════════════════════════════════════════════════ */

/* app-mode 클래스는 html + body 둘 다 붙음 (?app=1) */

/* ── 대기 중: idle 화면만 — 메인 모니터도 orb.html과 동일하게 ── */
/* (별도 변경 없음: idle-screen이 이미 data-mode="idle" 일 때 표시됨) */

/* ── 대화 중: voice overlay 숨기고 채팅창 전면으로 ── */
html.app-mode[data-mode="voice"] .vo {
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1 !important;
}

html.app-mode[data-mode="voice"] .vo-chat {
  position: fixed !important;
  inset: 0 !important;
  transform: translateX(0) !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100vh !important;
  border-radius: 0 !important;
  border-left: none !important;
  background:
    radial-gradient(circle at 47% 20%, rgba(255,173,66,0.08), transparent 30%),
    radial-gradient(circle at 64% 60%, rgba(65,231,255,0.07), transparent 35%),
    rgba(5, 7, 16, 0.99) !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: 55 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

/* app-mode 채팅 헤더 (기본은 숨김) */
.app-chat-header { display: none; }
html.app-mode[data-mode="voice"] .app-chat-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 28px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(3,3,10,0.82), rgba(3,3,10,0));
  flex-shrink: 0;
}
.app-chat-title { flex: 1; }
.app-chat-status { }
.app-chat-actions {
  display: flex; align-items: center; gap: 8px;
}

/* 일반 브라우저 채팅 헤더 숨김 → app-mode에서 */
html.app-mode[data-mode="voice"] .vo-chat-head { display: none !important; }

/* app-mode에서 메시지 영역이 flex 1로 채우도록 */
html.app-mode[data-mode="voice"] .vo-msgs {
  flex: 1;
  min-height: 0;
  padding: 20px 28px;
  max-height: none !important;
}

/* app-mode 하단 트랜스크립트 바 (기본 숨김) */
.app-transcript-bar { display: none; }
html.app-mode[data-mode="voice"] .app-transcript-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  border-top: 1px solid var(--line);
  background: rgba(3,3,10,0.7);
  flex-shrink: 0;
  min-height: 48px;
}
.app-tx-label {
  font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); flex-shrink: 0;
}
.app-tx-text {
  font-size: 0.92rem; color: var(--cyan);
  opacity: 0.85; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Mini orb: app-mode voice 중에도 보이도록 */
html.app-mode[data-mode="voice"] .mini-orb {
  display: flex !important;
  z-index: 60;
}
.cp-msg.jarvis .message-copy { justify-self: start; }
