/* ============================================================
   OllieChat — a friendly, chunky, hand-made feel.
   Soft neo-brutalism: flat colours, 2px ink outlines, hard
   offset shadows, rounded corners, a dot-grid page. Nothing
   glossy, nothing gradient-y.
   Type: Bricolage Grotesque + JetBrains Mono.
   ============================================================ */

:root {
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-ui: "Bricolage Grotesque", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;

  --side-w: 274px;
  --read-w: 860px;
  --canvas-w: 480px;

  --ease: cubic-bezier(0.3, 0.7, 0.4, 1);
}

/* ---- Day (light) ---- */
[data-theme="day"] {
  --bg: #e9e8df;
  --dot: rgba(30, 28, 24, 0.07);
  --panel: #ffffff;
  --panel-2: #ffffff;
  --panel-inset: #f3f1e9;
  --ink: #1f1d18;
  --ink-soft: #2c2a24;
  --muted: #6c675c;
  --faint: #9b9587;
  --border: #1f1d18;
  --line-soft: #e2ded2;
  --primary: #e44c8f;
  --primary-ink: #ffffff;
  --primary-wash: #e44c8f1a;
  --secondary: #f5c531;
  --purple: #6e3fa3;
  --good: #6e3fa3;
  --danger: #e8412a;
  --shadow: #1f1d18;
  --code-bg: #f7f1f3;
  --code-border: #1f1d18;
  color-scheme: light;
}

/* ---- Night (dark) ---- */
[data-theme="night"] {
  --bg: #17121a;
  --dot: rgba(255, 240, 250, 0.05);
  --panel: #241a26;
  --panel-2: #2a1f2c;
  --panel-inset: #1d1620;
  --ink: #f2e9ee;
  --ink-soft: #e2d6dd;
  --muted: #a495a0;
  --faint: #6f6270;
  --border: #453747;
  --line-soft: #2e2432;
  --primary: #f2609f;
  --primary-ink: #1a0d14;
  --primary-wash: #f2609f22;
  --secondary: #f5c531;
  --purple: #a274d6;
  --good: #a274d6;
  --danger: #f0603f;
  --shadow: #000000;
  --code-bg: #1d1620;
  --code-border: #453747;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.4px, transparent 1.5px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

::selection { background: var(--primary); color: var(--primary-ink); }
button { font-family: inherit; cursor: pointer; color: inherit; }
textarea, input { font-family: inherit; }

/* icon helper: SVGs inherit colour + size */
.ico { display: inline-flex; align-items: center; justify-content: center; }
.ico svg { width: 1em; height: 1em; display: block; }

/* the signature press-button feel */
.pressable {
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0 var(--shadow);
  transition: transform 0.09s var(--ease), box-shadow 0.09s var(--ease), background 0.14s;
}
.pressable:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow); }
.pressable:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }

/* Theme dropdown (Ollie) */
.side-theme { display: flex; align-items: center; gap: 8px; padding: 4px 2px 10px; }
.side-theme .ico { color: var(--muted); font-size: 16px; }
.side-theme-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); flex: 1; }
.theme-select {
  font-family: var(--font-ui); font-size: 13px; font-weight: 700;
  color: var(--ink); background: var(--panel);
  border: 2px solid var(--border); border-radius: var(--r-sm);
  box-shadow: 2px 2px 0 var(--shadow);
  padding: 5px 8px; cursor: pointer; outline: none;
  transition: transform 0.09s var(--ease), box-shadow 0.09s var(--ease);
}
.theme-select:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }

/* Generated image / video (from the generate_image / generate_video tools) */
.gen-media { margin: 10px 0; }
.gen-media-img, .gen-media-vid { max-width: min(420px, 100%); border: 2px solid var(--border); border-radius: var(--r-md); box-shadow: 3px 3px 0 var(--shadow); display: block; }
.gen-media-img { cursor: zoom-in; }
.gen-media-note { color: var(--muted); font-size: 13px; padding: 6px 0; font-style: italic; }
.gen-media-loading { position: relative; width: min(420px, 100%); height: 260px; border-radius: var(--r-md); border: 2px solid var(--border); box-shadow: 3px 3px 0 var(--shadow); overflow: hidden; background: var(--panel-inset); }
.gen-media-loading.video { height: 236px; }
.gen-media-shimmer { position: absolute; inset: 0; background: linear-gradient(105deg, transparent 30%, color-mix(in srgb, var(--primary) 18%, transparent) 48%, transparent 66%); background-size: 220% 100%; animation: gen-shimmer 1.5s linear infinite; }
@keyframes gen-shimmer { from { background-position: 220% 0; } to { background-position: -220% 0; } }
.gen-media-label { position: absolute; left: 14px; bottom: 18px; display: flex; align-items: baseline; gap: 9px; font-size: 13px; color: var(--muted); }
.gen-media-pct { font-family: var(--font-mono); font-size: 23px; font-weight: 800; color: var(--ink); }
.gen-media-track { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: color-mix(in srgb, var(--ink) 12%, transparent); }
.gen-media-bar { height: 100%; width: 0; background: var(--primary); transition: width 0.32s ease; }
.gen-file { display: flex; align-items: center; gap: 11px; margin: 10px 0; padding: 11px 13px; max-width: min(420px, 100%); border: 2px solid var(--border); border-radius: var(--r-md); box-shadow: 3px 3px 0 var(--shadow); background: var(--panel-inset); }
.gen-file-ico { font-size: 20px; color: var(--muted); flex: 0 0 auto; }
.gen-file-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.gen-file-name { font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen-file-size { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }
.gen-file-dl { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--primary-ink); background: var(--primary); padding: 7px 13px; border-radius: var(--r-sm); text-decoration: none; }
.gen-file-dl:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--shadow); }
.run-term { margin: 10px 0; max-width: 100%; border: 2px solid var(--border); border-radius: var(--r-md); box-shadow: 3px 3px 0 var(--shadow); overflow: hidden; background: var(--code-bg); }
.run-term-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel-inset); border-bottom: 2px solid var(--border); font-family: var(--font-mono); font-size: 12px; }
.run-term-glyph { color: var(--good); font-weight: 800; flex: 0 0 auto; }
.run-term-cmd { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-term-body { margin: 0; padding: 12px; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; color: var(--ink-soft); white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; }
.run-term.run-term-err .run-term-glyph { color: var(--danger); }
/* File card extras + preview */
.gen-file-badge { flex: 0 0 auto; font-family: var(--font-mono); font-size: 9.5px; font-weight: 800; letter-spacing: 0.04em; color: var(--primary-ink); background: var(--primary); padding: 3px 6px; border-radius: 5px; }
.gen-file-btn { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--ink); background: var(--panel); border: 2px solid var(--border); box-shadow: 2px 2px 0 var(--shadow); padding: 6px 11px; border-radius: var(--r-sm); cursor: pointer; }
.gen-file-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }
.preview-modal { width: min(920px, calc(100vw - 36px)); height: min(84vh, 900px); max-height: min(84vh, 900px); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.preview-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin: 0; border-bottom: 2px solid var(--border); }
.preview-title { font-size: 15px; font-family: var(--font-mono); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.preview-dl { text-decoration: none; font-size: 13px; padding: 7px 13px; white-space: nowrap; }
.preview-body { flex: 1; min-height: 0; overflow: auto; }
.preview-code-holder pre { margin: 0; border: none; border-radius: 0; box-shadow: none; height: 100%; }
.preview-md { padding: 20px 22px; }
.preview-pdf { width: 100%; height: 100%; border: none; display: block; }
/* Roleplay */
.btn-roleplay { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 8px; padding: 9px 12px; font-size: 13.5px; font-weight: 700; color: var(--ink); background: var(--panel-inset); border: 2px solid var(--border); border-radius: var(--r-md); cursor: pointer; }
.btn-roleplay:hover { border-color: var(--primary); }
.btn-roleplay .ico { color: var(--primary); font-size: 16px; }
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.rp-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 28px 0; font-size: 14px; }
.rp-card { position: relative; display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; background: var(--panel-inset); border: 2px solid var(--border); border-radius: var(--r-md); cursor: pointer; }
.rp-card:hover { border-color: var(--primary); }
.rp-card-img { width: 100%; height: 118px; object-fit: cover; display: block; background: var(--panel-2); }
.rp-card-noimg { display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 34px; }
.rp-card-body { padding: 10px 12px; min-width: 0; }
.rp-card-name { font-weight: 700; color: var(--ink); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-card-about { font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rp-card-edit { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); background: color-mix(in srgb, var(--panel) 82%, transparent); color: var(--muted); cursor: pointer; }
.rp-card-edit:hover { color: var(--ink); }
.rp-form .field-row { display: block; margin-bottom: 13px; }
.rp-form .field-input, .rp-form .modal-textarea, .rp-form select { width: 100%; }
.rp-form-top { display: flex; gap: 14px; align-items: flex-start; }
.rp-form-fields { flex: 1; min-width: 0; }
.rp-image-drop { flex: 0 0 auto; width: 116px; height: 116px; border: 2px dashed var(--border); border-radius: var(--r-md); overflow: hidden; cursor: pointer; display: flex; align-items: center; justify-content: center; background: var(--panel-inset); }
.rp-image-drop img { width: 100%; height: 100%; object-fit: cover; }
.rp-image-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--faint); font-size: 12px; }
.rp-image-placeholder .ico { font-size: 22px; }
.attach-thumb { width: 34px; height: 34px; object-fit: cover; border: 2px solid var(--border); border-radius: var(--r-sm); flex: 0 0 auto; }
.msg-actions { display: flex; gap: 6px; margin: 6px 0 2px; }
.msg-action-btn { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: var(--r-sm); display: inline-flex; }
.msg-action-btn:hover { color: var(--ink); background: var(--panel-inset); }
.msg-action-btn.speaking { color: var(--primary); }
.msg-action-btn .ico { font-size: 16px; }
.set-group { display: grid; gap: 14px; margin: 0 0 6px; }
.set-field { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.set-field > label { font-size: 14px; font-weight: 700; color: var(--ink); }
.set-field select { min-width: 200px; max-width: 240px; }
.set-field input.field-input { min-width: 200px; max-width: 240px; }
.set-tuning { margin-top: 4px; padding-top: 12px; border-top: 2px solid var(--border); }
.set-tuning-title { font-size: 13px; font-weight: 800; color: var(--ink); margin-bottom: 10px; }
.set-slider { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.set-slider label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 700; color: var(--muted); }
.set-slider output { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 800; }
.set-slider input[type="range"] { width: 100%; accent-color: var(--primary); margin: 0; }

/* ============================================================
   Layout
   ============================================================ */
#app { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100dvh; }

/* ---- Sidebar ---- */
#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column;
  padding: 18px 14px 14px; gap: 14px; min-height: 0;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px; }
.brand-logo { width: 40px; height: 40px; flex-shrink: 0; cursor: default; }
.brand-logo, .brand-logo * { cursor: default; }   /* never show the click/pointer cursor */
.brand-logo svg { width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; }
.brand-name {
  font-family: var(--font-display); font-weight: 800; font-size: 22px;
  letter-spacing: -0.02em; line-height: 1; color: var(--ink);
}
.brand-sub {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.02em;
  color: var(--muted); margin-top: 4px;
}

.btn-new {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 11px 14px;
  background: var(--primary); color: var(--primary-ink);
  border-radius: 12px; font-size: 14px; font-weight: 700;
  border: none; box-shadow: 0 2px 12px color-mix(in srgb, var(--primary) 32%, transparent);
  transition: filter 0.12s, transform 0.1s var(--ease), box-shadow 0.12s;
}
.btn-new:hover { filter: brightness(1.05); box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 38%, transparent); }
.btn-new:active { transform: scale(0.98); }
.btn-new .ico { font-size: 16px; }

/* conversation list */
.chat-list {
  flex: 1; overflow-y: auto; margin: 0 -4px; padding: 2px 4px;
  display: flex; flex-direction: column; gap: 5px;
}
.chat-item-row {
  display: flex; align-items: stretch; gap: 2px; width: 100%;
  border-radius: var(--r-sm);
}
.chat-item-row:hover { background: var(--panel-inset); }
.chat-item-row.active {
  background: var(--panel-inset);
  box-shadow: inset 0 0 0 2px var(--line-soft);
}
.chat-item {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; text-align: left;
  padding: 9px 11px; border: 2px solid transparent; background: transparent;
  color: var(--ink-soft); border-radius: var(--r-sm); font-size: 13.5px; font-weight: 500;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  cursor: pointer;
}
.chat-item:hover { background: transparent; }
.chat-item.active {
  background: transparent; border-color: transparent;
  box-shadow: none; color: var(--ink); font-weight: 600;
}
.chat-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-item-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-sub { display: flex; align-items: center; gap: 5px; min-width: 0; }
.chat-item-model { font-size: 11px; color: var(--faint); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.generating .chat-item-model { color: var(--primary); }
.chat-item-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex: 0 0 auto; animation: pulse-dot 1.1s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.3; transform: scale(0.65); } }
.chat-item-del {
  flex-shrink: 0;
  opacity: 0; border: none; background: transparent; color: var(--muted);
  width: 36px; min-width: 36px; padding: 0; border-radius: 8px;
  font-size: 15px; display: grid; place-items: center;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.chat-item-row:hover .chat-item-del,
.chat-item-row:focus-within .chat-item-del { opacity: 0.65; }
.chat-item-del:hover,
.chat-item-del:focus-visible { opacity: 1; color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.chat-item-del:active { transform: scale(0.92); }
.chat-empty {
  padding: 14px 11px; color: var(--faint); font-size: 12.5px;
  font-family: var(--font-mono); line-height: 1.7;
}

/* footer */
.side-foot {
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.side-section { display: flex; flex-direction: column; gap: 1px; }
.side-section-label {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--faint); padding: 2px 11px 6px;
}
.side-more-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; border: none; background: transparent; padding: 0; cursor: pointer;
  color: inherit; font: inherit;
}
.side-more-toggle .side-section-label { padding-bottom: 4px; }
.side-more-caret { font-size: 14px; color: var(--faint); transition: transform 0.15s var(--ease); margin-right: 8px; }
.side-more-toggle[aria-expanded="true"] .side-more-caret { transform: rotate(180deg); }
.side-more { display: flex; flex-direction: column; gap: 1px; padding-top: 2px; }
.side-more[hidden] { display: none !important; }
.side-link {
  display: flex; align-items: center; gap: 10px; border: none; background: transparent;
  color: var(--muted); padding: 8px 11px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; text-align: left; width: 100%;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.side-link:hover { background: var(--panel-inset); color: var(--ink); }
.side-link .ico { font-size: 15px; color: var(--faint); flex-shrink: 0; }
.side-link:hover .ico { color: var(--primary); }
.side-link-quiet { font-size: 12.5px; padding: 7px 11px; color: var(--faint); }
.side-link-quiet:hover { color: var(--ink-soft); }

/* ============================================================
   Main column
   ============================================================ */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 88%, var(--panel));
  backdrop-filter: blur(8px);
  z-index: 5;
}
.menu-btn { display: none; font-size: 20px; }

.model-picker { position: relative; }
.model-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); color: var(--ink);
  padding: 7px 12px; border-radius: 999px;
  font-size: 14px; font-weight: 700;
  border: 1.5px solid var(--border); box-shadow: none;
  transition: background 0.12s, border-color 0.12s, transform 0.09s var(--ease);
}
.model-btn:hover { background: var(--panel-2); border-color: var(--muted); }
.model-btn:active { transform: scale(0.98); }
.model-btn-label { font-family: var(--font-display); letter-spacing: -0.01em; }
.caret-ico { font-size: 14px; color: var(--muted); }

.model-menu {
  position: absolute; top: calc(100% + 9px); left: 0; width: 380px;
  background: var(--panel); border: 2px solid var(--border);
  border-radius: var(--r-lg); box-shadow: 6px 6px 0 var(--shadow);
  padding: 7px; z-index: 40; max-height: 72vh; overflow-y: auto;
  animation: pop 0.13s var(--ease);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
/* Portaled to <body> so topbar backdrop-filter can't trap position:fixed */
.model-menu.model-menu-portal {
  position: fixed;
  z-index: 200;
}
.model-menu.model-menu-sheet {
  left: 10px !important;
  right: 10px !important;
  top: max(10px, env(safe-area-inset-top, 0px)) !important;
  bottom: max(10px, env(safe-area-inset-bottom, 0px)) !important;
  width: auto !important;
  max-height: none !important;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
/* Explicit hide — fixed/sheet layout must not keep the menu painted when closed */
.model-menu[hidden] { display: none !important; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Model catalogue search — sticky under the multi-agent toggle */
.model-search {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  margin: 2px 0 6px; padding: 8px 10px;
  background: var(--panel-inset);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 6px 10px -6px color-mix(in srgb, var(--shadow) 40%, transparent);
}
.model-search-ico { color: var(--muted); font-size: 15px; flex-shrink: 0; }
.model-search-input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.01em;
}
.model-search-input::placeholder { color: var(--faint); font-weight: 500; }
.model-search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.model-search-clear {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border: none; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer; flex-shrink: 0;
}
.model-search-clear:hover { background: var(--panel); color: var(--ink); }
.model-search-clear .ico { font-size: 14px; }
.model-search-empty {
  margin: 8px 6px 10px; padding: 14px 12px; text-align: center;
  font-size: 13px; font-weight: 600; color: var(--muted);
  border: 1.5px dashed var(--line-soft); border-radius: var(--r-md);
}

/* ---- provider groups (outer) + brand groups (inner) ---- */
.model-provider { border-radius: var(--r-md); margin-bottom: 4px; border: 2px solid transparent; }
.model-provider.open { border-color: var(--line-soft); background: color-mix(in srgb, var(--panel-inset) 55%, transparent); }
.model-provider-head {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 2px solid transparent; padding: 10px 10px; border-radius: var(--r-md);
  transition: background 0.11s;
}
.model-provider-head:hover { background: var(--panel-inset); }
.model-provider-mark {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 13px;
  background: var(--primary); color: #fff; border: 2px solid var(--border);
  box-shadow: 1px 1px 0 var(--shadow);
}
.model-provider-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.model-provider-name { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--ink); }
.model-provider-blurb { font-size: 11px; color: var(--muted); line-height: 1.3; }
.model-provider-body { display: none; padding: 2px 6px 8px 8px; }
.model-provider.open .model-provider-body { display: block; }
.model-provider.open > .model-provider-head .model-group-caret { transform: rotate(90deg); }
.model-provider.locked { opacity: 0.55; }
.model-provider.locked .model-provider-head {
  cursor: not-allowed; pointer-events: auto;
}
.model-provider.locked .model-provider-head:hover { background: transparent; }
.model-provider.locked .model-provider-name { color: var(--muted); }
.model-provider.locked .model-provider-mark { filter: grayscale(0.85); opacity: 0.75; }
.model-group-lock { font-size: 13px; flex-shrink: 0; opacity: 0.85; }

.model-provider .model-group { margin-left: 4px; }
.model-provider .model-group-body { margin-left: 14px; }

.badge.provider {
  border-color: var(--primary); color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

/* ---- brand groups (collapsible) ---- */
.model-group { border-radius: var(--r-md); margin-bottom: 2px; }
.model-group-head {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: transparent; border: 2px solid transparent; padding: 9px 10px; border-radius: var(--r-md);
  transition: background 0.11s;
}
.model-group-head:hover { background: var(--panel-inset); }
.model-group-head .brand-ico { width: 24px; height: 24px; }
.model-group-name { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--ink); }
.model-group-count { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }
.model-group-caret { color: var(--muted); font-size: 16px; transition: transform 0.15s var(--ease); flex-shrink: 0; }
.model-group.open .model-group-caret { transform: rotate(90deg); }
.model-group-body { display: none; padding: 2px 0 6px 8px; margin-left: 11px; border-left: 2px solid var(--line-soft); }
.model-group.open .model-group-body { display: block; }
.model-group.all-off .model-group-name { color: var(--muted); }
.model-group.all-off .brand-ico { filter: grayscale(0.6); opacity: 0.7; }

.model-option {
  display: block; width: 100%; text-align: left; border: 2px solid transparent;
  background: transparent; padding: 10px 11px; border-radius: var(--r-md);
  transition: background 0.11s, border-color 0.11s;
}
.model-option:hover { background: var(--panel-inset); }
.model-option.selected { background: var(--primary-wash); border-color: var(--border); }
.model-option-top { display: flex; align-items: center; gap: 9px; }
.model-option-name { font-family: var(--font-display); font-size: 15.5px; font-weight: 700; color: var(--ink); }

/* brand logo tile — colored mark on a white chip so it reads in any theme */
.brand-ico {
  width: 26px; height: 26px; flex-shrink: 0; object-fit: contain;
  background: #fff; border: 2px solid var(--border); border-radius: 7px;
  padding: 3px; box-shadow: 1px 1px 0 var(--shadow);
}
.brand-ico.sm { width: 22px; height: 22px; border-radius: 6px; padding: 2.5px; box-shadow: none; }
/* Brand tiles: white chip + colored SVG marks (same treatment for every brand) */
.brand-ico[data-brand="kimi"] { background: #0e1626; }
.brand-ico[data-brand="nvidia"],
.brand-ico[data-brand="meta"],
.brand-ico[data-brand="microsoft"],
.brand-ico[data-brand="mistral"],
.brand-ico[data-brand="bfl"],
.brand-ico[data-brand="google"],
.brand-ico[data-brand="bytedance"],
.brand-ico[data-brand="stability"],
.brand-ico[data-brand="openai"],
.brand-ico[data-brand="claude"],
.brand-ico[data-brand="qwen"],
.brand-ico[data-brand="deepseek"],
.brand-ico[data-brand="minimax"],
.brand-ico[data-brand="zhipu"],
.brand-ico[data-brand="gemini"],
.brand-ico[data-brand="openweight"] {
  background: #fff;
  filter: none;
}
.model-badges { display: flex; gap: 5px; margin-left: auto; }
.badge {
  font-family: var(--font-mono); font-size: 8.5px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 3px 6px; border-radius: 20px;
  border: 1.5px solid var(--line-soft); color: var(--muted);
}
.badge.on { border-color: var(--good); color: var(--good); }
.badge.off { border-color: var(--line-soft); color: var(--faint); }
.badge.disabled {
  border-color: var(--danger); color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
/* A "collab" virtual model (e.g. OllieAI) — two models per reply. */
.badge.collab {
  border-color: var(--good, #4ade80); color: var(--good, #4ade80);
  background: color-mix(in srgb, var(--good, #4ade80) 12%, transparent);
}
/* A disabled model can't be picked — dim it and kill the hover affordance. */
.model-option.disabled { opacity: 0.5; cursor: not-allowed; }
.model-option.disabled:hover { background: transparent; }
.model-option.disabled .brand-ico { filter: grayscale(1); }
.model-option-desc { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }

.model-menu-note {
  display: flex; gap: 8px; margin: 6px 4px 3px; padding: 10px 11px;
  border-radius: var(--r-md); background: var(--primary-wash);
  border: 1.5px dashed var(--primary);
  font-size: 11px; color: var(--ink-soft); line-height: 1.5;
}
.model-menu-note .ico { color: var(--primary); font-size: 15px; flex-shrink: 0; margin-top: 1px; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.turn-meta { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.topbar-actions {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  border: 1px solid var(--line-soft);
}
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; background: transparent; color: var(--muted);
  padding: 7px 10px; border-radius: 999px;
  font: inherit; font-size: 12.5px; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tb-btn .ico { font-size: 15px; display: inline-flex; }
.tb-btn .ico svg { width: 15px; height: 15px; }
.tb-btn:hover { background: var(--panel-inset); color: var(--ink); }
.tb-discord:hover { color: #7289da; }
.tb-ghost { color: var(--faint); }
.icon-btn {
  border: none; background: transparent; color: var(--muted);
  font-size: 12px; font-family: var(--font-mono); font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase; padding: 7px 10px; border-radius: var(--r-sm);
  transition: color 0.12s, background 0.12s;
}
.icon-btn:hover { color: var(--ink); background: var(--panel-inset); }

/* ============================================================
   Transcript
   ============================================================ */
/* No smooth scroll-behavior here: during streaming we pin scrollTop to the
   bottom many times a second, and a smooth animation on each one causes jank.
   The jump-to-bottom button opts into a smooth scroll explicitly instead. */
.transcript { flex: 1; overflow-y: auto; padding: 36px 24px 26px; overflow-anchor: none; }

/* Floating "jump to latest" button — sits just above the composer, shows only
   when the user has scrolled up away from the newest message. */
.scroll-bottom {
  position: absolute; left: 50%; transform: translateX(-50%) translateY(6px);
  bottom: 104px; z-index: 6;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface, #17171f); color: var(--text, #e4e4ec);
  border: 1px solid var(--line-soft, #2a2a3a);
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease;
}
.scroll-bottom svg { width: 18px; height: 18px; }
.scroll-bottom.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.scroll-bottom:hover { border-color: var(--primary, #f2609f); color: var(--primary, #f2609f); }

/* empty state */
.hero { max-width: var(--read-w); margin: 6vh auto 0; animation: rise 0.45s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.hero-wave {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 20px;
  padding: 8px 14px 8px 10px; background: var(--panel); border: 2px solid var(--border);
  border-radius: 40px; box-shadow: 3px 3px 0 var(--shadow);
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; color: var(--ink-soft);
}
.hero-wave .hero-logo { width: 24px; height: 24px; }
.hero-wave .hero-logo svg { width: 100%; height: 100%; }
.hero h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(32px, 5vw, 52px); line-height: 1.02; letter-spacing: -0.03em;
  margin: 0 0 16px; color: var(--ink); max-width: 16ch;
}
.hero h1 em { font-style: normal; color: var(--primary); }
.hero p { font-size: 16px; color: var(--muted); max-width: 48ch; line-height: 1.6; margin: 0 0 26px; }
.hero-prompts { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-prompt {
  border: 2px solid var(--border); background: var(--panel); color: var(--ink-soft);
  padding: 9px 14px; border-radius: 40px; font-size: 13.5px; font-weight: 500;
  box-shadow: 2px 2px 0 var(--shadow);
  transition: transform 0.09s var(--ease), box-shadow 0.09s var(--ease), color 0.12s;
}
.hero-prompt:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); color: var(--primary); }
.hero-prompt:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }

/* messages */
.msg { max-width: var(--read-w); margin: 0 auto 26px; animation: rise 0.28s var(--ease); }
.msg-role { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
.avatar {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--border);
  display: grid; place-items: center; font-size: 15px; flex-shrink: 0;
  box-shadow: 2px 2px 0 var(--shadow);
}
.avatar.assistant { background: var(--primary); color: #fff; }
.avatar.user { background: var(--secondary); color: var(--border); }
.msg-role .who { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--ink); }
.msg-role .role-model { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }

.msg-body { font-size: 15.5px; line-height: 1.72; color: var(--ink-soft); word-wrap: break-word; }

/* user words pop in a chunky bubble */
.msg.user .msg-body {
  display: inline-block; background: var(--panel); color: var(--ink);
  border: 2px solid var(--border); border-radius: 4px var(--r-md) var(--r-md) var(--r-md);
  box-shadow: 3px 3px 0 var(--shadow); padding: 11px 15px; max-width: 100%;
}
.msg.user .msg-body p:first-child { margin-top: 0; } .msg.user .msg-body p:last-child { margin-bottom: 0; }

.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.msg-images img {
  max-width: 180px; max-height: 180px; border-radius: var(--r-sm);
  border: 2px solid var(--border); box-shadow: 2px 2px 0 var(--shadow); object-fit: cover;
}

/* markdown */
.md p { margin: 0 0 14px; } .md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 {
  font-family: var(--font-display); font-weight: 700; line-height: 1.25;
  margin: 24px 0 12px; letter-spacing: -0.015em; color: var(--ink);
}
.md h1 { font-size: 25px; } .md h2 { font-size: 21px; } .md h3 { font-size: 18px; } .md h4 { font-size: 16px; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 22px; }
.md li { margin: 5px 0; } .md li::marker { color: var(--primary); font-weight: 700; }
.md a { color: var(--primary); font-weight: 600; text-underline-offset: 2px; }
.md strong { color: var(--ink); font-weight: 700; }
.md blockquote { margin: 0 0 14px; padding: 4px 0 4px 15px; border-left: 3px solid var(--primary); color: var(--muted); }
.md hr { border: none; border-top: 2px solid var(--line-soft); margin: 20px 0; }
.md code {
  font-family: var(--font-mono); font-size: 0.85em; background: var(--code-bg);
  border: 1.5px solid var(--code-border); padding: 1px 5px; border-radius: 5px; color: var(--ink);
}
.md pre {
  background: var(--code-bg); border: 2px solid var(--code-border); border-radius: var(--r-md);
  padding: 14px 16px; overflow-x: auto; margin: 0 0 16px; position: relative;
  box-shadow: 3px 3px 0 var(--shadow);
}
.md pre code { background: none; border: none; padding: 0; color: var(--ink); font-size: 13px; line-height: 1.6; }
.md table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 14px; }
.md th, .md td { border: 2px solid var(--border); padding: 7px 11px; text-align: left; }
.md th { background: var(--panel-inset); font-weight: 700; color: var(--ink); }

.code-copy {
  position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px; border: 2px solid var(--border); background: var(--panel);
  color: var(--muted); opacity: 0; transition: opacity 0.13s, color 0.13s;
}
.md pre:hover .code-copy { opacity: 1; }
.code-copy:hover { color: var(--primary); }
.code-copy .ico { font-size: 12px; }

/* thinking foldout */
.thinking {
  margin: 0 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-inset) 80%, transparent);
  overflow: hidden;
  box-shadow: none;
  transition: border-color 0.15s, background 0.15s;
}
.thinking.open, .thinking.streaming {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--line-soft));
  background: color-mix(in srgb, var(--primary) 6%, var(--panel-inset));
}
.thinking-head {
  display: flex; align-items: center; gap: 8px; width: 100%; border: none; background: transparent;
  text-align: left; padding: 10px 12px; color: var(--ink-soft);
  font-family: var(--font-display); font-size: 12.5px; font-weight: 700; letter-spacing: 0.01em;
  cursor: pointer;
}
.thinking-head:hover { color: var(--primary); }
.thinking-head .think-spark { color: var(--primary); font-size: 15px; flex-shrink: 0; }
.thinking-head .label { color: inherit; }
.thinking-head .caret { margin-left: auto; font-size: 14px; color: var(--muted); transition: transform 0.18s var(--ease); flex-shrink: 0; }
.thinking.open .thinking-head .caret { transform: rotate(90deg); }
/* Soft pulse while streaming thoughts */
.think-pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary); opacity: 0; flex-shrink: 0;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 40%, transparent);
}
.thinking.streaming .think-pulse {
  opacity: 1;
  animation: thinkPulse 1.4s ease-out infinite;
}
@keyframes thinkPulse {
  0% { transform: scale(0.85); box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px transparent; }
  100% { transform: scale(0.85); box-shadow: 0 0 0 0 transparent; }
}
.thinking-body {
  display: none; padding: 0 14px 12px 36px; font-family: var(--font-mono);
  font-size: 12.5px; line-height: 1.7; color: var(--muted); white-space: pre-wrap;
  word-wrap: break-word; max-height: 340px; overflow-y: auto;
}
.thinking.open .thinking-body { display: block; animation: thinkBodyIn 0.18s var(--ease); }
@keyframes thinkBodyIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* tool-call chip */
.tool-run {
  margin: 0 0 14px; border: 2px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; background: var(--panel); box-shadow: 3px 3px 0 var(--shadow);
}
.tool-run-head {
  display: flex; align-items: center; gap: 9px; width: 100%; border: none; background: transparent;
  text-align: left; padding: 10px 13px; color: var(--ink-soft); font-size: 13px;
}
.tool-run-head:hover { background: var(--panel-inset); }
.tool-run-glyph { color: var(--primary); font-size: 15px; }
.tool-run-name { font-family: var(--font-mono); font-weight: 700; }
.tool-run-arg { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-run-status {
  margin-left: auto; font-family: var(--font-mono); font-size: 9px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--good);
  border: 1.5px solid var(--good); padding: 2px 6px; border-radius: 20px;
}
.tool-run-status.running { color: var(--muted); border-color: var(--line-soft); }
.tool-run-body { display: none; padding: 6px 13px 13px; border-top: 2px solid var(--line-soft); }
.tool-run.open .tool-run-body { display: block; }
.tool-result-item { padding: 8px 0; border-bottom: 1.5px solid var(--line-soft); }
.tool-result-item:last-child { border-bottom: none; }
.tool-result-item a { color: var(--primary); font-size: 13.5px; font-weight: 700; text-decoration: none; }
.tool-result-item a:hover { text-decoration: underline; }
.tool-result-item .url { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); margin: 2px 0; word-break: break-all; }
.tool-result-item .snip { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.tool-raw { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: pre-wrap; word-break: break-word; margin: 0; }

/* ── ask_question card ─────────────────────────────────────────── */
.ask-card {
  margin: 0 0 14px; border: 2px solid var(--primary); border-radius: var(--r-md);
  background: var(--panel); box-shadow: 3px 3px 0 var(--shadow); padding: 13px 14px;
}
.ask-head { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 11px; }
.ask-glyph { color: var(--primary); font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.ask-q { font-weight: 700; font-size: 14.5px; color: var(--ink); line-height: 1.45; }
.ask-options { display: flex; flex-direction: column; gap: 7px; }
.ask-opt {
  text-align: left; width: 100%; padding: 9px 12px; border: 2px solid var(--border);
  border-radius: var(--r-sm, 9px); background: var(--panel-inset); color: var(--ink-soft);
  font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background 0.1s, border-color 0.1s, transform 0.06s;
}
.ask-opt:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-wash); }
.ask-opt:active:not(:disabled) { transform: translateY(1px); }
.ask-opt.chosen { border-color: var(--primary); background: var(--primary-wash); color: var(--ink); }
.ask-opt.chosen::after { content: ' ✓'; color: var(--primary); font-weight: 800; }
.ask-custom { display: flex; gap: 7px; margin-top: 9px; }
.ask-input {
  flex: 1; padding: 9px 11px; border: 2px solid var(--border); border-radius: var(--r-sm, 9px);
  background: var(--panel-inset); color: var(--ink); font-size: 13.5px; font-family: inherit;
}
.ask-input:focus { outline: none; border-color: var(--primary); }
.ask-send {
  padding: 9px 15px; border: 2px solid var(--primary); border-radius: var(--r-sm, 9px);
  background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; cursor: pointer;
}
.ask-send:hover:not(:disabled) { filter: brightness(1.06); }
.ask-card.answered { border-color: var(--border); opacity: 0.96; }
.ask-card.answered .ask-opt:disabled { cursor: default; opacity: 0.65; }
.ask-card.answered .ask-opt.chosen { opacity: 1; }
.ask-card.answered .ask-custom { display: none; }
.ask-answer { margin-top: 9px; font-size: 13px; color: var(--ink-soft); }
.ask-answer-label { color: var(--muted); font-weight: 700; }

/* ── Benchmark modal ───────────────────────────────────────────── */
.bench-models { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; }
.bench-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px 6px 7px;
  border: 2px solid var(--border); border-radius: 20px; background: var(--panel);
  color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color 0.1s, background 0.1s, color 0.1s;
}
.bench-chip:hover { border-color: var(--primary); }
.bench-chip.on { border-color: var(--primary); background: var(--primary-wash); color: var(--ink); }
.bench-chip .brand-ico { opacity: 0.6; transition: opacity 0.1s; }
.bench-chip.on .brand-ico { opacity: 1; }
.bench-bar { display: flex; align-items: center; gap: 14px; margin: 0 0 14px; }
#bench-run.running { background: var(--danger); border-color: var(--danger); }
.bench-progress { display: flex; align-items: center; gap: 11px; flex: 1; }
.bench-progress-track { flex: 1; height: 8px; border-radius: 20px; background: var(--panel-inset); border: 1.5px solid var(--line-soft); overflow: hidden; }
.bench-progress-fill { height: 100%; width: 0; background: var(--primary); transition: width 0.25s ease; }
.bench-progress-text { font-size: 12px; color: var(--muted); font-family: var(--font-mono); white-space: nowrap; }

.bench-table-wrap { overflow-x: auto; }
.bench-cmp { width: 100%; border-collapse: collapse; }
.bench-cmp th, .bench-cmp td { padding: 12px 10px; text-align: center; vertical-align: middle; }
.bench-cmp thead th {
  border-bottom: 2px solid var(--border); font-family: var(--font-display);
  font-size: 13.5px; font-weight: 700; color: var(--ink); white-space: nowrap;
}
.bench-cmp thead th .brand-ico { display: block; margin: 0 auto 5px; }
.bench-corner { width: 27%; }
.bench-cat { text-align: left !important; }
.bench-cat-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--ink); }
.bench-cat-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.bench-cmp tbody tr { border-bottom: 1.5px solid var(--line-soft); }
.bench-cmp tbody tr:last-child { border-bottom: none; }
.bench-cell { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.bench-cell.running { color: var(--muted); font-weight: 400; }
.bench-cell.best { color: var(--ink); font-weight: 800; background: var(--primary-wash); border-radius: 8px; }
.bench-overall { border-top: 2px solid var(--border); }
.bench-overall .bench-cell { font-size: 17px; }
.bench-speed .bench-cell { font-size: 14px; color: var(--muted); }
.bench-speed .bench-cell.best { color: var(--ink); }
.bench-method { font-size: 12px; color: var(--muted); line-height: 1.55; margin-top: 16px; }
.bench-method strong { color: var(--ink-soft); }

/* streaming caret */
.caret-blink::after {
  content: "▋"; color: var(--primary); margin-left: 1px;
  animation: blink 1s steps(2, start) infinite; font-size: 0.8em;
}
@keyframes blink { to { visibility: hidden; } }

/* Legacy hook — wait-card is the modern placeholder */
.msg-status {
  display: flex; align-items: center; gap: 11px;
  padding: 3px 0 2px; color: var(--muted);
  font-family: var(--font-display); font-weight: 500; font-size: 15px; letter-spacing: -0.01em;
}
.status-text { transition: opacity 0.2s var(--ease); }

/* ── Wait / working card ─────────────────────────────────────── */
.wait-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 10px;
  align-items: center;
  max-width: 340px;
  margin: 2px 0 6px;
  padding: 12px 14px 11px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--line-soft));
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--primary) 8%, var(--panel)) 0%,
      var(--panel) 55%,
      color-mix(in srgb, var(--panel-inset) 80%, var(--panel)) 100%);
  overflow: hidden;
  animation: waitIn 0.28s var(--ease);
}
@keyframes waitIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.wait-orb {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  grid-row: 1;
}
.wait-orb-core {
  position: relative; z-index: 1;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 18%, var(--panel));
  color: var(--primary);
  font-size: 14px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent);
}
.wait-orb-core svg { width: 15px; height: 15px; }
.wait-orb-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--primary) 45%, transparent);
  animation: waitRing 1.8s ease-out infinite;
}
.wait-orb-ring-2 {
  animation-delay: 0.6s;
  border-color: color-mix(in srgb, var(--primary) 28%, transparent);
}
@keyframes waitRing {
  0% { transform: scale(0.72); opacity: 0.85; }
  100% { transform: scale(1.35); opacity: 0; }
}
.wait-copy {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  grid-column: 2; grid-row: 1;
}
.wait-phase {
  font-family: var(--font-display);
  font-size: 13.5px; font-weight: 750; letter-spacing: -0.015em;
  color: var(--ink);
}
.wait-line, .wait-card .status-text {
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  line-height: 1.35;
  transition: opacity 0.2s var(--ease);
  min-height: 1.2em;
}
.wait-bar {
  grid-column: 1 / -1;
  height: 3px; border-radius: 99px;
  background: color-mix(in srgb, var(--primary) 10%, var(--line-soft));
  overflow: hidden;
}
.wait-bar-fill {
  display: block; height: 100%; width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg,
    transparent,
    var(--primary),
    color-mix(in srgb, var(--primary) 60%, #fff),
    var(--primary),
    transparent);
  background-size: 200% 100%;
  animation: waitBar 1.6s ease-in-out infinite;
}
@keyframes waitBar {
  0% { transform: translateX(-80%); }
  100% { transform: translateX(280%); }
}

/* Keep old dots available if anything still uses them */
.status-dots { display: inline-flex; gap: 5px; }
.status-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--primary);
  animation: statusBounce 1.3s infinite ease-in-out both;
}
.status-dots span:nth-child(1) { animation-delay: -0.24s; }
.status-dots span:nth-child(2) { animation-delay: -0.12s; }
@keyframes statusBounce {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.35; }
  40% { transform: scale(1); opacity: 1; }
}

/* error */
.msg-error {
  border: 2px solid var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent);
  color: var(--danger); border-radius: var(--r-md); padding: 12px 15px; font-size: 13.5px;
  line-height: 1.5; box-shadow: 3px 3px 0 var(--shadow);
}
.msg-error strong { color: var(--danger); }

/* ============================================================
   Composer
   ============================================================ */
.composer { margin: 0 auto; width: min(100%, calc(var(--read-w) + 80px)); padding: 0 22px 22px; }
.composer-card {
  background: var(--panel); border: 1.5px solid var(--border); border-radius: 20px;
  box-shadow: 0 8px 28px color-mix(in srgb, var(--shadow) 18%, transparent);
  transition: border-color 0.14s, box-shadow 0.14s;
}
.composer:focus-within .composer-card {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: 0 10px 32px color-mix(in srgb, var(--primary) 12%, transparent);
}

.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 0; }
.attach-thumb { position: relative; width: 54px; height: 54px; border-radius: var(--r-sm); overflow: hidden; border: 2px solid var(--border); }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-thumb button {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid #fff; background: var(--border); color: #fff; font-size: 10px;
  display: grid; place-items: center; padding: 0;
}
.attach-thumb button .ico { font-size: 10px; }
.attach-file {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm);
  border: 2px solid var(--border); background: var(--panel-inset);
  max-width: 100%;
}
.attach-file-ico { color: var(--primary); font-size: 16px; flex-shrink: 0; }
.attach-file-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.attach-file-name {
  font-weight: 700; font-size: 12.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-file-size { font-family: var(--font-mono); font-size: 10px; color: var(--faint); }
.attach-file button {
  border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 4px;
}
.attach-file button:hover { color: var(--danger, #f43f5e); }

/* File chips inside a sent user message (not the raw dump) */
.msg-files {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px;
}
.msg-body.md:not(:has(> :not(.msg-files):not(.msg-images))) .msg-files,
.msg-body.md > .msg-files:first-child { margin-top: 0; }
.msg-file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: min(100%, 280px);
  padding: 8px 11px;
  border-radius: 12px;
  border: 1.5px solid color-mix(in srgb, var(--primary) 35%, var(--border));
  background: color-mix(in srgb, var(--primary) 10%, var(--panel));
  color: var(--ink);
}
.msg-file-ico { color: var(--primary); font-size: 16px; flex-shrink: 0; }
.msg-file-meta { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.msg-file-name {
  font-weight: 700; font-size: 12.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-file-size {
  font-family: var(--font-mono); font-size: 10px; color: var(--faint);
}

.composer-input {
  width: 100%; border: none; background: transparent; resize: none;
  padding: 15px 17px 8px; color: var(--ink); font-size: 15.5px; line-height: 1.55;
  outline: none; max-height: 210px; min-height: 26px;
}
.composer-input::placeholder { color: var(--faint); }

.composer-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 8px 8px;
  border-top: 1px solid var(--line-soft);
}
.composer-left {
  display: flex; align-items: center; gap: 2px;
  min-width: 0;
}
.composer-right {
  margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}

/* Icon buttons — quiet by default */
.c-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  width: 36px; height: 36px; padding: 0;
  border: none; border-radius: 10px;
  background: transparent; color: var(--muted);
  cursor: pointer; font: inherit;
  transition: background 0.12s, color 0.12s;
}
.c-btn:hover { background: var(--panel-inset); color: var(--ink); }
.c-btn:active { transform: scale(0.96); }
.c-btn .ico { font-size: 17px; display: inline-flex; }
.c-btn .ico svg { width: 18px; height: 18px; }
.c-btn.active, .c-btn.toggle.active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
}
.c-btn.has-active::after {
  content: "";
  position: absolute; top: 7px; right: 7px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 2px var(--panel);
}
.c-btn.recording, .c-btn.recording.active {
  background: color-mix(in srgb, var(--danger, #f43f5e) 16%, transparent) !important;
  color: var(--danger, #f43f5e) !important;
  animation: mic-pulse 1.1s ease-in-out infinite;
  width: auto; padding: 0 10px 0 8px; gap: 6px;
}
.c-btn.busy { opacity: 0.75; pointer-events: none; cursor: wait; }
.c-mic-timer {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: inherit;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger, #f43f5e) 25%, transparent); }
}

/* Think — only labeled control */
.c-think {
  width: auto;
  height: 36px;
  min-height: 36px;
  padding: 0 10px 0 10px;
  gap: 6px;
  border: 1px solid var(--line-soft);
  background: var(--panel-inset);
  color: var(--ink-soft);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Sparkles + caret: force optical centering of SVG icons */
.c-think > .ico {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  line-height: 0;
  margin: 0;
  padding: 0;
}
.c-think > .ico svg {
  display: block;
  width: 15px;
  height: 15px;
  margin: 0;
  /* sparkles glyph is slightly top-heavy in the viewBox */
  transform: translateY(0.5px);
}
.c-think .think-label {
  letter-spacing: -0.01em;
  max-width: 4.8em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
  display: inline-block;
}
.c-think .think-caret {
  width: 12px !important;
  height: 12px !important;
  opacity: 0.65;
  margin: 0 !important;
}
.c-think .think-caret svg {
  width: 12px !important;
  height: 12px !important;
  transform: none;
}
.c-think.active, .c-think.toggle.active {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  background: color-mix(in srgb, var(--primary) 12%, var(--panel));
  color: var(--primary);
}

/* ⋯ more menu */
.composer-more-wrap { position: relative; }
.composer-more-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  min-width: 220px; z-index: 30;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 36px color-mix(in srgb, var(--shadow) 35%, transparent);
  animation: pop 0.12s var(--ease);
}
/* Portaled to <body> so overflow-x:auto on the composer bar can't clip it */
.composer-more-menu.composer-more-portal {
  position: fixed;
  z-index: 160;
  max-width: calc(100vw - 16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.composer-more-menu[hidden] { display: none !important; }
.more-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  border: none; background: transparent;
  color: var(--ink-soft);
  padding: 9px 10px; border-radius: 10px;
  font: inherit; cursor: pointer;
  transition: background 0.1s;
}
.more-item:hover { background: var(--panel-inset); color: var(--ink); }
.more-item .ico { font-size: 16px; color: var(--muted); flex-shrink: 0; }
.more-item:hover .ico { color: var(--ink); }
.more-item-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.more-item-title { font-size: 13px; font-weight: 650; }
.more-item-sub { font-size: 11px; color: var(--faint); font-weight: 500; }
.more-check { font-size: 14px; color: var(--primary); opacity: 0; flex-shrink: 0; }
.more-item.active .more-check { opacity: 1; }
.more-item.active {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.more-item.active .ico { color: var(--primary); }
.more-item.active .more-item-title { color: var(--primary); }

/* Legacy .chip hooks (modals / other UI may still use them) */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1.5px solid transparent; background: transparent; color: var(--muted);
  padding: 6px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.chip.toggle.active { color: var(--primary); }
.chip-lab { line-height: 1; }

.mic-banner {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 12px 0; padding: 8px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger, #f43f5e) 16%, var(--panel));
  border: 1.5px solid var(--danger, #f43f5e);
  color: var(--ink); font-size: 12.5px; font-weight: 600;
}
.mic-banner[hidden] { display: none !important; }
.mic-banner .mic-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--danger, #f43f5e);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger, #f43f5e) 50%, transparent);
  animation: mic-dot 1.1s ease-out infinite;
}
@keyframes mic-dot {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger, #f43f5e) 55%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Per-message speak button */
.msg-speak {
  display: inline-flex; align-items: center; gap: 5px;
  margin: 6px 0 0; padding: 5px 10px;
  border: 1.5px solid var(--line-soft); border-radius: 999px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.msg-speak:hover { color: var(--ink); border-color: var(--border); background: var(--panel-inset); }
.msg-speak.playing { color: var(--primary); border-color: var(--primary); background: var(--primary-wash); }
.msg-speak .ico { font-size: 13px; }

/* Voice settings modal fields */
.field-label {
  display: block; margin: 14px 0 6px;
  font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--ink);
}
.field-input {
  width: 100%; box-sizing: border-box;
  background: var(--panel-inset); color: var(--ink);
  border: 2px solid var(--border); border-radius: var(--r-md);
  padding: 10px 12px; font: inherit; font-size: 13.5px;
}
.field-input.mono { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.02em; }
.field-input:focus { outline: none; border-color: var(--primary); }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row .field-input { flex: 1; min-width: 0; }
.field-hint { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.field-hint a, .modal-note a { color: var(--primary); }
.field-hint code { font-family: var(--font-mono); font-size: 10.5px; }
.switch-row {
  display: flex; align-items: center; gap: 14px;
  margin: 18px 0 8px; padding: 12px 12px;
  background: var(--panel-inset); border: 2px solid var(--border); border-radius: var(--r-md);
}
.switch-row > span { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.switch-title { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--ink); }
.switch-sub { font-size: 11.5px; color: var(--muted); line-height: 1.4; }


.think-wrap { position: relative; display: inline-flex; }
.think-menu {
  position: absolute; bottom: calc(100% + 8px); right: 0; left: auto; width: 176px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px color-mix(in srgb, var(--shadow) 32%, transparent); padding: 5px; z-index: 40;
  animation: pop 0.12s var(--ease);
}
.think-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: none; background: transparent; color: var(--ink-soft);
  padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600;
  transition: background 0.1s;
}
.think-opt:hover { background: var(--panel-inset); }
.think-opt.sel { background: var(--primary-wash); color: var(--ink); }
.think-opt .tick { margin-left: auto; color: var(--primary); font-size: 14px; opacity: 0; }
.think-opt.sel .tick { opacity: 1; }
.think-opt .sub { font-family: var(--font-mono); font-size: 9px; color: var(--faint); font-weight: 400; }

.composer-hint { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.send-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  background: var(--primary); color: var(--primary-ink, #fff);
  border: none; border-radius: 50%;
  font-size: 14px; font-weight: 700;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--primary) 35%, transparent);
  transition: filter 0.12s, transform 0.1s var(--ease), box-shadow 0.12s, background 0.16s;
}
.send-btn:hover { filter: brightness(1.06); box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 42%, transparent); }
.send-btn:active { transform: scale(0.96); }
.send-btn .send-glyph { font-size: 16px; display: inline-flex; }
.send-btn .send-glyph svg { width: 17px; height: 17px; }
.send-btn .send-label { display: none; }
.send-btn.stopping {
  background: var(--danger);
  box-shadow: 0 2px 12px color-mix(in srgb, var(--danger) 35%, transparent);
}
.send-btn.stopping:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--danger) 42%, transparent);
}

/* ============================================================
   Modals
   ============================================================ */
/* Above model menu sheet (z-index 200) so key/settings dialogs always surface */
.overlay { position: fixed; inset: 0; background: #0000006e; z-index: 220; animation: fade 0.15s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 36px)); max-height: calc(100vh - 52px); overflow-y: auto;
  background: var(--panel); border: 2px solid var(--border); border-radius: var(--r-lg);
  box-shadow: 7px 7px 0 var(--shadow); z-index: 230; padding: 22px 24px 24px;
  animation: modalIn 0.18s var(--ease);
}
.modal[hidden], .overlay[hidden] { display: none !important; }
.modal-wide { width: min(700px, calc(100vw - 36px)); }
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; transform: translate(-50%, -50%); } }

.modal-head { display: flex; align-items: center; margin-bottom: 6px; }
.modal-head h2 { font-family: var(--font-display); font-weight: 800; font-size: 23px; letter-spacing: -0.02em; margin: 0; color: var(--ink); }
.modal-close {
  margin-left: auto; border: 2px solid var(--border); background: var(--panel); color: var(--ink);
  width: 32px; height: 32px; border-radius: var(--r-sm); display: grid; place-items: center;
  font-size: 16px; box-shadow: 2px 2px 0 var(--shadow); transition: transform 0.09s var(--ease), box-shadow 0.09s, color 0.12s;
}
.modal-close:hover { color: var(--danger); transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }
.modal-close:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.modal-note { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 4px 0 18px; }
.modal-note code, .field-row code { font-family: var(--font-mono); font-size: 0.85em; background: var(--code-bg); padding: 1px 5px; border-radius: 5px; border: 1.5px solid var(--code-border); }

/* Install to iOS steps */
.ios-install-steps {
  list-style: none; margin: 0 0 8px; padding: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.ios-install-steps li {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--line-soft, var(--border));
  background: var(--panel-inset, color-mix(in srgb, var(--ink) 4%, var(--panel)));
}
.ios-step-num {
  flex-shrink: 0;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  color: var(--primary-ink, #fff);
  background: var(--primary);
  box-shadow: 2px 2px 0 var(--shadow);
}
.ios-install-steps strong {
  display: block; font-size: 13.5px; font-weight: 700; color: var(--ink);
  margin-bottom: 2px;
}
.ios-step-sub {
  display: block; font-size: 12.5px; line-height: 1.45; color: var(--muted);
}

.modal-textarea, .field {
  width: 100%; background: var(--panel-inset); border: 2px solid var(--border); border-radius: var(--r-md);
  padding: 11px 13px; color: var(--ink); font-size: 14px; line-height: 1.6; outline: none; resize: vertical;
  transition: box-shadow 0.12s;
}
.modal-textarea:focus, .field:focus { box-shadow: 3px 3px 0 var(--primary); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }

.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.modal-actions .spacer { flex: 1; }
.btn-solid {
  display: inline-flex; align-items: center; gap: 7px; background: var(--primary); color: #fff;
  border: 2px solid var(--border); padding: 10px 18px; border-radius: var(--r-md); font-size: 14px; font-weight: 700;
  box-shadow: 3px 3px 0 var(--shadow); transition: transform 0.09s var(--ease), box-shadow 0.09s var(--ease);
}
.btn-solid:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow); }
.btn-solid:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px; background: var(--panel); color: var(--ink-soft);
  border: 2px solid var(--border); padding: 10px 16px; border-radius: var(--r-md); font-size: 14px; font-weight: 600;
  box-shadow: 2px 2px 0 var(--shadow); transition: transform 0.09s var(--ease), box-shadow 0.09s var(--ease), color 0.12s;
}
.btn-ghost:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); color: var(--primary); }
.btn-ghost:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.btn-ghost .ico { font-size: 15px; }
.btn-danger {
  background: transparent; color: var(--danger); border: 2px solid transparent;
  padding: 10px 14px; border-radius: var(--r-md); font-size: 14px; font-weight: 600;
}
.btn-danger:hover { border-color: var(--danger); }

/* tools list */
.tools-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.tool-card {
  display: flex; align-items: center; gap: 12px; border: 2px solid var(--border); border-radius: var(--r-md);
  padding: 12px 14px; background: var(--panel-inset); box-shadow: 2px 2px 0 var(--shadow);
}
.tool-card.builtin { background: var(--primary-wash); }
.tool-card-main { flex: 1; min-width: 0; }
.tool-card-name { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--ink); }
.tool-card-name .tag { color: var(--faint); font-weight: 400; }
.tool-card-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-card-edit { border: none; background: transparent; color: var(--primary); font-size: 12px; font-family: var(--font-mono); font-weight: 700; padding: 4px 6px; }
.tool-card-edit:hover { text-decoration: underline; }

/* toggle switch */
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--panel); border: 2px solid var(--border); border-radius: 20px; transition: background 0.15s; }
.switch .track::before {
  content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px;
  background: var(--border); border-radius: 50%; transition: transform 0.16s var(--ease);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(18px); background: #fff; }

.tools-add { margin-bottom: 4px; }
.tool-editor { margin-top: 16px; border-top: 2px solid var(--line-soft); padding-top: 18px; }
.field-row { margin-bottom: 14px; }
.field-row label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.field-row label .hint { font-weight: 400; color: var(--faint); font-size: 11.5px; }

/* about */
.about-body p { font-size: 14.5px; line-height: 1.68; color: var(--ink-soft); margin: 0 0 15px; }
.about-lead { font-size: 16px !important; }
.about-list { list-style: none; padding: 0; margin: 0 0 16px; }
.about-list li { font-size: 13.5px; color: var(--muted); line-height: 1.6; margin-bottom: 9px; }
.about-list .k {
  display: inline-block; min-width: 62px; font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--primary); margin-right: 8px;
}
.about-note {
  display: flex; gap: 10px; padding: 13px 15px; border-radius: var(--r-md);
  background: var(--primary-wash); border: 2px solid var(--border); box-shadow: 2px 2px 0 var(--shadow);
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.55; margin-bottom: 16px;
}
.about-note .ico { color: var(--primary); font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.about-foot { font-size: 14px !important; color: var(--ink) !important; font-weight: 600; }

.about-donate {
  border: 2px solid var(--border); border-radius: var(--r-md);
  background: var(--primary-wash); box-shadow: 2px 2px 0 var(--shadow);
  padding: 13px 15px; margin-bottom: 16px;
}
.about-donate .dn-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 9px; }
.about-donate .dn-row { display: flex; gap: 8px; align-items: center; }
.about-donate code {
  flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 11px; color: var(--ink);
  background: var(--panel); border: 2px solid var(--border); border-radius: var(--r-sm);
  padding: 7px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.about-donate .dn-copy {
  flex-shrink: 0; border: 2px solid var(--border); background: var(--primary); color: #fff;
  font-family: var(--font-ui); font-weight: 700; font-size: 12px; padding: 7px 12px;
  border-radius: var(--r-sm); box-shadow: 2px 2px 0 var(--shadow); cursor: pointer;
}
.about-donate .dn-copy:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.about-donate .dn-note { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 7px; letter-spacing: 0.04em; }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 40px;
  font-size: 13.5px; font-weight: 600; z-index: 200; border: 2px solid var(--border);
  box-shadow: 3px 3px 0 var(--shadow); animation: toastIn 0.18s var(--ease);
}
[data-theme="day"] .toast { background: var(--ink); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.spinner-mini { width: 12px; height: 12px; border: 2px solid var(--line-soft); border-top-color: var(--primary); border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* scrollbars */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-soft); border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* ============================================================
   New: brand avatars, tokens, discord, CLI, multi-agent, notes
   ============================================================ */

/* assistant avatar = the model's brand mark */
.avatar-brand {
  width: 26px; height: 26px; flex-shrink: 0; object-fit: contain;
  background: #fff; border: 2px solid var(--border); border-radius: 8px;
  padding: 3px; box-shadow: 2px 2px 0 var(--shadow);
}
.avatar-brand[data-brand="kimi"] { background: #0e1626; }

/* per-message token counter */
.role-tokens {
  margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--faint);
  border: 1.5px solid var(--line-soft); padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}

/* legacy class hooks — restyled as quiet topbar actions */
.discord-btn, .status-btn { /* superseded by .tb-btn */ }

/* Status modal contents */
.status-loading, .status-err { padding: 8px 2px; color: var(--text2, #9898ac); font-size: 14px; }
.status-err { color: var(--danger, #ef4444); }
.status-head-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 22%, transparent); }
.status-dot.lvl-ok { background: #22c55e; color: #22c55e; }
.status-dot.lvl-warn { background: #f59e0b; color: #f59e0b; }
.status-dot.lvl-crit { background: #ef4444; color: #ef4444; }
.status-title { font-weight: 700; font-size: 16px; }
.status-reasons { margin: 0 0 12px; padding-left: 18px; color: var(--text2, #9898ac); font-size: 13.5px; line-height: 1.6; }
.status-metrics { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.status-metric {
  flex: 1 1 90px; min-width: 90px; text-align: center;
  border: 1px solid var(--line-soft, #2a2a3a); border-radius: 10px; padding: 10px 8px;
}
.sm-num { display: block; font-size: 20px; font-weight: 700; }
.sm-label { display: block; font-size: 11px; color: var(--text3, #5e5e72); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.status-foot { font-size: 12px; color: var(--text3, #5e5e72); }
.status-foot a { color: var(--primary); }

/* "OllieCLI — Beta" pill in the sidebar */
.new-tag {
  margin-left: auto; font-family: var(--font-mono); font-size: 8px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--good);
  border: 1.5px solid var(--good); padding: 2px 6px; border-radius: 20px; white-space: nowrap;
}

/* OllieCLI modal — beta badge + install command box */
.beta-badge {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--good); border: 2px solid var(--good);
  border-radius: 20px; padding: 2px 8px; vertical-align: middle; margin-left: 6px;
}
.cli-install { display: flex; gap: 8px; align-items: center; margin: 6px 0 16px; }
.cli-install code {
  flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 13px; color: var(--ink);
  background: var(--code-bg); border: 2px solid var(--code-border); border-radius: var(--r-sm);
  padding: 10px 12px; overflow-x: auto; white-space: nowrap;
}
.cli-copy {
  flex-shrink: 0; border: 2px solid var(--border); background: var(--primary); color: #fff;
  font-family: var(--font-ui); font-weight: 700; font-size: 12px; padding: 10px 14px;
  border-radius: var(--r-sm); box-shadow: 2px 2px 0 var(--shadow); cursor: pointer;
}
.cli-copy:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }

/* multi-agent — toggle row + roster picks in the model menu */
.ma-toggle-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 11px; margin-bottom: 6px;
  border: 2px solid var(--border); border-radius: var(--r-md); background: var(--panel-inset);
}
.ma-toggle-row.on { background: var(--primary-wash); }
.ma-toggle-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ma-toggle-title { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--ink); }
.ma-toggle-sub { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.ma-pick {
  min-width: 34px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase;
  border: 1.5px dashed var(--line-soft); color: var(--faint); border-radius: 20px; padding: 0 8px;
}
.ma-pick.on { border-style: solid; border-color: var(--primary); color: var(--primary); background: var(--primary-wash); }
.ma-pick .ico { font-size: 13px; }

/* multi-agent — team header + per-agent dividers */
.avatar-team { display: inline-flex; align-items: center; }
.avatar-brand.stacked { width: 24px; height: 24px; margin-right: -9px; box-shadow: 1px 1px 0 var(--shadow); }
.avatar-brand.stacked:last-child { margin-right: 0; }
.agent-divider {
  display: flex; align-items: center; gap: 8px; margin: 20px 0 11px;
  padding-bottom: 7px; border-bottom: 2px dashed var(--line-soft);
}
.agent-divider .brand-ico.sm { width: 20px; height: 20px; }
.agent-role { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--ink); }
.agent-model { font-family: var(--font-mono); font-size: 10px; color: var(--faint); margin-left: auto; }

/* gentle inline note (e.g. after a blank-answer retry) */
.msg-note {
  display: flex; align-items: center; gap: 8px; margin: 6px 0 0;
  padding: 10px 13px; border: 2px dashed var(--line-soft); border-radius: var(--r-md);
  background: var(--panel-inset); color: var(--muted); font-size: 13px; line-height: 1.5;
}
.msg-note .ico { color: var(--primary); font-size: 15px; flex-shrink: 0; }

/* ============================================================
   Canvas — live HTML artifact panel (right column)
   ============================================================ */
#app { transition: grid-template-columns 0.22s var(--ease); }
#app.canvas-open { grid-template-columns: var(--side-w) 1fr var(--canvas-w); }
.canvas {
  background: var(--panel); border-left: 2px solid var(--border);
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  animation: canvasIn 0.24s var(--ease);
}
.canvas[hidden] { display: none; }   /* beat the .canvas display:flex above */
@keyframes canvasIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.canvas-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 2px solid var(--border); background: var(--bg); flex-shrink: 0;
}
.canvas-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid var(--border); flex-shrink: 0; }
.canvas-title {
  font-family: var(--font-display); font-weight: 700; font-size: 13.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%;
}
.canvas-tabs { display: flex; gap: 3px; margin-left: 6px; background: var(--panel-inset); border: 2px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.canvas-tab {
  border: none; background: transparent; color: var(--muted); font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 10px; border-radius: 5px; transition: background 0.12s, color 0.12s;
}
.canvas-tab.active { background: var(--primary); color: #fff; }
.canvas-actions { display: flex; gap: 2px; margin-left: auto; }
.canvas-act {
  border: none; background: transparent; color: var(--muted); width: 28px; height: 28px;
  border-radius: var(--r-sm); display: grid; place-items: center; font-size: 15px;
  transition: background 0.12s, color 0.12s;
}
.canvas-act:hover { background: var(--panel-inset); color: var(--primary); }
.canvas-body { position: relative; flex: 1; min-height: 0; background: #fff; }
[data-theme="night"] .canvas-body { background: #0e0b10; }
.canvas-frame { width: 100%; height: 100%; border: none; background: #fff; display: block; }
.canvas-code {
  position: absolute; inset: 0; margin: 0; overflow: auto; padding: 14px 16px;
  background: var(--code-bg); color: var(--ink); font-size: 12px; line-height: 1.6; white-space: pre;
}
.canvas-code code { font-family: var(--font-mono); background: none; border: none; padding: 0; }
.canvas-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--faint); background: var(--panel);
}
.canvas-empty .ico { font-size: 40px; opacity: 0.5; }
.canvas-empty p { font-family: var(--font-mono); font-size: 12px; margin: 0; }

/* canvas chip while streaming an artifact */
.tool-run.canvas-chip .tool-run-glyph { color: var(--primary); }
.tool-run.canvas-chip .tool-run-open {
  margin-left: auto; font-family: var(--font-mono); font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--primary); border: 1.5px solid var(--primary);
  padding: 3px 8px; border-radius: 20px; background: var(--primary-wash);
}

/* ============================================================
   Responsive + phone polish
   ============================================================ */
#sidebar-backdrop { display: none; position: fixed; inset: 0; background: #0006; z-index: 30; }

/* Safe areas (notch / home indicator) */
body {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}
#app {
  height: 100dvh;
  min-height: 100dvh;
  /* iOS keyboard / visualViewport sets --app-height via JS when available */
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
}
#topbar {
  padding-top: max(10px, env(safe-area-inset-top, 0px));
}
#composer {
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}
#sidebar {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
}

/* canvas overlays instead of taking a column on narrower screens */
@media (max-width: 1100px) {
  #app.canvas-open { grid-template-columns: var(--side-w) 1fr; }
  .canvas {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 70;
    box-shadow: -8px 0 0 rgba(0, 0, 0, 0.15);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

@media (max-width: 860px) {
  #app, #app.canvas-open { grid-template-columns: 1fr; }
  #sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 60;
    transform: translateX(-100%); transition: transform 0.24s var(--ease);
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    box-shadow: 8px 0 32px rgba(0,0,0,0.25);
  }
  #app.side-open #sidebar { transform: none; }
  #app.side-open #sidebar-backdrop { display: block; }
  .menu-btn {
    display: inline-flex !important;
    align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px;
    font-size: 22px;
  }
  /* Always show delete on touch — hover-only trash is unusable on phones */
  .chat-item-row { gap: 4px; }
  .chat-item { padding: 12px 10px; min-height: 44px; }
  .chat-item-del {
    opacity: 0.7 !important;
    width: 44px; min-width: 44px; min-height: 44px;
    font-size: 17px;
    color: var(--muted);
  }
  .chat-item-del:active,
  .chat-item-del:focus-visible {
    opacity: 1 !important;
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 14%, transparent);
  }
  .composer-hint { display: none; }
  .transcript {
    padding: 16px 14px 12px;
    /* room so last messages sit above the floating composer */
    padding-bottom: 8px;
  }
  .hero { margin-top: 2vh; padding: 0 4px; }
  .hero h1 { font-size: clamp(1.55rem, 7vw, 2rem) !important; }
  .hero-prompts { gap: 8px; }
  .hero-prompt {
    font-size: 12.5px; padding: 10px 12px;
    max-width: 100%;
  }
  .canvas { width: 100vw; top: 0; }

  #topbar {
    gap: 8px;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
  }
  .model-btn {
    max-width: min(52vw, 220px);
    padding: 8px 10px;
    min-height: 40px;
  }
  .model-btn-label {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 13.5px;
  }
  .topbar-actions { gap: 0; }
  .tb-btn {
    min-width: 40px; min-height: 40px;
    padding: 8px;
  }
  .tb-label, .discord-label, .status-label { display: none !important; }
  .turn-meta { display: none; }

  /* Model menu sheet — applied via .model-menu-sheet (ported to body in JS) */
  .model-menu.model-menu-sheet {
    z-index: 200 !important;
  }

  /* Composer: sticky, keyboard-friendly */
  .composer {
    width: 100%;
    padding: 0 10px max(10px, env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
  }
  .composer-card { border-radius: 18px; }
  /* 16px prevents iOS focus zoom */
  .composer-input {
    font-size: 16px !important;
    padding: 12px 14px 6px;
    min-height: 24px;
  }
  .composer-bar {
    padding: 4px 6px 8px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .composer-left { gap: 0; flex: 1; min-width: 0; overflow-x: auto; }
  .c-btn {
    width: 42px; height: 42px; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .c-think {
    height: 40px;
    min-height: 40px;
    padding: 0 10px;
    max-width: 120px;
  }
  .c-think .think-label { max-width: 3.8em; font-size: 12px; }
  .c-think > .ico { width: 16px; height: 16px; }
  .send-btn {
    width: 44px; height: 44px; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .composer-more-menu,
  .composer-more-menu.composer-more-portal {
    min-width: min(260px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
  }
  .more-item {
    padding: 12px 12px;
    min-height: 48px;
  }
  .think-menu {
    right: 0; left: auto;
    width: min(200px, calc(100vw - 24px));
  }

  .scroll-bottom {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    width: 44px; height: 44px;
  }

  .msg { margin-bottom: 16px; }
  .msg.user .msg-body { max-width: 92%; font-size: 15px; }
  .msg.assistant .msg-body { font-size: 15.5px; }
  .msg-body.md pre { font-size: 12px; padding: 12px; border-radius: 12px; }

  /* Modals: almost full-screen sheets on phones */
  .modal, .modal-wide {
    top: auto; bottom: 0; left: 0; right: 0;
    transform: none;
    width: 100%;
    max-height: min(92dvh, 100%);
    max-height: min(92dvh, 100svh);
    border-radius: 20px 20px 0 0;
    padding: 18px 16px max(18px, env(safe-area-inset-bottom, 0px));
    animation: sheetUp 0.22s var(--ease);
  }
  @keyframes sheetUp {
    from { transform: translateY(12%); opacity: 0.6; }
    to { transform: none; opacity: 1; }
  }
  .modal-textarea, .field-input { font-size: 16px !important; }
  .modal-head h2 { font-size: 20px; }

  /* Settings & form controls: stack the label above a full-width control so
     nothing gets cramped or overflows on a narrow phone. */
  .set-group { gap: 16px; }
  .set-field { flex-direction: column; align-items: stretch; gap: 6px; }
  .set-field > label { font-size: 13px; font-weight: 700; }
  .set-field select, .theme-select { min-width: 0; max-width: none; width: 100%; font-size: 16px; padding: 10px 12px; }
  .switch-row { gap: 12px; }
  .switch { width: 46px; height: 26px; }
  .switch .track::before { width: 18px; height: 18px; }
  .switch input:checked + .track::before { transform: translateX(20px); }

  /* Generated media + thumbnails fit the narrower column */
  .gen-media-img, .gen-media-vid, .gen-media-loading { max-width: 100%; width: 100%; }
  .gen-media-loading { height: 220px; }

  /* Live mode is full-viewport stage — no panel padding overrides needed */

  /* Wait card */
  .wait-card { max-width: 100%; }

  /* Touch: remove sticky hover states feeling stuck */
  .chip:hover, .c-btn:hover { /* keep base */ }
}

/* Keyboard open (class set by JS via visualViewport) */
body.kb-open .scroll-bottom { display: none !important; }
body.kb-open #topbar { padding-top: 6px; }
body.kb-open .hero { display: none; }

@media (max-width: 720px) {
  .tb-label { display: none; }
  .c-think .think-label { max-width: 3.2em; }
}
@media (max-width: 600px) {
  .discord-label, .status-label, .tb-label { display: none; }
}

/* Phones in landscape: keep composer compact */
@media (max-height: 480px) and (orientation: landscape) {
  .transcript { padding-top: 10px; }
  .hero { display: none; }
  .composer-input { max-height: 80px; }
  .wait-card { padding: 8px 10px; }
}

/* ── Easter egg (10 clicks on the logo) — a skydive ─────────────────── */
#egg-overlay {
  position: fixed; inset: 0; z-index: 100000;
  background: linear-gradient(180deg, #0e2a58 0%, #2c62a3 34%, #5b98d4 64%, #b7e0f8 100%);
  opacity: 0; transition: opacity 0.6s ease;
  overflow: hidden; pointer-events: none;
}
#egg-overlay.show { opacity: 1; pointer-events: auto; }   /* blocks the page, but clicking does nothing */

/* Two full-bleed layers of upward motion: clouds (parallax) + thin wind streaks.
   Everything RISES past a roughly-fixed character, which reads as him falling. */
#egg-sky, #egg-wind, #egg-sky-front { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#egg-sky       { z-index: 1; }   /* clouds behind him */
#egg-wind      { z-index: 2; }
/* #egg-img is z-index 3 */
#egg-sky-front { z-index: 4; }   /* clouds sweeping in FRONT of him */

.egg-cloud { position: absolute; top: 110%; will-change: transform; animation: egg-rise linear infinite; }
.egg-cloud-shape {
  width: 66px; height: 66px; border-radius: 50%; background: #fff;
  box-shadow:
     40px 14px 0 -3px #fff,   80px 22px 0 -9px #fff,  -30px 20px 0 -6px #fff,
     22px 30px 0  2px #fff,   58px 34px 0 -2px #fff,  108px 30px 0 -12px #fff;
  filter: blur(2px);
}
/* Foreground clouds sit "closer": bigger, softer, and they wipe across him. */
.egg-cloud.front .egg-cloud-shape { filter: blur(6px); opacity: 0.95; }
@keyframes egg-rise { to { transform: translateY(-155vh); } }

.egg-streak {
  position: absolute; top: 110%; width: 2px; border-radius: 3px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  will-change: transform; animation: egg-streak-rise linear infinite;
}
@keyframes egg-streak-rise { to { transform: translateY(-160vh); } }

#egg-img {
  position: fixed; left: 50%; top: 50%; z-index: 3;
  width: min(48vw, 380px); height: auto;
  transform: translate(-50%, calc(-50% - 130vh));   /* start above the screen */
  will-change: transform;
  /* Layered shadow + soft rim so he pops off the sky. */
  filter: drop-shadow(0 22px 40px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.35));
}
/* Plummet in from above and POP: scale past 1 then settle where the tumble begins. */
#egg-img.enter { animation: egg-enter 1.2s cubic-bezier(0.34, 1.4, 0.5, 1) forwards; }
@keyframes egg-enter {
  0%   { transform: translate(-50%, calc(-50% - 130vh)) rotate(-42deg) scale(0.55); }
  70%  { transform: translate(-50%, calc(-50% + 3vh))   rotate(11deg)  scale(1.18); }
  100% { transform: translate(-50%, -52%) rotate(-8deg) scale(1); }
}
/* Flail and tumble in place while the clouds/wind rush up — the "falling" look. */
#egg-img.tumble { animation: egg-tumble 2.6s ease-in-out infinite; }
@keyframes egg-tumble {
  0%   { transform: translate(-50%, -52%) rotate(-8deg); }
  20%  { transform: translate(-53%, -49%) rotate(7deg); }
  45%  { transform: translate(-49%, -53%) rotate(-3deg); }
  65%  { transform: translate(-51%, -48%) rotate(9deg); }
  85%  { transform: translate(-48%, -51%) rotate(-6deg); }
  100% { transform: translate(-50%, -52%) rotate(-8deg); }
}
/* Let go — accelerate the rest of the way down and out the bottom. */
#egg-img.dropping { animation: egg-exit 2.2s cubic-bezier(0.5, 0, 0.75, 1) forwards; }
@keyframes egg-exit {
  0%   { transform: translate(-50%, -52%) rotate(-8deg); opacity: 1; }
  80%  { transform: translate(-50%, calc(-50% + 122vh)) rotate(22deg); opacity: 1; }
  100% { transform: translate(-50%, calc(-50% + 132vh)) rotate(26deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #egg-sky, #egg-wind, #egg-sky-front { display: none; }
  #egg-img.enter, #egg-img.tumble, #egg-img.dropping { animation-duration: 0.01ms; animation-iteration-count: 1; }
}

/* ── Live voice mode (GPT Live–style immersive stage) ────────── */
body.live-open { overflow: hidden; }
.live-mode {
  --live-energy: 0;
  --live-scale: 1;
  --live-glow: 0.4;
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: stretch; justify-content: center;
  padding: 0;
  color: #f4f0ff;
  background:
    radial-gradient(ellipse 80% 60% at 50% 42%, rgba(255, 79, 154, 0.14), transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 80%, rgba(103, 232, 249, 0.08), transparent 55%),
    radial-gradient(circle at 50% 50%, #16101f 0%, #08060c 70%);
  backdrop-filter: blur(18px);
  animation: live-fade-in 0.28s ease;
}
.live-mode[hidden] { display: none !important; }
@keyframes live-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.live-stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(16px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(14px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
}

.live-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 5;
  width: 44px; height: 44px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
  display: grid; place-items: center;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.live-close:hover { background: rgba(255,255,255,0.12); }
.live-close:active { transform: scale(0.94); }

.live-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
  min-height: 0;
  padding: 40px 16px 12px;
}

.live-orb-wrap {
  position: relative;
  width: min(52vw, 240px);
  height: min(52vw, 240px);
  display: grid;
  place-items: center;
}

.live-orb-glow {
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 120, 180, calc(var(--live-glow) * 0.55)) 0%, transparent 68%);
  filter: blur(18px);
  pointer-events: none;
  transition: opacity 0.15s;
}

.live-orb-ring {
  position: absolute;
  inset: -6%;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.08);
  box-shadow:
    0 0 0 12px rgba(255,255,255,0.02),
    inset 0 0 40px rgba(255,255,255,0.04);
  pointer-events: none;
  animation: live-ring 4.5s ease-in-out infinite;
}
@keyframes live-ring {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.04); opacity: 0.9; }
}

.live-orb {
  width: 62%;
  height: 62%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.55), transparent 28%),
    radial-gradient(circle at 50% 50%, #ff9ec8 0%, #ff4f9a 42%, #7c3aed 78%, #1e1030 100%);
  box-shadow:
    0 0 40px rgba(255, 79, 154, 0.35),
    0 20px 50px rgba(0,0,0,0.35),
    inset 0 -10px 30px rgba(0,0,0,0.25);
  transform: scale(var(--live-scale));
  transition: transform 0.06s linear, filter 0.2s ease;
  will-change: transform;
}
.live-mode[data-phase="listening"] .live-orb {
  animation: live-breathe 3s ease-in-out infinite;
}
.live-mode[data-phase="capturing"] .live-orb {
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.6), transparent 28%),
    radial-gradient(circle at 50% 50%, #fda4af 0%, #f43f5e 45%, #9f1239 85%);
  animation: live-pulse 1.1s ease-in-out infinite;
}
.live-mode[data-phase="thinking"] .live-orb,
.live-mode[data-phase="processing"] .live-orb {
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.5), transparent 28%),
    radial-gradient(circle at 50% 50%, #a5b4fc 0%, #818cf8 40%, #4f46e5 80%);
  animation: live-think 1.6s ease-in-out infinite;
}
.live-mode[data-phase="speaking"] .live-orb {
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.65), transparent 28%),
    radial-gradient(circle at 50% 50%, #67e8f9 0%, #22d3ee 35%, #ff4f9a 75%, #7c3aed 100%);
  animation: live-speak 0.7s ease-in-out infinite;
}
.live-orb.muted {
  filter: grayscale(0.9) brightness(0.65);
  animation: none !important;
  transform: scale(0.92);
}
@keyframes live-breathe {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}
@keyframes live-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}
@keyframes live-think {
  0%, 100% { filter: hue-rotate(0deg) brightness(1); }
  50% { filter: hue-rotate(18deg) brightness(1.1); }
}
@keyframes live-speak {
  0%, 100% { filter: brightness(1.05); }
  40% { filter: brightness(1.2); }
  70% { filter: brightness(0.98); }
}

.live-status {
  margin: 0;
  font-family: var(--font-display, inherit);
  font-size: clamp(1.05rem, 3.6vw, 1.35rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  color: rgba(255,255,255,0.92);
  text-align: center;
}
.live-partial {
  margin: 0;
  max-width: 28rem;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  text-align: center;
  min-height: 1.2em;
}
.live-partial[hidden] { display: none !important; }
.live-level { display: none !important; }

.live-transcript {
  width: min(100%, 420px);
  max-height: 22vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 8px 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.live-transcript::-webkit-scrollbar { display: none; }
.live-bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
  animation: live-cap-in 0.22s ease;
}
@keyframes live-cap-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.live-bubble-user {
  align-self: flex-end;
  background: rgba(255, 79, 154, 0.16);
  border-color: rgba(255, 79, 154, 0.28);
}
.live-bubble-assistant { align-self: stretch; }
.live-bubble.streaming { opacity: 0.85; }
.live-bubble-who {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: rgba(255,255,255,0.4); margin-bottom: 3px;
}
.live-bubble-text {
  font-size: 14px; line-height: 1.45;
  color: rgba(255,255,255,0.9);
  white-space: pre-wrap; word-break: break-word;
}

.live-dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 0 4px;
}
.live-dock-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 72px;
  min-height: 72px;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.live-dock-btn .ico { font-size: 22px; }
.live-dock-btn:hover { background: rgba(255,255,255,0.12); }
.live-dock-btn:active { transform: scale(0.96); }
.live-dock-btn.active {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fb7185;
}
.live-dock-label { letter-spacing: 0.02em; }

.live-hint {
  margin: 2px 0 0;
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.38);
  text-align: center;
}

/* Live = unique cyan orb (not mic) */
.c-live { color: #67e8f9; }
.c-live:hover { color: #a5f3fc; background: color-mix(in srgb, #67e8f9 12%, transparent); }
#chip-live.active {
  background: color-mix(in srgb, #67e8f9 18%, transparent) !important;
  color: #67e8f9 !important;
  box-shadow: 0 0 0 1px color-mix(in srgb, #67e8f9 35%, transparent);
}

@media (max-width: 560px) {
  .live-orb-wrap {
    width: min(64vw, 220px);
    height: min(64vw, 220px);
  }
  .live-transcript { max-height: 26vh; }
  .live-dock-btn {
    min-width: 78px; min-height: 78px;
    border-radius: 24px;
  }
  .live-close { width: 46px; height: 46px; }
}

/* Legacy hooks (in case old markup briefly caches) */
.live-panel { display: contents; }
.live-ctrl, .live-end-btn { display: none; }
