/* PepTrack — hand-rolled dark UI. No frameworks. */

:root {
  --bg: #09090b;
  --bg-soft: #101013;
  --card: #18181b;
  --border: #27272a;
  --text: #fafafa;
  --muted: #a1a1aa;
  --faint: #71717a;
  --accent: #10b981;
  --accent-hover: #34d399;
  --danger: #ef4444;
  --nav-h: 60px;
  --radius: 12px;
  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.inline-form { display: inline; margin: 0; }
.site-main { min-height: calc(100vh - var(--nav-h)); }

/* ---------- top nav ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: rgba(9, 9, 11, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  /* installed-PWA mode draws under the iOS status bar (black-translucent) */
  height: calc(var(--nav-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
}
body { padding-bottom: env(safe-area-inset-bottom); }
.topnav-inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: .01em;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; color: var(--accent-hover); }
.topnav-links { display: flex; gap: .25rem; flex: 1; }
.topnav-right { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.nav-link {
  color: var(--muted);
  padding: .4rem .7rem;
  border-radius: 8px;
  font-size: .925rem;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
}
.nav-link:hover { color: var(--text); background: var(--card); text-decoration: none; }
.nav-link.active { color: var(--text); background: var(--card); }

/* ---------- flash ---------- */
.flash {
  max-width: 1200px;
  margin: 1rem auto 0;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius);
  transition: opacity .3s ease;
}
.flash.flash-hide { opacity: 0; }
.flash-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: .1rem .35rem;
}
.flash-close:hover { color: var(--text); }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border); margin-top: 4rem; }
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  font-size: .85rem;
  color: var(--faint);
}
.footer-inner p { margin: 0 0 .35rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: .925rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #052e22; }
.btn-primary:hover { background: var(--accent-hover); color: #052e22; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--faint); background: var(--card); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: #fca5a5; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 15%, transparent); }
.btn-sm { padding: .3rem .7rem; font-size: .825rem; border-radius: 8px; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }

/* ---------- badges ---------- */
.badge, .chip {
  display: inline-flex;
  align-items: center;
  padding: .18rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.cat-healing   { background: color-mix(in srgb, #38bdf8 14%, transparent); color: #7dd3fc; border-color: color-mix(in srgb, #38bdf8 30%, transparent); }
.cat-glp1      { background: color-mix(in srgb, #10b981 14%, transparent); color: #6ee7b7; border-color: color-mix(in srgb, #10b981 30%, transparent); }
.cat-gh        { background: color-mix(in srgb, #8b5cf6 16%, transparent); color: #c4b5fd; border-color: color-mix(in srgb, #8b5cf6 32%, transparent); }
.cat-longevity { background: color-mix(in srgb, #f59e0b 14%, transparent); color: #fcd34d; border-color: color-mix(in srgb, #f59e0b 30%, transparent); }
.cat-cognitive { background: color-mix(in srgb, #d946ef 14%, transparent); color: #f0abfc; border-color: color-mix(in srgb, #d946ef 30%, transparent); }
.cat-immune    { background: color-mix(in srgb, #84cc16 14%, transparent); color: #bef264; border-color: color-mix(in srgb, #84cc16 30%, transparent); }
.cat-sexual    { background: color-mix(in srgb, #f43f5e 14%, transparent); color: #fda4af; border-color: color-mix(in srgb, #f43f5e 30%, transparent); }
.cat-cosmetic  { background: color-mix(in srgb, #ec4899 14%, transparent); color: #f9a8d4; border-color: color-mix(in srgb, #ec4899 30%, transparent); }
.cat-fatloss   { background: color-mix(in srgb, #f97316 14%, transparent); color: #fdba74; border-color: color-mix(in srgb, #f97316 30%, transparent); }
.cat-other     { background: color-mix(in srgb, #a1a1aa 14%, transparent); color: #d4d4d8; border-color: color-mix(in srgb, #a1a1aa 30%, transparent); }

.status-active    { background: color-mix(in srgb, #10b981 14%, transparent); color: #6ee7b7; border-color: color-mix(in srgb, #10b981 30%, transparent); }
.status-paused    { background: color-mix(in srgb, #f59e0b 14%, transparent); color: #fcd34d; border-color: color-mix(in srgb, #f59e0b 30%, transparent); }
.status-completed { background: color-mix(in srgb, #38bdf8 14%, transparent); color: #7dd3fc; border-color: color-mix(in srgb, #38bdf8 30%, transparent); }
.status-cancelled { background: color-mix(in srgb, #a1a1aa 14%, transparent); color: #d4d4d8; border-color: color-mix(in srgb, #a1a1aa 30%, transparent); }
.status-planned   { background: color-mix(in srgb, #3b82f6 14%, transparent); color: #93c5fd; border-color: color-mix(in srgb, #3b82f6 30%, transparent); }

.effect-positive { background: color-mix(in srgb, #10b981 14%, transparent); color: #6ee7b7; border-color: color-mix(in srgb, #10b981 30%, transparent); }
.effect-negative { background: color-mix(in srgb, #ef4444 14%, transparent); color: #fca5a5; border-color: color-mix(in srgb, #ef4444 30%, transparent); }
.effect-neutral  { background: color-mix(in srgb, #a1a1aa 14%, transparent); color: #d4d4d8; border-color: color-mix(in srgb, #a1a1aa 30%, transparent); }

.badge-official { background: color-mix(in srgb, var(--accent) 14%, transparent); color: #6ee7b7; border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.badge-diff     { background: var(--bg-soft); color: var(--muted); border-color: var(--border); }
.badge-peptide  { background: var(--bg-soft); color: var(--muted); border-color: var(--border); }
.badge-current  { background: color-mix(in srgb, var(--accent) 18%, transparent); color: #6ee7b7; border-color: color-mix(in srgb, var(--accent) 40%, transparent); margin-left: .5rem; }
.badge-expired  { background: color-mix(in srgb, var(--danger) 14%, transparent); color: #fca5a5; border-color: color-mix(in srgb, var(--danger) 35%, transparent); margin-left: .4rem; }
.badge-expiring { background: color-mix(in srgb, #f59e0b 14%, transparent); color: #fcd34d; border-color: color-mix(in srgb, #f59e0b 35%, transparent); margin-left: .4rem; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* ---------- alerts ---------- */
.alert { padding: .7rem 1rem; border-radius: 10px; margin: 0 0 1rem; font-size: .9rem; }
.alert-error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: #fca5a5;
}
.alert-success {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: #6ee7b7;
}
.form-result { margin-top: 1rem; }
.form-result .alert { margin: 0; }

/* ---------- forms ---------- */
.field { display: block; margin: 0 0 1rem; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="search"],
select, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: .925rem;
  padding: .55rem .75rem;
  transition: border-color .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
}
textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
.form-grid-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.form-hint { font-size: .875rem; }

input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}
.range-out { color: var(--accent-hover); font-weight: 600; margin-left: .4rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--faint);
  font-weight: 600;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
}
.table td { padding: .6rem .75rem; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: color-mix(in srgb, var(--card) 60%, var(--bg-soft)); }
.empty-cell { text-align: center; color: var(--faint); padding: 1.5rem 1rem !important; }
.row-finished td { opacity: .5; }
.actions { text-align: right; }

/* ---------- layout pages ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 2.5rem 1.25rem; }
.page-head { margin-bottom: 1.75rem; }
.page-head h1 { font-size: 1.9rem; }
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-title { font-size: 1.1rem; font-weight: 600; margin-bottom: .25rem; }
.empty-state .btn { margin-top: .75rem; }

/* ---------- landing ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(60% 50% at 70% 20%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}
.hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 5rem 1.25rem 4.5rem;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 3rem;
  align-items: center;
}
.hero-eyebrow {
  color: var(--accent-hover);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.hero-title {
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 1.1rem;
}
.hero-sub { font-size: 1.1rem; color: var(--muted); max-width: 34rem; margin-bottom: 1.75rem; }
.hero-ctas { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 2rem; }
.hero-chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.glass-card {
  background: color-mix(in srgb, var(--card) 72%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid color-mix(in srgb, #ffffff 9%, transparent);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.cycle-mock { transform: rotate(1.2deg); }
.mock-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.mock-title { font-weight: 600; font-size: 1.05rem; }
.mock-dose { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .9rem; }
.mock-dose-value { font-size: 1.9rem; font-weight: 700; color: var(--accent-hover); }
.mock-row {
  display: flex;
  justify-content: space-between;
  padding: .5rem 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  font-size: .9rem;
}
.mock-row:first-of-type { margin-top: .9rem; }
.features { max-width: 1200px; margin: 0 auto; padding: 4.5rem 1.25rem 1rem; }
.section-title { font-size: 1.7rem; text-align: center; margin-bottom: 2.25rem; }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.feature-card { transition: border-color .15s ease, transform .15s ease; }
.feature-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); transform: translateY(-2px); }
.feature-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-hover);
  font-size: 1.1rem;
  margin-bottom: .9rem;
}
.cta-band {
  max-width: 1200px;
  margin: 3rem auto 0;
  padding: 4rem 1.25rem 5rem;
  text-align: center;
}
.cta-band h2 { font-size: 1.9rem; }
.cta-band .btn { margin-top: .75rem; }

/* ---------- auth ---------- */
.auth-wrap {
  min-height: calc(100vh - var(--nav-h) - 120px);
  display: grid;
  place-items: center;
  padding: 3rem 1.25rem;
}
.auth-card { width: 100%; max-width: 400px; padding: 2rem; }
.auth-card h1 { font-size: 1.4rem; }
.auth-alt { text-align: center; margin: 1rem 0 0; font-size: .9rem; }

/* ---------- library ---------- */
.filter-bar { display: flex; gap: .75rem; margin-bottom: 1.5rem; }
.filter-bar input[type="search"] { flex: 1; }
.filter-bar select { width: auto; min-width: 200px; }
.peptide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.peptide-card { display: block; color: var(--text); transition: border-color .15s ease, transform .15s ease; }
.peptide-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 40%, transparent); transform: translateY(-2px); }
.peptide-card-top { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .8rem; }
.peptide-halflife { font-size: .8rem; }
.peptide-card h3 { margin-bottom: .35rem; }
.peptide-card p { margin: 0; font-size: .875rem; }

/* ---------- peptide detail ---------- */
.breadcrumb { font-size: .85rem; margin-bottom: 1.5rem; display: flex; gap: .5rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 2rem; align-items: start; }
.detail-hero { margin-bottom: 1.5rem; }
.detail-hero h1 { font-size: 2.2rem; margin: .6rem 0 .4rem; }
.detail-meta { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .925rem; }
.detail-section { margin-bottom: 2rem; }
.detail-section h2 { font-size: 1.25rem; margin-bottom: .75rem; }
.callout {
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  margin-bottom: 1.5rem;
  font-size: .9rem;
}
.callout-warning {
  background: color-mix(in srgb, #f59e0b 10%, transparent);
  border: 1px solid color-mix(in srgb, #f59e0b 35%, transparent);
  color: #fcd34d;
}
.sticky { position: sticky; top: calc(var(--nav-h) + 1.5rem); }
.side-title { margin-bottom: 1rem; }
.fact-list { margin: 0 0 1.25rem; }
.fact-list > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .5rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  font-size: .875rem;
}
.fact-list > div:last-child { border-bottom: none; }
.fact-list dt { color: var(--faint); }
.fact-list dd { margin: 0; text-align: right; }
.side-note { font-size: .8rem; text-align: center; margin: .6rem 0 0; }
.protocol-card { margin-bottom: 1rem; }
.protocol-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.protocol-badges { display: flex; gap: .4rem; }
.protocol-goal { font-size: .875rem; color: var(--accent-hover); }
.stack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.stack-card { display: block; color: var(--text); transition: border-color .15s ease; }
.stack-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.stack-synergy { font-size: .875rem; color: var(--muted); margin-bottom: .4rem; }
.stack-caution { font-size: .8rem; color: #fcd34d; margin: 0; }

/* ---------- timeline ---------- */
.timeline { position: relative; margin-top: 1rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
}
.timeline-step { position: relative; padding: 0 0 1.25rem 1.75rem; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: 0;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--faint);
}
.timeline-step.current .timeline-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent);
}
.timeline-step.current .timeline-title { color: var(--accent-hover); }
.timeline-title { font-weight: 600; font-size: .95rem; }
.timeline-weeks { font-weight: 400; font-size: .85rem; margin-left: .35rem; }
.timeline-dose { color: var(--text); font-size: .9rem; margin: .15rem 0; }
.timeline-notes { font-size: .85rem; }

/* ---------- app shell ---------- */
.app-shell { display: grid; grid-template-columns: 240px 1fr; align-items: start; }
.app-sidebar {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.app-nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.app-nav a {
  color: var(--muted);
  padding: .5rem .75rem;
  border-radius: 9px;
  font-size: .925rem;
}
.app-nav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
.app-nav a.active {
  color: var(--text);
  background: var(--card);
  box-shadow: inset 2px 0 0 var(--accent);
}
.app-sidebar-bottom { display: grid; gap: .6rem; }
.sidebar-user {
  font-size: .9rem;
  font-weight: 600;
  padding: 0 .25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-main { padding: 2rem 2rem 3rem; max-width: 1080px; width: 100%; min-width: 0; }
.app-main .card { margin-bottom: 1.25rem; }
.app-head { margin-bottom: 1.5rem; }
.app-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }

/* ---------- dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { text-align: left; margin-bottom: 0 !important; }
.stat-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; }
.stat-label { color: var(--faint); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.today-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .8rem 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.today-row:first-of-type { border-top: none; padding-top: .25rem; }
.today-line { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.today-name { color: var(--text); font-weight: 600; }
.today-step { font-size: .875rem; margin-top: .15rem; }
.chart { display: flex; gap: 6px; height: 150px; margin-top: .5rem; }
.chart-col { flex: 1; display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.chart-bar-wrap { flex: 1; display: flex; align-items: flex-end; }
.chart-bar {
  width: 100%;
  min-height: 3px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
  opacity: .9;
}
.chart-label {
  font-size: .62rem;
  color: var(--faint);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}

/* ---------- two-column app pages ---------- */
.two-col { display: grid; grid-template-columns: 1.05fr .95fr; gap: 1.25rem; align-items: start; }
.side-col > .card { margin-bottom: 1.25rem; }
.calc-out { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .25rem; }
.calc-row { display: flex; justify-content: space-between; padding: .5rem 0; font-size: .925rem; }
.calc-row strong { color: var(--accent-hover); }

/* ---------- cycles ---------- */
.cycle-list { display: grid; gap: .75rem; }
.cycle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text);
  margin-bottom: 0 !important;
  transition: border-color .15s ease;
}
.cycle-row:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.cycle-main { flex: 1; min-width: 0; }
.cycle-title-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .2rem; }
.cycle-title { font-weight: 600; font-size: 1.02rem; }
.cycle-sub { font-size: .85rem; margin-bottom: .5rem; }
.cycle-chevron { color: var(--faint); font-size: 1.4rem; }
.progress { height: 7px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width .3s ease;
}
.progress-card .progress-head { display: flex; justify-content: space-between; font-size: .875rem; margin-bottom: .6rem; }
.status-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.cycle-goal, .cycle-notes { font-size: .9rem; }

/* ---------- cycle_new custom steps ---------- */
.custom-steps {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.step-row {
  display: grid;
  grid-template-columns: 1fr .7fr .55fr .7fr 1fr auto;
  gap: .5rem;
  align-items: end;
  margin-bottom: .6rem;
}
.step-row input,
.step-row select { padding: .45rem .6rem; font-size: .85rem; }
.step-row .step-label { display: block; font-size: .7rem; color: var(--faint); margin-bottom: .25rem; }
.step-remove { padding: .45rem .6rem; }
#protocol-preview .preview-step {
  padding: .55rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  font-size: .875rem;
}
#protocol-preview .preview-step:last-child { border-bottom: none; }
#protocol-preview .preview-meta { margin-bottom: .75rem; }

/* ---------- effects ---------- */
.effect-list { display: grid; gap: .75rem; }
.effect-row { margin-bottom: 0 !important; }
.effect-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.effect-date { font-size: .825rem; margin-left: auto; }
.severity { font-size: .8rem; letter-spacing: .05em; }
.severity-1 { color: #fcd34d; }
.severity-2 { color: #fdba74; }
.severity-3 { color: #fca5a5; }
.effect-desc { margin: .6rem 0 0; }
.effect-dose { font-size: .825rem; margin: .4rem 0 0; }

/* ---------- settings ---------- */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.profile-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.days-pills { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pill { position: relative; cursor: pointer; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: inline-flex;
  padding: .35rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: .825rem;
  transition: all .12s ease;
}
.pill input:checked + span {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  color: #6ee7b7;
}
.pill:hover span { border-color: var(--faint); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-inner { grid-template-columns: 1fr; padding-top: 3.5rem; }
  .cycle-mock { transform: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .two-col { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .app-nav { flex-direction: row; gap: .25rem; }
  .app-nav a { white-space: nowrap; }
  .app-nav a.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .app-sidebar-bottom { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
  .app-sidebar-bottom .btn-block { width: auto; }
  .app-main { padding: 1.5rem 1rem 3rem; }
}
@media (max-width: 640px) {
  .features-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .filter-bar { flex-direction: column; }
  .filter-bar select { width: 100%; }
  .step-row { grid-template-columns: 1fr 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .topnav-inner { gap: .75rem; padding: 0 .75rem; }
  .app-head-row { flex-direction: column; }
}

/* ---------- blends ---------- */
.blend-row {
  display: grid;
  grid-template-columns: 1fr .8fr auto;
  gap: .5rem;
  margin-bottom: .5rem;
  align-items: center;
}
.blend-row select,
.blend-row input { padding: .45rem .6rem; font-size: .85rem; }
.blend-badge {
  display: inline-block; margin-left: .4rem; padding: .05rem .4rem;
  border-radius: .35rem; font-size: .65rem; letter-spacing: .04em;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
}
.dose-split { font-size: .75rem; }
@media (max-width: 640px) {
  .blend-row { grid-template-columns: 1fr auto; }
}

/* ---------- assistant ----------
   Reads as a lab readout, not a chat clone: the user's words are contained,
   the assistant's are flush against a hairline with a provenance strip
   showing which of your records it actually opened. */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }

.chat-page { display: flex; flex-direction: column; min-height: 26rem; }
/* Above the shell's mobile breakpoint the sidebar is fixed-height, so the chat
   column can claim exactly the space left under the sticky topnav — the
   transcript then scrolls on its own and the composer never leaves the screen.
   Below it the sidebar becomes a stacked bar of unknown height, so the page
   scrolls normally instead. (--nav-h topnav + .app-main 2rem/3rem padding.) */
@media (min-width: 901px) {
  .chat-page { height: calc(100vh - var(--nav-h) - 5rem); }
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-bottom: .9rem; border-bottom: 1px solid var(--border);
}
.chat-head-title { display: flex; align-items: baseline; gap: .6rem; }
.chat-head-title h1 { font-size: 1.35rem; margin: 0; }
.chat-model {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .68rem; color: var(--faint); letter-spacing: .02em;
  padding: .1rem .4rem; border: 1px solid var(--border); border-radius: 5px;
}
.chat-head-actions { display: flex; align-items: center; gap: .5rem; }

/* History as a disclosure, so the transcript keeps the full width. */
.chat-history { position: relative; }
.chat-history summary { list-style: none; cursor: pointer; }
.chat-history summary::-webkit-details-marker { display: none; }
.chat-history[open] summary { border-color: var(--faint); }
.chat-list {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 30;
  width: 17rem; max-height: 20rem; overflow-y: auto;
  list-style: none; margin: 0; padding: .3rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.chat-list-item { display: flex; align-items: center; border-radius: 6px; }
.chat-list-item a {
  flex: 1; min-width: 0; padding: .45rem .55rem; color: var(--muted); font-size: .84rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-list-item:hover { background: var(--bg-soft); }
.chat-list-item:hover a { color: var(--text); text-decoration: none; }
.chat-list-item.active a { color: var(--accent-hover); }
.btn-icon {
  background: none; border: 0; color: var(--faint); cursor: pointer;
  padding: .2rem .45rem; font-size: 1rem; line-height: 1; border-radius: 5px;
}
.btn-icon:hover { color: #fca5a5; }

/* ---- transcript ---- */
.chat-scroll { flex: 1; overflow-y: auto; padding: 1.5rem 0 .5rem; scrollbar-width: thin; }
.chat-transcript { display: flex; flex-direction: column; gap: 1.6rem; max-width: 46rem; }

.turn { animation: turn-in .28s ease both; }
@keyframes turn-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .turn { animation: none; } }

.turn-body { line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }

/* User: contained, right, tinted — clearly "your words". */
.turn-user { align-self: flex-end; max-width: 82%; }
.turn-user .turn-body {
  padding: .65rem .9rem; border-radius: 12px 12px 3px 12px;
  background: color-mix(in srgb, var(--accent) 13%, var(--card));
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
}

/* Assistant: flush, open, marked with the app's hexagon. */
.turn-assistant { display: grid; grid-template-columns: 1.5rem 1fr; gap: .85rem; }
.turn-mark { color: var(--accent); font-size: .95rem; line-height: 1.7; text-align: center; }
.turn-mark-error { color: var(--danger); }
.turn-main { min-width: 0; }
.turn-error { color: #fca5a5; }

/* Provenance: which records were opened to answer. */
.turn-sources { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-bottom: .5rem; }
.turn-sources-label {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint); margin-right: .1rem;
}
.turn-source {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .68rem; color: var(--muted);
  padding: .1rem .4rem; border-radius: 4px;
  background: var(--bg-soft); border: 1px solid var(--border);
}

/* ---- empty state ---- */
.chat-intro { margin: auto 0; padding: 2rem 0; max-width: 34rem; }
.chat-intro-mark { font-size: 2rem; color: var(--accent); margin-bottom: .6rem; }
.chat-intro-lead { font-size: 1.15rem; font-weight: 600; margin: 0 0 .2rem; }
.chat-intro-sub { font-size: .9rem; margin-bottom: 1.1rem; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: .45rem; }
.chat-suggest {
  font-family: inherit; font-size: .84rem; color: var(--muted); cursor: pointer;
  padding: .4rem .75rem; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border);
  transition: color .15s ease, border-color .15s ease, transform .15s ease;
}
.chat-suggest:hover {
  color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transform: translateY(-1px);
}

/* ---- composer ---- */
.chat-composer { padding: .5rem 0 .25rem; background: var(--bg); }
.chat-composer-inner {
  display: flex; align-items: flex-end; gap: .5rem;
  max-width: 46rem; padding: .5rem .5rem .5rem .9rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.chat-composer-inner:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.chat-composer textarea {
  flex: 1; border: 0; background: none; color: var(--text);
  font-family: inherit; line-height: 1.5;
  /* 16px minimum: iOS Safari zooms the viewport when focusing a smaller input. */
  font-size: 1rem;
  padding: .45rem 0; resize: none; max-height: 11rem; outline: none;
}
.chat-composer textarea::placeholder { color: var(--faint); }
.chat-send {
  flex: none; width: 2.1rem; height: 2.1rem; border-radius: 9px; border: 0;
  background: var(--accent); color: #052e22; font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: background .15s ease, opacity .15s ease;
}
.chat-send:hover { background: var(--accent-hover); }
.chat-send:disabled { opacity: .45; cursor: default; }

.chat-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 46rem; padding: .45rem .2rem 0;
  font-size: .72rem; color: var(--faint);
}
.chat-legal { margin-left: auto; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.chat-pending { align-items: center; gap: .3rem; color: var(--accent-hover); }
.chat-dot {
  width: 4px; height: 4px; border-radius: 50%; background: currentColor;
  animation: chat-pulse 1.1s ease-in-out infinite;
}
.chat-dot:nth-child(2) { animation-delay: .16s; }
.chat-dot:nth-child(3) { animation-delay: .32s; margin-right: .25rem; }
@keyframes chat-pulse { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-dot { animation: none; opacity: .7; } }

@media (max-width: 720px) {
  .turn-user { max-width: 92%; }
  .turn-assistant { grid-template-columns: 1.1rem 1fr; gap: .6rem; }
  .chat-list { width: min(17rem, calc(100vw - 3rem)); }
}

/* rendered markdown inside assistant turns */
.turn-body.md { white-space: normal; }
.turn-body.md > :first-child { margin-top: 0; }
.turn-body.md > :last-child { margin-bottom: 0; }
.turn-body.md p { margin: 0 0 .7rem; }
.turn-body.md ul, .turn-body.md ol { margin: 0 0 .7rem; padding-left: 1.15rem; }
.turn-body.md li { margin-bottom: .25rem; }
.turn-body.md li::marker { color: var(--faint); }
.turn-body.md strong { color: #fff; font-weight: 600; }
.turn-body.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 4px; padding: .05rem .3rem;
}
.turn-body.md .md-head { font-weight: 600; color: var(--text); margin-bottom: .3rem; }
