/* ── Tokens (LLMntal.ai design system) ───────────────────────────────────── */
:root {
  --bg:           #17141d;
  --bg-card:      #1e1b27;
  --bg-card-2:    #231f2e;
  --bg-user:      #2a2536;
  --border:       rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);
  --teal:         #4dd9c0;
  --purple:       #a855f7;
  --text:         #e8e6ed;
  --muted:        #6b6880;
  --muted-2:      #9896a4;
  --danger:       #f87171;
  --danger-bg:    rgba(248,113,113,0.06);
  --ctx-amber:    #f59e0b;
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --radius:       12px;
  --radius-sm:    8px;
  --nav-h:        52px;
}

/* ── Reset + fixed-viewport layout ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */
nav {
  flex-shrink: 0;
  height: var(--nav-h);
  background: rgba(23, 20, 29, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.nav-inner {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.nav-logo {
  font-weight: 700;
  font-size: 0.95rem;
  background: linear-gradient(to right, var(--teal), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}
.nav-tag {
  font-size: 0.68rem;
  color: var(--muted-2);
  border: 1px solid var(--border);
  padding: 0.18rem 0.6rem;
  border-radius: 99px;
  background: var(--bg-card);
}

/* ── Main (fills remaining viewport) ─────────────────────────────────────── */
main {
  flex: 1;
  min-height: 0;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0.9rem 1.5rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero { flex-shrink: 0; }
.hero-eyebrow {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 0.3rem;
}
.hero h1 {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}
.gradient-text {
  background: linear-gradient(to right, var(--teal), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  color: var(--muted-2);
  font-size: 0.78rem;
  line-height: 1.5;
  max-width: 600px;
}

/* ── Capability toggle row ───────────────────────────────────────────────── */
.capabilities-section { flex-shrink: 0; }
.section-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.capabilities-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

/* Live toggle */
.capability-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.capability-toggle:hover {
  border-color: var(--border-hover);
}
.capability-toggle.active {
  border-color: rgba(77, 217, 192, 0.35);
  background: rgba(77, 217, 192, 0.06);
}
.capability-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* The toggle switch track */
.toggle-track {
  width: 30px;
  height: 17px;
  border-radius: 99px;
  background: var(--muted);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.capability-toggle.active .toggle-track {
  background: var(--teal);
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.capability-toggle.active .toggle-thumb {
  transform: translateX(13px);
}
.toggle-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted-2);
  white-space: nowrap;
}
.capability-toggle.active .toggle-label {
  color: var(--text);
}

/* ── Segmented control (three-way search mode) ───────────────────────────── */
.search-segmented {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  gap: 0;
}
.seg-btn {
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--muted-2);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.seg-btn:last-child {
  border-right: none;
}
.seg-btn:hover:not(:disabled):not(.seg-btn--active) {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.seg-btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
  z-index: 1;
}
.seg-btn--active {
  background: rgba(77, 217, 192, 0.12);
  color: var(--teal);
  font-weight: 600;
}
.seg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
/* annotation colour per mode */
.capability-annotation.search-on {
  color: var(--teal);
}

/* Coming soon chips */
.capability-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px dashed rgba(255,255,255,0.07);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  opacity: 0.45;
  cursor: default;
  user-select: none;
}
.chip-label {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.chip-soon {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 0.06rem 0.35rem;
  border-radius: 99px;
}

/* Inline annotation under the row */
.capability-annotation {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted-2);
  line-height: 1.4;
  min-height: 1.4em;
  transition: color 0.2s;
}
.capability-annotation.search-on {
  color: var(--teal);
}

/* ── Model selector ──────────────────────────────────────────────────────── */
.model-selector-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
}
.model-select {
  background: transparent;
  border: none;
  color: var(--muted-2);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  padding: 0;
  /* Let the browser render the native dropdown arrow */
  appearance: auto;
  -webkit-appearance: auto;
  max-width: 200px;
}
.model-select:focus { color: var(--text); }
.model-select option {
  background: var(--bg-card);
  color: var(--text);
}

/* Model caption */
.model-caption {
  margin-top: 0.25rem;
  font-size: 0.66rem;
  color: var(--muted);
  font-style: italic;
}

/* ── System prompt toggle button ─────────────────────────────────────────── */
.sysprompt-toggle-btn {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  color: var(--muted-2);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.sysprompt-toggle-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}
.sysprompt-toggle-btn[aria-expanded="true"] {
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.06);
  color: var(--text);
}

/* ── System prompt collapsible panel ─────────────────────────────────────── */
.sysprompt-panel {
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: fadeIn 0.18s ease-out;
}
.sysprompt-annotation {
  font-size: 0.72rem;
  color: var(--muted-2);
  line-height: 1.45;
  font-style: italic;
}
.sysprompt-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 0.74rem;
  line-height: 1.5;
  padding: 0.5rem 0.7rem;
  resize: vertical;
  outline: none;
  width: 100%;
  min-height: 140px;
  transition: border-color 0.15s;
}
.sysprompt-textarea:focus { border-color: var(--purple); }
.sysprompt-textarea.edited { border-color: rgba(168, 85, 247, 0.4); }
.sysprompt-footer {
  display: flex;
  justify-content: flex-end;
  min-height: 1.4rem;
}
.sysprompt-reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted-2);
  font-family: var(--font);
  font-size: 0.66rem;
  padding: 0.18rem 0.6rem;
  border-radius: 99px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.sysprompt-reset-btn:hover { border-color: var(--purple); color: var(--purple); }

/* ── Reasoning block (thinking mode) ────────────────────────────────────── */
.reasoning-block {
  background: var(--bg-card);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  animation: fadeIn 0.18s ease-out;
}

.reasoning-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.reasoning-body {
  font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--muted-2);
  max-height: 12em;
  overflow-y: auto;
  word-break: break-word;
  white-space: pre-wrap;
}
.reasoning-body::-webkit-scrollbar { width: 4px; }
.reasoning-body::-webkit-scrollbar-track { background: transparent; }
.reasoning-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Live stats footer — token counter, timer, tok/s */
.reasoning-stats {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 0.35rem;
  margin-top: 0.15rem;
  line-height: 1.3;
}

/* Collapsed summary row */
.reasoning-summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.7rem;
  text-align: left;
  transition: color 0.15s;
}
.reasoning-summary:hover { color: var(--muted-2); }
.reasoning-word-count { flex: 1; }
.reasoning-arrow {
  font-size: 0.7rem;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Search activity — done state (static, subdued) ─────────────────────── */
/* .search-activity[hidden] covered by global [hidden] rule in reset */
.search-activity.done {
  color: var(--muted);
  font-style: normal;
}
.search-activity.done .search-activity-dot {
  animation: none;
  background: var(--muted);
  opacity: 0.5;
}

/* ── Chat card ────────────────────────────────────────────────────────────── */
.chat-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Thread ──────────────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.85rem 0.9rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Empty / suggestions ─────────────────────────────────────────────────── */
#empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1.5rem 1rem;
  text-align: center;
  flex: 1;
  min-height: 200px;
}
.empty-prompt {
  color: var(--muted-2);
  font-size: 0.85rem;
}
.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  max-width: 600px;
}
.suggestion-btn {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--muted-2);
  font-family: var(--font);
  font-size: 0.74rem;
  padding: 0.35rem 0.8rem;
  border-radius: 99px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-align: left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.suggestion-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(77, 217, 192, 0.06);
}

/* ── Message turns ───────────────────────────────────────────────────────── */
#turns {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.turn {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  animation: fadeIn 0.22s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* User bubble */
.user-bubble {
  align-self: flex-end;
  background: var(--bg-user);
  color: var(--text);
  padding: 0.5rem 0.8rem;
  border-radius: 12px 12px 3px 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 80%;
  border: 1px solid var(--border);
  word-break: break-word;
}

/* Assistant card */
.assistant-card {
  align-self: flex-start;
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Search activity line inside assistant bubble */
.search-activity[hidden] { display: none; }
.search-activity {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  color: var(--teal);
  font-style: italic;
  padding: 0.3rem 0;
}
.search-activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  flex-shrink: 0;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.3; transform: scale(0.6); }
}

/* The answer text bubble */
.answer-bubble {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 3px 12px 12px 12px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}
.answer-bubble p { margin: 0 0 0.55em; }
.answer-bubble p:last-child { margin-bottom: 0; }
.answer-bubble a {
  color: var(--teal);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.answer-bubble a:hover { opacity: 0.8; }

/* ── Markdown elements inside answer bubble ──────────────────────────────── */
/* Headings — modest sizes, chat-bubble context */
.answer-bubble h4,
.answer-bubble h5,
.answer-bubble h6 {
  font-weight: 700;
  line-height: 1.3;
  margin: 0.6em 0 0.3em;
  color: var(--text);
}
.answer-bubble h4 { font-size: 1em; }
.answer-bubble h5 { font-size: 0.93em; }
.answer-bubble h6 { font-size: 0.87em; color: var(--muted-2); }
.answer-bubble h4:first-child,
.answer-bubble h5:first-child,
.answer-bubble h6:first-child { margin-top: 0; }

/* Lists */
.answer-bubble ul,
.answer-bubble ol {
  margin: 0.3em 0 0.55em 1.35em;
  padding: 0;
  line-height: 1.55;
}
.answer-bubble ul { list-style: disc; }
.answer-bubble ol { list-style: decimal; }
.answer-bubble li { margin-bottom: 0.15em; }

/* Inline code */
.answer-bubble code {
  font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 0.82em;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 3px;
  padding: 0.1em 0.35em;
}

/* Code blocks */
.answer-bubble pre {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  margin: 0.4em 0 0.55em;
  overflow-x: auto;
  line-height: 1.5;
}
.answer-bubble pre code {
  /* Reset inline-code chrome inside pre */
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 0.8em;
  color: var(--text);
}

/* Blockquote */
.answer-bubble blockquote {
  border-left: 3px solid var(--purple);
  margin: 0.35em 0 0.55em 0;
  padding: 0.25em 0.75em;
  color: var(--muted-2);
  font-style: italic;
}

/* Horizontal rule */
.answer-bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.65em 0;
}

/* Blinking cursor during streaming */
.answer-cursor .answer-text-node::after {
  content: '▋';
  color: var(--teal);
  animation: blink 0.8s step-end infinite;
  margin-left: 2px;
  font-size: 0.8em;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Citation list */
.citations {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.citations-label {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.1rem;
}
.citation-chip {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  text-decoration: none;
  padding: 0.2rem 0;
}
.citation-num {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--purple);
  flex-shrink: 0;
  min-width: 1.1rem;
}
.citation-title {
  font-size: 0.74rem;
  color: var(--muted-2);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-word;
  line-height: 1.35;
  transition: color 0.15s;
}
.citation-chip:hover .citation-title { color: var(--teal); }
.citation-domain {
  font-size: 0.62rem;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Error notice in thread */
.error-notice {
  align-self: flex-start;
  max-width: 88%;
  background: var(--danger-bg);
  border: 1px solid rgba(248,113,113,0.22);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--danger);
}
.error-notice.budget-exhausted {
  background: rgba(168, 85, 247, 0.06);
  border-color: rgba(168, 85, 247, 0.22);
  color: var(--muted-2);
}
.error-notice .error-suggestion {
  margin-top: 0.3rem;
  font-size: 0.74rem;
  opacity: 0.85;
}

/* Budget low footer note */
.budget-note {
  font-size: 0.66rem;
  color: var(--muted);
  text-align: center;
  padding: 0.15rem 0;
  animation: fadeIn 0.3s ease-out;
}

/* ── Input area ──────────────────────────────────────────────────────────── */
.chat-input {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.9rem 0.75rem;
  background: var(--bg-card-2);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Suggested questions row (above textarea) */
.input-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.1rem;
}
.input-suggestion-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.7rem;
  padding: 0.22rem 0.6rem;
  border-radius: 99px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.input-suggestion-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

/* Textarea + send row */
.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
#message-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  line-height: 1.45;
  padding: 0.55rem 0.8rem;
  resize: none;
  outline: none;
  max-height: 120px;
  transition: border-color 0.15s;
  min-height: 40px;
}
#message-input:focus { border-color: var(--teal); }
#message-input:disabled { opacity: 0.45; cursor: not-allowed; }
#message-input::placeholder { color: var(--muted); }
#send-btn {
  background: linear-gradient(135deg, var(--teal), var(--purple));
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  height: 40px;
  transition: opacity 0.15s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  /* SVG icon inline */
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
#send-btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
#send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* Input hint row */
.input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.input-hint {
  font-size: 0.62rem;
  color: var(--muted);
  flex: 1;
}
.input-hint kbd {
  font-family: inherit;
  font-size: 0.6rem;
  padding: 0.06rem 0.3rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--teal);
}
#clear-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.62rem;
  padding: 0.18rem 0.5rem;
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#clear-btn:hover { border-color: var(--teal); color: var(--teal); }

/* Auto-clear on changes label — compact, muted, consistent with clear button row */
.clear-on-change-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.62rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.clear-on-change-label input[type="checkbox"] {
  width: 11px;
  height: 11px;
  accent-color: var(--teal);
  cursor: pointer;
  flex-shrink: 0;
}
.clear-on-change-label:hover { color: var(--muted-2); }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.page-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 0.45rem 1rem;
  font-size: 0.62rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  line-height: 1.4;
}
.page-footer a {
  color: var(--muted-2);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* ── First-use overlay ───────────────────────────────────────────────────── */
#notice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 20, 29, 0.92);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
#notice-overlay.hidden { display: none; }
.notice-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  max-width: 440px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  animation: fadeIn 0.3s ease-out;
}
.notice-card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.notice-card p {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--muted-2);
}
.notice-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.notice-card li {
  font-size: 0.8rem;
  color: var(--muted-2);
  padding-left: 1.1rem;
  position: relative;
  line-height: 1.45;
}
.notice-card li::before {
  content: '·';
  position: absolute;
  left: 0.3rem;
  color: var(--teal);
  font-weight: 700;
}
#notice-accept-btn {
  background: linear-gradient(to right, var(--teal), var(--purple));
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-start;
  transition: opacity 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#notice-accept-btn:hover { opacity: 0.88; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  main { padding: 0.6rem 0.85rem; gap: 0.55rem; }
  .hero h1 { font-size: 1.1rem; }
  .hero-sub { display: none; }
  .user-bubble, .assistant-card { max-width: 94%; }
  .notice-card { padding: 1.4rem 1.25rem; }
  .input-suggestions { display: none; }
}
@media (max-height: 620px) {
  .hero { display: none; }
  main { gap: 0.5rem; padding-top: 0.5rem; }
}

/* ── Demo drawer — CSS vars ──────────────────────────────────────────────── */
:root {
  --demo-accent:   #4dd9c0;   /* overridden per-demo by JS */
  --drawer-w:      230px;
}

/* ── Page body: drawer + main two-column grid (desktop) ──────────────────── */
.page-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* ── Demo drawer (persistent on desktop, overlay on mobile) ──────────────── */
.demo-drawer {
  width: var(--drawer-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 20;
  transition: transform 0.22s ease;
}
.demo-drawer::-webkit-scrollbar { width: 4px; }
.demo-drawer::-webkit-scrollbar-track { background: transparent; }
.demo-drawer::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.drawer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 0.9rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.drawer-brand {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.drawer-close-btn {
  display: none;   /* shown only on mobile */
  background: transparent;
  border: none;
  color: var(--muted-2);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  transition: color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.drawer-close-btn:hover { color: var(--text); }

/* Demo nav list */
.drawer-nav { flex: 1; padding: 0.45rem 0; }
.demo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.demo-item { width: 100%; }

/* Shared entry base */
.demo-entry {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  width: 100%;
  padding: 0.5rem 0.85rem;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
  text-align: left;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.demo-entry:hover:not(.demo-entry--disabled):not(.demo-entry--active) {
  background: rgba(255,255,255,0.04);
}
.demo-entry--active {
  background: color-mix(in srgb, var(--demo-accent) 12%, transparent);
  border-left: 2px solid var(--demo-accent);
  padding-left: calc(0.85rem - 2px);
}
.demo-entry--active .demo-title {
  color: var(--demo-accent);
}
.demo-entry--disabled {
  opacity: 0.4;
  cursor: default;
}

.demo-icon {
  font-size: 1rem;
  line-height: 1.2;
  flex-shrink: 0;
  margin-top: 0.05rem;
}
.demo-text {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  flex: 1;
  min-width: 0;
}
.demo-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.demo-tagline {
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.demo-ext-icon {
  font-size: 0.65rem;
  color: var(--muted);
  flex-shrink: 0;
  margin-top: 0.25rem;
  align-self: flex-start;
}
.demo-soon-badge {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 0.05rem 0.3rem;
  border-radius: 99px;
  flex-shrink: 0;
  align-self: center;
}

/* Drawer footer */
.drawer-footer {
  flex-shrink: 0;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid var(--border);
}
.drawer-footer-link {
  font-size: 0.65rem;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.drawer-footer-link:hover { color: var(--muted-2); }

/* ── Main: fills remaining space, keeps its existing feel ────────────────── */
/* (existing `main` styles are preserved; we just adjust width behaviour) */
main {
  flex: 1;
  min-width: 0;   /* prevent overflow in flex child */
}

/* ── feature-hidden: hide a control but keep it in the DOM ──────────────── */
.feature-hidden {
  visibility: hidden;
  pointer-events: none;
  /* keep space so the row doesn't collapse; alternatively use display:none
     if you prefer the row to reflow — but hidden is cleaner for mid-demo
     switching */
}

/* ── Hamburger button (mobile only) ─────────────────────────────────────── */
.hamburger-btn {
  display: none;   /* shown only on mobile */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.hamburger-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--muted-2);
  border-radius: 2px;
  transition: background 0.15s;
}
.hamburger-btn:hover .hamburger-bar { background: var(--text); }

/* ── Mobile drawer scrim ─────────────────────────────────────────────────── */
.drawer-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23, 20, 29, 0.7);
  backdrop-filter: blur(2px);
  z-index: 19;
  opacity: 0;
  /* Invisible must mean intangible: the mobile media query keeps this element
     display:block for the fade transition, so without pointer-events:none it
     silently swallows EVERY tap on the page (hamburger included). */
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.drawer-scrim.scrim-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Mobile overrides (<= 900px: drawer becomes overlay) ─────────────────── */
@media (max-width: 900px) {
  .hamburger-btn { display: flex; }
  .drawer-close-btn { display: flex; }

  .drawer-scrim { display: block; }

  .demo-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--drawer-w);
    transform: translateX(calc(-1 * var(--drawer-w) - 2px));
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    /* override border-right with shadow for overlay feel */
    border-right: none;
  }
  .demo-drawer.drawer-open {
    transform: translateX(0);
  }

  .page-body {
    /* On mobile main takes full width; drawer floats over it */
    display: block;
    overflow: visible;
  }
  main {
    height: 100%;
    display: flex;
    flex-direction: column;
  }
}

/* ── Nav: account for hamburger on mobile ────────────────────────────────── */
@media (max-width: 900px) {
  .nav-inner {
    /* hamburger + logo + tag all in a row — already flex; just ensure gap */
    gap: 0.6rem;
  }
}

/* ── Drawer home link (portal mode, pinned above footer) ─────────────────── */
.drawer-home-wrap {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 0.3rem 0;
}
.drawer-home-link {
  color: var(--muted-2);
  transition: background 0.12s, color 0.12s;
}
.drawer-home-link:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.drawer-home-link .demo-title {
  color: inherit;
  font-weight: 500;
}

/* ── Cover mode ──────────────────────────────────────────────────────────── */

/* In cover mode the page scrolls rather than fitting the viewport */
html.cover-mode,
html.cover-mode body {
  height: auto;
  overflow: auto;
}
html.cover-mode body {
  display: block;
}
html.cover-mode .page-body {
  display: block;
}
html.cover-mode main {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: auto;
}
html.cover-mode .chat-section {
  flex: none;
}
html.cover-mode .chat-card {
  flex: none;
}
html.cover-mode .chat-messages {
  min-height: 260px;
  max-height: 380px;
  overflow-y: auto;
}

/* Cover hero */
.cover-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1rem 1.2rem;
  gap: 0.85rem;
  flex-shrink: 0;
}
.cover-logo {
  max-width: 220px;
  width: 100%;
  height: auto;
  display: block;
}
.cover-tagline {
  font-size: 0.92rem;
  color: var(--muted-2);
  line-height: 1.5;
  max-width: 480px;
}

/* Demo cards grid */
.cover-demos {
  flex-shrink: 0;
  padding: 0.5rem 0 1rem;
}
.cover-demos-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.cover-demo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.cover-demo-card:hover:not(.cover-demo-card--disabled) {
  border-color: var(--card-accent, var(--teal));
  background: color-mix(in srgb, var(--card-accent, var(--teal)) 6%, var(--bg-card));
  transform: translateY(-2px);
}
.cover-demo-card--disabled {
  opacity: 0.45;
  cursor: default;
}
.cover-demo-card--link {
  /* external link cards get the same hover as preset cards */
}
.cover-card-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.cover-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.cover-card-tagline {
  font-size: 0.72rem;
  color: var(--muted-2);
  line-height: 1.4;
}
.cover-card-soon {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 0.06rem 0.35rem;
  border-radius: 99px;
  margin-top: 0.1rem;
  align-self: flex-start;
}
.cover-card-ext {
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: auto;
  padding-top: 0.4rem;
}

@media (max-width: 600px) {
  .cover-demos-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.55rem;
  }
  .cover-hero { padding: 1.2rem 1rem 0.8rem; }
}

/* ── Event markers (system event rows in the thread) ────────────────────── */
.event-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  animation: fadeIn 0.2s ease-out;
}
.event-marker-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.68rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.event-marker-icon {
  font-size: 0.7rem;
  flex-shrink: 0;
  opacity: 0.7;
}
.event-marker-line {
  width: 36px;
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}
.event-marker-text {
  white-space: nowrap;
  transition: color 0.15s;
}
.event-marker-row:hover .event-marker-text {
  color: var(--muted-2);
}
.event-marker-verbatim {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 0.7rem;
  color: var(--muted-2);
  line-height: 1.5;
  max-width: 520px;
  width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  animation: fadeIn 0.15s ease-out;
}
.event-marker.expanded .event-marker-verbatim {
  display: block;
}

/* ── No-deliberation settle line ─────────────────────────────────────────── */
.search-activity.done.no-deliberation {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}
.search-activity-no-delib {
  font-size: 0.68rem;
  color: var(--muted);
  font-style: italic;
  padding: 0;
}

/* ── Auto-clear context message ──────────────────────────────────────────── */
#empty-state .empty-context {
  font-size: 0.72rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.15rem;
  animation: fadeIn 0.25s ease-out;
}

/* ── External link SVG icon ──────────────────────────────────────────────── */
.ext-link-icon {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.15s;
}
/* drawer entry */
.demo-ext-icon.ext-link-icon {
  margin-top: 0.25rem;
  align-self: flex-start;
}
/* cover card */
.cover-card-ext-icon {
  display: inline-flex;
  align-items: center;
  align-self: flex-end;
  margin-top: auto;
  padding-top: 0.4rem;
  color: var(--muted);
  transition: color 0.15s;
}
.cover-demo-card:hover .cover-card-ext-icon {
  color: var(--muted-2);
}
.demo-entry:hover .ext-link-icon {
  color: var(--muted-2);
}

/* ── Context-utilization ring gauge ──────────────────────────────────────── */
.ctx-ring-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: default;
  /* sits between input-hint and clear-btn in the input-meta row */
}
/* Muted background track */
.ctx-ring-track {
  stroke: var(--border-hover);
}
/* Progress arc — color is set inline by JS; smooth transition */
.ctx-ring-arc {
  stroke: var(--teal);
  transition: stroke-dashoffset 0.4s ease, stroke 0.3s ease;
}

/* Tooltip for the disabled thinking toggle (hover + tap) */
#thinking-toggle-wrap { position: relative; }
.ctx-ring-wrap { position: relative; cursor: default; }
.ctx-ring-wrap[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-2, #222);
  color: var(--text, #ddd);
  border: 1px solid var(--border, #444);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
  line-height: 1.3;
  width: max-content;
  max-width: 240px;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.ctx-ring-wrap[data-tip]:hover::after,
.ctx-ring-wrap.tip-visible::after {
  opacity: 1;
}

#thinking-toggle-wrap[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-2, #222);
  color: var(--text, #ddd);
  border: 1px solid var(--border, #444);
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
  line-height: 1.3;
  white-space: nowrap;
  max-width: 260px;
  white-space: normal;
  width: max-content;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
#thinking-toggle-wrap[data-tip]:hover::after,
#thinking-toggle-wrap.tip-visible::after {
  opacity: 1;
}
