:root {
  color-scheme: light;
  --ink: #2d2628;
  --muted: #756b6d;
  --paper: #f8f3ef;
  --card: rgba(255, 255, 255, 0.86);
  --line: #e8ded8;
  --rose: #b65c73;
  --rose-dark: #8f4055;
  --rose-pale: #f6dfe4;
  --plum: #76536f;
  --sage: #6e8878;
  --shadow: 0 14px 40px rgba(76, 48, 55, 0.09);
  --radius: 24px;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgba(231, 194, 203, .38), transparent 32rem),
    linear-gradient(155deg, #fbf8f5 0%, var(--paper) 60%, #f3ece8 100%);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
button:disabled { opacity: .6; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 5px;
  color: var(--rose-dark);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-family: Georgia, serif; font-size: 1.65rem; font-weight: 500; letter-spacing: -.035em; }
h3 { margin-bottom: 0; font-size: 1rem; }

.login-view {
  width: min(100%, 420px);
  min-height: 100dvh;
  margin: auto;
  padding: max(15vh, 90px) 28px 40px;
  text-align: center;
}
.login-mark {
  display: grid;
  width: 74px;
  height: 74px;
  margin: 0 auto 26px;
  place-items: center;
  border-radius: 26px;
  color: white;
  background: linear-gradient(145deg, #c8798c, var(--rose-dark));
  box-shadow: 0 18px 38px rgba(143, 64, 85, .26);
  font-family: Georgia, serif;
  font-size: 2.3rem;
}
.login-copy { margin: 12px auto 28px; max-width: 280px; line-height: 1.5; }
.pin-form { text-align: left; }
.pin-form input { text-align: center; letter-spacing: .55em; font-size: 1.55rem; }
.privacy-note { margin: 30px auto 0; max-width: 270px; color: var(--muted); font-size: .77rem; line-height: 1.5; }

.app { width: min(100%, 560px); min-height: 100dvh; margin: auto; }
.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 20px 13px;
  background: rgba(248, 243, 239, .86);
  border-bottom: 1px solid rgba(232, 222, 216, .65);
  backdrop-filter: blur(18px);
}
.icon-button, .close-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.72);
  box-shadow: 0 5px 18px rgba(70, 42, 49, .08);
  font-weight: 800;
}
.content { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.panel { display: none; animation: rise .25s ease; }
.panel.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

.start-card, .active-card {
  overflow: hidden;
  padding: 24px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.start-card { text-align: center; }
.start-card h2 { margin-top: 4px; }
.start-card > .muted { margin: 8px 0 22px; font-size: .9rem; }
.side-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side-button {
  position: relative;
  min-height: 146px;
  padding: 18px 10px;
  border: 0;
  border-radius: 24px;
  color: #623847;
  background: linear-gradient(145deg, #fae8eb, #f1d6dd);
  box-shadow: inset 0 1px rgba(255,255,255,.8);
}
.side-button.right { color: #544052; background: linear-gradient(145deg, #eee6ee, #e3d5e4); }
.side-letter { display: block; margin-bottom: 7px; font-family: Georgia, serif; font-size: 3rem; line-height: 1; }
.side-name { font-size: .85rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.recommended {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--sage);
  font-size: .56rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.last-feed { margin: 18px 0 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.last-feed-side { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.last-feed-start { color: var(--rose-dark); font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; }
.last-feed-end { color: var(--muted); font-size: .8rem; }
.last-feed-duration { color: var(--muted); font-size: .8rem; }
.last-feed-empty { color: var(--muted); font-size: .82rem; }

.active-card { position: relative; text-align: center; background: linear-gradient(160deg, #fff 0%, #f9e8ec 100%); }
.pulse {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 18px;
  color: var(--rose-dark);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.pulse::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 7px rgba(182,92,115,.11); }
.pulse.paused { color: var(--muted); }
.pulse.paused::before { background: var(--muted); box-shadow: 0 0 0 7px rgba(117,107,109,.1); }
.timer-side { color: var(--muted); font-size: .88rem; }
.timer-value { margin: 8px 0 5px; font-variant-numeric: tabular-nums; font-size: clamp(3.3rem, 15vw, 5rem); font-weight: 300; letter-spacing: -.06em; }
.total-time { margin-bottom: 24px; color: var(--muted); font-size: .8rem; }
.active-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.timer-utilities { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 9px; }
.cancel-link { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--muted); font-size: .75rem; text-decoration: underline; }
.sleep-block { margin-top: 12px; }
.sleep-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border: 1px solid rgba(255,255,255,.78); border-radius: 22px; background: linear-gradient(145deg, rgba(244,240,249,.94), rgba(229,223,242,.82)); box-shadow: 0 8px 25px rgba(78,63,103,.07); }
.sleep-card h3 { margin-bottom: 3px; font-family: Georgia, serif; font-size: 1.25rem; font-weight: 500; }
.sleep-card p { margin-bottom: 0; color: var(--muted); font-size: .76rem; }
.sleep-card p strong { color: #66547f; font-variant-numeric: tabular-nums; }
.sleep-text { color: #675486; }
.button.sleep-primary { color: white; background: linear-gradient(145deg, #8876a7, #66547f); box-shadow: 0 8px 20px rgba(81,65,109,.18); }
.active-sleep > div:first-child { display: grid; }
.active-sleep strong { margin: 4px 0; font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.active-sleep small { color: var(--muted); font-size: .7rem; }
.sleeping-status { color: #66547f; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.sleep-actions { display: grid; justify-items: center; }
.sleep-actions .cancel-link { min-height: 36px; }

.section-block { margin-top: 28px; }
.section-heading, .page-heading, .balance-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-heading { margin: 6px 4px 22px; }
.heading-actions { display: flex; gap: 6px; }
.text-button { min-width: 44px; min-height: 44px; padding: 8px 0; border: 0; color: var(--rose-dark); background: none; font-size: .8rem; font-weight: 750; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stats-grid.four { grid-template-columns: repeat(2, 1fr); }
.stat {
  min-width: 0;
  padding: 16px 12px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 18px;
  background: rgba(255,255,255,.65);
}
.stat strong { display: block; margin-bottom: 4px; font-size: 1.25rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat span { color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.sleep-stat { background: rgba(244,240,249,.72); }

.feed-list, .history-list { display: grid; gap: 9px; }
.feed-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 18px;
  background: rgba(255,255,255,.68);
  text-align: left;
}
button.feed-row { cursor: pointer; }
.feed-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 15px; color: var(--rose-dark); background: var(--rose-pale); font-family: Georgia, serif; font-size: 1.1rem; }
.sleep-row .feed-icon { color: #66547f; background: #e9e3f1; }
.feed-main strong, .feed-main small { display: block; }
.feed-main strong { margin-bottom: 3px; font-size: .9rem; }
.feed-main small, .feed-end { color: var(--muted); font-size: .72rem; }
.feed-end { color: var(--muted); font-size: 1.25rem; text-align: right; }
.empty-state { padding: 28px 18px; border: 1px dashed #d9cbc5; border-radius: 20px; color: var(--muted); text-align: center; font-size: .86rem; line-height: 1.5; }
.day-heading { margin: 20px 4px 9px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.insight-card { margin-bottom: 12px; padding: 20px; border: 1px solid rgba(255,255,255,.78); border-radius: 24px; background: rgba(255,255,255,.7); box-shadow: 0 8px 28px rgba(70,42,49,.05); }
.insight-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.insight-heading > strong { color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.sleep-rhythm-card { overflow: hidden; }
.sleep-rhythm-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.sleep-rhythm-summary > span { padding: 11px 12px; border-radius: 14px; background: rgba(244,240,249,.72); }
.sleep-rhythm-summary > .muted { grid-column: 1 / -1; }
.sleep-rhythm-summary small, .sleep-rhythm-summary strong { display: block; }
.sleep-rhythm-summary small { margin-bottom: 3px; color: var(--muted); font-size: .64rem; }
.sleep-rhythm-summary strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.sleep-chart-legend { display: flex; justify-content: flex-end; gap: 16px; margin: 17px 3px 0; color: var(--muted); font-size: .65rem; font-weight: 700; }
.sleep-chart-legend span { display: flex; align-items: center; gap: 5px; }
.sleep-chart-legend span::before { content: ""; width: 15px; border-top: 3px solid var(--rose); border-radius: 9px; }
.sleep-chart-legend .yesterday::before { border-top: 2px solid #a99171; }
.sleep-chart-legend .expected::before { border-top: 2px dashed #66547f; }
.sleep-rhythm-chart { min-height: 190px; margin: 0 -6px; }
.sleep-rhythm-chart svg { display: block; width: 100%; overflow: visible; }
.sleep-grid-line { stroke: var(--line); stroke-width: 1; }
.sleep-axis-label { fill: var(--muted); font-size: 9px; text-anchor: middle; }
.sleep-axis-label.y { text-anchor: end; }
.sleep-now-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: .55; }
.sleep-curve { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sleep-curve.today { stroke: var(--rose); stroke-width: 3; }
.sleep-curve.yesterday { stroke: #a99171; stroke-width: 2; }
.sleep-curve.expected { stroke: #66547f; stroke-width: 2; stroke-dasharray: 6 5; }
.sleep-now-dot.today { fill: var(--rose); }
.sleep-now-dot.expected { fill: #66547f; }
.chart-note { margin: -2px 2px 0; color: var(--muted); font-size: .69rem; line-height: 1.45; }
.sleep-likelihood-title { margin: 20px 0 12px; font-size: .72rem; font-weight: 800; }
.sleep-likelihood-chart { display: grid; gap: 10px; }
.sleep-likelihood-row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.sleep-likelihood-slot { display: grid; gap: 4px; min-width: 0; text-align: center; }
.sleep-likelihood-slot > i { display: block; height: 30px; border-radius: 6px; }
.sleep-likelihood-slot > small { color: var(--muted); font-size: .52rem; font-style: normal; font-variant-numeric: tabular-nums; }
.likelihood-0 { background: #f0ebf3; }
.likelihood-1 { background: #dcd1e4; }
.likelihood-2 { background: #b7a3c8; }
.likelihood-3 { background: #88709f; }
.likelihood-4 { background: #5c4774; }
.sleep-likelihood-legend { display: flex; flex-wrap: wrap; gap: 7px 12px; margin: 15px 0 11px; color: var(--muted); font-size: .57rem; font-weight: 700; }
.sleep-likelihood-legend span { display: flex; align-items: center; gap: 4px; }
.sleep-likelihood-legend i { width: 8px; height: 8px; border-radius: 3px; }
.likelihood-note { margin-top: 0; }
.pattern-list { display: grid; gap: 0; margin-top: 12px; }
.pattern-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); }
.pattern-row:first-child { border-top: 0; }
.pattern-row small, .pattern-row strong { display: block; }
.pattern-row small { margin-bottom: 3px; color: var(--muted); font-size: .64rem; }
.pattern-row strong { font-size: .9rem; font-variant-numeric: tabular-nums; }
.pattern-row p { max-width: 155px; margin: 0; color: var(--muted); font-size: .65rem; line-height: 1.35; text-align: right; }
.history-insight-heading { margin: 25px 4px 13px; }
.week-chart { display: grid; height: 190px; grid-auto-flow: column; grid-auto-columns: 1fr; gap: clamp(2px,1.5vw,8px); align-items: end; margin-top: 22px; }
.week-chart.dense > .bar-column > strong { display: none; }
.week-chart.dense .bar-column small { font-size: .5rem; }
.bar-column { display: grid; height: 100%; grid-template-rows: auto 1fr auto; gap: 7px; align-items: end; text-align: center; }
.bar-column > strong { overflow: hidden; color: var(--muted); font-size: .56rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.bar-wrap { display: flex; height: 100%; align-items: end; justify-content: center; }
.bar { width: min(100%, 27px); height: var(--level); min-height: 4px; border-radius: 9px 9px 4px 4px; background: linear-gradient(#c97d8e, #a84e66); box-shadow: 0 5px 14px rgba(168,78,102,.16); }
.bar.sleep-bar { background: linear-gradient(#9a89b5, #66547f); box-shadow: 0 5px 14px rgba(86,69,116,.14); }
.bar.awake-bar { background: linear-gradient(#84b199, #4f8168); box-shadow: 0 5px 14px rgba(79,129,104,.16); }
.bar.between-bar { background: linear-gradient(#e2b878, #c68a3e); box-shadow: 0 5px 14px rgba(198,138,62,.16); }
.bar-column small { color: var(--muted); font-size: .65rem; font-weight: 700; }
.balance-heading { align-items: center; }
.balance-heading strong { color: var(--rose-dark); font-size: .8rem; }
.balance-track { overflow: hidden; height: 13px; margin: 22px 0 12px; border-radius: 99px; background: #e3d5e4; }
.balance-track span { display: block; width: var(--level); height: 100%; border-radius: inherit; background: #cf8093; }
.level-0 { --level: 0%; }
.level-1 { --level: 5%; }
.level-2 { --level: 10%; }
.level-3 { --level: 15%; }
.level-4 { --level: 20%; }
.level-5 { --level: 25%; }
.level-6 { --level: 30%; }
.level-7 { --level: 35%; }
.level-8 { --level: 40%; }
.level-9 { --level: 45%; }
.level-10 { --level: 50%; }
.level-11 { --level: 55%; }
.level-12 { --level: 60%; }
.level-13 { --level: 65%; }
.level-14 { --level: 70%; }
.level-15 { --level: 75%; }
.level-16 { --level: 80%; }
.level-17 { --level: 85%; }
.level-18 { --level: 90%; }
.level-19 { --level: 95%; }
.level-20 { --level: 100%; }
.balance-details { display: flex; justify-content: space-between; color: var(--muted); font-size: .76rem; }
.gentle-note { padding: 9px 14px; color: var(--muted); font-size: .72rem; line-height: 1.5; text-align: center; }
.growth-hero { margin-bottom: 18px; padding: 30px 22px; border: 1px solid rgba(255,255,255,.8); border-radius: 26px; background: linear-gradient(150deg, rgba(255,255,255,.88), rgba(235,241,233,.85)); box-shadow: var(--shadow); text-align: center; }
.growth-hero > span { display: grid; width: 52px; height: 52px; margin: 0 auto 14px; place-items: center; border-radius: 18px; color: #fff; background: var(--sage); font-size: 1.5rem; }
.growth-hero h3 { margin-bottom: 6px; font-family: Georgia, serif; font-size: 1.4rem; font-weight: 500; }
.growth-hero p { margin-bottom: 0; color: var(--muted); font-size: .82rem; }
.growth-hero.has-data strong, .growth-hero.has-data small { display: block; }
.growth-hero.has-data strong { margin: 10px 0 7px; font-family: Georgia, serif; font-size: 1.75rem; font-weight: 500; }
.growth-hero.has-data small { color: var(--muted); font-size: .75rem; }
.growth-chart-card { margin-bottom: 18px; padding: 17px 13px 14px; border: 1px solid rgba(255,255,255,.8); border-radius: 24px; background: rgba(255,255,255,.72); box-shadow: var(--shadow); }
.growth-chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 10px; }
.growth-chart-heading h3 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 1.25rem; font-weight: 500; }
.growth-chart-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 12px; background: #eee6e2; }
.growth-chart-switch button { min-height: 34px; padding: 0 10px; border: 0; border-radius: 9px; color: var(--muted); background: none; font-size: .7rem; font-weight: 800; }
.growth-chart-switch button.active { color: var(--ink); background: white; box-shadow: 0 2px 8px rgba(62,43,48,.1); }
.growth-chart { display: block; width: 100%; height: auto; overflow: visible; }
.growth-grid { stroke: var(--line); stroke-width: .75; }
.growth-tick { stroke: var(--muted); stroke-width: .7; }
.growth-axis-label, .growth-axis-title, .growth-percentile-label { fill: var(--muted); font-family: system-ui, sans-serif; font-size: 8px; font-weight: 650; }
.growth-axis-title { font-size: 8.5px; font-weight: 800; }
.growth-percentile-label { font-size: 7px; }
.growth-reference-line { fill: none; stroke: var(--sage); stroke-width: .85; stroke-dasharray: 2.5 2.5; opacity: .52; }
.growth-reference-line.median { stroke-width: 1.5; stroke-dasharray: none; opacity: .9; }
.growth-baby-line { fill: none; stroke: var(--rose-dark); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.growth-baby-point { fill: #fff; stroke: var(--rose-dark); stroke-width: 2.8; }
.growth-chart-legend { display: flex; gap: 16px; justify-content: center; margin: 5px 0 9px; color: var(--muted); font-size: .65rem; font-weight: 700; }
.growth-chart-legend span::before { display: inline-block; width: 18px; margin: 0 5px 3px 0; border-top: 2px solid; content: ""; vertical-align: middle; }
.growth-chart-legend .baby::before { border-color: var(--rose-dark); }
.growth-chart-legend .reference::before { border-color: var(--sage); border-top-style: dashed; }
.growth-chart-latest { margin: 0 5px 8px; color: var(--ink); font-size: .75rem; font-weight: 800; text-align: center; }
.growth-chart-note { margin: 0 7px; color: var(--muted); font-size: .65rem; line-height: 1.45; text-align: center; }
.growth-list { display: grid; gap: 8px; }
.growth-row { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 15px 17px; border: 1px solid rgba(255,255,255,.8); border-radius: 17px; background: rgba(255,255,255,.68); text-align: left; }
.growth-row strong, .growth-row small { display: block; }
.growth-row strong { margin-bottom: 4px; font-size: .92rem; }
.growth-row small { color: var(--muted); font-size: .72rem; }
.growth-row b { color: var(--muted); font-size: 1.2rem; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  width: min(100%, 560px);
  margin: auto;
  grid-template-columns: repeat(3, 1fr);
  padding: 7px 14px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(226,213,207,.8);
  background: rgba(250,247,244,.92);
  backdrop-filter: blur(20px);
}
.bottom-nav.four { grid-template-columns: repeat(4, 1fr); }
.nav-item { display: grid; gap: 3px; min-height: 54px; place-items: center; border: 0; color: #8a8081; background: none; font-size: .65rem; font-weight: 700; }
.nav-item span { font-size: 1.25rem; line-height: 1; }
.nav-item.active { color: var(--rose-dark); }

.button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  background: #eee6e2;
  font-weight: 800;
}
.button.primary { color: white; background: linear-gradient(145deg, #bd6a7e, var(--rose-dark)); box-shadow: 0 9px 22px rgba(143,64,85,.2); }
.button.secondary { color: var(--rose-dark); background: rgba(255,255,255,.82); }
.button.small { min-height: 42px; padding: 0 16px; color: white; background: var(--rose-dark); }
.button.tiny { min-height: 38px; padding: 0 11px; border-radius: 13px; color: white; background: var(--rose-dark); font-size: .7rem; }
.button.tiny.sleep { background: #66547f; }
.button.full { width: 100%; }
.button.danger-text { color: #a03a45; background: none; box-shadow: none; }

dialog { color: var(--ink); }
dialog::backdrop { background: rgba(48,35,39,.34); backdrop-filter: blur(3px); }
.sheet {
  width: min(100% - 16px, 540px);
  max-height: calc(100dvh - 20px);
  margin: auto auto 8px;
  padding: 14px 20px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border: 0;
  border-radius: 28px;
  background: #fcfaf8;
  box-shadow: 0 24px 70px rgba(50,30,35,.25);
}
.sheet.compact { max-width: 430px; }
.sheet-handle { width: 44px; height: 5px; margin: 0 auto 17px; border-radius: 99px; background: #ded3cf; }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.close-button { box-shadow: none; background: #f0e9e5; font-size: 1.5rem; font-weight: 400; }
label, legend { display: block; color: #51484a; font-size: .75rem; font-weight: 800; }
input, textarea {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  border: 1px solid #ddd1cc;
  border-radius: 14px;
  outline: none;
  color: var(--ink);
  background: white;
  font-size: 1rem;
}
input:focus, textarea:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(182,92,115,.11); }
textarea { resize: vertical; }
/* iOS renders native date/time controls at a fixed intrinsic width that ignores
   width:100%, so on iPhone the field overflows the sheet to the right. Dropping the
   native appearance makes them honor the shared input box model above. */
input[type="date"],
input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value { margin: 0; text-align: left; }
.sheet label, .sheet fieldset { margin-bottom: 15px; }
.duration-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side-dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; background: #ca788c; }
.side-dot.right { background: #957493; }
fieldset { padding: 0; border: 0; }
legend { margin-bottom: 8px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 13px; background: #eee6e2; }
.range-picker { grid-template-columns: repeat(3,1fr); margin: -8px 4px 18px; font-size: .82rem; font-weight: 600; }
.range-picker span { padding: 8px; }
.segmented label { margin: 0; }
/* These radios are hidden behind their labels, but the shared input rule above still
   sizes them to width:100%. Absolutely positioned with no positioned ancestor, that
   resolves against the viewport, so each one overflows the page to the right of its own
   cell. Keep them zero-sized and focusable rather than laid out. */
.segmented input { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 10px; border-radius: 10px; text-align: center; }
.segmented input:checked + span { background: white; box-shadow: 0 2px 8px rgba(62,43,48,.1); }
.optional { color: var(--muted); font-weight: 500; }
.form-error { min-height: 18px; margin: -3px 0 9px; color: #a03a45; font-size: .76rem; text-align: center; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 65px;
  padding: 10px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  background: none;
  text-align: left;
  text-decoration: none;
}
.settings-row strong, .settings-row small { display: block; }
.settings-row strong { margin-bottom: 4px; font-size: .88rem; }
.settings-row small { color: var(--muted); font-size: .7rem; }
.settings-row b { color: var(--muted); font-size: 1.2rem; }
.settings-footnote { margin: 22px 8px 4px; color: var(--muted); font-size: .7rem; line-height: 1.5; text-align: center; }
.toast {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 20px;
  width: fit-content;
  max-width: calc(100% - 40px);
  margin: auto;
  padding: 11px 17px;
  border-radius: 99px;
  color: white;
  background: #3d3436;
  box-shadow: 0 10px 28px rgba(40,30,33,.22);
  font-size: .78rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #f5eef0;
    --muted: #b9adb0;
    --paper: #171316;
    --card: rgba(39, 31, 35, .94);
    --line: #46383e;
    --rose: #df8299;
    --rose-dark: #efa0b3;
    --rose-pale: #4b2b35;
    --plum: #b99ab5;
    --sage: #86a594;
    --shadow: 0 14px 40px rgba(0, 0, 0, .25);
  }
  html, body { background: var(--paper); }
  body {
    background:
      radial-gradient(circle at 100% 0%, rgba(105, 49, 67, .35), transparent 30rem),
      linear-gradient(155deg, #1e181b 0%, var(--paper) 62%, #21191d 100%);
  }
  .topbar { background: rgba(23, 19, 22, .88); border-bottom-color: rgba(75, 59, 66, .7); }
  .icon-button, .close-button { background: rgba(51, 42, 46, .94); box-shadow: 0 5px 18px rgba(0,0,0,.18); }
  .start-card, .active-card, .stat, .feed-row, .insight-card, .growth-row, .growth-chart-card {
    border-color: rgba(99, 78, 87, .42);
    background: rgba(39, 31, 35, .88);
  }
  .side-button { color: #ffd9e2; background: linear-gradient(145deg, #56303b, #432832); }
  .side-button.right { color: #ecd9ec; background: linear-gradient(145deg, #4b3a4c, #392f3c); }
  .active-card { background: linear-gradient(160deg, #2b2226 0%, #3b252d 100%); }
  .button.secondary { color: #ffd5df; background: rgba(63, 49, 55, .94); }
  .sleep-card { border-color: rgba(104, 88, 131, .42); background: linear-gradient(145deg, rgba(43,39,53,.97), rgba(51,43,68,.94)); }
  .sleep-text, .sleeping-status, .sleep-card p strong { color: #c8b4e2; }
  .sleep-rhythm-summary > span { background: rgba(55,48,68,.72); }
  .sleep-chart-legend .yesterday::before { border-top-color: #d6bd98; }
  .sleep-chart-legend .expected::before { border-top-color: #c8b4e2; }
  .sleep-curve.yesterday { stroke: #d6bd98; }
  .sleep-curve.expected { stroke: #c8b4e2; }
  .sleep-now-dot.expected { fill: #c8b4e2; }
  .likelihood-0 { background: #352f3a; }
  .likelihood-1 { background: #51465d; }
  .likelihood-2 { background: #756388; }
  .likelihood-3 { background: #a388bc; }
  .likelihood-4 { background: #cdb3e1; }
  .stat { background: rgba(42, 34, 38, .82); }
  .sleep-stat { background: rgba(43, 39, 54, .88); }
  .sleep-row .feed-icon { color: #d3bce9; background: #3e344d; }
  .insight-card { box-shadow: 0 8px 28px rgba(0,0,0,.16); }
  .balance-track { background: #4a394b; }
  .growth-hero { border-color: rgba(99, 78, 87, .42); background: linear-gradient(150deg, rgba(42,35,39,.96), rgba(37,48,40,.92)); }
  .growth-chart-switch { background: #362d31; }
  .growth-chart-switch button.active { background: #514047; box-shadow: 0 2px 8px rgba(0,0,0,.22); }
  .growth-baby-point { fill: #2c2528; }
  .bottom-nav { border-top-color: rgba(75, 59, 66, .8); background: rgba(25, 21, 23, .94); }
  .button { background: #393034; }
  .sheet { color: var(--ink); background: #211b1e; box-shadow: 0 24px 70px rgba(0,0,0,.5); }
  .sheet-handle { background: #57484e; }
  label, legend { color: #ddd1d4; }
  input, textarea { border-color: #58484e; color: var(--ink); background: #2c2528; }
  input:focus, textarea:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(223,130,153,.15); }
  .segmented { background: #362d31; }
  .segmented input:checked + span { background: #514047; box-shadow: 0 2px 8px rgba(0,0,0,.22); }
  .close-button { background: #352c30; }
  .settings-row { border-bottom-color: var(--line); }
  .empty-state { border-color: #55454b; }
  dialog::backdrop { background: rgba(4,3,4,.62); }
}

@media (min-width: 700px) {
  body { padding: 22px 0; }
  .app { overflow: hidden; min-height: calc(100dvh - 44px); border: 1px solid rgba(255,255,255,.8); border-radius: 34px; background: rgba(248,243,239,.72); box-shadow: 0 25px 80px rgba(60,37,43,.13); }
  .topbar { top: 22px; border-radius: 34px 34px 0 0; }
  .bottom-nav { bottom: 22px; border-radius: 0 0 34px 34px; }
}

@media (min-width: 700px) and (prefers-color-scheme: dark) {
  .app { border-color: rgba(99, 78, 87, .42); background: rgba(23, 19, 22, .8); box-shadow: 0 25px 80px rgba(0,0,0,.35); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
