@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(fonts/manrope-latin.woff2) format('woff2');
}

/* Tokens: light is the base, dark applies for system-dark or an explicit override */
:root {
  --bg: #f4f3ef; --surf: #ffffff; --surf2: #ebeae4; --track: #e6e5df; --pill: #ffffff;
  --line: rgba(21,26,43,.09); --line2: rgba(21,26,43,.18);
  --text: #151a2b; --muted: #5b6276; --muted2: #3a4156;
  --acc: oklch(.82 .11 75); --accInk: #1d1606; --accText: oklch(.52 .11 65);
  --recBg: #fbf5e8; --recBorder: oklch(.82 .11 75 / .55); --sheet: #ffffff;
  --pill-shadow: 0 1px 3px rgba(21,26,43,.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121a2e; --surf: #1b2540; --surf2: #26314f; --track: #1b2540; --pill: #2c3961;
    --line: rgba(255,255,255,.08); --line2: rgba(255,255,255,.16);
    --text: #eef0f5; --muted: #9aa4bd; --muted2: #c4cadb;
    --acc: oklch(.82 .11 75); --accInk: #1d1606; --accText: oklch(.84 .11 75);
    --recBg: #222d4d; --recBorder: rgba(242,194,122,.28); --sheet: #1b2540;
    --pill-shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121a2e; --surf: #1b2540; --surf2: #26314f; --track: #1b2540; --pill: #2c3961;
  --line: rgba(255,255,255,.08); --line2: rgba(255,255,255,.16);
  --text: #eef0f5; --muted: #9aa4bd; --muted2: #c4cadb;
  --acc: oklch(.82 .11 75); --accInk: #1d1606; --accText: oklch(.84 .11 75);
  --recBg: #222d4d; --recBorder: rgba(242,194,122,.28); --sheet: #1b2540;
  --pill-shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
h1, h2 { margin: 0; }
hr { border: 0; height: 1px; background: var(--line); margin: 0; width: 100%; }
[hidden] { display: none !important; }
small { font-size: 13px; color: var(--muted); margin-left: 2px; font-weight: 700; }

/* Layout */
.app {
  height: 100dvh; max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column; position: relative; overflow: hidden;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
.top { flex: none; padding: calc(env(safe-area-inset-top) + 12px) 20px 0; display: flex; flex-direction: column; gap: 14px; }
.title-row { display: flex; justify-content: space-between; align-items: center; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.content {
  flex: 1; overflow-y: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding: 16px 20px calc(44px + env(safe-area-inset-bottom));
}
.content::-webkit-scrollbar { display: none; }
section { display: flex; flex-direction: column; gap: 16px; }

/* Controls */
.icon-btn {
  width: 44px; height: 44px; border-radius: 99px; border: 0; background: var(--surf); color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn .knob { fill: var(--surf); }
.track { display: flex; background: var(--track); border-radius: 12px; padding: 3px; gap: 3px; }
.pill {
  flex: 1; height: 38px; border-radius: 9px; border: 0; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 700;
}
.pill[aria-selected="true"], .pill[aria-pressed="true"] { background: var(--pill); color: var(--text); box-shadow: var(--pill-shadow); }
.card { background: var(--surf); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; height: 40px; border-radius: 99px; border: 0; font-size: 14px; font-weight: 700;
  background: var(--surf2); color: var(--muted2);
}
.seg-btn[aria-pressed="true"] { background: var(--acc); color: var(--accInk); }
.time-input {
  width: 100%; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: 800 40px 'Manrope', sans-serif; letter-spacing: -0.02em; text-align: center;
  -webkit-appearance: none; appearance: none; min-width: 0;
}
.time-input.xl { height: 72px; }
.time-input.lg { height: 64px; font-size: 34px; }
.time-input::-webkit-date-and-time-value { text-align: center; }
.time-input::-webkit-calendar-picker-indicator { opacity: .55; }
.chips { display: flex; gap: 8px; }
.chip {
  flex: 1; height: 40px; border-radius: 99px; border: 1px solid var(--line2); background: transparent;
  font-size: 13px; font-weight: 600;
}
.label-s { font-size: 13px; font-weight: 700; color: var(--muted); }
.body-s { font-size: 14px; font-weight: 500; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0; text-wrap: pretty; }
.center { text-align: center; }
.muted { color: var(--muted); font-weight: 500; }
.acc-text { color: var(--accText); }

/* Cycles results */
.res-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 2px 0; }
.res-head h2 { font-size: 16px; font-weight: 800; }
.link-muted { border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; font-weight: 500; text-align: right; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 14px 16px; border-radius: 16px; background: transparent; border: 1px solid var(--line);
  color: var(--text); text-align: left; font: inherit;
}
.row.rec { background: var(--recBg); border-color: var(--recBorder); }
.row .main { display: flex; flex-direction: column; gap: 2px; }
.row .t { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.row .t small { font-size: 14px; margin-left: 0; }
.row .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.badge {
  background: var(--acc); color: var(--accInk); font-size: 11px; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; padding: 5px 9px; border-radius: 99px;
}

/* Install banner */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 18px; background: var(--surf); }
.app-icon { border-radius: 11px; flex: none; display: block; }
.app-icon.sm { border-radius: 11px; }
.banner-text { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.banner-text strong { font-size: 14px; font-weight: 700; }
.banner-text span { font-size: 12px; color: var(--muted); line-height: 1.35; }
.btn-solid { height: 36px; padding: 0 14px; border-radius: 99px; border: 0; background: var(--text); color: var(--bg); font-size: 13px; font-weight: 700; }
.dismiss { width: 32px; height: 44px; border: 0; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; padding: 0; }

/* Duration */
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stepper { display: flex; align-items: center; justify-content: space-between; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 6px; }
.step-btn {
  width: 44px; height: 44px; border-radius: 10px; border: 0; background: var(--surf2); color: var(--text);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.step-btn.sq { border-radius: 12px; }
.step-btn.round { border-radius: 99px; }
.step-val { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.presets { display: flex; gap: 6px; }
.preset {
  flex: 1; height: 36px; border-radius: 99px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line2); background: transparent; color: var(--text); padding: 0;
}
.preset[aria-pressed="true"] { border-color: var(--acc); background: var(--acc); color: var(--accInk); }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; background: none;
  padding: 4px 0; font-size: 14px; font-weight: 600; text-align: left; color: var(--text);
}
.switch { flex: none; width: 46px; height: 28px; border-radius: 99px; padding: 3px; background: var(--surf2); display: flex; transition: background .2s; }
.switch-knob { width: 22px; height: 22px; border-radius: 99px; background: var(--muted); transition: transform .2s, background .2s; }
.switch-row[aria-checked="true"] .switch { background: var(--acc); }
.switch-row[aria-checked="true"] .switch-knob { background: var(--accInk); transform: translateX(18px); }
.card.result { background: var(--recBg); border: 1px solid var(--recBorder); border-radius: 22px; padding: 20px; gap: 6px; }
.result-time { font-size: 52px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.result-time small { font-size: 20px; margin-left: 0; }
.suggest {
  margin-top: 8px; align-self: flex-start; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line2); background: var(--bg); color: var(--text);
  font-size: 13px; font-weight: 600; text-align: left;
}

/* Age guide */
.age-row { display: flex; align-items: center; justify-content: space-between; }
.age-ctl { display: flex; align-items: center; gap: 10px; }
.age-val { min-width: 84px; text-align: center; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.age-mine { display: flex; flex-direction: column; gap: 2px; }
.age-mine .label-s { font-weight: 600; }
.age-hours { font-size: 44px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.1; }
.age-hours small { font-size: 18px; margin-left: 6px; font-weight: 800; }
.groups { display: flex; flex-direction: column; gap: 6px; }
.group { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); }
.group.me { background: var(--recBg); border-color: var(--recBorder); }
.group .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.group .nm { display: flex; flex-direction: column; gap: 1px; }
.group .nm strong { font-size: 14px; font-weight: 700; }
.group .nm span { font-size: 12px; color: var(--muted); }
.group .hr { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--surf2); position: relative; overflow: hidden; }
.bar span { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: var(--muted); opacity: .45; }
.group.me .bar span { background: var(--acc); opacity: 1; }

/* Toast + update bar */
.toast {
  position: absolute; left: 50%; bottom: calc(34px + env(safe-area-inset-bottom)); z-index: 6;
  transform: translate(-50%, 12px); opacity: 0; transition: all .2s; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; }
body.has-update .toast { bottom: calc(100px + env(safe-area-inset-bottom)); }
.update {
  position: absolute; left: 16px; right: 16px; bottom: calc(30px + env(safe-area-inset-bottom)); z-index: 2;
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; border-radius: 18px;
  background: var(--pill); color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 14px; font-weight: 600;
}
.update span { flex: 1; }
.btn-acc { height: 36px; padding: 0 14px; border-radius: 99px; border: 0; background: var(--acc); color: var(--accInk); font-size: 13px; font-weight: 700; }

/* Sheets */
.scrim { position: fixed; inset: 0; z-index: 3; background: rgba(5,8,18,.5); opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.hi { z-index: 7; }
.scrim.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; max-width: 520px; margin: 0 auto;
  background: var(--sheet); border-radius: 28px 28px 0 0;
  padding: 10px 22px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 20px;
  transform: translateY(105%); transition: transform .32s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -10px 40px rgba(0,0,0,.25);
  max-height: 92dvh; overflow-y: auto;
}
.sheet.hi { z-index: 8; }
.sheet.on { transform: translateY(0); }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--line2); align-self: center; flex: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-label { display: flex; flex-direction: column; gap: 2px; }
.set-label strong { font-size: 15px; font-weight: 700; }
.set-label small { font-size: 12px; font-weight: 400; margin-left: 0; }
.set-ctl { display: flex; align-items: center; gap: 8px; }
.set-val { min-width: 62px; text-align: center; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.set-theme { display: flex; flex-direction: column; gap: 8px; }
.set-theme strong { font-size: 15px; font-weight: 700; }
.link-acc { align-self: flex-start; border: 0; background: none; padding: 6px 0; color: var(--accText); font-size: 14px; font-weight: 700; }
.ios-app { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); }
.ios-app .app-icon { border-radius: 12px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: flex; align-items: center; gap: 14px; }
.num { flex: none; width: 28px; height: 28px; border-radius: 99px; background: var(--surf2); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; }
.txt { flex: 1; font-size: 15px; line-height: 1.35; }
.acc-stroke { color: var(--accText); flex: none; }
.btn-big { height: 50px; border-radius: 14px; border: 0; background: var(--text); color: var(--bg); font-size: 15px; font-weight: 700; }

button:focus-visible, input:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .scrim, .toast, .switch, .switch-knob { transition: none; }
}
