:root {
  --bg: #F6EDE3;
  --paper: #FFF9F3;
  --ink: #3A2A22;
  --muted: #8B7466;
  --line: #E8D8C8;
  --accent: #D06B4F;
  --accent-dark: #B4533C;
  --good: #5D8F6A;
  --good-soft: #E6F0E8;
  --night: #5C5878;
  --bottle: #5B7C99;
  --nappy: #C4923A;
  --sleep: #7A6A9A;
  --food: #6A8F5A;
  --shower: #4F8F8A;
  --outing: #B5684A;
  --other: #8B7466;
  --danger: #B44A3C;
  --shadow: 0 8px 24px rgba(58, 42, 34, 0.08);
  --radius: 18px;
  --tabbar-h: 68px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --font: "SF Pro Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bot) + 16px);
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, white);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: calc(var(--safe-top) + 14px) 20px 12px;
  border-bottom: 1px solid transparent;
}
.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.eyebrow {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
h1 {
  margin: 2px 0 0;
  font-size: 26px;
  letter-spacing: -0.03em;
  font-weight: 720;
  line-height: 1.15;
}
.summary {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.icon-btn.is-on { outline: 2px solid var(--accent); }
.icon-btn.is-off { opacity: 0.7; }

.view { padding: 12px 16px 24px; }

.hero {
  background: linear-gradient(180deg, #fff 0%, var(--paper) 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.hero.is-done {
  background: var(--good-soft);
}
.kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-dark);
}
.hero-time {
  margin: 0;
  font-size: 32px;
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.hero h2 {
  margin: 4px 0 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.hero-detail {
  margin: 8px 0 0;
  color: var(--muted);
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f3e6d8;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.chip.kind-bottle { background: #e4edf4; color: #35536b; }
.chip.kind-nappy { background: #f7edd6; color: #7a5a18; }
.chip.kind-sleep { background: #ece7f5; color: #4f436d; }
.chip.kind-food { background: #e7f0e2; color: #3d5c32; }
.chip.kind-shower { background: #e1f0ef; color: #2f5f5b; }
.chip.kind-outing { background: #f6e5dc; color: #7a3d28; }
.chip.kind-other { background: #f3e6d8; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.01em;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.ghost {
  background: transparent;
  color: var(--accent-dark);
  width: auto;
  min-height: 44px;
  padding: 0 10px;
}
.btn.good { background: var(--good); }
.hero .btn { margin-top: 16px; }

.section-label {
  margin: 18px 4px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.step {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 12px 8px;
  margin-bottom: 10px;
  min-height: 72px;
}
.step.is-done {
  opacity: 0.62;
  background: #f4eee7;
}
.step.is-done .step-title { text-decoration: line-through; }
.step.is-current {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.step.is-overdue:not(.is-done) .step-time { color: var(--danger); }

.tick {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: transparent;
  flex-shrink: 0;
}
.tick.is-on {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}
.step-main { min-width: 0; }
.step-time {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.step-title {
  margin: 1px 0 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.step-detail {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.duration {
  border: 0;
  background: #f3e6d8;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  min-height: 36px;
  min-width: 52px;
}
.duration:focus { outline: 2px solid var(--accent); }

.install-banner, .note {
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 14px;
}
.install-banner p, .note p { margin: 0 0 8px; }
.install-banner p:last-child, .note p:last-child { margin: 0; }

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.row > .btn { width: auto; flex: 1 1 140px; }

/* Log */
.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.day-nav h2 {
  margin: 0;
  font-size: 18px;
  text-align: center;
  flex: 1;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
}
.stat b { display: block; font-size: 16px; letter-spacing: -0.02em; }
.stat span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.quick-add {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.quick-add button {
  min-height: 56px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 14px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.quick-add .q-ico { font-size: 18px; }

.log-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.log-item:last-child { border-bottom: 0; }
.log-time { font-weight: 700; font-size: 14px; padding-top: 2px; }
.log-body b { display: block; }
.log-body span { color: var(--muted); font-size: 13px; }
.log-del {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

/* Settings */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}
.card p.help, p.help {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}
label.field {
  display: block;
  margin: 10px 0;
  font-weight: 650;
  font-size: 14px;
}
label.field input, label.field select, label.field textarea,
.field-input {
  display: block;
  width: 100%;
  margin-top: 6px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
}
label.field textarea { min-height: 80px; resize: vertical; }
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  font-weight: 650;
}
.toggle input {
  width: 46px;
  height: 28px;
  accent-color: var(--accent);
}

.step-edit {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
}
.step-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.step-edit-head strong { font-size: 15px; }
.icon-mini {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  font-weight: 700;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Tabs */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 520px;
  height: calc(var(--tabbar-h) + var(--safe-bot));
  padding: 6px 10px var(--safe-bot);
  background: color-mix(in srgb, var(--paper) 92%, white);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  z-index: 30;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  border-radius: 12px;
}
.tab.is-active { color: var(--accent-dark); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tab-icon { font-size: 16px; font-weight: 800; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 24, 16, 0.35);
}
.sheet-card {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 520px;
  background: var(--paper);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + var(--safe-bot));
  box-shadow: 0 -10px 40px rgba(0,0,0,0.12);
  max-height: 86dvh;
  overflow: auto;
}
.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  margin: 6px auto 12px;
}
.sheet-card h2 { margin: 0 0 12px; font-size: 20px; }
.choice {
  width: 100%;
  min-height: 52px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  font-weight: 700;
  text-align: left;
  padding: 0 16px;
}
.choice:active { background: #f6eee6; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bot) + 16px);
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  z-index: 60;
  font-weight: 600;
  max-width: min(90vw, 480px);
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

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