:root {
  --bg: #0f1216;
  --panel: #1a1f26;
  --border: #2a313b;
  --text: #e8ebef;
  --muted: #9aa4b2;
  --accent: #5b8cff;
  --danger: #e15b5b;
  --none: #3a4048;
  --mild: #4f7a3f;
  --moderate: #a9822f;
  --severe: #a13f3f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }
.login-body { position: relative; overflow-x: hidden; min-height: 100vh; }
.login-bg {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 140vw;
  height: 140vw;
  max-width: 900px;
  max-height: 900px;
  transform: translate(-50%, -50%);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.12;
  z-index: 0;
  pointer-events: none;
}
.wrap.narrow { max-width: 380px; padding-top: 60px; text-align: center; position: relative; z-index: 1; }
.logo { display: block; margin: 0 auto 8px; border-radius: 50%; }
.wrap.narrow form { text-align: left; }

h1 { font-size: 1.4rem; margin: 0; }
.tagline { color: var(--muted); font-size: 0.9rem; margin: 4px 0 20px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { border-radius: 50%; }

.btn, button[type="submit"] {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
}
.btn-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.btn-link:hover { color: var(--text); }
.btn-danger { background: var(--danger); margin-left: 10px; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-date { color: var(--muted); font-size: 0.9rem; }
.badge { background: var(--accent); color: white; font-size: 0.8rem; padding: 3px 9px; border-radius: 999px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tag { font-size: 0.78rem; padding: 3px 8px; border-radius: 999px; background: var(--none); color: #fff; }

/* Analysis page period selector (Ward, Aug 2026 — "the user will need
   to be able to select the period"). Pill-link row, same shape as .tag
   but interactive/clickable with a clear active state. */
.period-selector { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.period-chip {
  font-size: 0.82rem;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
}
.period-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.lvl-mild { background: var(--mild); }
.lvl-moderate { background: var(--moderate); }
.lvl-severe { background: var(--severe); }
.card-trigger { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }

form.incident-form, form { display: flex; flex-direction: column; gap: 16px; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
legend { padding: 0 6px; color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 10px;
}
label:last-child { margin-bottom: 0; }

input, select, textarea {
  background: #0d1015;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 1rem;
  font-family: inherit;
}
textarea { resize: vertical; }

.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 560px) {
  .grid3 { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
}

.form-actions { display: flex; align-items: center; padding-bottom: 20px; }

.error { color: var(--danger); }
.notice { color: var(--accent); }
.notice-warning { color: var(--moderate); font-size: 0.9rem; }

.founders { display: flex; flex-wrap: wrap; gap: 20px; }
.founder-card { flex: 1 1 180px; text-align: center; }
.founder-photo { width: 110px; height: 110px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); background: var(--panel); cursor: pointer; transition: border-color 0.15s; }
.founder-photo:hover, .founder-photo:focus-visible { border-color: var(--accent); outline: none; }
.founder-card h4 { margin: 10px 0 4px; }
.founder-bio { margin-top: 18px; }
.founder-bio h5 { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 6px; }
.founder-bio p { line-height: 1.6; }
.notice-success {
  background: rgba(79, 122, 63, 0.2);
  border: 1px solid var(--mild);
  color: #b8e6a8;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 500;
}
.add-another-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }

/* ---------- Section nav ---------- */
.mainnav {
  display: flex;
  gap: 10px; /* wider than a text-link nav needs — most of these are now
                32x32 icon tap targets (Ward, Aug 2026: "space out"
                for mobile), and 4px between them was too tight to tap
                reliably on a phone. */
  overflow-x: auto;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
}
.mainnav.subnav {
  margin-top: -14px;
  margin-bottom: 18px;
  padding-left: 4px;
  font-size: 0.92rem;
  opacity: 0.9;
}
.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 8px 12px;
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
}
.nav-link.active { color: var(--text); background: var(--panel); border-bottom: 2px solid var(--accent); }
.nav-link.logout { margin-left: auto; }
/* Icon nav tabs (Ward, Aug 2026 — "turn all the other tabs into icons
   where we can... 32x32 would be a decent size") — emoji rather than
   custom SVG, matching the attention bell (🔔) already used this way in
   this same nav. Icon-only, no visible label — title/aria-label carry
   the name for a hover tooltip and for screen readers. Composes with the
   existing .nav-link/.nav-link.active rules above (color/background/
   active border-bottom all still apply) rather than replacing them. */
.nav-link.icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}
/* wherewhen's own tab uses an image (its logo), not an emoji glyph like
   the others here — a small round softens its solid-background square
   (Ward's Aug 2026 minimalist redesign, same full-bleed-badge treatment
   as the app's own icon-192.png) instead of a hard-edged block sitting
   among otherwise-transparent icons. */
.nav-link.icon img {
  border-radius: 6px;
}

/* ---------- Dashboard hub ---------- */
.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}
@media (max-width: 560px) {
  .hub-grid { grid-template-columns: 1fr; }
}
.hub-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
}
.hub-card h2 { font-size: 1.05rem; margin: 6px 0 4px; }
.hub-card p { color: var(--muted); font-size: 0.85rem; margin: 0; line-height: 1.4; }
.hub-card-top { display: flex; justify-content: space-between; align-items: center; }
.hub-icon { font-size: 1.3rem; }
.hub-count { color: var(--muted); font-size: 0.85rem; }
.section-label { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 12px; }

.analysis-grid {
  /* Single column, not 2-up (Fulgrim, PLAN.md §11 chart rendering,
     Aug 2026) — this grid was 2-column when every card just held a
     placeholder line; real charts/tables need the container's full
     width to be legible, so it switched to one full-width card per row. */
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 28px;
}
.analysis-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.analysis-card h2 { font-size: 1.05rem; margin: 6px 0 4px; }
.analysis-card p { color: var(--muted); font-size: 0.85rem; margin: 0 0 6px; line-height: 1.4; }
.analysis-card-top { display: flex; justify-content: space-between; align-items: center; }

/* section tag colors, distinct from severity tags */
.tag-incident { background: #7a3f4f; }
.tag-daily { background: #3f6a7a; }
.tag-therapy { background: #5f4f8a; }
.tag-cardiac { background: #b03a3a; }
.tag-medical { background: #3f7a5f; }

.btn-cardiac { background: #b03a3a; }
.btn-medical { background: #3f7a5f; }

.cat-anxiety:has(input:checked) { background: #7a3f4f; }
.cat-cardiac:has(input:checked) { background: #b03a3a; }
.cat-medical:has(input:checked) { background: #3f7a5f; }

.med-change-list { margin: 0 0 10px; padding-left: 18px; color: var(--text); font-size: 0.9rem; }
.med-change-list li { margin-bottom: 4px; }

.day-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.85rem; }
.day-table th, .day-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.day-table th { color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- 7-day summary ---------- */
.week-summary { display: flex; flex-direction: column; gap: 8px; margin-bottom: 28px; }
.week-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}
.week-date { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 6px; }
.week-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  font-size: 0.95rem;
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: white;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
}
.pill-good { background: var(--mild); }
.pill-bad { background: var(--severe); }
.pill-neutral { background: var(--moderate); }
.pill-zero { background: #000; color: #fff; border: 1px solid #444; }
.pill-som-unset { background: var(--none); }
.pill-som-1 { background: #a13f3f; }
.pill-som-2 { background: #b06a4f; }
.pill-som-3 { background: #a9822f; }
.pill-som-4 { background: #7a9a4f; }
.pill-som-5 { background: #4f7a3f; }
.week-pills + .week-pills { margin-top: 6px; }

/* ---------- Medication checklist ---------- */
.med-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.med-item { font-size: 0.9rem; }

/* ---------- State of mind scale ---------- */
.som-scale { display: flex; flex-wrap: wrap; gap: 6px; }
.som-option {
  flex: 1 1 auto;
  min-width: 90px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0;
}
.som-option input { position: absolute; opacity: 0; pointer-events: none; }
.som-option:has(input:checked) { color: white; border-color: transparent; }
.som-1:has(input:checked) { background: #a13f3f; }
.som-2:has(input:checked) { background: #b06a4f; }
.som-3:has(input:checked) { background: #a9822f; }
.som-4:has(input:checked) { background: #7a9a4f; }
.som-5:has(input:checked) { background: #4f7a3f; }
.som-clear:has(input:checked) { background: var(--none); }

/* ---------- Therapy report ---------- */
.report-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 24px;
}
.report-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 560px) {
  .report-stats { grid-template-columns: repeat(2, 1fr); }
}
.report-stat { display: flex; flex-direction: column; }
.report-num { font-size: 1.3rem; font-weight: 600; }
.report-label { color: var(--muted); font-size: 0.75rem; line-height: 1.3; }
.report-subhead { font-size: 0.9rem; color: var(--muted); margin: 12px 0 8px; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- Weight trend chart ---------- */
.trend-chart { width: 100%; height: auto; display: block; }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart-point { fill: var(--accent); }

/* ---------- Attention/reminders (Fulgrim, feature list §3.2) ---------- */
.attention-icon {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  text-decoration: none;
  opacity: 0.55;
}
.attention-icon-active {
  opacity: 1;
  background: var(--severe);
  border-color: var(--severe);
  animation: attention-blink 1.6s ease-in-out infinite;
}
@keyframes attention-blink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(161, 63, 63, 0.6); }
  50% { box-shadow: 0 0 0 8px rgba(161, 63, 63, 0); }
}
.attention-banner {
  background: rgba(161, 63, 63, 0.12);
  border: 1px solid var(--severe);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 24px;
}
.attention-banner .section-label { margin-bottom: 8px; }
.demo-banner {
  background: rgba(91, 140, 255, 0.12);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  text-align: center;
}
.attention-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid rgba(161, 63, 63, 0.3);
}
.attention-item:first-of-type { border-top: none; padding-top: 0; }
.attention-item-label { color: var(--text); text-decoration: none; font-size: 0.92rem; }
.attention-item-label:hover { text-decoration: underline; }
.attention-snooze-form { margin: 0; }
.attention-snooze-btn { padding: 0; font-size: 0.8rem; white-space: nowrap; }

/* ---------- Analysis chart rendering (Fulgrim, PLAN.md §11) ---------- */
.av-bar-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.av-bar-row { display: grid; grid-template-columns: 90px 1fr 40px; align-items: center; gap: 8px; font-size: 0.85rem; }
.av-bar-label { color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.av-bar-track { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; height: 14px; overflow: hidden; }
.av-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px 0 0 6px; }
.av-bar-count { color: var(--text); text-align: right; }

/* ---------- Blood pressure readings (Fulgrim, feature list §1.2) ---------- */
.bp-reading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.bp-reading-row:first-child { border-top: none; padding-top: 0; }
.bp-reading-row form { margin: 0; }
.chart-line-diastolic { fill: none; stroke: var(--moderate); stroke-width: 2.5; }
.chart-point-diastolic { fill: var(--moderate); }
.av-range-bar { fill: var(--accent); opacity: 0.55; rx: 2; }

/* Custom chart tooltip (Ward, Aug 2026 — "day and value if I hover...
   used on a mobile device") — replaces the browser's native SVG <title>
   tooltip, which is desktop-hover-only and has poor/inconsistent mobile
   support. One shared floating element, positioned by JS in analysis.php;
   pointer-events: none so it never itself blocks the tap/hover that's
   meant to reach the chart underneath it. */
.av-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  max-width: 240px;
  white-space: nowrap;
}

/* ---------- Radio/checkbox rows (export page, medication list) ---------- */
.radio-row, .checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.92rem;
}
.radio-row input, .checkbox-row input { width: auto; }
