:root {
  --paper: #f7f7f2;
  --surface: #ffffff;
  --surface-soft: #f0f2ee;
  --ink: #182525;
  --muted: #6c7976;
  --line: #dfe5df;
  --teal: #0c7778;
  --teal-dark: #075355;
  --teal-soft: #dff1ef;
  --coral: #d5574f;
  --coral-soft: #f7e4df;
  --gold: #c18b2f;
  --gold-soft: #f5ecd7;
  --violet: #6c5a92;
  --shadow: 0 16px 38px rgba(27, 53, 49, .08);
  --radius: 16px;
  --sidebar: 248px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(12, 119, 120, .25);
  outline-offset: 2px;
}
button:disabled { cursor: not-allowed; opacity: .55; }

.app-shell { min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 20px;
  background: var(--teal-dark);
  color: #ecfbf8;
  z-index: 20;
}
.brand-lockup { display: flex; gap: 12px; align-items: center; padding: 0 10px; }
.brand-lockup strong { display: block; font: 700 20px/1.05 "Space Grotesk", sans-serif; letter-spacing: -.04em; }
.brand-lockup small { display: block; margin-top: 5px; color: #a7d8d3; font-size: 10px; font-weight: 700; letter-spacing: .16em; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #f8eee0;
  position: relative;
}
.brand-mark::before, .brand-mark::after, .brand-mark span {
  content: "";
  position: absolute;
  width: 18px;
  height: 7px;
  border-radius: 10px;
  background: var(--coral);
  transform: rotate(32deg);
}
.brand-mark::after { background: var(--gold); transform: rotate(-32deg); }
.brand-mark span { width: 6px; height: 26px; background: var(--teal); transform: rotate(0); }
.side-caption { margin: 58px 10px 14px; color: #83bcb8; font-size: 10px; font-weight: 700; letter-spacing: .16em; }
.side-nav { display: grid; gap: 5px; }
.nav-link, .settings-link {
  border: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 12px;
  color: #a7d8d3;
  background: transparent;
  border-radius: 10px;
  text-align: left;
  transition: background .2s, color .2s, transform .2s;
}
.nav-link svg, .settings-link svg { width: 18px; height: 18px; flex: 0 0 auto; }
.nav-link span, .settings-link span { flex: 1; }
.nav-link b { font-size: 10px; font-weight: 500; opacity: .45; }
.nav-link:hover, .settings-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: #e8f3ef; color: var(--teal-dark); box-shadow: 0 8px 18px rgba(0,0,0,.1); }
.nav-link.active b { opacity: .7; }
.side-footer { margin-top: auto; display: grid; gap: 18px; padding: 0 2px; }
.offline-note { display: flex; align-items: flex-start; gap: 8px; padding: 12px; border: 1px solid rgba(255,255,255,.13); border-radius: 10px; color: #a7d8d3; font-size: 11px; line-height: 1.3; }
.online-dot { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: #70d3a4; box-shadow: 0 0 0 4px rgba(112,211,164,.12); flex: 0 0 auto; }
.settings-link { padding: 10px; }

.main-content { min-height: 100vh; margin-left: var(--sidebar); padding: 0 42px 60px; }
.topbar { max-width: 1240px; min-height: 100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.topbar-copy { min-width: 0; }
.eyebrow, .section-kicker { display: block; color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.topbar h1, .view-heading h2, .today-intro h2 { margin: 5px 0 0; font: 700 clamp(24px, 3vw, 34px)/1.06 "Space Grotesk", sans-serif; letter-spacing: -.05em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-button, .round-action {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); transition: border .2s, color .2s, transform .2s;
}
.icon-button svg, .round-action svg { width: 18px; height: 18px; }
.icon-button:hover, .round-action:hover { border-color: var(--teal); color: var(--teal); transform: translateY(-1px); }
.profile-chip { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); }
.profile-chip svg { width: 15px; color: var(--muted); }
.profile-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); font: 700 13px "Space Grotesk", sans-serif; }

#viewRoot { max-width: 1240px; margin: 0 auto; }
.view { display: none; padding-top: 38px; animation: appear .25s ease both; }
.view.active { display: block; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.today-intro { min-height: 170px; display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 8px 4px 22px; }
.today-intro h2 { font-size: clamp(32px, 4vw, 50px); max-width: 570px; }
.today-intro p, .view-heading p { max-width: 570px; margin: 12px 0 0; color: var(--muted); }
.progress-orbit { width: 126px; height: 126px; position: relative; flex: 0 0 auto; }
.progress-orbit svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.orbit-track, .orbit-value { fill: none; stroke-width: 7; }
.orbit-track { stroke: #e2e8e3; }
.orbit-value { stroke: var(--teal); stroke-linecap: round; stroke-dasharray: 301.59; stroke-dashoffset: 301.59; transition: stroke-dashoffset .5s ease, stroke .3s; }
.orbit-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.orbit-label strong { display: block; color: var(--teal-dark); font: 700 24px/1 "Space Grotesk", sans-serif; letter-spacing: -.04em; }
.orbit-label span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 16px 6px; }
.metric-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; flex: 0 0 auto; }
.metric-icon svg { width: 16px; height: 16px; }
.metric-icon.teal { background: var(--teal-soft); color: var(--teal); }
.metric-icon.coral { background: var(--coral-soft); color: var(--coral); }
.metric-icon.gold { background: var(--gold-soft); color: var(--gold); }
.metric-icon.ink { background: #e9eceb; color: var(--ink); }
.metric strong { display: block; font: 700 16px/1 "Space Grotesk", sans-serif; }
.metric span:last-child { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 18px; margin-top: 28px; align-items: start; }
.right-rail { display: grid; gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.routine-panel, .read-panel, .alert-panel { padding: 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel-head h3, .page-subhead h3 { margin: 4px 0 0; font: 700 19px/1.1 "Space Grotesk", sans-serif; letter-spacing: -.035em; }
.panel-icon { width: 19px; height: 19px; color: var(--teal); }
.text-button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--teal); font-size: 12px; font-weight: 700; padding: 5px 0; }
.text-button svg { width: 14px; height: 14px; }
.text-button:hover { color: var(--teal-dark); }
.next-dose-strip { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 20px 0 12px; padding: 10px 12px; border-radius: 9px; background: var(--teal-soft); color: var(--teal-dark); font-size: 12px; font-weight: 600; }
.next-dose-strip svg { width: 15px; height: 15px; }
.routine-list { display: grid; gap: 8px; }
.time-group { display: grid; gap: 7px; margin-top: 18px; }
.time-group:first-child { margin-top: 0; }
.time-heading { display: flex; align-items: center; justify-content: space-between; padding: 4px 3px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.time-heading span:last-child { font-size: 10px; letter-spacing: 0; }
.supplement-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); text-align: left; color: var(--ink); transition: border .2s, background .2s, transform .2s; }
.supplement-row:hover { border-color: #a8cdca; background: #fbfdfc; transform: translateY(-1px); }
.supplement-row.checked { border-color: #a9d5c6; background: #f0f8f4; }
.supplement-row.paused { opacity: .58; }
.dose-check { display: grid; place-items: center; width: 25px; height: 25px; border: 1.5px solid #bdc9c5; border-radius: 7px; color: transparent; flex: 0 0 auto; }
.dose-check svg { width: 15px; height: 15px; stroke-width: 3; }
.checked .dose-check { border-color: var(--teal); background: var(--teal); color: white; }
.supplement-emoji { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; background: var(--surface-soft); font-size: 16px; flex: 0 0 auto; }
.supplement-copy { min-width: 0; flex: 1; }
.supplement-copy strong { display: block; font: 700 14px/1.2 "Space Grotesk", sans-serif; }
.supplement-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dose-state { color: var(--muted); font-size: 11px; font-weight: 600; }
.checked .dose-state { color: var(--teal); }
.paused .dose-state { color: var(--coral); }
.wellbeing-card { display: flex; align-items: center; gap: 12px; min-height: 88px; margin: 18px 0; padding: 15px; border-radius: 12px; background: var(--surface-soft); }
.wellbeing-score { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--gold-soft); color: var(--gold); font: 700 17px "Space Grotesk", sans-serif; }
.wellbeing-card strong { display: block; font-size: 14px; }
.wellbeing-card p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.outline-button, .primary-button, .danger-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 9px; padding: 9px 14px; font-size: 12px; font-weight: 700; transition: transform .2s, box-shadow .2s, background .2s; }
.outline-button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.outline-button:hover { border-color: var(--teal); color: var(--teal); }
.primary-button { border: 1px solid var(--teal); background: var(--teal); color: white; box-shadow: 0 7px 18px rgba(12,119,120,.18); }
.primary-button:hover { background: var(--teal-dark); transform: translateY(-1px); }
.danger-button { border: 1px solid #ecc5bd; background: #fff8f6; color: var(--coral); }
.danger-button:hover { background: var(--coral-soft); }
.outline-button svg, .primary-button svg, .danger-button svg { width: 16px; height: 16px; }
.full { width: 100%; }
.alert-item { display: flex; gap: 9px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.alert-item:first-child { margin-top: 17px; }
.alert-item svg { width: 16px; height: 16px; margin-top: 2px; color: var(--coral); flex: 0 0 auto; }
.alert-item strong { display: block; font-size: 12px; }
.alert-item span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.empty-mini { padding: 14px 0 4px; color: var(--muted); font-size: 12px; }
.info-band { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 15px 17px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.info-mark { width: 33px; height: 33px; display: grid; place-items: center; border-radius: 9px; background: var(--gold-soft); color: var(--gold); flex: 0 0 auto; }
.info-mark svg { width: 17px; height: 17px; }
.info-band strong { display: block; font-size: 12px; }
.info-band p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.info-band .text-button { margin-left: auto; white-space: nowrap; }

.view-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.view-heading h2 { font-size: clamp(30px, 4vw, 44px); }
.view-heading p { margin-top: 8px; }
.labs-layout, .diary-layout { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(0, 1.25fr); gap: 20px; align-items: start; }
.form-panel, .diary-form-panel { padding: 22px; position: sticky; top: 24px; }
.form-stack { display: grid; gap: 15px; margin-top: 20px; }
.form-stack label { display: grid; gap: 6px; color: var(--ink); font-size: 12px; font-weight: 700; }
.form-stack input, .form-stack select, .form-stack textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); padding: 11px 12px; font-size: 14px; font-weight: 400; }
.form-stack input::placeholder, .form-stack textarea::placeholder { color: #9aa7a3; }
.form-stack textarea { resize: vertical; min-height: 88px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reference-box { padding: 10px; border-radius: 8px; background: var(--teal-soft); color: var(--teal-dark); font-size: 11px; line-height: 1.4; }
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-button { border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); padding: 7px 11px; font-size: 11px; font-weight: 700; }
.filter-button.active, .filter-button:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.lab-card { padding: 15px 16px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.lab-card-head, .lab-card-value, .record-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.lab-card-title { display: flex; align-items: center; gap: 7px; font: 700 13px "Space Grotesk", sans-serif; }
.lab-card-title span { font-size: 15px; }
.status-pill { border-radius: 999px; padding: 4px 8px; font-size: 9px; font-weight: 800; letter-spacing: .07em; }
.status-ideal { color: #267d58; background: #e4f3e9; }
.status-normal { color: var(--teal); background: var(--teal-soft); }
.status-low, .status-high { color: #a46817; background: var(--gold-soft); }
.status-critical { color: #ad4138; background: var(--coral-soft); }
.lab-card-value { align-items: baseline; margin-top: 14px; }
.lab-card-value strong { font: 700 26px/1 "Space Grotesk", sans-serif; letter-spacing: -.04em; }
.lab-card-value span { margin-right: auto; color: var(--muted); font-size: 11px; }
.lab-card-value time { color: var(--muted); font-size: 11px; }
.lab-scale { position: relative; height: 7px; margin-top: 13px; border-radius: 999px; background: #eef0ed; }
.ideal-zone { position: absolute; inset: 0 auto 0 var(--ideal-left); width: var(--ideal-width); border-radius: 999px; background: #bfe3d2; }
.lab-marker { position: absolute; top: 50%; left: var(--marker-left); width: 13px; height: 13px; border: 3px solid white; border-radius: 50%; background: var(--marker-color); box-shadow: 0 1px 5px rgba(0,0,0,.2); transform: translate(-50%, -50%); }
.lab-range { display: flex; justify-content: space-between; margin-top: 6px; color: #9aa7a3; font-size: 10px; }
.lab-range span:nth-child(2) { color: #5d9977; }
.missing-lab { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; border: 1px dashed var(--line); border-radius: 11px; color: var(--muted); font-size: 12px; }
.missing-lab strong { color: var(--ink); }
.mini-action { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border: 0; background: transparent; color: var(--teal); font-size: 11px; font-weight: 700; }
.mini-action svg { width: 13px; height: 13px; }

.date-badge, .count-badge { align-self: center; border-radius: 999px; padding: 7px 10px; background: var(--teal-soft); color: var(--teal-dark); font-size: 11px; font-weight: 700; white-space: nowrap; }
.energy-control { padding: 16px; border-radius: 11px; background: var(--surface-soft); }
.energy-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; font-weight: 600; }
.energy-head strong { color: var(--gold); font: 700 20px "Space Grotesk", sans-serif; }
.energy-control input[type=range] { width: 100%; margin: 17px 0 0; accent-color: var(--gold); }
.range-labels { display: flex; justify-content: space-between; margin-top: 4px; color: #99a5a1; font-size: 10px; }
.field-label { margin-bottom: 8px; color: var(--ink); font-size: 12px; font-weight: 700; }
.field-label span { color: var(--muted); font-weight: 400; }
.symptom-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.symptom-button { display: flex; align-items: center; gap: 6px; min-height: 39px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-align: left; font-size: 11px; font-weight: 600; }
.symptom-button:hover { border-color: #afcdca; }
.symptom-button.selected { border-color: #edb3a9; background: var(--coral-soft); color: #8e3933; }
.symptom-button .symptom-level { margin-left: auto; color: var(--coral); font-size: 10px; font-weight: 800; }
.page-subhead { margin: 0 0 13px; }
.diary-history { min-width: 0; }
.diary-record, .history-record { padding: 15px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.record-head { color: var(--muted); font-size: 11px; }
.record-head strong { color: var(--gold); font: 700 16px "Space Grotesk", sans-serif; }
.record-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.record-tag { padding: 4px 7px; border-radius: 5px; background: var(--coral-soft); color: #8e3933; font-size: 10px; font-weight: 600; }
.record-note { margin: 11px 0 0; padding-top: 9px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; font-style: italic; }
.record-tools { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.month-switcher { display: flex; align-items: center; gap: 9px; color: var(--teal-dark); font: 700 14px "Space Grotesk", sans-serif; text-transform: capitalize; }
.month-switcher .icon-button { width: 34px; height: 34px; }
.calendar-panel { padding: 20px; }
.calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-week { margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; text-align: center; letter-spacing: .06em; }
.calendar-cell { min-height: 68px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1px solid #edf0ed; border-radius: 9px; background: #fcfdfc; color: var(--muted); font-size: 12px; position: relative; }
.calendar-cell.empty { border-color: transparent; background: transparent; }
.calendar-cell.today { border-color: var(--teal); color: var(--teal-dark); font-weight: 800; }
.calendar-cell.future { opacity: .4; }
.calendar-cell.has-data { cursor: pointer; }
.calendar-cell.has-data:hover { background: var(--teal-soft); }
.calendar-cell-day { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; }
.calendar-cell.today .calendar-cell-day { background: var(--teal); color: white; }
.calendar-marks { display: flex; gap: 3px; min-height: 6px; }
.calendar-marks i, .legend-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; }
.mark-complete { background: #4ca879; }.mark-partial { background: var(--gold); }.mark-diary { background: var(--coral); }.mark-lab { background: var(--violet); }
.calendar-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 17px; color: var(--muted); font-size: 10px; }
.calendar-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot.complete { background: #4ca879; }.legend-dot.partial { background: var(--gold); }.legend-dot.diary { background: var(--coral); }.legend-dot.lab { background: var(--violet); }
.day-detail { margin-top: 15px; padding: 18px; }
.day-detail h3 { margin: 0; font: 700 18px "Space Grotesk", sans-serif; }
.day-detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 15px; }
.detail-number { padding: 10px; border-radius: 9px; background: var(--surface-soft); }.detail-number strong { display: block; font: 700 19px "Space Grotesk", sans-serif; }.detail-number span { color: var(--muted); font-size: 10px; }
.history-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; }

.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.segmented button { border: 0; border-radius: 6px; background: transparent; color: var(--muted); padding: 8px 11px; font-size: 11px; font-weight: 700; }
.segmented button.active { background: var(--teal); color: white; }
.insight-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.insight-stat { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.insight-stat strong { display: block; font: 700 26px/1 "Space Grotesk", sans-serif; letter-spacing: -.05em; }.insight-stat span { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.insights-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.insights-grid .panel { padding: 22px; }
.average-row { display: grid; grid-template-columns: 130px 1fr 30px; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.average-row:last-child { border-bottom: 0; }.average-bar { height: 7px; border-radius: 99px; background: var(--surface-soft); overflow: hidden; }.average-bar i { display: block; height: 100%; border-radius: inherit; background: var(--coral); }.average-row strong { color: var(--coral); text-align: right; font-size: 12px; }

.mobile-nav { display: none; }
.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(16, 39, 37, .45); z-index: 50; }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(100%, 500px); max-height: min(800px, calc(100vh - 40px)); overflow: auto; padding: 24px; border-radius: 18px; background: var(--surface); box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }.modal-head h2 { margin: 5px 0 0; font: 700 28px "Space Grotesk", sans-serif; letter-spacing: -.05em; }.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }.modal-tools { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }.modal-footnote { margin: 18px 0 0; color: var(--muted); font-size: 11px; }
.setting-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 9px; background: var(--surface-soft); }.setting-line strong, .setting-line span { display: block; }.setting-line strong { font-size: 12px; }.setting-line span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.switch { position: relative; display: inline-flex; width: 42px; height: 24px; flex: 0 0 auto; }.switch input { position: absolute; opacity: 0; }.switch span { width: 42px; height: 24px; border-radius: 999px; background: #cbd4d0; transition: background .2s; }.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }.switch input:checked + span { background: var(--teal); }.switch input:checked + span::after { transform: translateX(18px); }
.toast { position: fixed; left: 50%; bottom: 25px; z-index: 80; max-width: calc(100% - 30px); padding: 11px 15px; border-radius: 999px; background: var(--ink); color: white; box-shadow: 0 12px 25px rgba(0,0,0,.16); font-size: 12px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; }.toast.show { opacity: 1; transform: translate(-50%, 0); }.toast.error { background: var(--coral); }
.empty-state { padding: 22px 8px; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 1050px) {
  :root { --sidebar: 220px; }
  .main-content { padding-left: 28px; padding-right: 28px; }
  .profile-name { display: none; }
  .content-grid { grid-template-columns: 1fr; }.right-rail { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 780px) {
  body { padding-bottom: 72px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 0 16px 30px; }
  .topbar { min-height: 78px; }.topbar h1 { font-size: 23px; }.topbar-actions { gap: 7px; }
  .profile-chip { padding-right: 4px; }.profile-chip > svg { display: none; }
  .view { padding-top: 25px; }.today-intro { min-height: 150px; padding-bottom: 19px; }.today-intro h2 { font-size: 36px; }.today-intro p { font-size: 13px; }
  .progress-orbit { width: 100px; height: 100px; }.orbit-label strong { font-size: 20px; }
  .metric-row { grid-template-columns: repeat(2, 1fr); }.metric { padding: 12px 3px; }.metric span:last-child { white-space: normal; }.metric strong { font-size: 14px; }
  .right-rail, .labs-layout, .diary-layout, .history-columns, .insights-grid { grid-template-columns: 1fr; }
  .form-panel, .diary-form-panel { position: static; }.view-heading { align-items: flex-start; flex-direction: column; margin-bottom: 20px; }.view-heading > .primary-button { width: 100%; }.segmented { align-self: stretch; }.segmented button { flex: 1; }
  .insight-stats { grid-template-columns: repeat(2, 1fr); }.calendar-cell { min-height: 55px; }.history-columns { margin-top: 21px; }.month-switcher { align-self: stretch; justify-content: space-between; width: 100%; }
  .mobile-nav { position: fixed; inset: auto 0 0; display: grid; grid-template-columns: repeat(5, 1fr); z-index: 30; padding: 7px 4px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
  .mobile-nav button { display: grid; place-items: center; gap: 3px; padding: 3px 0; border: 0; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; }.mobile-nav button svg { width: 18px; height: 18px; }.mobile-nav button.active { color: var(--teal); }
  .info-band { align-items: flex-start; flex-wrap: wrap; }.info-band .text-button { margin-left: 45px; }
}
@media (max-width: 430px) {
  .today-intro { align-items: flex-start; }.today-intro h2 { font-size: 32px; }.today-intro p { max-width: 230px; }.progress-orbit { width: 82px; height: 82px; margin-top: 2px; }.orbit-label strong { font-size: 18px; }.orbit-label span { font-size: 9px; }
  .metric-icon { width: 28px; height: 28px; }.metric-icon svg { width: 14px; height: 14px; }.metric strong { font-size: 13px; }.metric span:last-child { font-size: 10px; }
  .routine-panel, .read-panel, .alert-panel, .form-panel, .diary-form-panel, .insights-grid .panel { padding: 16px; }.panel-head h3 { font-size: 17px; }.text-button { font-size: 11px; }.text-button:not(#markAll) { font-size: 11px; }
  .dose-state { display: none; }.supplement-copy span { max-width: 190px; }.calendar-week, .calendar-grid { gap: 3px; }.calendar-cell { min-height: 48px; border-radius: 7px; }.calendar-legend { gap: 8px; }
  .day-detail-grid { grid-template-columns: 1fr 1fr; }.day-detail-grid .detail-number:last-child { grid-column: span 2; }
  .modal { padding: 18px; }.modal-actions, .modal-tools { flex-direction: column; }.modal-actions button, .modal-tools button { width: 100%; }.form-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
@media print {
  .sidebar, .topbar-actions, .mobile-nav, .primary-button, .outline-button, .danger-button, .filter-bar, .toast { display: none !important; }
  .main-content { margin: 0; padding: 0; }.view { display: none !important; }.view.active { display: block !important; }.panel { box-shadow: none; }
}
