/* ═══════════════════════════════════════════════════════
   Zo Co-browse — Design System "The Observatory"
   Midnight + amber (dark) / Cream + amber (light)
   Fonts: Fraunces (display), Figtree (UI), JetBrains Mono (code)
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,300..900&family=Fraunces:ital,opsz,wght,SOFT,WONK@0,9..144,100..900,0..100,0..1;1,9..144,100..900,0..100,0..1&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');

/* ── Dark (default) ── */
:root {
  --font-display: 'Fraunces', Georgia, serif;
  --font-ui: 'Figtree', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', monospace;

  --bg-deep: #070914;
  --bg-surface: #0f1128;
  --bg-elevated: #181b3e;
  --bg-hover: #21255a;
  --bg-active: #282d6a;
  --bg-chat: #080a1a;
  --bg-input: #0c0e24;
  --bg-glass: rgba(15, 17, 40, 0.72);

  --text: #e8e6f0;
  --text-muted: #8884a8;
  --text-faint: #5a5680;
  --text-inverse: #070914;

  --amber: #f0a832;
  --amber-muted: #b07a2a;
  --amber-glow: rgba(240, 168, 50, 0.15);
  --amber-glow-strong: rgba(240, 168, 50, 0.30);

  --indigo: #6366f1;
  --indigo-muted: #4a4dc0;

  --green: #34d399;
  --red: #f87171;
  --orange: #fb923c;

  --border: #25284a;
  --border-soft: #1a1d3a;
  --border-focus: var(--amber);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --header-h: 52px;
  --input-h: 44px;
}

/* ── Light ── */
@media (prefers-color-scheme: light) {
  :root {
    --bg-deep: #f4f1ea;
    --bg-surface: #ffffff;
    --bg-elevated: #faf8f5;
    --bg-hover: #f0ece4;
    --bg-active: #e8e2d8;
    --bg-chat: #fcfaf7;
    --bg-input: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.85);

    --text: #1a1814;
    --text-muted: #7a756c;
    --text-faint: #a8a298;
    --text-inverse: #f4f1ea;

    --amber: #c47f20;
    --amber-muted: #dba14a;
    --amber-glow: rgba(196, 127, 32, 0.10);
    --amber-glow-strong: rgba(196, 127, 32, 0.20);

    --indigo: #5254cc;
    --indigo-muted: #6e70d6;

    --border: #ddd8ce;
    --border-soft: #e8e4dc;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  }
}

/* ── Manual override ── */
[data-theme="dark"] {
  --bg-deep: #070914;
  --bg-surface: #0f1128;
  --bg-elevated: #181b3e;
  --bg-hover: #21255a;
  --bg-active: #282d6a;
  --bg-chat: #080a1a;
  --bg-input: #0c0e24;
  --bg-glass: rgba(15, 17, 40, 0.72);
  --text: #e8e6f0;
  --text-muted: #8884a8;
  --text-faint: #5a5680;
  --text-inverse: #070914;
  --amber: #f0a832;
  --amber-muted: #b07a2a;
  --amber-glow: rgba(240, 168, 50, 0.15);
  --amber-glow-strong: rgba(240, 168, 50, 0.30);
  --indigo: #6366f1;
  --indigo-muted: #4a4dc0;
  --green: #34d399;
  --red: #f87171;
  --orange: #fb923c;
  --border: #25284a;
  --border-soft: #1a1d3a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --header-h: 52px;
  --input-h: 44px;
}

[data-theme="light"] {
  --bg-deep: #f4f1ea;
  --bg-surface: #ffffff;
  --bg-elevated: #faf8f5;
  --bg-hover: #f0ece4;
  --bg-active: #e8e2d8;
  --bg-chat: #fcfaf7;
  --bg-input: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --text: #1a1814;
  --text-muted: #7a756c;
  --text-faint: #a8a298;
  --text-inverse: #f4f1ea;
  --amber: #c47f20;
  --amber-muted: #dba14a;
  --amber-glow: rgba(196, 127, 32, 0.10);
  --amber-glow-strong: rgba(196, 127, 32, 0.20);
  --indigo: #5254cc;
  --indigo-muted: #6e70d6;
  --green: #2ea97c;
  --red: #dc4444;
  --orange: #d97706;
  --border: #ddd8ce;
  --border-soft: #e8e4dc;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* ── Sepia (warm paper tones) ── */
[data-theme="sepia"] {
  --bg-deep: #efe3c9;
  --bg-surface: #f6ecda;
  --bg-elevated: #f4e8d0;
  --bg-hover: #eadec2;
  --bg-active: #e0d0b0;
  --bg-chat: #f3e8d4;
  --bg-input: #faf2e2;
  --bg-glass: rgba(246, 236, 218, 0.88);
  --text: #3d3024;
  --text-muted: #7a6b5a;
  --text-faint: #a89880;
  --text-inverse: #f6ecda;
  --amber: #a0592a;
  --amber-muted: #b8733e;
  --amber-glow: rgba(160, 89, 42, 0.12);
  --amber-glow-strong: rgba(160, 89, 42, 0.22);
  --indigo: #6a5acd;
  --indigo-muted: #8b7fd6;
  --green: #5a8a5a;
  --red: #b8433a;
  --orange: #b86a2a;
  --border: #d4c8b0;
  --border-soft: #e0d6c2;
  --shadow-sm: 0 1px 3px rgba(61,48,36,0.10);
  --shadow-md: 0 4px 12px rgba(61,48,36,0.12);
  --shadow-lg: 0 8px 32px rgba(61,48,36,0.14);
}

/* ── Forest (deep green + gold) ── */
[data-theme="forest"] {
  --bg-deep: #0f1a14;
  --bg-surface: #142118;
  --bg-elevated: #1a2d22;
  --bg-hover: #1f382a;
  --bg-active: #254332;
  --bg-chat: #0d1710;
  --bg-input: #111e16;
  --bg-glass: rgba(20, 33, 24, 0.80);
  --text: #dce8d4;
  --text-muted: #8a9e82;
  --text-faint: #5a7052;
  --text-inverse: #0f1a14;
  --amber: #c9a84c;
  --amber-muted: #a8883c;
  --amber-glow: rgba(201, 168, 76, 0.15);
  --amber-glow-strong: rgba(201, 168, 76, 0.28);
  --indigo: #6b8f71;
  --indigo-muted: #8aaa90;
  --green: #4ade80;
  --red: #f87171;
  --orange: #d9a040;
  --border: #2a4032;
  --border-soft: #1e3026;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.6);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.7);
}

/* ── Ocean (deep teal + coral) ── */
[data-theme="ocean"] {
  --bg-deep: #0a1820;
  --bg-surface: #0f1f2a;
  --bg-elevated: #142838;
  --bg-hover: #193046;
  --bg-active: #1e3a54;
  --bg-chat: #08141c;
  --bg-input: #0d1c26;
  --bg-glass: rgba(15, 31, 42, 0.82);
  --text: #d8eaf0;
  --text-muted: #7a9aaa;
  --text-faint: #4a7080;
  --text-inverse: #0a1820;
  --amber: #e06b5a;
  --amber-muted: #c05a4a;
  --amber-glow: rgba(224, 107, 90, 0.18);
  --amber-glow-strong: rgba(224, 107, 90, 0.32);
  --indigo: #5ab0c8;
  --indigo-muted: #7ac4da;
  --green: #4ae0c0;
  --red: #f87171;
  --orange: #e88a50;
  --border: #1a3850;
  --border-soft: #122838;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.6);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.7);
}

/* ── Theme palette popover ── */
.theme-popover {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 999;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  padding: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 210px;
  opacity: 0;
  transform: translateY(-4px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.theme-popover.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font);
}
.theme-option:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
.theme-option.selected {
  border-color: var(--amber);
  color: var(--text);
}
.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
}
.theme-swatch.dark { background: #0f1128; }
.theme-swatch.light { background: #ffffff; border-color: #ddd8ce; }
.theme-swatch.sepia { background: #f6ecda; }
.theme-swatch.forest { background: #142118; }
.theme-swatch.ocean { background: #0f1f2a; }
.theme-label { line-height: 1.2; }

/* ── Options page theme picker ── */
.theme-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.theme-picker-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  transition: border-color 0.12s, background 0.12s;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font);
}
.theme-picker-option:hover { border-color: var(--amber-muted); }
.theme-picker-option.selected { border-color: var(--amber); background: var(--amber-glow); color: var(--text); }

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  height: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
input, textarea, select {
  font-family: var(--font-ui);
  color: var(--text);
}
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 10px 0 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 14px;
  right: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber-muted), transparent);
  opacity: 0.4;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  font-variation-settings: 'wght' 700, 'SOFT' 80;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.header-brand .brand-star {
  color: var(--amber);
  font-size: 18px;
  line-height: 1;
  filter: drop-shadow(0 0 6px var(--amber-glow));
}
.header-brand .brand-zo {
  background: linear-gradient(135deg, var(--amber), var(--indigo));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  position: relative;
}

/* ── Icon buttons ── */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  transition: all 0.15s ease;
  position: relative;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.icon-btn:active {
  background: var(--bg-active);
  transform: scale(0.93);
}
.icon-btn.active {
  color: var(--amber);
  background: var(--amber-glow);
}
.icon-btn.active:hover {
  background: var(--amber-glow-strong);
}

/* ── Status dot ── */
.status-dot-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: all 0.3s ease;
  cursor: pointer;
}
.dot-connected {
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}
.dot-disconnected {
  background: var(--red);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.3);
}

/* ── Page bar ── */
.page-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  min-height: 28px;
}
.page-icon {
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}
#page-url {
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* ── Controls bar (model/persona/preset) ── */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.controls-bar label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.controls-bar select {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 11px;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.controls-bar select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-glow);
}
.controls-bar .create-preset-btn {
  font-size: 14px;
  width: 24px;
  height: 24px;
}

/* ── Action chips ── */
.chips-wrap {
  display: flex;
  gap: 6px;
  padding: 6px 14px 4px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips-wrap::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.chip:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-glow);
  box-shadow: 0 0 12px var(--amber-glow);
}
.chip:active {
  transform: scale(0.95);
}

/* ── Messages area ── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-chat);
}

.msg {
  display: flex;
  gap: 8px;
  animation: msgIn 0.25s ease-out;
  max-width: 100%;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-body {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.msg-user {
  justify-content: flex-end;
}
.msg-user .msg-body {
  background: linear-gradient(135deg, var(--amber), var(--indigo));
  color: white;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.msg-user .msg-body p { color: white; }

.msg-assistant {
  justify-content: flex-start;
}
.msg-assistant .msg-body {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.msg-system {
  justify-content: center;
}
.msg-system .msg-body {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 16px;
  max-width: 90%;
}

.msg-thinking {
  justify-content: flex-start;
}
.msg-thinking .msg-body {
  background: transparent;
  color: var(--text-faint);
  font-style: italic;
  font-size: 12px;
}

.msg-error {
  justify-content: flex-start;
}
.msg-error .msg-body {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-bottom-left-radius: 4px;
  color: var(--red);
  font-size: 12px;
}

/* ── Message body content ── */
.msg-body p { margin-bottom: 6px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { font-weight: 600; }
.msg-body code {
  font-family: var(--font-code);
  font-size: 12px;
  background: var(--bg-hover);
  padding: 1px 5px;
  border-radius: 4px;
}
.msg-body pre {
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  margin: 6px 0;
}
.msg-body pre code {
  background: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.5;
}
.msg-body a {
  color: var(--indigo);
  text-decoration: underline;
}
.msg-assistant .msg-body a { color: var(--amber); }

/* ── TTS button ── */
.msg-tts-btn {
  align-self: flex-end;
  margin-bottom: 4px;
  flex-shrink: 0;
}

/* ── Actions bar (pending actions) ── */
#actions-bar {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#actions-reasoning {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.actions-buttons {
  display: flex;
  gap: 6px;
}

/* ── Input area ── */
.input-area {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-soft);
}

.input-wrap {
  flex: 1;
  position: relative;
}

#query-input {
  width: 100%;
  min-height: 36px;
  max-height: 120px;
  padding: 8px 34px 8px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  outline: none;
  resize: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#query-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-glow);
}
#query-input::placeholder {
  color: var(--text-faint);
  font-size: 12px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-faint);
}
.btn:active {
  transform: scale(0.96);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(135deg, var(--amber), var(--indigo));
  color: white;
  border: none;
}
.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 0 16px var(--amber-glow);
}
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
}

#send-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  font-size: 16px;
}
#send-btn:disabled {
  opacity: 0.4;
}

/* ── Mic button ── */
.mic-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  margin-bottom: 2px;
}
.mic-btn.recording {
  color: var(--red);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── History view ── */
#history-view {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
}

.history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.history-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  font-variation-settings: 'wght' 600, 'SOFT' 60;
  color: var(--text);
  margin-right: auto;
}

#history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.history-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all 0.15s ease;
}
.history-card:hover {
  border-color: var(--amber-muted);
  box-shadow: 0 0 12px var(--amber-glow);
}
.history-card-active {
  border-left: 3px solid var(--amber);
  background: var(--amber-glow);
}

.history-card-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card-meta {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-card-delete {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  opacity: 0;
}
.history-card:hover .history-card-delete {
  opacity: 1;
}
.history-card-delete:hover {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}

.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: 13px;
}

/* ── Layout shell ── */
#chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: var(--bg-deep);
}

.hidden { display: none !important; }

/* ── TTS btn within messages ── */
.tts-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px;
  opacity: 0.5;
  transition: opacity 0.15s;
  line-height: 1;
}
.tts-btn:hover {
  opacity: 1;
}

/* ── Auto-scroll anchor ── */
.scroll-anchor { height: 1px; }

/* ── Theme toggle in options ── */
.theme-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.theme-toggle-row label {
  font-size: 12px;
  color: var(--text-muted);
}
.theme-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  border: none;
  padding: 0;
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--amber);
  transition: transform 0.2s;
}
.theme-toggle.theme-light::after {
  transform: translateX(18px);
  background: var(--indigo);
}

.theme-toggle {
  font-size: 14px;
}
.theme-toggle:hover {
  color: var(--amber);
}

/* ── Loading spinner ── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Options Page ── */
body.options-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg-deep);
  overflow: auto;
}

.options-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow-lg);
}
.options-card-header {
  text-align: center;
  margin-bottom: 24px;
}
.options-card-header .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--indigo));
  color: var(--text-inverse);
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-display);
  margin-bottom: 10px;
}
.options-card-header h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  font-variation-settings: 'SOFT' 80, 'WONK' 1;
  color: var(--text);
  margin-bottom: 4px;
}
.options-card-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.form-group input,
.form-group select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-glow);
}
.form-group select option {
  background: var(--bg-surface);
  color: var(--text);
}

.form-hint {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 3px;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 18px 0;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.form-actions .btn { flex: 1; }

#status-message {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  text-align: center;
  transition: all 0.2s;
  min-height: 34px;
}
.status-ok {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid var(--green);
  color: var(--green);
}
.status-err {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--red);
  color: var(--red);
}
.status-info {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
}

/* ── Dark/light class for options page ── */
[data-theme="dark"].options-page,
[data-theme="dark"] .options-page,
[data-theme="dark"] body {
  background: #070914;
}
[data-theme="light"].options-page,
[data-theme="light"] .options-page,
[data-theme="light"] body {
  background: #f4f1ea;
}
[data-theme="sepia"].options-page,
[data-theme="sepia"] .options-page,
[data-theme="sepia"] body {
  background: #efe3c9;
}
[data-theme="forest"].options-page,
[data-theme="forest"] .options-page,
[data-theme="forest"] body {
  background: #0f1a14;
}
[data-theme="ocean"].options-page,
[data-theme="ocean"] .options-page,
[data-theme="ocean"] body {
  background: #0a1820;
}

/* ── Theme popover ── */
.theme-popover {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px;
  display: none;
  min-width: 200px;
  box-shadow: var(--shadow-lg);
  gap: 2px;
}
.theme-popover.open {
  display: flex;
  flex-direction: column;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.theme-option:hover {
  background: var(--bg-hover);
}
.theme-option.selected {
  background: var(--amber-glow);
  color: var(--amber);
}
.theme-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
}
.theme-swatch.system {
  background: linear-gradient(135deg, #0a0c1a 50%, #f4f1ea 50%);
}
.theme-swatch.dark {
  background: linear-gradient(135deg, #0f1128, #181b3e);
}
.theme-swatch.light {
  background: linear-gradient(135deg, #fcf9f2, #e8e4dc);
}
.theme-swatch.sepia {
  background: linear-gradient(135deg, #efe3c9, #d4c5a6);
}
.theme-swatch.forest {
  background: linear-gradient(135deg, #142118, #1e3628);
}
.theme-swatch.ocean {
  background: linear-gradient(135deg, #0f1f2a, #1a3a4a);
}

/* ── Responsive tweaks ── */
@media (max-width: 300px) {
  .header { padding: 0 8px; }
  .toolbar { padding: 4px 8px; }
  .toolbar-select { max-width: 80px; }
  .msg { max-width: 100%; }
}
/* ── Persona Routing Badge ── */
.routing-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
}
.routing-badge:hover {
  border-color: var(--amber);
  color: var(--text);
}
.routing-badge.lite {
  background: color-mix(in srgb, var(--indigo) 15%, transparent);
  border-color: var(--indigo);
  color: var(--indigo);
}
.routing-badge.full {
  background: color-mix(in srgb, var(--amber) 15%, transparent);
  border-color: var(--amber);
  color: var(--amber);
}
.routing-badge.auto {
  background: color-mix(in srgb, var(--text-faint) 10%, transparent);
  border-color: var(--border);
  color: var(--text-muted);
}
