:root {
  --bg: #fbf4ee;
  --card: #ffffff;
  --text: #3a2e33;
  --muted: #8a7a80;
  --accent: #e07a7a;
  --accent-soft: #fbe3df;
  --accent-2: #8fb9a8;
  --tip: #fff6d9;
  --border: #f0e2da;
  --shadow: 0 2px 12px rgb(120 80 70 / 0.08);
  --radius: 20px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1a1d;
    --card: #2b2428;
    --text: #f3e9ec;
    --muted: #b3a2a8;
    --accent: #f0928f;
    --accent-soft: #4a3034;
    --accent-2: #8fb9a8;
    --tip: #3a3326;
    --border: #3c3236;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

main {
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.05rem; margin-bottom: 6px; }
p { margin: 0; }
p + p { margin-top: 10px; }
a { color: var(--accent); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* hero */
.hero { text-align: center; padding-top: 24px; }
.big {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  margin: 4px 0 14px;
  font-variant-numeric: tabular-nums;
}
.progress {
  position: relative;
  height: 12px;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: inherit;
  transition: width 0.6s ease;
}
.tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--card);
  opacity: 0.7;
}
.hero-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: left;
}
.hero-meta span:last-child { text-align: right; }
.due { margin-top: 12px; }

/* week nav */
.weeknav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.weeknav > button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.weeknav > button:disabled { opacity: 0.3; cursor: default; }
.weeknav-label { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pill {
  font-size: 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 10px;
  border: 0;
  font-weight: 600;
}
button.pill { cursor: pointer; font-family: inherit; }

/* size */
.size { display: flex; align-items: center; gap: 18px; }
.size-emoji {
  font-size: 3.6rem;
  line-height: 1;
  flex: none;
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 50%;
}
.size h2 { margin: 2px 0; }

.tip { background: var(--tip); }
.tip .eyebrow { margin-bottom: 6px; }

/* install hint (iOS) */
.install { position: relative; padding-right: 44px; }
.install .eyebrow { margin-bottom: 6px; }
.install-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.share-icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* welcome */
.welcome { text-align: center; display: grid; gap: 12px; justify-items: center; padding: 32px 22px; }
.welcome h1 { font-size: 1.7rem; }

/* footer */
footer { display: grid; gap: 10px; padding: 8px 4px; text-align: center; }
.footer-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* buttons */
button { font: inherit; }
.primary, .ghost {
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 600;
}
.primary { background: var(--accent); color: #fff; border: 0; }
.ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }
.danger { color: var(--muted); font-size: 0.85rem; }

/* dialog */
dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 22px;
  width: min(420px, calc(100vw - 32px));
  background: var(--card);
  color: var(--text);
}
dialog::backdrop { background: rgb(30 20 25 / 0.45); }
dialog form { display: grid; gap: 14px; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  margin: 0;
}
.segmented label {
  text-align: center;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.95rem;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.field { display: grid; gap: 6px; font-weight: 600; }
.field input {
  font: inherit;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-height: 46px;
  width: 100%;
}
.hint { font-size: 0.85rem; color: var(--muted); }
.error { color: #c0392b; font-size: 0.9rem; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

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

.more {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}
