:root {
  --bg: #07080b;
  --bg-grain: #0a0c11;
  --panel: #0f1218;
  --panel-raised: #141823;
  --panel-inset: #0a0d13;
  --border: #1f2532;
  --border-strong: #2a3142;
  --text: #e8eef7;
  --muted: #7e8798;
  --dim: #5a6273;
  --accent: #a8ffda;
  --accent-glow: rgba(168, 255, 218, 0.18);
  --accent-dim: #5bd4a4;
  --blue: #7ab8ff;
  --rose: #ff9cb0;
  --amber: #ffd27a;
  --danger: #ff7b7b;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 20px 60px -20px rgba(0, 0, 0, 0.6);
}

/* Use system fonts — zero third-party network calls, zero SRI concerns,
   excellent rendering on all modern OSes. The --sans stack below covers
   macOS (San Francisco via BlinkMacSystemFont), iOS, Windows (Segoe UI),
   Linux (Roboto / generic sans-serif). */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 85% -20%, rgba(168, 255, 218, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(122, 184, 255, 0.05), transparent 60%),
    var(--bg);
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.04 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.6;
  mix-blend-mode: screen;
}

body > * { position: relative; z-index: 1; }

::selection { background: var(--accent); color: #04140e; }

/* Keyboard-focus ring — keeps keyboard users oriented without bothering
   mouse users (who don't trigger :focus-visible). */
button:focus-visible,
a:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 5px;
}
/* Composer already has its own :focus-within ring; don't double up. */
.composer textarea:focus-visible { outline: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1a2030; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #2a3144; background-clip: content-box; }

/* ===== TOPBAR ===== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 18, 24, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--blue) 100%);
  position: relative;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 6px 18px -6px var(--accent-glow);
  flex-shrink: 0;
}

.mark::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  background: var(--bg);
  clip-path: polygon(0 40%, 40% 40%, 40% 0, 60% 0, 60% 40%, 100% 40%, 100% 60%, 60% 60%, 60% 100%, 40% 100%, 40% 60%, 0 60%);
  opacity: 0.92;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.15;
}

.brand-title em { font-style: normal; color: var(--accent); }

.brand-sub {
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--mono);
  font-weight: 500;
}

.field select,
.field input {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--panel-inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-width: 170px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.field select:hover { border-color: var(--border-strong); }
.field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:hover { background: #1b2130; border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #04130d;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset, 0 6px 20px -8px var(--accent-glow);
}

.btn.primary:hover { filter: brightness(1.08); }

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-raised); }

/* ===== MAIN ===== */

main.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 24px 20px;
  gap: 18px;
  min-height: 0;
}

.thanks {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(168, 255, 218, 0.12), rgba(122, 184, 255, 0.06));
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.01em;
}

/* ===== HERO / EMPTY STATE ===== */

.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  padding: 14px 2px 8px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(28px, 4.4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--text);
}

.hero h1 .accent {
  background: linear-gradient(90deg, var(--accent), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  color: var(--muted);
  font-size: 15px;
  max-width: 560px;
}

.hero-sub code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--panel-inset);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent);
}

.pool-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 2px 0 2px 0;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.pool-stats b {
  color: var(--accent);
  font-weight: 700;
}

.pool-stats .pool-label {
  color: var(--dim);
  margin-left: 6px;
  letter-spacing: 0.02em;
}

.pool-stats a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
}
.pool-stats a:hover { border-bottom-color: var(--blue); }

.pool-stats .pool-sep {
  color: var(--border-strong);
  font-weight: 300;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.suggestion {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  line-height: 1.4;
}

.suggestion small {
  display: block;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.suggestion:hover { border-color: var(--accent); background: var(--panel-raised); }
.suggestion:active { transform: translateY(1px); }

/* ===== MESSAGES ===== */

.messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 4px 2px 8px;
}

.msg { display: flex; flex-direction: column; gap: 6px; }

.msg .role {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg .role::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dim);
}

.msg.user .role::before { background: var(--blue); }
.msg.assistant .role::before { background: var(--accent); }

.msg .bubble {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 14.5px;
  line-height: 1.6;
  position: relative;
}

.msg.user .bubble {
  background: linear-gradient(180deg, #162135 0%, #111a2a 100%);
  border-color: #233352;
}

.msg.assistant .bubble {
  background: var(--panel);
  border-color: var(--border);
}

.msg.error .bubble {
  background: #1f1011;
  border-color: #4a1f22;
  color: var(--danger);
}

.msg pre {
  background: var(--panel-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  margin: 10px 0;
}

.msg code {
  font-family: var(--mono);
  font-size: 12.8px;
  background: var(--panel-inset);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.msg pre code { background: transparent; padding: 0; border: 0; }

.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--panel-inset);
  color: var(--muted);
  border: 1px solid var(--border);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.msg-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  flex-wrap: wrap;
}

.msg-actions-hover {
  opacity: 0.35;
  transition: opacity 0.15s;
}
.msg:hover .msg-actions-hover,
.msg-actions-hover:focus-within { opacity: 1; }

.msg-action.copied {
  color: var(--accent);
  border-color: var(--accent);
}

.msg-action {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.msg-action:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--panel);
}

.msg-tried {
  color: var(--dim);
  margin-left: auto;
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

/* Markdown rendering inside assistant bubbles */

.msg.assistant .bubble .md-p {
  margin: 0 0 12px 0;
  white-space: pre-wrap;
}
.msg.assistant .bubble .md-p:last-child { margin-bottom: 0; }

.msg.assistant .bubble .md-h {
  margin: 14px 0 8px 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.msg.assistant .bubble .md-h:first-child { margin-top: 0; }

.msg.assistant .bubble .md-list {
  margin: 0 0 12px 0;
  padding-left: 22px;
}

.msg.assistant .bubble .md-list li {
  margin-bottom: 4px;
}

.msg.assistant .bubble :not(pre) > code {
  font-family: var(--mono);
  font-size: 12.8px;
  background: var(--panel-inset);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.msg.assistant .bubble a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: rgba(122, 184, 255, 0.4);
  text-underline-offset: 2px;
}
.msg.assistant .bubble a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.msg.assistant .bubble strong { color: var(--text); }
.msg.assistant .bubble em { color: var(--muted); font-style: italic; }

.mdcode {
  background: var(--panel-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 10px 0;
  overflow: hidden;
}

.mdcode-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: #0b0e14;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10.5px;
}

.mdcode-lang {
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.mdcode-copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.mdcode-copy:hover { color: var(--accent); border-color: var(--accent); }
.mdcode-copy.copied { color: var(--accent); border-color: var(--accent); }

.mdcode pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.8px;
  line-height: 1.55;
}

.mdcode pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
}

/* ===== STATUS + THINKING DOTS ===== */

.status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status.err { color: var(--danger); }
.status.ok { color: var(--accent-dim); }

.dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: bounce 1.2s infinite;
}
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.cursor::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 1.1em;
  vertical-align: -2px;
  background: var(--accent);
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
  border-radius: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Bubble state while the model is emitting reasoning tokens (pre-content). */
.msg.assistant .bubble.thinking {
  color: var(--muted);
  font-style: italic;
  font-family: var(--mono);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.msg.assistant .bubble.thinking::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinking-pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes thinking-pulse {
  0%, 100% { transform: scale(0.6); opacity: 0.4; }
  50%      { transform: scale(1); opacity: 1; }
}

/* ===== COMPOSER ===== */

.composer {
  display: flex;
  gap: 10px;
  align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 10px 10px 14px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow);
}

.composer textarea {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  outline: none;
  padding: 8px 4px;
  line-height: 1.5;
}

.composer textarea::placeholder { color: var(--dim); }

.composer .btn.primary { align-self: stretch; padding: 0 20px; }

/* ===== FOOTER ===== */

.foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: rgba(15, 18, 24, 0.6);
  backdrop-filter: blur(14px);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.foot a { color: var(--blue); text-decoration: none; border-bottom: 1px dashed transparent; transition: border-color 0.15s, color 0.15s; }
.foot a:hover { border-bottom-color: var(--blue); color: var(--accent); }

.donate-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.donate-btn {
  display: inline-block;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--accent) !important;
  background: var(--panel-inset);
  font-family: var(--mono);
  font-size: 11.5px;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  border-bottom: 1px solid var(--border) !important;
}

.donate-btn:hover { background: var(--panel-raised); border-color: var(--accent) !important; transform: translateY(-1px); }
.donate-btn.primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dim) 100%) !important;
  color: #04130d !important;
  border-color: transparent !important;
  font-weight: 600;
}
.donate-btn.primary:hover { filter: brightness(1.08); }

/* ===== API DRAWER ===== */

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -30px 0 60px -30px rgba(0, 0, 0, 0.8);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 99;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.drawer-head .muted {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.drawer-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all 0.15s;
}
.drawer-close:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-raised); }

.drawer-body {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.api-lede {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.endpoint {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.endpoint-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.method {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  letter-spacing: 0.06em;
}
.method.get { background: rgba(122, 184, 255, 0.14); color: var(--blue); border: 1px solid rgba(122, 184, 255, 0.35); }
.method.post { background: rgba(168, 255, 218, 0.12); color: var(--accent); border: 1px solid rgba(168, 255, 218, 0.35); }
.method.npm { background: rgba(255, 210, 122, 0.12); color: var(--amber); border: 1px solid rgba(255, 210, 122, 0.35); }

.endpoint-url {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
  background: var(--panel-inset);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 4px;
  flex: 1;
  min-width: 0;
}

.endpoint-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}

.tab {
  background: transparent;
  color: var(--muted);
  border: none;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover:not(.active) { color: var(--text); }

.code-block {
  position: relative;
  background: var(--panel-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0;
}

.code-block pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
}

.code-block pre .kw { color: var(--rose); }
.code-block pre .str { color: var(--accent); }
.code-block pre .cmt { color: var(--dim); font-style: italic; }
.code-block pre .fn { color: var(--blue); }

.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, border-color 0.15s, color 0.15s;
}

.code-block:hover .copy,
.code-block:focus-within .copy { opacity: 1; }

.copy:hover { color: var(--accent); border-color: var(--accent); }
.copy.copied { color: var(--accent); border-color: var(--accent); }

/* ===== MOBILE ===== */

@media (max-width: 700px) {
  .topbar { padding: 10px 14px; gap: 12px; }
  .brand-sub { display: none; }
  .controls { gap: 8px; }
  .field select { min-width: 130px; font-size: 12px; }
  main.chat { padding: 18px 14px 14px; gap: 14px; }
  .hero h1 { font-size: 26px; }
  .foot { padding: 12px 14px; font-size: 10.5px; }
  .drawer { width: 100%; }

  /* Tap-target sizing: 44px min for comfortable thumb taps per Apple HIG.
     Don't apply to msg-action (those live behind hover and are secondary). */
  .btn { min-height: 40px; padding: 10px 14px; }
  .btn.primary { padding: 0 18px; }
  .donate-btn { padding: 9px 14px; font-size: 12.5px; }
  .suggestion { padding: 14px; }

  /* Composer textarea + send button grow on mobile for comfort. */
  .composer { padding: 8px; border-radius: 12px; }
  .composer textarea { font-size: 16px; /* >=16px prevents iOS zoom on focus */ }

  /* Pool stats strip — stack vertically instead of flex-wrapping awkwardly. */
  .pool-stats { flex-direction: column; align-items: flex-start; gap: 4px; }
  .pool-stats .pool-sep { display: none; }

  /* API drawer tabs: allow horizontal scroll when many provider tabs are shown. */
  .tabs { overflow-x: auto; scrollbar-width: thin; }

  /* Code blocks in assistant bubbles get more internal room. */
  .mdcode pre { padding: 10px 12px; font-size: 12.5px; }
}

/* Reduce motion — respect the OS-level preference. */
@media (prefers-reduced-motion: reduce) {
  .drawer { transition: none; }
  .drawer-scrim { transition: none; }
  .msg-actions-hover { transition: none; opacity: 1; }
  .dots span { animation: none; opacity: 0.7; }
  .cursor::after { animation: none; }
  .msg.assistant .bubble.thinking::before { animation: none; opacity: 1; transform: scale(1); }
}
