@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&display=swap');
@import './variables.css';

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

html { font-size: var(--text-base); -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-muted);
  line-height: 1.6;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: var(--nav-height);
  -webkit-font-smoothing: antialiased;
}

/* ─── SPLASH ─────────────────────────────────────────────────────────────── */

.splash {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}
.splash.hidden { opacity: 0; pointer-events: none; }
.splash-logo { width: 120px; height: 120px; opacity: 0.9; }

/* ─── BETA BANNER ────────────────────────────────────────────────────────── */

#beta-banner {
  background: var(--input-bg) !important;
  color: var(--text-secondary) !important;
  border-bottom: 1px solid var(--border) !important;
  font-size: 13px !important;
}
#beta-banner a { color: var(--text-secondary) !important; }

/* ─── VIEWS ──────────────────────────────────────────────────────────────── */

.view { display: none; padding: var(--space-lg) var(--space-lg) var(--space-2xl); }
.view.active { display: block; }

/* ─── CARDS ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-preferred);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-full);
  border: none;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition);
  width: 100%;
  letter-spacing: 0.01em;
}
.btn:active { opacity: 0.75; }

.btn-primary {
  background: var(--accent-amber);
  color: var(--bg-primary);
}
.btn-ghost {
  background: var(--input-bg);
  color: var(--input-text);
}

/* ─── INPUTS ─────────────────────────────────────────────────────────────── */

textarea,
input[type="text"],
input[type="number"] {
  background: var(--input-bg);
  color: var(--input-text);
  font-family: var(--font-body);
  border: none;
  border-radius: var(--radius-sm);
  outline: none;
}
textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus {
  box-shadow: 0 0 0 2px var(--bg-tertiary);
}

.datetime-input {
  background: var(--input-bg);
  color: var(--input-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px var(--space-sm);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  display: block;
  margin-top: var(--space-sm);
  color-scheme: light;
  outline: none;
}

/* ─── FORM ───────────────────────────────────────────────────────────────── */

.field { margin-bottom: var(--space-lg); }
.field:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.field-label-optional {
  color: var(--text-secondary);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--text-sm);
}
.field-note {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.6;
}
.field-hidden { display: none; }

/* ─── CHIPS ──────────────────────────────────────────────────────────────── */

.chips { display: flex; flex-wrap: wrap; gap: var(--space-sm); }

.chip {
  min-height: var(--tap-min);
  padding: 10px var(--space-md);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--bg-tertiary);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  line-height: 1.3;
}
.chip:active { opacity: 0.7; }
.chip.selected {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
  background: rgba(217,154,171,0.15);
}

/* ─── SLIDERS ────────────────────────────────────────────────────────────── */

.slider-wrap { padding: var(--space-sm) 0; }

input[type=range] {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  appearance: none;
  background: var(--bg-tertiary);
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-amber);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(205,116,146,0.35);
}
input[type=range]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--accent-amber);
  cursor: pointer;
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ─── SECTION HEADINGS ───────────────────────────────────────────────────── */

.section-title {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

/* ─── PAGE HEADER ────────────────────────────────────────────────────────── */

.page-header {
  padding: var(--space-xl) 0 var(--space-2xl);
}
.page-header h1 {
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.25;
}
.page-header p {
  color: var(--text-secondary);
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
}

/* ─── SECTION CARDS (today view) ─────────────────────────────────────────── */

.section-card {
  background: var(--input-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity var(--transition);
  border: 1.5px solid transparent;
}
.section-card:active { opacity: 0.75; }
.section-card.has-data { border-color: var(--bg-tertiary); }

.section-card-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.section-card-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.section-card-status {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.section-card-status.filled { color: var(--accent-sage); }
.section-card-arrow {
  font-size: 26px;
  color: var(--text-secondary);
  flex-shrink: 0;
  line-height: 1;
}

/* ─── SECTION SHEETS (bottom sheet modals) ───────────────────────────────── */

.section-sheet {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.section-sheet-inner {
  background: var(--bg-primary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 90dvh;
  width: 100%;
  max-width: 480px;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  -webkit-overflow-scrolling: touch;
}
.section-sheet.open .section-sheet-inner {
  transform: translateY(0);
}
.section-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.section-sheet-title {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-muted);
}
.section-sheet-done {
  background: var(--accent-amber);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-full);
  padding: 10px var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  min-height: var(--tap-min);
  transition: opacity var(--transition);
}
.section-sheet-done:active { opacity: 0.75; }
.section-sheet-body {
  padding: var(--space-lg);
}

/* ─── BOTTOM NAV ─────────────────────────────────────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-sm);
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.55);
  font-size: 11px;
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: none;
  border: none;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: #fff; }
.nav-icon { display: flex; align-items: center; justify-content: center; height: 24px; }

/* ─── ONBOARDING ─────────────────────────────────────────────────────────── */

.onboarding {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 200;
  overflow-y: auto;
  max-width: 480px;
  margin: 0 auto;
}
.onboarding-step {
  display: none;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-2xl) var(--space-lg) var(--space-2xl);
  min-height: 100dvh;
}
.onboarding-step.active { display: flex; }

.onboarding-progress {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}
.onboarding-header { display: flex; flex-direction: column; gap: var(--space-sm); }
.onboarding-header h1 {
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.25;
}
.onboarding-header p {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: 1.6;
}
.onboard-chips { gap: var(--space-sm); }

.btn-skip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-preferred);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-full);
  border: none;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  cursor: pointer;
  width: 100%;
  background: transparent;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: var(--space-sm);
  text-align: center;
  min-height: var(--tap-min);
  width: 100%;
}

/* ─── JOURNEY OPTIONS (onboarding) ──────────────────────────────────────── */

.journey-options { display: flex; flex-direction: column; gap: var(--space-sm); }
.journey-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
  padding: var(--space-lg);
  background: var(--input-bg);
  border: 1.5px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  transition: border-color var(--transition);
  width: 100%;
}
.journey-option:active { border-color: var(--accent-amber); }
.journey-option-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-muted);
}
.journey-option-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─── MEDICATIONS ────────────────────────────────────────────────────────── */

.med-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}
.med-item:last-child { border-bottom: none; }
.med-name { font-size: var(--text-base); color: var(--text-muted); }
.med-dose { font-size: var(--text-sm); color: var(--text-secondary); margin-left: var(--space-sm); }
.med-remove-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  transition: color var(--transition);
}
.med-remove-btn:active { color: var(--accent-rose); }
.med-form-row { display: flex; gap: var(--space-sm); }
.med-input {
  background: var(--input-bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--input-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  outline: none;
  min-height: var(--tap-min);
  flex: 1;
}
.med-input:focus { box-shadow: 0 0 0 2px var(--bg-tertiary); }
.med-input-sm { flex: 0 0 90px; }

/* ─── BLOOD PRESSURE ─────────────────────────────────────────────────────── */

.bp-row { display: flex; align-items: center; gap: var(--space-sm); }
.bp-input {
  width: 80px;
  background: var(--input-bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--input-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  text-align: center;
  outline: none;
  min-height: var(--tap-min);
}
.bp-input:focus { box-shadow: 0 0 0 2px var(--bg-tertiary); }
.bp-sep { color: var(--text-secondary); font-size: var(--text-lg); font-weight: 300; }
.bp-unit { color: var(--text-secondary); font-size: var(--text-sm); }

/* ─── EWS / HRV CARD ─────────────────────────────────────────────────────── */

.hrv-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}
.hrv-card-header .section-title { margin-bottom: 0; }
.post-mvp-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--input-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.hrv-card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}
.hrv-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}
.hrv-status-dot.ok      { background: var(--accent-sage); }
.hrv-status-dot.warning { background: var(--warning); }
.hrv-status-dot.alert   { background: var(--accent-rose); }
.ews-monitors { display: flex; flex-direction: column; gap: var(--space-md); margin-bottom: var(--space-lg); }
.ews-monitor { display: flex; align-items: center; gap: var(--space-md); }
.ews-monitor-name   { font-size: var(--text-sm); color: var(--text-muted); font-weight: 500; }
.ews-monitor-status { font-size: 12px; color: var(--text-secondary); }
.ews-combined { border-top: 1px solid var(--border); padding-top: var(--space-md); }
.ews-combined-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.ews-combined-desc { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }

/* ─── PROFILE ────────────────────────────────────────────────────────────── */

.profile-empty { color: var(--text-secondary); font-size: var(--text-sm); margin-bottom: var(--space-sm); }
.profile-meta { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-md); }
.profile-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
}
.profile-tags { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.profile-tag {
  font-size: 13px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(217,154,171,0.18);
  color: var(--text-on-green);
  border: 1px solid rgba(217,154,171,0.3);
}

/* ─── SAFETY MODAL ───────────────────────────────────────────────────────── */

.safety-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-md);
  max-width: 480px;
  margin: 0 auto;
}
.safety-modal-card {
  background: #2a1f1c;
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-md) var(--radius-md);
  padding: var(--space-xl) var(--space-lg);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}
.safety-modal-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.safety-modal-eyebrow.urgent   { color: #c4a265; }
.safety-modal-eyebrow.emergency { color: #e07878; }
.safety-modal-title {
  font-size: var(--text-lg);
  font-weight: 400;
  color: #f0ebe6;
  letter-spacing: -0.01em;
}
.safety-modal-body {
  color: #c8b9b2;
  line-height: 1.7;
  font-size: var(--text-base);
}
.safety-modal-actions { display: flex; flex-direction: column; gap: var(--space-sm); }

/* ─── HISTORY ────────────────────────────────────────────────────────────── */

.history-empty {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.8;
}
.history-date-group { margin-bottom: var(--space-xl); }
.history-date-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}
.history-entry {
  background: var(--input-bg);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.history-entry-top { display: flex; align-items: center; justify-content: space-between; }
.history-entry-time { font-size: var(--text-sm); color: var(--text-secondary); font-weight: 300; }
.history-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}
.history-badge-checkin { background: rgba(90,144,114,0.18); color: var(--accent-sage); }
.history-badge-flare   { background: rgba(217,154,171,0.2); color: var(--text-on-green); }
.history-entry-detail { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.6; }
.history-entry-tags { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.history-edit-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 4px var(--space-sm);
  min-height: var(--tap-min);
  transition: color var(--transition);
}
.history-edit-btn:active { color: var(--accent-rose); }
.history-tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-on-green);
}

/* ─── COMPLETION ─────────────────────────────────────────────────────────── */

.completion {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
}
.completion h2 {
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}
.completion p { color: var(--text-secondary); font-size: var(--text-base); }
