/* =========================================================
   Healthcare Tracker — Design System
   3 light themes (eucalyptus / periwinkle / linen) + dark
   Indicator ramps for symptoms avoid red/pink entirely.
   ========================================================= */

:root {
  /* ---- Indicator ramps (theme-independent) ---- */
  /* Bleeding — deep mulberry / aubergine (not red) */
  --bleed-0: oklch(0.97 0.005 320);
  --bleed-1: oklch(0.88 0.025 320);
  --bleed-2: oklch(0.75 0.045 320);
  --bleed-3: oklch(0.58 0.07 320);
  --bleed-4: oklch(0.42 0.07 320);
  --bleed-5: oklch(0.30 0.06 320);

  /* Pain — warm ochre / amber (not red) */
  --pain-0: oklch(0.97 0.012 75);
  --pain-1: oklch(0.90 0.04 75);
  --pain-2: oklch(0.80 0.08 75);
  --pain-3: oklch(0.70 0.10 70);
  --pain-4: oklch(0.60 0.11 65);
  --pain-5: oklch(0.50 0.10 55);

  /* Sleep — indigo */
  --sleep-0: oklch(0.96 0.015 265);
  --sleep-3: oklch(0.65 0.07 265);
  --sleep-5: oklch(0.45 0.09 270);

  /* Mood — sage */
  --mood-0: oklch(0.96 0.015 155);
  --mood-3: oklch(0.68 0.07 155);
  --mood-5: oklch(0.50 0.08 160);

  /* Irregular bleeding marker — teal, distinct from the bleed ramp (not red/pink) */
  --irregular: oklch(0.58 0.10 200);

  /* ---- Geometry ---- */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;

  --font-sans: "Noto Sans JP", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --shadow-1: 0 1px 2px rgba(20, 28, 24, 0.04), 0 1px 1px rgba(20, 28, 24, 0.02);
  --shadow-2: 0 4px 12px rgba(20, 28, 24, 0.06), 0 1px 2px rgba(20, 28, 24, 0.03);
  --shadow-pop: 0 12px 32px rgba(20, 28, 24, 0.12), 0 2px 6px rgba(20, 28, 24, 0.04);
}

/* ======================  LIGHT THEMES  ====================== */

/* ---- Theme A: Eucalyptus (default) ---- */
[data-theme="eucalyptus"][data-mode="light"] {
  --bg: #f3f1ea;
  --bg-2: #e9e6dc;
  --surface: #fbfaf6;
  --surface-2: #f5f2e9;
  --surface-inset: #efece2;

  --text: #1d2724;
  --text-muted: #5c6a64;
  --text-soft: #8a958f;
  --border: rgba(29, 39, 36, 0.08);
  --border-strong: rgba(29, 39, 36, 0.16);

  --primary: oklch(0.50 0.06 160);
  --primary-hover: oklch(0.44 0.07 160);
  --primary-soft: oklch(0.92 0.035 160);
  --primary-fg: #fbfaf6;

  --accent: oklch(0.62 0.09 75);   /* ochre */
  --accent-soft: oklch(0.94 0.04 75);
}

/* ---- Theme B: Periwinkle ---- */
[data-theme="periwinkle"][data-mode="light"] {
  --bg: #f1f2f7;
  --bg-2: #e6e8f0;
  --surface: #ffffff;
  --surface-2: #f5f6fb;
  --surface-inset: #ebedf4;

  --text: #1a2030;
  --text-muted: #5b6378;
  --text-soft: #8a91a3;
  --border: rgba(26, 32, 48, 0.08);
  --border-strong: rgba(26, 32, 48, 0.16);

  --primary: oklch(0.54 0.10 265);
  --primary-hover: oklch(0.48 0.11 265);
  --primary-soft: oklch(0.93 0.04 265);
  --primary-fg: #ffffff;

  --accent: oklch(0.65 0.07 200);
  --accent-soft: oklch(0.94 0.03 200);
}

/* ---- Theme C: Linen ---- */
[data-theme="linen"][data-mode="light"] {
  --bg: #efe8dc;
  --bg-2: #e3dac9;
  --surface: #f9f4e9;
  --surface-2: #f1ead9;
  --surface-inset: #ebe2cf;

  --text: #2a2417;
  --text-muted: #6b6452;
  --text-soft: #9a927c;
  --border: rgba(42, 36, 23, 0.10);
  --border-strong: rgba(42, 36, 23, 0.18);

  --primary: oklch(0.46 0.06 195);
  --primary-hover: oklch(0.40 0.07 195);
  --primary-soft: oklch(0.91 0.03 195);
  --primary-fg: #f9f4e9;

  --accent: oklch(0.60 0.09 50);
  --accent-soft: oklch(0.93 0.04 50);
}

/* ======================  DARK MODE  ====================== */

[data-theme="eucalyptus"][data-mode="dark"] {
  --bg: #131816;
  --bg-2: #0d1110;
  --surface: #1c2220;
  --surface-2: #232b28;
  --surface-inset: #181e1c;

  --text: #e8ebe7;
  --text-muted: #9aa49e;
  --text-soft: #6b766f;
  --border: rgba(232, 235, 231, 0.08);
  --border-strong: rgba(232, 235, 231, 0.18);

  --primary: oklch(0.78 0.08 160);
  --primary-hover: oklch(0.85 0.08 160);
  --primary-soft: oklch(0.30 0.05 160);
  --primary-fg: #0e1413;

  --accent: oklch(0.78 0.10 75);
  --accent-soft: oklch(0.32 0.06 75);
}

[data-theme="periwinkle"][data-mode="dark"] {
  --bg: #14161f;
  --bg-2: #0e1018;
  --surface: #1d2030;
  --surface-2: #252840;
  --surface-inset: #181a26;

  --text: #e8eaf4;
  --text-muted: #9aa1b8;
  --text-soft: #6c7388;
  --border: rgba(232, 234, 244, 0.08);
  --border-strong: rgba(232, 234, 244, 0.18);

  --primary: oklch(0.78 0.10 265);
  --primary-hover: oklch(0.85 0.10 265);
  --primary-soft: oklch(0.30 0.07 265);
  --primary-fg: #0e1018;

  --accent: oklch(0.78 0.08 200);
  --accent-soft: oklch(0.30 0.05 200);
}

[data-theme="linen"][data-mode="dark"] {
  --bg: #1a160e;
  --bg-2: #14110a;
  --surface: #241f15;
  --surface-2: #2c271b;
  --surface-inset: #1f1b12;

  --text: #ece4d2;
  --text-muted: #a09a85;
  --text-soft: #756f5c;
  --border: rgba(236, 228, 210, 0.08);
  --border-strong: rgba(236, 228, 210, 0.18);

  --primary: oklch(0.78 0.08 195);
  --primary-hover: oklch(0.85 0.08 195);
  --primary-soft: oklch(0.28 0.05 195);
  --primary-fg: #14110a;

  --accent: oklch(0.78 0.10 50);
  --accent-soft: oklch(0.30 0.06 50);
}

/* Dark mode tweaks indicator ramps */
[data-mode="dark"] {
  --bleed-0: oklch(0.20 0.02 320);
  --bleed-1: oklch(0.30 0.04 320);
  --bleed-2: oklch(0.42 0.06 320);
  --bleed-3: oklch(0.58 0.08 320);
  --bleed-4: oklch(0.72 0.08 320);
  --bleed-5: oklch(0.85 0.07 320);

  --pain-0: oklch(0.22 0.025 75);
  --pain-1: oklch(0.35 0.05 75);
  --pain-2: oklch(0.48 0.08 75);
  --pain-3: oklch(0.62 0.10 70);
  --pain-4: oklch(0.75 0.11 65);
  --pain-5: oklch(0.85 0.10 55);

  --sleep-0: oklch(0.22 0.02 265);
  --sleep-3: oklch(0.65 0.08 265);
  --sleep-5: oklch(0.82 0.08 270);

  --mood-0: oklch(0.22 0.02 155);
  --mood-3: oklch(0.68 0.07 155);
  --mood-5: oklch(0.82 0.08 160);

  --irregular: oklch(0.74 0.10 200);
}

/* ======================  RESET + BASE  ====================== */

* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: "palt";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.55;
}

body {
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

#root { min-height: 100vh; }

button {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 0;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: inherit; }

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-soft); background-clip: content-box; }

/* ======================  LAYOUT  ====================== */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s-6) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-3);
}
.sidebar-brand .mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--primary);
  display: grid; place-items: center;
  color: var(--primary-fg);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.sidebar-brand .name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.sidebar-brand .sub {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 1px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-soft);
  padding: 0 var(--s-3);
  margin-bottom: var(--s-2);
  font-weight: 600;
  font-family: var(--font-mono);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 9px var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-soft);
}
.nav-item.active .count { color: var(--primary); }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  border-top: 1px solid var(--border);
}
.cycle-pill {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.cycle-pill .day-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.cycle-pill .day-label {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.main {
  padding: var(--s-7) var(--s-8);
  max-width: 100%;
  overflow-x: hidden;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--s-7);
  gap: var(--s-5);
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}
.page-head .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--s-1);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.page-head-actions { display: flex; gap: var(--s-3); align-items: center; }

/* ======================  PRIMITIVES  ====================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.card.tight { padding: var(--s-4); }
.card.flat { background: var(--surface-2); border-color: transparent; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  gap: var(--s-3);
}
.card-head h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.card-head .meta {
  font-size: 11px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 14px; height: 14px; }
.btn.primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: transparent;
}
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.lg { padding: 11px 18px; font-size: 14px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}
.chip.solid {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
}
.chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-soft);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--s-4) 0;
}

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

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 24, 0.35);
  backdrop-filter: blur(4px);
  z-index: 100;
  animation: fade-in 0.18s ease;
}
[data-mode="dark"] .drawer-backdrop { background: rgba(0, 0, 0, 0.55); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
  box-shadow: -24px 0 64px rgba(20, 28, 24, 0.12);
}
.drawer.entering { transform: translateX(100%); }
.drawer-head {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  background: var(--surface);
}
.drawer-head .titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drawer-head h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-head .sub {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-soft);
  letter-spacing: 0.04em;
}
.drawer-tabs {
  display: flex;
  gap: 0;
  padding: 0 var(--s-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
}
.drawer-tab {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 500;
  transition: color 0.12s ease, border-color 0.12s ease;
  flex-shrink: 0;
}
.drawer-tab:hover { color: var(--text); }
.drawer-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-6);
}
.drawer-foot {
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  background: var(--surface);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}
.field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 6px;
}

.time-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}
.time-pill input {
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  width: 72px;
  outline: none;
  padding: 0;
  color: var(--text);
}
.time-pill button {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface-inset);
  display: grid; place-items: center;
  color: var(--text-soft);
  margin-left: 2px;
}
.time-pill button:hover { background: var(--bleed-3); color: white; }
.time-pill button svg { width: 10px; height: 10px; }

.drawer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
}

/* ======================  POPOVER  ====================== */

.popover {
  position: fixed;
  z-index: 110;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--s-4);
  box-shadow: var(--shadow-pop);
  animation: fade-in 0.12s ease;
}

.modal-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  z-index: 110;
  box-shadow: var(--shadow-pop);
  animation: fade-in 0.14s ease;
}

/* ======================  MED SLOT ADJUSTMENTS  ====================== */

.med-actual-time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface-inset);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
.med-actual-time:hover { background: var(--primary-soft); color: var(--primary); }
.med-actual-time.diff { color: var(--accent); background: var(--accent-soft); }
.med-actual-time .icon { width: 11px; height: 11px; opacity: 0.7; }

.rescue-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

/* ======================  SLIDER  ====================== */

.slider-row {
  display: grid;
  grid-template-columns: 100px 1fr 40px;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-3) 0;
}
.slider-row .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.slider-row .label .sub {
  display: block;
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 400;
  font-family: var(--font-mono);
  margin-top: 1px;
}
.slider-row .value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  text-align: right;
  color: var(--text);
}

.intensity-track {
  position: relative;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  user-select: none;
}
.intensity-cell {
  flex: 1;
  height: 100%;
  border-radius: 4px;
  background: var(--surface-inset);
  transition: background-color 0.12s ease, transform 0.08s ease;
  position: relative;
}
.intensity-cell:hover { transform: scaleY(1.08); }
.intensity-cell.bleed.on-1 { background: var(--bleed-1); }
.intensity-cell.bleed.on-2 { background: var(--bleed-2); }
.intensity-cell.bleed.on-3 { background: var(--bleed-3); }
.intensity-cell.bleed.on-4 { background: var(--bleed-4); }
.intensity-cell.bleed.on-5 { background: var(--bleed-5); }

.intensity-cell.pain.on-1 { background: var(--pain-1); }
.intensity-cell.pain.on-2 { background: var(--pain-2); }
.intensity-cell.pain.on-3 { background: var(--pain-3); }
.intensity-cell.pain.on-4 { background: var(--pain-4); }
.intensity-cell.pain.on-5 { background: var(--pain-5); }

.intensity-cell.sleep.on-1 { background: var(--sleep-0); }
.intensity-cell.sleep.on-2 { background: oklch(0.80 0.04 265); }
.intensity-cell.sleep.on-3 { background: var(--sleep-3); }
.intensity-cell.sleep.on-4 { background: oklch(0.55 0.08 268); }
.intensity-cell.sleep.on-5 { background: var(--sleep-5); }

.intensity-cell.mood.on-1 { background: oklch(0.88 0.03 155); }
.intensity-cell.mood.on-2 { background: oklch(0.80 0.05 155); }
.intensity-cell.mood.on-3 { background: var(--mood-3); }
.intensity-cell.mood.on-4 { background: oklch(0.58 0.08 158); }
.intensity-cell.mood.on-5 { background: var(--mood-5); }

[data-mode="dark"] .intensity-cell.sleep.on-1 { background: oklch(0.32 0.04 265); }
[data-mode="dark"] .intensity-cell.sleep.on-2 { background: oklch(0.45 0.06 265); }
[data-mode="dark"] .intensity-cell.sleep.on-4 { background: oklch(0.72 0.09 268); }
[data-mode="dark"] .intensity-cell.mood.on-1 { background: oklch(0.32 0.04 155); }
[data-mode="dark"] .intensity-cell.mood.on-2 { background: oklch(0.45 0.06 155); }
[data-mode="dark"] .intensity-cell.mood.on-4 { background: oklch(0.72 0.09 158); }

.intensity-cell.sleep.on { background: var(--sleep-3); }
.intensity-cell.mood.on { background: var(--mood-3); }
.intensity-cell.neutral.on { background: var(--text-muted); opacity: 0.65; }

/* ======================  DASHBOARD STATS  ====================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-4);
}
.stat {
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.stat .stat-label {
  font-size: 11px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  font-family: var(--font-mono);
}
.stat .stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  font-family: var(--font-mono);
  line-height: 1.1;
}
.stat .stat-value .unit {
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 400;
}
.stat .stat-trend {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat .trend-bar {
  display: flex;
  gap: 2px;
  margin-top: var(--s-2);
  height: 28px;
  align-items: flex-end;
}
.stat .trend-bar .b {
  flex: 1;
  background: var(--surface-inset);
  border-radius: 2px;
  min-height: 4px;
}

/* ======================  TIMELINE / MEDS  ====================== */

.med-list { display: flex; flex-direction: column; gap: var(--s-2); }
.med-item {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.med-item:hover { border-color: var(--border-strong); }
.med-item.done { opacity: 0.55; }
.med-item.done .med-name { text-decoration: line-through; }

.med-time {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 56px;
  letter-spacing: -0.01em;
}
.med-info { flex: 1; min-width: 0; }
.med-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}
.med-dose {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.checkbox {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.checkbox:hover { border-color: var(--primary); }
.checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox.checked svg { color: var(--primary-fg); }
.checkbox svg { width: 14px; height: 14px; opacity: 0; }
.checkbox.checked svg { opacity: 1; }

/* ======================  CALENDAR  ====================== */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.cal-head {
  background: var(--surface-2);
  padding: var(--s-3) var(--s-3);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
  text-transform: uppercase;
}
.cal-head.weekend-sat { color: var(--accent); }
.cal-head.weekend-sun { color: var(--bleed-4); }

.cal-cell {
  background: var(--surface);
  min-height: 92px;
  min-width: 0;
  padding: var(--s-2) var(--s-3) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background-color 0.12s ease;
  position: relative;
  overflow: hidden;
}
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.out { background: var(--surface-inset); color: var(--text-soft); }
.cal-cell.today { background: var(--primary-soft); }
.cal-cell.today .day-num { color: var(--primary); font-weight: 700; }

.day-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
}

.cell-dots { display: flex; gap: 3px; align-items: center; }
.cell-dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.cell-dot.bleed-1 { background: var(--bleed-2); }
.cell-dot.bleed-2 { background: var(--bleed-3); }
.cell-dot.bleed-3 { background: var(--bleed-4); }
.cell-dot.bleed-4 { background: var(--bleed-5); }
.cell-dot.pain { background: var(--pain-3); }
.cell-dot.mood { background: var(--mood-3); }
.cell-dot.note { background: var(--text-soft); }
.cell-dot.irregular { background: var(--irregular); }

.cell-bleed-bar {
  height: 6px;
  border-radius: 3px;
  width: 100%;
  margin-top: auto;
}
.cell-bleed-bar.b-1 { background: var(--bleed-2); }
.cell-bleed-bar.b-2 { background: var(--bleed-3); }
.cell-bleed-bar.b-3 { background: var(--bleed-4); }
.cell-bleed-bar.b-4 { background: var(--bleed-5); }

.cell-mini {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* ======================  TRENDS / CHART  ====================== */

.chart-wrap {
  width: 100%;
  position: relative;
}
.chart-wrap svg { width: 100%; height: auto; display: block; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.legend-swatch {
  width: 12px; height: 12px; border-radius: 3px;
}

/* ======================  FORM  ====================== */

.input, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--text);
  transition: border-color 0.12s ease, background-color 0.12s ease;
  outline: none;
}
.input:focus, .textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}
.textarea { min-height: 100px; resize: vertical; line-height: 1.6; }

.label-text {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.toggle {
  width: 36px; height: 20px;
  background: var(--surface-inset);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.18s ease;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  background: var(--surface);
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform 0.18s ease, background-color 0.18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle.on { background: var(--primary); }
.toggle.on::after { transform: translateX(16px); background: var(--primary-fg); }

/* ======================  REPORT  ====================== */

.report-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-8) var(--s-9);
  max-width: 820px;
}
.report-doc h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 var(--s-3);
}
.report-doc .meta-row {
  display: flex;
  gap: var(--s-6);
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--s-7);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--border);
}
.report-doc h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-soft);
  margin: var(--s-6) 0 var(--s-3);
  font-family: var(--font-mono);
}
.report-doc p { margin: 0 0 var(--s-3); line-height: 1.7; font-size: 14px; }
.report-doc ul {
  margin: 0 0 var(--s-4);
  padding-left: var(--s-5);
  font-size: 14px;
  line-height: 1.8;
}

/* ======================  UTILS  ====================== */

.row { display: flex; align-items: center; gap: var(--s-3); }
.row.between { justify-content: space-between; }
.row.between > * { min-width: 0; }
.row .mono { white-space: nowrap; }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
.grid-12 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s-4); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-5 { gap: var(--s-5); }
.gap-6 { gap: var(--s-6); }
.between { justify-content: space-between; }
.center { justify-content: center; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.tiny { font-size: 11px; }
.small { font-size: 12.5px; }

@media (max-width: 1024px) {
  .app { grid-template-columns: 80px 1fr; }
  .sidebar { padding: var(--s-5) var(--s-2); }
  .sidebar-brand .text-block, .nav-item .label, .nav-label, .cycle-pill .day-label, .sidebar-footer { display: none; }
  .sidebar-footer { display: flex; }
  .main { padding: var(--s-5) var(--s-5); }
  .grid-12 { grid-template-columns: 1fr; }
}

.mobile-topbar { display: none; }
.mobile-nav-backdrop { display: none; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .mobile-topbar-toggle {
    display: grid;
    place-items: center;
    width: 36px; height: 36px;
    border-radius: var(--r-sm);
    color: var(--text);
    background: transparent;
  }
  .mobile-topbar-toggle:hover { background: var(--surface-2); }
  .mobile-topbar-toggle .icon { width: 22px; height: 22px; }
  .mobile-topbar-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
  }

  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 82vw;
    height: 100vh;
    padding: var(--s-6) var(--s-4);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 50;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  }
  .sidebar-brand .text-block,
  .nav-item .label,
  .nav-label,
  .cycle-pill .day-label { display: block; }
  .sidebar-footer { display: flex; }

  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    z-index: 40;
  }
  body.menu-open { overflow: hidden; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .main { padding: var(--s-4); }
  .page-head h1 { font-size: 22px; }

  /* Let header controls wrap instead of overflowing the viewport */
  .page-head-actions { flex-wrap: wrap; }

  /* Keep all 7 day columns visible on narrow screens by tightening cells */
  .cal-head { padding: var(--s-2) var(--s-1); }
  .cal-cell { min-height: 64px; padding: var(--s-2) var(--s-1) var(--s-2); }
  .cell-dots { gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
  .cell-mini { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
}
