/* ===================================================================
   Fibro & Me — Stylesheet
   Design tokens mirror the original prototype: purple is used
   deliberately as the fibromyalgia awareness color, not an arbitrary
   brand choice.
=================================================================== */

:root {
  --bg: #F7F5F9;
  --surface: #FFFFFF;
  --ink: #2E2A3D;
  --ink-soft: #6E6980;
  --line: #E7E3ED;
  --primary: #6C5B8C;
  --primary-dark: #4A3D66;
  --primary-soft: #EDE8F5;
  --sage: #8FA88F;
  --zone-none: #E7E3ED;
  --zone-mild: #B9A6D9;
  --zone-moderate: #8C5FA8;
  --zone-severe: #B0487A;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: 84px;
}

h1, h2, h3 { font-family: "Fraunces", serif; margin: 0; }

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

.loading-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
}

/* ---------- Splash & onboarding ---------- */
.splash-screen {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px;
  cursor: pointer;
}
.splash-icon {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255,255,255,0.16);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
}
.splash-screen h1 { font-size: 36px; font-weight: 600; margin-bottom: 10px; }
.splash-screen p { font-size: 14px; color: rgba(255,255,255,0.75); max-width: 260px; }

.onboard-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
}
.onboard-slide {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.onboard-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
}
.onboard-slide h1 { font-size: 24px; font-weight: 600; margin-bottom: 12px; }
.onboard-slide p { font-size: 15px; color: var(--ink-soft); line-height: 1.6; max-width: 300px; }
.onboard-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 20px; }
.onboard-dot { width: 6px; height: 6px; border-radius: 3px; background: var(--line); transition: all 150ms ease; }
.onboard-dot.active { width: 20px; background: var(--primary); }
.onboard-actions { display: flex; gap: 10px; padding-bottom: 32px; }

/* ---------- Shared buttons ---------- */
.btn {
  border: none; border-radius: var(--radius-md); font-size: 15px; font-weight: 600;
  padding: 16px 0; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: none; border: 1.5px solid var(--line); color: var(--ink-soft); }
.btn-disabled { background: var(--line); color: var(--ink-soft); cursor: default; }
.btn-block { width: 100%; }
.btn-flex1 { flex: 1; }
.btn-flex2 { flex: 2; }

/* ---------- App header (persistent wordmark) ---------- */
.app-header {
  display: flex; align-items: center; gap: 8px; padding: 16px 20px 0;
}
.app-header span {
  font-family: "Fraunces", serif; font-weight: 600; font-size: 15px; color: var(--primary); letter-spacing: 0.2px;
}

.sync-pill {
  position: fixed; top: 10px; right: 10px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-soft); box-shadow: 0 2px 8px rgba(46,42,61,0.08);
}
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--zone-moderate); }

/* ---------- Generic tab/page layout ---------- */
.tab-page { padding: 28px 20px 20px; }
.tab-page h1 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.tab-page .subtitle { font-size: 14px; color: var(--ink-soft); margin: 0 0 16px; }
.section-label {
  font-size: 13px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: 0.4px; margin-bottom: 10px;
}
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 16px; }
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.card-title span {
  font-size: 13px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.4px;
}
.row-line { padding: 12px 0; border-bottom: 1px solid var(--line); }
.row-line:last-child { border-bottom: none; }
.field-label { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.field-input {
  width: 100%; border: none; background: none; font-size: 15px; font-weight: 500; color: var(--ink); padding: 0;
}
.text-input {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px;
}
textarea.plain {
  width: 100%; border: none; background: none; font-size: 15px; resize: none; color: var(--ink);
}

/* ---------- Today tab ---------- */
.flare-banner {
  background: #FBEAF0; border: 1px solid rgba(176,72,122,0.13); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 18px; display: flex; gap: 10px; align-items: flex-start;
}
.flare-banner strong { font-size: 14px; }
.flare-banner p { font-size: 13px; color: var(--ink-soft); margin: 2px 0 0; }

.checkin-cta {
  width: 100%; background: var(--primary); color: #fff; border: none; border-radius: 18px;
  padding: 18px 20px; display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.logged-banner {
  background: var(--primary-soft); border-radius: 18px; padding: 18px 20px;
  display: flex; align-items: center; gap: 12px;
}
.logged-check {
  background: var(--primary); border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logged-banner .title { font-weight: 600; font-size: 15px; }
.logged-banner .sub { font-size: 13px; color: var(--ink-soft); }

.plan-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.plan-remaining { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.plan-remaining.over { color: var(--zone-severe); }
.budget-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.budget-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.spoon-row { display: flex; gap: 6px; }
.spoon-btn { background: none; border: none; cursor: pointer; padding: 2px; }
.activity-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.activity-check {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; cursor: pointer;
  border: 2px solid var(--line); background: transparent; display: flex; align-items: center; justify-content: center;
}
.activity-check.done { border-color: var(--primary); background: var(--primary); }
.activity-name { flex: 1; font-size: 14px; }
.activity-name.done { text-decoration: line-through; color: var(--ink-soft); }
.activity-cost { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 3px; }
.composer-row { display: flex; gap: 8px; margin-top: 12px; }
.composer-row input, .composer-row select { flex: 1; }
.icon-btn {
  background: var(--primary-soft); border: none; border-radius: var(--radius-sm);
  padding: 0 12px; cursor: pointer; color: var(--primary); display: flex; align-items: center; justify-content: center;
}
.chart-box { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; height: 180px; margin-bottom: 8px; }
.chart-caption { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

/* ---------- Body map (check-in) ---------- */
.body-map-wrap { text-align: center; }
.body-map-legend { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.legend-item { display: flex; align-items: center; font-size: 12px; color: var(--ink-soft); }
.zone { cursor: pointer; stroke: var(--ink); stroke-opacity: 0.12; stroke-width: 1; transition: fill 150ms ease; }

/* ---------- Segmented control ---------- */
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.segmented button {
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer;
}
.segmented button.active { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ---------- Toggle switch ---------- */
.toggle {
  width: 44px; height: 26px; border-radius: 999px; border: none; padding: 3px;
  background: var(--line); cursor: pointer; display: flex; flex-shrink: 0;
}
.toggle.on { background: var(--primary); justify-content: flex-end; }
.toggle:not(.on) { justify-content: flex-start; }
.toggle-knob { width: 20px; height: 20px; border-radius: 50%; background: #fff; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 420px; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 8px 0 12px; z-index: 30;
}
.nav-btn {
  background: none; border: none; display: flex; flex-direction: column; align-items: center;
  gap: 4px; cursor: pointer; color: var(--ink-soft);
}
.nav-btn.active { color: var(--primary); }
.nav-btn span { font-size: 10px; font-weight: 500; }
.nav-btn.active span { font-weight: 600; }

/* ---------- Meds tab ---------- */
.med-row { background: var(--surface); border-radius: 16px; padding: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.med-name { font-size: 15px; font-weight: 600; }
.med-name.done { color: var(--ink-soft); text-decoration: line-through; }
.med-time { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.icon-ghost-btn { background: none; border: none; cursor: pointer; color: var(--ink-soft); padding: 6px; }
.pill-btn { background: var(--primary-soft); color: var(--primary); border: none; border-radius: var(--radius-sm); padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }

/* ---------- Profile tab ---------- */
.profile-header { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-family: "Fraunces", serif;
  font-size: 20px; font-weight: 600; flex-shrink: 0;
}
.profile-name-input {
  font-family: "Fraunces", serif; font-size: 20px; font-weight: 600; color: var(--ink);
  border: none; background: none; padding: 0; width: 100%;
}
.reset-link {
  width: 100%; background: none; border: none; padding: 16px 0 0; font-size: 13px;
  color: var(--ink-soft); text-decoration: underline; cursor: pointer;
}

/* ---------- Talk tab ---------- */
.crisis-note { background: var(--primary-soft); border-radius: 16px; padding: 12px 14px; margin-bottom: 18px; }
.crisis-note button {
  display: flex; align-items: center; gap: 8px; background: none; border: none; padding: 0;
  cursor: pointer; color: var(--primary); font-size: 13px; font-weight: 600; width: 100%; text-align: left;
}
.crisis-detail { font-size: 13px; color: var(--ink); margin-top: 10px; line-height: 1.6; }
.journal-entry { margin-bottom: 20px; }
.journal-meta { font-size: 11px; color: var(--ink-soft); margin-bottom: 6px; }
.journal-user-bubble {
  background: var(--primary-soft); border-radius: 16px 16px 4px 16px; padding: 10px 14px;
  font-size: 14px; color: var(--ink); margin-bottom: 8px; margin-left: 30px;
}
.journal-reply-row { display: flex; gap: 8px; align-items: flex-start; }
.journal-avatar {
  width: 22px; height: 22px; border-radius: 50%; background: var(--primary); display: flex;
  align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px;
}
.journal-reply-bubble {
  background: var(--surface); border-radius: 4px 16px 16px 16px; padding: 10px 14px;
  font-size: 14px; color: var(--ink); line-height: 1.5;
}
.error-line { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; color: var(--zone-severe); margin-top: 8px; }

/* ---------- Community tab ---------- */
.board-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.board-chip {
  flex-shrink: 0; padding: 7px 13px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.board-chip.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.post-card { background: var(--surface); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.post-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.post-author { font-size: 13px; font-weight: 600; }
.post-board { font-size: 11px; color: var(--ink-soft); }
.post-text { font-size: 14px; color: var(--ink); line-height: 1.5; margin-bottom: 10px; }
.post-actions { display: flex; align-items: center; gap: 16px; }
.post-action { display: flex; align-items: center; gap: 5px; background: none; border: none; cursor: pointer; color: var(--ink-soft); font-size: 12px; padding: 0; }
.post-action.active { color: var(--primary); cursor: default; }
.post-action.report-active { color: var(--zone-severe); cursor: default; }
.post-replies { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.reply-item { margin-bottom: 8px; }
.reply-author { font-size: 12px; font-weight: 600; }
.reply-text { font-size: 13px; color: var(--ink); line-height: 1.45; }

/* ---------- Modals (bottom sheets) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(46,42,61,0.4); display: flex;
  align-items: flex-end; justify-content: center; z-index: 60;
}
.modal-sheet {
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 28px 24px 32px;
  width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto;
}
.modal-icon-circle {
  border-radius: 50%; width: 48px; height: 48px; display: flex; align-items: center;
  justify-content: center; margin-bottom: 16px;
}
.modal-title { font-family: "Fraunces", serif; font-size: 19px; font-weight: 600; margin-bottom: 8px; }
.modal-body { font-size: 14px; color: var(--ink-soft); margin-bottom: 14px; line-height: 1.5; }

/* ---------- Check-in flow (full screen) ---------- */
.checkin-screen {
  position: fixed; inset: 0; background: var(--bg); max-width: 420px; margin: 0 auto;
  display: flex; flex-direction: column; z-index: 50;
}
.checkin-top { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 8px; }
.checkin-progress { display: flex; gap: 5px; }
.checkin-dot { width: 26px; height: 4px; border-radius: 2px; background: var(--line); }
.checkin-dot.active { background: var(--primary); }
.checkin-body { flex: 1; overflow-y: auto; padding: 12px 20px 20px; }
.checkin-body h2 { font-size: 22px; margin: 8px 0 4px; }
.checkin-body p.hint { font-size: 14px; color: var(--ink-soft); margin: 0 0 12px; }
.checkin-actions { padding: 12px 20px 24px; display: flex; gap: 10px; }
.spoon-picker { display: flex; gap: 10px; justify-content: center; padding: 20px 0; }
.spoon-picker button { background: none; border: none; cursor: pointer; padding: 4px; }
.spoon-caption { text-align: center; font-size: 14px; color: var(--ink-soft); }

@media (max-width: 380px) {
  .nav-btn span { font-size: 9px; }
}
