:root {
  color-scheme: light;
  --paper: #f7f2e8;
  --surface: #fffaf0;
  --surface-strong: #ffffff;
  --ink: #25211c;
  --muted: #746d63;
  --line: #ded4c3;
  --feed: #d56b52;
  --bottle: #2f80a0;
  --sleep: #5b67a8;
  --nappy: #5c8a62;
  --pump: #bd7d35;
  --med: #8b5a8e;
  --shadow: 0 18px 50px rgba(47, 39, 29, 0.14);
  --nav-height: 76px;
  font-family: ui-rounded, "Avenir Next", "Nunito Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(213, 107, 82, 0.12), transparent 32rem),
    linear-gradient(315deg, rgba(47, 128, 160, 0.12), transparent 28rem),
    var(--paper);
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(var(--nav-height) + max(16px, env(safe-area-inset-bottom)));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
  background: linear-gradient(180deg, var(--paper) 72%, rgba(247, 242, 232, 0));
}

.eyebrow,
.label,
.mini-meta,
.stat-tile span,
.primary-action small {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 12vw, 2.8rem);
  font-weight: 700;
  line-height: 0.92;
}

h2 {
  font-size: 1.04rem;
  font-weight: 850;
}

.icon-button,
.nav-item,
.log-option,
.primary-action,
.text-button,
.secondary-button,
.save-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.84);
}

.icon-button svg {
  width: 22px;
  height: 22px;
}

.view {
  display: none;
  animation: liftIn 0.22s ease-out;
}

.view.is-active {
  display: block;
}

.next-card,
.activity-panel,
.timer-panel,
.form-card,
.date-strip {
  border: 1px solid rgba(222, 212, 195, 0.92);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: var(--shadow);
}

.next-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 18px;
  overflow: hidden;
}

.next-card strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.75rem, 10vw, 2.55rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.next-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.ring {
  --progress: 0;
  display: grid;
  width: 90px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 58%, transparent 59%),
    conic-gradient(var(--feed) calc(var(--progress) * 1%), rgba(213, 107, 82, 0.16) 0);
}

.ring span {
  max-width: 64px;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.primary-action,
.log-option {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-strong);
}

.primary-action {
  min-height: 116px;
  padding: 16px;
  text-align: left;
}

.primary-action span:not(.action-icon) {
  display: block;
  margin-top: 16px;
  font-size: 1.16rem;
  font-weight: 900;
}

.action-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: var(--surface-strong);
  background: var(--feed);
}

.primary-action:nth-child(2) .action-icon {
  background: var(--bottle);
}

.action-icon svg {
  width: 25px;
  height: 25px;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.tile-grid.wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-tile {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.stat-tile strong {
  display: block;
  margin-top: 14px;
  font-size: clamp(1.35rem, 8vw, 2rem);
  line-height: 1;
}

.accent-feed {
  --accent: var(--feed);
}

.accent-bottle {
  --accent: var(--bottle);
}

.accent-sleep {
  --accent: var(--sleep);
}

.accent-nappy {
  --accent: var(--nappy);
}

.accent-pump {
  --accent: var(--pump);
}

.accent-med {
  --accent: var(--med);
}

.activity-panel,
.timer-panel {
  padding: 16px;
  margin-top: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  margin-bottom: 12px;
}

.text-button {
  min-width: 44px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(92, 138, 98, 0.12);
  font-weight: 850;
}

.timeline-list,
.timer-stack {
  display: grid;
  gap: 8px;
}

.empty-state {
  min-height: 96px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  font-weight: 750;
}

.timeline-item,
.timer-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 10px;
  border: 1px solid rgba(222, 212, 195, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.timeline-dot {
  width: 10px;
  height: 42px;
  border-radius: 999px;
  background: var(--accent);
}

.timeline-item h3,
.timer-item h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.15;
}

.timeline-item p,
.timer-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.timeline-time {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.delete-entry {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #963d2c;
  background: rgba(213, 107, 82, 0.12);
}

.delete-entry svg {
  width: 18px;
  height: 18px;
}

.log-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.log-option {
  display: grid;
  min-height: 116px;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 14px;
  font-weight: 900;
}

.log-option svg {
  width: 32px;
  height: 32px;
}

.date-strip {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  text-align: center;
}

.date-strip strong {
  display: block;
  margin-top: 2px;
  font-size: 1.18rem;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  align-items: end;
  min-height: 150px;
  padding-top: 12px;
}

.bar {
  position: relative;
  display: grid;
  align-items: end;
  min-height: 120px;
}

.bar span {
  display: block;
  min-height: 6px;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, var(--feed), var(--bottle));
}

.bar small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  text-align: center;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.form-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.form-card label {
  display: grid;
  gap: 7px;
}

.form-card label > span,
.switch-row span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  outline: none;
}

textarea {
  min-height: 82px;
  padding-top: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--bottle);
  box-shadow: 0 0 0 3px rgba(47, 128, 160, 0.16);
}

.inline-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.inline-input span {
  color: var(--muted);
  font-weight: 850;
}

.switch-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.switch-row input {
  width: 54px;
  min-height: 30px;
  accent-color: var(--nappy);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.secondary-button,
.save-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 900;
}

.secondary-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.secondary-button.danger {
  color: #963d2c;
}

.secondary-button.full {
  width: 100%;
}

.save-button {
  color: #fffdf8;
  background: var(--ink);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 520px);
  min-height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(222, 212, 195, 0.9);
  background: rgba(255, 250, 240, 0.94);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  gap: 4px;
  justify-items: center;
  align-content: center;
  min-width: 0;
  min-height: 58px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 850;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.is-active {
  color: var(--ink);
  background: rgba(213, 107, 82, 0.15);
}

.entry-dialog {
  width: min(calc(100% - 24px), 500px);
  max-height: min(680px, calc(100vh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.entry-dialog::backdrop {
  background: rgba(37, 33, 28, 0.42);
  backdrop-filter: blur(5px);
}

.entry-dialog form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.dialog-head {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 12px;
  align-items: center;
}

#dialogFields {
  display: grid;
  gap: 12px;
}

#dialogFields label {
  display: grid;
  gap: 7px;
}

#dialogFields label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.entry-dialog menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 20;
  display: none;
  max-width: 488px;
  min-height: 48px;
  margin: 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 12px 16px;
  color: #fffaf0;
  background: rgba(37, 33, 28, 0.94);
  box-shadow: var(--shadow);
  font-weight: 850;
  text-align: center;
}

.toast.is-visible {
  display: flex;
  animation: toastIn 0.2s ease-out;
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 32px;
  }

  .tile-grid.wide {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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