:root {
  --lmvh-ink: #151F4A;
  --lmvh-ink-deep: #0D1535;
  --lmvh-tint-50: #F2F3F9;
  --lmvh-tint-100: #EAECF5;
  --lmvh-tint-200: #C8CCE8;
  --lmvh-tint-400: #7A84C4;
  --lmvh-surface: #FAFAF8;
  --lmvh-surface-2: #F3F1EC;
  --lmvh-surface-3: #E8E4DC;
  --lmvh-border: #D8D2C8;
  --lmvh-border-light: #EAE6DF;
  --lmvh-text: #1A1714;
  --lmvh-text-mid: #4A4540;
  --lmvh-text-light: #8A837C;
  --lmvh-success: #2D6A4F;
  --lmvh-success-bg: #E8F5EE;
  --lmvh-warn: #B8860B;
  --lmvh-warn-bg: #FFF8E7;
  --lmvh-error: #C53030;
  --lmvh-error-bg: #FFF5F5;
  --lmvh-font-display: 'DM Serif Display', Georgia, serif;
  --lmvh-font-ui: 'Jost', system-ui, -apple-system, sans-serif;
  --lmvh-font-mono: 'DM Mono', 'Courier New', monospace;
  --lmvh-radius: 6px;
  --lmvh-radius-lg: 10px;
  --lmvh-shadow: 0 4px 16px rgba(21,31,74,0.10);
  --sidebar-w: 280px;
}

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

body {
  font-family: var(--lmvh-font-ui);
  font-size: 14px;
  color: var(--lmvh-text);
  background: var(--lmvh-surface);
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* -- Header -- */
.header { background: var(--lmvh-ink); height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 1.25rem; flex-shrink: 0; }
.header-left { display: flex; align-items: center; gap: 14px; }
.header-logo { height: 28px; width: auto; display: block; }
.header-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.2); }
.header-title { font-family: var(--lmvh-font-ui); font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.7); }
.header-right { display: flex; align-items: center; gap: 16px; }
.nav-link { font-size: 12px; color: rgba(255,255,255,0.5); text-decoration: none; transition: color 0.15s; }
.nav-link:hover { color: rgba(255,255,255,0.85); }

/* -- Console Body -- */
.console-body { display: flex; flex: 1; overflow: hidden; }

/* -- Agent Sidebar -- */
.agent-sidebar { width: var(--sidebar-w); border-right: 1px solid var(--lmvh-border-light); background: white; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 16px 20px 12px; font-family: var(--lmvh-font-ui); font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--lmvh-text-light); border-bottom: 1px solid var(--lmvh-border-light); }
.agent-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.agent-item { display: flex; align-items: center; gap: 12px; padding: 10px 20px; cursor: pointer; transition: background 0.12s; border-left: 3px solid transparent; }
.agent-item:hover { background: var(--lmvh-tint-50); }
.agent-item.active { background: var(--lmvh-tint-50); border-left-color: var(--lmvh-ink); }
.agent-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.agent-dot.ready { background: var(--lmvh-success); }
.agent-dot.dormant { background: var(--lmvh-border); }
.agent-dot.working { background: var(--lmvh-warn); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.agent-info { flex: 1; min-width: 0; }
.agent-name { font-family: var(--lmvh-font-display); font-size: 15px; color: var(--lmvh-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-role { font-size: 11px; color: var(--lmvh-text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* -- Chat Main -- */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header { padding: 14px 24px; border-bottom: 1px solid var(--lmvh-border-light); display: flex; align-items: center; gap: 12px; background: white; flex-shrink: 0; }
.chat-agent-name { font-family: var(--lmvh-font-display); font-size: 18px; color: var(--lmvh-ink); }
.chat-agent-role { font-size: 12px; color: var(--lmvh-text-light); }
.btn-new-chat { margin-left: auto; padding: 5px 14px; border: 1px solid var(--lmvh-border); border-radius: 20px; background: white; font-family: var(--lmvh-font-ui); font-size: 12px; font-weight: 500; color: var(--lmvh-text-mid); cursor: pointer; transition: all 0.15s; display: none; }
.btn-new-chat:hover { border-color: var(--lmvh-ink); color: var(--lmvh-ink); }
.btn-new-chat.visible { display: inline-block; }

/* -- Chat Thread -- */
.chat-thread { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--lmvh-text-light); }
.chat-empty-icon { opacity: 0.3; }
.chat-empty-text { font-size: 14px; }

.msg { max-width: 72%; padding: 12px 16px; border-radius: var(--lmvh-radius-lg); line-height: 1.55; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--lmvh-ink); color: white; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: white; border: 1px solid var(--lmvh-border-light); color: var(--lmvh-text); border-bottom-left-radius: 4px; }
.msg.assistant .msg-agent-label { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--lmvh-tint-400); margin-bottom: 6px; }
.msg .msg-file { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; margin-top: 8px; background: rgba(255,255,255,0.15); border-radius: 6px; font-size: 11px; font-family: var(--lmvh-font-mono); }
.msg.assistant .msg-file { background: var(--lmvh-tint-50); }

.msg-typing { align-self: flex-start; padding: 12px 16px; background: white; border: 1px solid var(--lmvh-border-light); border-radius: var(--lmvh-radius-lg); border-bottom-left-radius: 4px; display: flex; gap: 5px; align-items: center; }
.typing-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lmvh-tint-200); animation: typingBounce 1.2s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* -- Chat Input -- */
.chat-input-area { padding: 16px 24px 20px; border-top: 1px solid var(--lmvh-border-light); background: white; flex-shrink: 0; }
.chat-input-row { display: flex; align-items: flex-end; gap: 10px; background: var(--lmvh-surface); border: 1px solid var(--lmvh-border); border-radius: var(--lmvh-radius-lg); padding: 8px 12px; transition: border-color 0.15s; }
.chat-input-row:focus-within { border-color: var(--lmvh-tint-400); }
.chat-input { flex: 1; border: none; outline: none; background: transparent; font-family: var(--lmvh-font-ui); font-size: 14px; line-height: 1.5; color: var(--lmvh-text); resize: none; max-height: 120px; }
.chat-input::placeholder { color: var(--lmvh-text-light); }
.upload-btn { cursor: pointer; color: var(--lmvh-text-light); transition: color 0.15s; display: flex; align-items: center; padding: 2px; }
.upload-btn:hover { color: var(--lmvh-ink); }
.send-btn { border: none; background: var(--lmvh-ink); color: white; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: opacity 0.15s; flex-shrink: 0; }
.send-btn:disabled { opacity: 0.3; cursor: default; }
.send-btn:not(:disabled):hover { opacity: 0.85; }

.chat-file-preview { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 12px; background: var(--lmvh-tint-50); border-radius: var(--lmvh-radius); font-size: 12px; font-family: var(--lmvh-font-mono); color: var(--lmvh-text-mid); }
.file-remove { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--lmvh-text-light); padding: 0 2px; }
.file-remove:hover { color: var(--lmvh-error); }

/* -- Toast -- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--lmvh-ink); color: white; padding: 10px 24px; border-radius: 8px; font-size: 13px; font-weight: 500; opacity: 0; transition: all 0.3s ease; pointer-events: none; z-index: 999; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* -- Tool Trace (collapsed by default) -- */
.tool-trace { margin: 8px 0; }
.tool-trace-toggle { font-size: 11px; font-weight: 500; color: var(--lmvh-tint-400); cursor: pointer; padding: 4px 8px; border-radius: 4px; background: var(--lmvh-tint-50); border: 1px solid var(--lmvh-tint-200); display: inline-flex; align-items: center; gap: 4px; transition: all 0.15s; }
.tool-trace-toggle:hover { background: var(--lmvh-tint-100); color: var(--lmvh-ink); }
.tool-trace-toggle.open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.tool-trace-details { border: 1px solid var(--lmvh-tint-200); border-top: none; border-radius: 0 0 4px 4px; background: var(--lmvh-tint-50); padding: 6px; max-height: 240px; overflow-y: auto; }
.tool-trace-item { padding: 6px 8px; border-bottom: 1px solid var(--lmvh-border-light); font-size: 11px; }
.tool-trace-item:last-child { border-bottom: none; }
.tool-trace-name { font-family: var(--lmvh-font-mono); font-size: 11px; font-weight: 600; color: var(--lmvh-ink); }
.tool-trace-input { font-family: var(--lmvh-font-mono); font-size: 10px; color: var(--lmvh-text-light); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-trace-result { font-size: 10px; color: var(--lmvh-success); margin-top: 2px; }
.tool-trace-result.error { color: var(--lmvh-error); }

/* -- Message metadata -- */
.msg-meta { font-size: 10px; color: var(--lmvh-text-light); margin-top: 8px; font-family: var(--lmvh-font-mono); }

/* -- Typing text variant -- */
.typing-text { font-size: 12px; color: var(--lmvh-text-light); font-style: italic; }
