/* ============================================================
 * Peptide Chats — design system
 * Palette: deep navy ground, soft off-white text, cyan accent,
 * muted indigo secondary. Typography: Inter + JetBrains Mono.
 * ============================================================ */

:root {
  --bg: #0a0e1a;
  --bg-elev: #10172a;
  --panel: #141b2f;
  --panel-2: #1b2338;
  --border: #232c47;
  --border-soft: #1a2238;

  --text: #e8ecf4;
  --text-dim: #c3cad8;
  --muted: #8691a8;
  --faint: #5a6378;

  --accent: #22d3ee;
  --accent-hover: #67e8f9;
  --accent-dim: #0e7490;
  --accent-glow: rgba(34, 211, 238, 0.18);

  --indigo: #818cf8;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;

  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px -8px rgba(0,0,0,0.5);
  --shadow-lg: 0 20px 50px -15px rgba(0,0,0,0.6);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Inter", -apple-system, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Fira Code", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 50% -200px, rgba(34, 211, 238, 0.06), transparent 70%),
    radial-gradient(900px 500px at 100% 110%, rgba(129, 140, 248, 0.05), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(15px, 1.6vw, 16px);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

::selection { background: var(--accent-glow); color: var(--text); }

/* ============ Layout ============ */

.site-header {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  background: rgba(10, 14, 26, 0.72);
  border-bottom: 1px solid var(--border-soft);
}
.site-header .inner {
  max-width: 960px; margin: 0 auto;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex; align-items: center;
  gap: 6px; /* intentional tight gap — mark should feel fused to type */
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 500;
  text-decoration: none;
  line-height: 1;
}
.brand svg {
  width: 22px; height: 22px;
  color: var(--accent);
  flex-shrink: 0;
  transform: translateY(1px); /* optical alignment to x-height */
}
.brand .wordmark {
  font-size: 19px;
  letter-spacing: -0.035em; /* aggressive tracking for custom-wordmark feel */
  font-feature-settings: "ss01" on, "cv11" on;
  display: inline-flex;
  align-items: baseline;
}
.brand .wordmark-dim {
  color: var(--text-dim);
  margin-left: 0.05em;
}
.brand:hover { text-decoration: none; }
.brand:hover svg { color: var(--accent-hover); }

.nav-right { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.nav-right a { color: var(--text-dim); font-weight: 500; }
.nav-right a:hover { color: var(--text); text-decoration: none; }
.counter { color: var(--muted); font-family: var(--font-mono); font-size: 11px; font-weight: 600; padding: 3px 10px; border: 1px solid var(--border); border-radius: var(--radius-pill); letter-spacing: 0.1em; }
.counter.near-limit { color: var(--warn); border-color: rgba(251, 191, 36, 0.3); }
.counter.at-limit { color: var(--err); border-color: rgba(248, 113, 113, 0.3); }
.counter.beta { color: var(--accent); border-color: rgba(34, 211, 238, 0.3); background: rgba(34, 211, 238, 0.05); }

main.chat-main { max-width: 760px; margin: 0 auto; padding: 20px 20px 180px; min-height: calc(100vh - 60px); }

/* ============ Advisory banner ============ */

.advisory {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  background: rgba(129, 140, 248, 0.06);
  border: 1px solid rgba(129, 140, 248, 0.18);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-dim);
  margin-bottom: 20px;
}
.advisory .close-x { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 6px; line-height: 1; }
.advisory .close-x:hover { color: var(--text); }

/* ============ Chat ============ */

.messages { display: flex; flex-direction: column; gap: 18px; margin-bottom: 30px; }

.msg { display: flex; animation: fadein 320ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.msg.user { justify-content: flex-end; }
.msg.bot { justify-content: flex-start; }

.bubble {
  max-width: 92%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.msg.user .bubble {
  background: linear-gradient(135deg, #1d2a4f 0%, #22304f 100%);
  border: 1px solid #2a3a5e;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  color: var(--text);
}
.msg.bot .bubble {
  background: transparent;
  padding-left: 2px;
  color: var(--text);
  max-width: 100%;
}
.msg.bot .bubble p { margin: 0 0 12px; }
.msg.bot .bubble p:last-child { margin-bottom: 0; }

.plain-english {
  margin-top: 16px;
  padding: 14px 16px 12px;
  background: rgba(129, 140, 248, 0.06);
  border-left: 3px solid var(--indigo);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.55;
  animation: fadein 320ms ease;
}
.plain-english-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--indigo);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.plain-english-label::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--indigo);
  border-radius: 50%;
  opacity: 0.8;
}
.plain-english p { margin: 0 0 8px; }
.plain-english p:last-child { margin-bottom: 0; }

/* ============ Numbered inline citations + Sources section ============ */

.cite-sup {
  display: inline-block;
  vertical-align: super;
  font-size: 11px;
  line-height: 1;
  font-family: var(--font-mono);
  font-weight: 600;
  margin: 0 1px 0 2px;
  padding: 0 1px;
}
.cite-sup a {
  color: var(--accent);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 4px;
  display: inline-block;
  min-width: 20px;
  min-height: 20px;
  text-align: center;
  line-height: 16px;
  transition: background-color 160ms ease;
}
.cite-sup a:hover { background: var(--accent-glow); color: var(--accent-hover); text-decoration: none; }
.cite-sep { display: inline-block; width: 1px; }

@media (max-width: 640px) {
  .cite-sup a { min-width: 24px; min-height: 24px; padding: 3px 6px; line-height: 18px; font-size: 11px; }
}

.sources-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.sources-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.sources-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 11px 5px 7px;
  font-size: 12px;
  text-decoration: none !important;
  transition: all 160ms ease;
  min-height: 32px;
}
.source-chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(34, 211, 238, 0.06);
}
.source-chip .source-num {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  background: var(--accent-glow);
  color: var(--accent-hover);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  text-align: center;
  line-height: 16px;
}
.source-chip .source-pmid {
  font-family: var(--font-mono);
  font-size: 12px;
}

.pmid-chip {
  display: inline-block;
  padding: 1px 8px 2px;
  margin: 0 2px;
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent-hover);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none !important;
  white-space: nowrap;
  vertical-align: baseline;
  transition: all 160ms ease;
}
.pmid-chip:hover { background: rgba(34, 211, 238, 0.22); color: #ffffff; border-color: var(--accent); }

/* ============ Thinking state ============ */

.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 6px 0; animation: fadein 240ms ease; }
.thinking .dots { display: inline-flex; gap: 4px; }
.thinking .dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}
.thinking .dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking .dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1.15); }
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideup {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ Empty state ============ */

.empty-state {
  padding: 32px 0 20px;
  animation: fadein 400ms ease;
}
.empty-state .welcome { font-size: clamp(17px, 2.1vw, 19px); line-height: 1.5; color: var(--text); margin-bottom: 14px; }
.empty-state .welcome .accent { color: var(--accent); font-weight: 500; }
.empty-state .hint { font-size: 13px; color: var(--muted); margin-bottom: 20px; text-transform: uppercase; letter-spacing: 0.08em; }
.starter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.starter-chip {
  background: var(--panel);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 160ms ease;
  text-align: left;
}
.starter-chip:hover {
  background: var(--panel-2); color: var(--text);
  border-color: var(--accent-dim); transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ============ Composer ============ */

.composer-wrap {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 20px 20px 20px;
  z-index: 5;
}
.composer {
  max-width: 760px; margin: 0 auto;
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.composer:focus-within { border-color: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-glow); }
.composer textarea {
  flex: 1;
  background: transparent;
  color: var(--text);
  border: 0;
  resize: none;
  outline: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 10px 8px;
  max-height: 200px;
  min-height: 24px;
}
.composer textarea::placeholder { color: var(--faint); }
.btn-send {
  background: var(--accent);
  color: #0a1420;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 160ms ease;
  min-height: 44px;
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.btn-send:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }
.composer-hint { max-width: 760px; margin: 8px auto 0; font-size: 12px; color: var(--faint); text-align: center; }
@media (max-width: 640px) { .composer-hint { display: none; } }

/* ============ Waiver modal ============ */

.waiver-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 15, 0.85);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadein 300ms ease;
}
.waiver {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 540px; width: 100%;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  animation: slideup 380ms cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh; overflow-y: auto;
}
.waiver h2 { margin: 0 0 16px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.waiver ul { padding-left: 20px; margin: 16px 0; color: var(--text-dim); }
.waiver ul li { margin-bottom: 10px; font-size: 14px; line-height: 1.55; }
.waiver p { color: var(--text-dim); font-size: 14px; margin: 0 0 14px; }
.waiver .check-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px; background: var(--panel-2); border-radius: var(--radius-sm);
  margin: 20px 0; cursor: pointer;
}
.waiver .check-row input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }
.waiver .check-row label { font-size: 14px; color: var(--text); cursor: pointer; }
.waiver .btn-primary {
  width: 100%;
  background: var(--accent);
  color: #0a1420;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 14px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 160ms ease;
  min-height: 48px;
}
.waiver .btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.waiver .btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ Paywall ============ */

.paywall-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 8, 15, 0.75);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadein 240ms ease;
}
.paywall {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 440px; width: 100%;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: slideup 380ms cubic-bezier(0.16, 1, 0.3, 1);
}
.paywall h2 { margin: 0 0 10px; font-size: 20px; }
.paywall .big { color: var(--accent); font-size: 32px; font-weight: 700; margin: 10px 0; }
.paywall .small { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.paywall input[type=email] {
  width: 100%; background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font: inherit; margin-bottom: 10px; outline: none;
}
.paywall input[type=email]:focus { border-color: var(--accent-dim); }
.paywall .btn-primary {
  width: 100%; background: var(--accent); color: #0a1420;
  border: 0; border-radius: var(--radius-sm); padding: 12px;
  font: inherit; font-weight: 600; cursor: pointer; min-height: 44px;
}
.paywall .btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.paywall .btn-ghost { background: none; color: var(--muted); border: 0; padding: 10px; font: inherit; cursor: pointer; margin-top: 6px; }
.paywall .btn-ghost:hover { color: var(--text); }
.paywall .success { color: var(--ok); font-size: 14px; margin-top: 10px; }
.paywall .err { color: var(--err); font-size: 13px; margin-top: 6px; }

/* ============ Content pages (about, terms) ============ */

main.content { max-width: 720px; margin: 0 auto; padding: 40px 20px 80px; }
main.content h1 { font-family: var(--font-display); font-size: clamp(28px, 4.2vw, 36px); font-weight: 600; letter-spacing: -0.035em; margin: 0 0 10px; }
main.content h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-top: 36px; margin-bottom: 10px; color: var(--text); }
main.content .lede { font-size: 17px; color: var(--text-dim); margin-bottom: 24px; }
main.content p { color: var(--text-dim); margin: 0 0 14px; }
main.content ul { color: var(--text-dim); padding-left: 22px; }
main.content ul li { margin-bottom: 8px; }
main.content hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
main.content .meta { color: var(--muted); font-size: 13px; margin-top: 40px; }
.back-link { color: var(--muted); font-size: 13px; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ============ Mobile ============ */

@media (max-width: 640px) {
  .site-header .inner { padding: 12px 14px; }
  .nav-right { gap: 10px; }
  .nav-right a { font-size: 13px; }
  main.chat-main { padding: 14px 14px 180px; }
  .composer-wrap { padding: 14px; }
  .waiver, .paywall { padding: 24px 20px; }
  .brand .wordmark { font-size: 15px; }
}
