/* ── 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);
  --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; }
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);
}

/* 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);
}

/* ── 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 {
  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; }

/* 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); }

/* ── 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; }
}
