/* ===========================================================================
   Tempaura — mobile-first stylesheet. Calm blue/green palette, iOS-like surfaces,
   large touch targets, dark-mode aware. No build step / no external fonts.
   =========================================================================== */
:root {
  --primary: #7B81D6;        /* soft periwinkle (from logo) */
  --primary-dark: #646AC2;
  --accent: #8FC0F2;         /* soft sky blue (logo ring) */
  --accent-soft: #E7ECFB;
  --bg: #F5F5FC;             /* airy cool near-white */
  --surface: #FFFFFF;
  --surface-alt: #EFF0FA;
  --text: #34344A;           /* soft slate, not harsh black */
  --muted: #8E8CA6;
  --border: #E8E8F4;
  --danger: #C77E91;         /* muted rose */
  --warn: #CFA15C;           /* soft amber */
  --ok: #7FB6A6;             /* soft teal-sage */
  --radius: 20px;
  --shadow: 0 6px 20px rgba(86, 84, 140, 0.10);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #AEB2EC; --primary-dark: #9296D8; --accent: #A9CEF6; --accent-soft: #2E2E40;
    --bg: #15151E; --surface: #1E1E2A; --surface-alt: #272736; --text: #ECECF5; --muted: #9E9CB6;
    --border: #313143; --danger: #D69AA8; --warn: #D6B070; --ok: #93C2B2;
    --shadow: 0 6px 18px rgba(0,0,0,0.45);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  background: #0d1117; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
/* Phone frame on large screens; full-bleed on phones. */
#device {
  width: 100%; height: 100%;
}
@media (min-width: 600px) {
  body { background: radial-gradient(circle at 50% 30%, #20293a, #0d1117); }
  #device {
    width: 414px; height: 896px; max-height: 96vh;
    border-radius: 44px; overflow: hidden;
    box-shadow: 0 20px 70px rgba(0,0,0,0.55), inset 0 0 0 11px #11151c, inset 0 0 0 13px #2a2f39;
    background: var(--bg);
  }
}
.app {
  position: relative; height: 100%; width: 100%;
  background: var(--bg); display: flex; flex-direction: column; overflow: hidden;
}
.loading { margin: auto; color: var(--muted); }

/* ---- Header ---- */
.appbar {
  flex: 0 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; min-height: 56px;
}
.appbar h1 { font-size: 20px; margin: 0; font-weight: 600; font-family: var(--font-display); }
.appbar .sub { color: var(--muted); font-size: 13px; }
.appbar .spacer { flex: 1; }
.appbar button.icon { background: none; border: none; color: var(--primary); font-size: 15px; font-weight: 600; }

/* ---- Scrollable content ---- */
.content { flex: 1 1 auto; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.content.with-tabs { padding-bottom: 92px; }

/* ---- Tab bar ---- */
.tabbar {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom); z-index: 20;
}
.tabbar button {
  flex: 1; background: none; border: none; padding: 8px 0 10px;
  color: var(--muted); font-size: 10px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; cursor: pointer;
}
.tabbar button.active { color: var(--primary); }
.tabbar .ico { font-size: 22px; line-height: 1; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.card h3 { margin: 0 0 10px; font-size: 16px; font-family: var(--font-display); font-weight: 600; }
.card .label { color: var(--muted); font-size: 13px; }
.section-title { font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.4px; margin: 6px 2px 8px; font-weight: 600; }

/* ---- Risk ring ---- */
.risk { display: flex; align-items: center; gap: 16px; }
.ring { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--ring-color) var(--ring-deg), var(--border) 0); flex: 0 0 auto; }
.ring .inner { width: 74px; height: 74px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; text-align: center; }
.ring .pct { font-size: 22px; font-weight: 600; font-family: var(--font-display); }
.ring .cap { font-size: 10px; color: var(--muted); text-transform: uppercase; }

/* ---- Quick actions grid ---- */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 6px; text-align: center; cursor: pointer; box-shadow: var(--shadow);
}
.quick .ico { font-size: 26px; }
.quick .t { font-size: 11px; color: var(--text); margin-top: 4px; display: block; }
.quick.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.quick.primary .t { color: #fff; }

/* ---- Stats row ---- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat .v { font-size: 22px; font-weight: 600; font-family: var(--font-display); }
.stat .k { font-size: 12px; color: var(--muted); }
.trend-improving { color: var(--ok); } .trend-worsening { color: var(--danger); } .trend-stable { color: var(--muted); }

/* ---- Forms ---- */
label.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
label.field span { display: block; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 16px; background: var(--surface); color: var(--text); font-family: inherit;
}
textarea { min-height: 70px; resize: vertical; }
.btn {
  display: block; width: 100%; padding: 14px; border: none; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
  margin-top: 4px;
}
.btn:active { background: var(--primary-dark); }
.btn.secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.ghost { background: var(--border); color: var(--text); }
.btn:disabled { opacity: 0.5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---- Severity slider ---- */
.severity-val { font-size: 44px; font-weight: 700; text-align: center; font-family: var(--font-display); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; cursor: pointer; user-select: none;
}
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- List items ---- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.sev-dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
.list-item .meta { flex: 1; } .list-item .meta .t { font-weight: 600; font-size: 14px; }
.list-item .meta .s { color: var(--muted); font-size: 12px; }

/* ---- Correlation bars ---- */
.corr { margin: 10px 0; }
.corr .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.corr .bartrack { height: 8px; background: var(--border); border-radius: 5px; position: relative; overflow: hidden; }
.corr .barfill { height: 100%; border-radius: 5px; }
.badge { font-size: 10px; padding: 2px 7px; border-radius: 10px; background: var(--accent); color: #fff; }

/* ---- Auth ---- */
.auth-wrap { margin: auto; width: 100%; max-width: 340px; padding: 20px; text-align: center; }
.logo { font-size: 40px; } .auth-wrap h1 { margin: 8px 0 2px; font-family: var(--font-display); font-weight: 700; }
.brand-logo { width: 180px; max-width: 70%; height: auto; margin: 0 auto 6px; display: block; }
.auth-wrap p.tag { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.link { color: var(--primary); background: none; border: none; font-size: 14px; cursor: pointer; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.insight { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.insight .label { color: rgba(255,255,255,0.85); }
.pill { display:inline-block; padding:3px 10px; border-radius:12px; font-size:11px; font-weight:600; }
.pill.low { background: #E4F0EA; color: var(--ok); }
.pill.moderate { background: #FBF1DE; color: var(--warn); }
.pill.high { background: #F6E1E8; color: var(--danger); }

.progress-steps { display: flex; gap: 6px; margin-bottom: 16px; }
.progress-steps .s { flex:1; height: 4px; border-radius: 3px; background: var(--border); }
.progress-steps .s.on { background: var(--primary); }

.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 24px;
  font-size: 14px; z-index: 100; box-shadow: var(--shadow); max-width: 320px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .ico { font-size: 40px; }
.waterglasses { display:flex; flex-wrap:wrap; gap:8px; font-size:30px; }
.waterglasses span { cursor:pointer; opacity:0.35; }
.waterglasses span.full { opacity:1; }

/* =========================================================================
   Parity components (Today briefing, progress bars, lists, pickers, etc.)
   ========================================================================= */
.tappable { cursor: pointer; }
.warn { color: var(--warn); }
.accent { color: var(--accent); }
.ok { color: var(--ok); }

/* Greeting + briefing hero */
.greeting { font-family: var(--font-display); font-size: 26px; font-weight: 600; margin: 2px 2px 14px; }
.insight .briefing { margin-top: 6px; font-size: 15px; line-height: 1.5; }

/* Risk factor mini chips */
.minichips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.minichip { background: var(--surface-alt); color: var(--muted); font-size: 11px; padding: 4px 9px; border-radius: 10px; }

/* Linear progress bar */
.bar-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; margin-bottom: 8px; }
.track { height: 9px; background: var(--border); border-radius: 6px; overflow: hidden; }
.track .fill { height: 100%; border-radius: 6px; transition: width .3s ease; }

/* Mini stat trio */
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; text-align: center; }
.mini .v { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.mini .k { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* 3-up stats */
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stat .v.trend-improving, .stat .v.trend-worsening, .stat .v.trend-stable { font-size: 16px; text-transform: capitalize; }

/* Top trigger + date chips */
.big-accent { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--accent); }
.datechips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.datechip { background: var(--accent-soft); color: var(--primary); font-size: 12px; padding: 6px 11px; border-radius: 12px; }
.datechip.danger { background: #F6E1E8; color: var(--danger); }
.weather-line { font-size: 14px; margin: 4px 0 6px; }

/* Inline add-row (input + button) */
.add-row { display: flex; gap: 8px; align-items: stretch; }
.add-row input { flex: 1; }
.btn.compact { width: auto; margin: 0; padding: 0 16px; white-space: nowrap; }

/* Toggle switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; font-size: 14px; }
.toggle { width: 46px; height: 28px; border-radius: 16px; background: var(--border); border: none; position: relative; cursor: pointer; flex: 0 0 auto; }
.toggle span { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .2s ease; }
.toggle.on { background: var(--primary); }
.toggle.on span { left: 21px; }

/* Trigger domain label */
.domain-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 12px 0 8px; font-weight: 600; }

/* Pill button rows (quick sleep/stress) */
.pillrow { display: flex; gap: 8px; flex-wrap: wrap; }
.pillbtn { flex: 1; min-width: 56px; padding: 12px 0; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; }
.pillbtn:active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Segmented control */
.segmented { display: flex; gap: 6px; background: var(--surface-alt); padding: 4px; border-radius: 14px; }
.segmented button { flex: 1; padding: 9px 4px; border: none; background: none; border-radius: 10px; font-size: 13px; color: var(--muted); cursor: pointer; text-transform: capitalize; font-family: inherit; }
.segmented button.on { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }

.taglist { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }

/* List rows: leading/trailing slots */
.list-item .lead { flex: 0 0 auto; font-size: 22px; }
.list-item .lead.time { font-weight: 700; color: var(--primary); font-size: 15px; }
.list-item .lead.meal { font-size: 11px; color: var(--muted); text-transform: uppercase; width: 64px; }
.list-item .trail { flex: 0 0 auto; font-size: 13px; }
.list-item .trail.accent { color: var(--accent); font-weight: 600; }
.list-item .trail.ok { color: var(--ok); font-weight: 600; }
.list-item .add-plus { font-size: 22px; color: var(--primary); }

/* Camera scanner */
.scanner { width: 100%; border-radius: 14px; margin-top: 10px; background: #000; max-height: 300px; object-fit: cover; }

/* Med picker list */
.picklist { margin-top: 8px; }
.pickitem { padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.pickitem.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.pickitem .t { font-weight: 600; font-size: 14px; }
.pickitem .s { font-size: 12px; opacity: .8; }

/* Cycle info grid */
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.info { background: var(--surface-alt); border-radius: 12px; padding: 10px 12px; }
.info .k { font-size: 11px; color: var(--muted); }
.info .v { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin-top: 2px; }

/* Forecast rows */
.forecast-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.forecast-row:last-child { border-bottom: none; }
.fday { width: 56px; font-size: 13px; font-weight: 600; }
.fdot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.fpct { width: 44px; font-weight: 700; font-size: 14px; }
.ffactor { flex: 1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Key/value rows */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: none; }

/* History */
.filter-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.month-head { font-size: 13px; font-weight: 700; color: var(--muted); margin: 8px 2px; }

/* More hub */
.nav-card .list-item { padding: 14px 0; }
.navico { font-size: 22px; }

/* Premium upsell card */
.premium-card { border: 1px solid var(--accent); background: linear-gradient(180deg, var(--surface), var(--accent-soft)); }
.premium-list { margin: 8px 0 14px; padding-left: 18px; font-size: 14px; color: var(--text); }
.premium-list li { margin: 4px 0; }

/* Compact combined risk + briefing hero */
.today-hero { display: flex; align-items: center; gap: 14px; }
.ring.small { width: 62px; height: 62px; }
.ring.small .inner { width: 48px; height: 48px; }
.ring.small .pct { font-size: 15px; }
.ring.small .cap { font-size: 8px; }
.hero-text { flex: 1; min-width: 0; }
.hero-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.hero-brief { font-size: 12.5px; line-height: 1.4; margin-top: 3px; }

/* Tappable progress rows (hydration / calories) */
.bar-tap { display: block; width: 100%; text-align: left; background: none; border: none; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; }
.bar-tap .add { color: var(--primary); font-weight: 700; margin-left: 6px; }
.bar-tap:active .fill { filter: brightness(0.95); }

/* 4-up compact quick log */
.quick-grid.four { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-grid.four .quick { padding: 12px 4px; }
.quick-grid.four .ico { font-size: 22px; }
.quick-grid.four .t { font-size: 10.5px; }

/* Gentle view-mount transition (softens page-to-page redraws) */
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.content { animation: viewIn 0.2s ease both; }
.auth-wrap { animation: viewIn 0.24s ease both; }
@media (prefers-reduced-motion: reduce) { .content, .auth-wrap { animation: none; } }

/* Bottom-sheet modal */
.sheet-overlay { position: absolute; inset: 0; z-index: 50; display: flex; align-items: flex-end;
  background: rgba(30, 26, 45, 0); transition: background 0.22s ease; }
.sheet-overlay.open { background: rgba(30, 26, 45, 0.40); }
.sheet { width: 100%; background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 12px 18px calc(20px + var(--safe-bottom)); box-shadow: 0 -10px 34px rgba(0,0,0,0.20);
  transform: translateY(100%); transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheet-overlay.open .sheet { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 3px; background: var(--border); margin: 2px auto 14px; }
.sheet-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin-bottom: 12px; }

/* Announcement banner */
.announce { position: relative; background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 14px; padding: 14px 36px 14px 14px; margin-bottom: 14px; }
.announce-t { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.announce-b { font-size: 13px; color: var(--text); }
.announce-x { position: absolute; top: 8px; right: 10px; background: none; border: none;
  font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; }
