:root {
  color-scheme: light dark;

  --bg: #fbf6f0;
  --glow: #fff2e6;
  --card: #ffffff;
  --ink: #2a2420;
  --muted: #75685f;
  --faint: #9c8e84;
  --line: #efe6dc;
  --chip: #fbf7f2;

  --accent: #e0785c;
  --accent-ink: #ffffff;
  --accent-soft: #fbeae4;

  --formula: #a9652e;
  --formula-bg: #faefe2;
  --breast: #3f7f78;
  --breast-bg: #e5f1ee;
  --danger: #c8564a;

  --shadow: 0 1px 2px rgba(60, 45, 30, 0.04), 0 12px 28px rgba(60, 45, 30, 0.05);
  --radius: 22px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141110;
    --glow: #241a14;
    --card: #1f1a17;
    --ink: #f3ebe4;
    --muted: #ab9e95;
    --faint: #7e7168;
    --line: #312823;
    --chip: #29221d;

    --accent: #e58a6f;
    --accent-ink: #241512;
    --accent-soft: #31201a;

    --formula: #e0a870;
    --formula-bg: #2c2117;
    --breast: #7fc0b6;
    --breast-bg: #182825;
    --danger: #e08479;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(900px 480px at 50% -160px, var(--glow), transparent 70%), var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

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

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.muted {
  color: var(--muted);
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---------- shell ---------- */

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 22px) 18px calc(env(safe-area-inset-bottom) + 104px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  box-shadow: 0 2px 6px rgba(90, 60, 40, 0.14);
}

.top-side {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-date {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sync-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--formula);
  background: var(--formula-bg);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- cards ---------- */

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

.card h2 {
  font-size: 15px;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}

/* ---------- summary ---------- */

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 20px;
  padding: 18px 20px;
}

.sum-kicker {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sum-big {
  margin-top: 3px;
  font-size: 38px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.sum-big i {
  margin: 0 4px 0 3px;
  font-style: normal;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--muted);
  vertical-align: 3px;
}

.sum-big.empty {
  font-size: 22px;
  letter-spacing: 0;
  color: var(--muted);
}

.sum-meta {
  margin-top: 5px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sum-today {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sum-line {
  font-size: 13px;
  color: var(--muted);
}

.sum-line b {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.sum-split {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- composer ---------- */

.composer {
  padding: 16px 18px 18px;
}

.lbl {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 18px 0 9px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.lbl:first-child {
  margin-top: 0;
}

.lbl .unit {
  font-weight: 500;
  letter-spacing: 0;
  color: var(--faint);
}

.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.time-row .lbl {
  margin: 0;
}

.time-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.time-now {
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

.time-now:active {
  background: var(--accent-soft);
}

.time-pick {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  margin-right: -6px;
  border-radius: 12px;
  background: var(--chip);
  border: 1px solid var(--line);
}

.time-pick:active {
  background: var(--accent-soft);
}

.time-main {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.time-day {
  font-size: 12.5px;
  color: var(--muted);
}

.time-edit {
  font-size: 12px;
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}

.time-pick input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  padding: 0;
}

.chips {
  display: flex;
  gap: 8px;
}

.chip {
  flex: 1;
  min-width: 0;
  height: 52px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  transition: transform 0.08s ease, background 0.15s ease;
}

.chip:active {
  transform: scale(0.96);
}

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 16px rgba(224, 120, 92, 0.24);
}

.chip.wide {
  flex: 0 0 auto;
  padding: 0 14px;
  font-size: 15px;
}

.custom-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 0 14px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}

.custom-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 0;
  outline: none;
  -moz-appearance: textfield;
}

.custom-wrap input::-webkit-outer-spin-button,
.custom-wrap input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.custom-wrap span {
  font-size: 14px;
  color: var(--muted);
}

.seg {
  display: flex;
  gap: 10px;
}

.seg button {
  flex: 1;
  height: 52px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  transition: transform 0.08s ease;
}

.seg button:active {
  transform: scale(0.97);
}

.seg button.on[data-type="formula"] {
  background: var(--formula-bg);
  border-color: var(--formula);
  color: var(--formula);
}

.seg button.on[data-type="breast"] {
  background: var(--breast-bg);
  border-color: var(--breast);
  color: var(--breast);
}

.primary {
  display: block;
  width: 100%;
  height: 56px;
  margin-top: 20px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 22px rgba(224, 120, 92, 0.26);
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.primary:active {
  transform: scale(0.985);
  opacity: 0.92;
}

.ghost {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  font-size: 13.5px;
  color: var(--muted);
}

.ghost:active {
  color: var(--accent);
}

.secondary {
  display: block;
  width: 100%;
  height: 46px;
  margin-top: 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 15px;
  font-weight: 600;
}

.secondary:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ---------- records ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 4px 4px;
}

.section-head h2 {
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.section-head span {
  font-size: 12.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.recs li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 6px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px;
  transition: background 0.15s ease;
}

.recs li:last-child {
  border-bottom: none;
}

.recs li:active {
  background: var(--chip);
}

.rec-time {
  width: 50px;
  flex: none;
  font-size: 14.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rec-main {
  font-size: 15px;
  color: var(--ink);
}

.rec-main b {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.rec-main i {
  font-style: normal;
  font-size: 12.5px;
  color: var(--faint);
  margin-left: 2px;
}

.rec-type {
  margin-left: auto;
  flex: none;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.rec-type.formula {
  color: var(--formula);
  background: var(--formula-bg);
}

.rec-type.breast {
  color: var(--breast);
  background: var(--breast-bg);
}

.rec-chev {
  width: 15px;
  height: 15px;
  flex: none;
  margin-left: 2px;
  color: var(--faint);
}

.empty {
  padding: 26px 10px 22px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}

.install-hint {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--faint);
}

.composer .install-hint {
  margin: 14px 0 0;
  text-align: center;
  line-height: 1.6;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 4px 6px;
  font-size: 13px;
  color: var(--muted);
}

.day-head:first-child {
  padding-top: 4px;
}

.day-head strong {
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
}

.day-sum {
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

/* ---------- settings ---------- */

.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  font-size: 14.5px;
  border-bottom: 1px solid var(--line);
}

.kv:last-of-type {
  border-bottom: none;
}

.kv span {
  color: var(--muted);
}

.kv b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: 10px 2px 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--faint);
}

.version {
  margin: 26px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
  letter-spacing: 0.06em;
}

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}

.tabbar button {
  flex: 1;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--faint);
  transition: color 0.15s ease;
}

.tabbar button svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.tabbar button.on {
  color: var(--accent);
}

/* ---------- sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(35, 26, 20, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade 0.18s ease;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: 620px;
  margin: 0 auto;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 20px 20px calc(env(safe-area-inset-bottom) + 20px);
  background: var(--card);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -10px 40px rgba(30, 20, 15, 0.18);
  animation: rise 0.22s cubic-bezier(0.22, 0.9, 0.3, 1);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sheet-head h2 {
  font-size: 17px;
}

.sheet-head button {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 4px;
}

.danger {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
}

@keyframes rise {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 96px);
  z-index: 60;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px 11px 18px;
  border-radius: 999px;
  background: rgba(42, 36, 32, 0.92);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.22s ease;
}

.toast button {
  padding: 4px 9px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 700;
  color: #ffb9a2;
  background: rgba(255, 255, 255, 0.09);
}

.toast button:active {
  background: rgba(255, 255, 255, 0.16);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* ---------- lock ---------- */

.lock {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 28px calc(env(safe-area-inset-bottom) + 48px);
  text-align: center;
}

.lock img {
  width: 74px;
  height: 74px;
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(90, 60, 40, 0.18);
  margin-bottom: 18px;
}

.lock h1 {
  font-size: 26px;
  letter-spacing: 0.08em;
}

.lock .tagline {
  margin: 6px 0 30px;
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.lock form {
  width: 100%;
  max-width: 320px;
}

.lock input {
  width: 100%;
  height: 54px;
  padding: 0 18px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 17px;
  text-align: center;
  letter-spacing: 0.08em;
  outline: none;
}

.lock input:focus {
  border-color: var(--accent);
}

.lock .primary {
  margin-top: 14px;
}

.lock .err {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
}

/* ---------- wide screens (iPad landscape) ---------- */

@media (min-width: 900px) {
  .wrap {
    max-width: 940px;
  }

  .sum-today {
    width: auto;
    align-items: flex-end;
    padding-top: 0;
    border-top: 0;
  }

  .home-grid {
    display: grid;
    grid-template-columns: 392px 1fr;
    gap: 22px;
    align-items: start;
  }

  .home-grid .card {
    margin-bottom: 0;
  }

  .home-grid .list {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 18px 6px;
  }

  .home-grid .section-head {
    padding: 4px 0 2px;
  }
}
