:root {
  --bg: #f7f2ee;
  --bg-soft: #fdf9f5;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --ink: #2f2a2d;
  --muted: #7b7275;
  --line: rgba(47, 42, 45, 0.1);
  --line-strong: rgba(47, 42, 45, 0.18);
  --accent: #c583a0;
  --accent-2: #8eb4d8;
  --accent-3: #f0ba8c;
  --success: #5d8f74;
  --warning: #b08a57;
  --danger: #b16161;
  --radius: 20px;
  --shadow: 0 18px 45px rgba(71, 56, 61, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 6% 0%, rgba(197, 131, 160, 0.2), transparent 30%),
    radial-gradient(circle at 98% 10%, rgba(142, 180, 216, 0.26), transparent 34%),
    linear-gradient(180deg, #fffdfb 0%, #f6f0ec 100%);
}

h1, h2, h3, h4, .hero-title, .stat-value {
  font-family: "Segoe UI", Arial, sans-serif;
}

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

.welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(247, 242, 238, 0.88);
  backdrop-filter: blur(12px);
}

.welcome-card {
  width: min(1020px, 100%);
  padding: 40px;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 14px;
  background: rgba(197, 131, 160, 0.18);
  color: #8c4d69;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
}

.welcome-card h1 {
  margin-top: 16px;
  font-size: clamp(38px, 5.5vw, 68px);
  line-height: 1;
}

.welcome-card p {
  margin-top: 14px;
  color: var(--muted);
  font-size: 16px;
  max-width: 720px;
}

.welcome-grid {
  margin-top: 24px;
  display: grid;
  gap: 16px;
  grid-template-columns: 1.15fr 0.85fr;
}

.welcome-panel,
.panel,
.stat-card,
.hero-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.welcome-panel {
  padding: 20px;
}

.welcome-panel h3 {
  font-size: 30px;
}

.feature-list,
.list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.feature-item,
.list-item {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
}

.welcome-actions {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.btn,
.welcome-btn {
  border: none;
  border-radius: 14px;
  padding: 11px 15px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.btn:hover,
.welcome-btn:hover {
  transform: translateY(-1px);
}

.btn:active,
.welcome-btn:active {
  transform: translateY(0);
}

.btn-primary,
.welcome-btn.primary {
  color: #fff;
  background: linear-gradient(135deg, #ca86a6, #8eb4d8);
}

.btn-secondary,
.welcome-btn.secondary {
  color: var(--ink);
  border: 1px solid var(--line-strong);
  background: #fff;
}

.btn-danger {
  color: var(--danger);
  background: rgba(177, 97, 97, 0.14);
  border: 1px solid rgba(177, 97, 97, 0.2);
}

.btn.mini {
  padding: 7px 10px;
  border-radius: 11px;
  font-size: 12px;
}

.app-shell {
  display: none;
  min-height: 100vh;
}

.app-shell.active {
  display: flex;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 300px;
  padding: 18px 16px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(252, 247, 244, 0.9);
  backdrop-filter: blur(14px);
}

.sidebar-header {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(140deg, rgba(197, 131, 160, 0.2), rgba(142, 180, 216, 0.2));
  margin-bottom: 14px;
}

.sidebar-header h2 {
  margin-top: 9px;
  font-size: 30px;
}

.sidebar-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.nav-group {
  margin-bottom: 12px;
}

.nav-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 8px 10px;
}

.nav-item {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
}

.nav-item:hover {
  background: rgba(197, 131, 160, 0.08);
}

.nav-item.active {
  border-color: rgba(197, 131, 160, 0.3);
  background: linear-gradient(135deg, rgba(197, 131, 160, 0.18), rgba(142, 180, 216, 0.18));
  color: #784660;
  font-weight: 700;
}

.nav-index {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.sidebar-footer {
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  background: linear-gradient(180deg, rgba(252, 247, 244, 0), rgba(252, 247, 244, 0.96) 20%);
}

.sidebar-footer .btn {
  width: 100%;
  margin-top: 8px;
}

.save-status {
  margin-top: 9px;
  font-size: 12px;
  color: var(--muted);
}

.main {
  margin-left: 300px;
  width: calc(100% - 300px);
  padding: 24px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  margin-bottom: 18px;
}

.page-header h1 {
  font-size: clamp(34px, 4.8vw, 60px);
  line-height: 1;
}

.page-header p,
.lead,
.mini-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
}

.hero-card {
  padding: 22px;
}

.hero-card.premium {
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.9), transparent 30%),
    linear-gradient(130deg, rgba(197, 131, 160, 0.24), rgba(142, 180, 216, 0.23), rgba(240, 186, 140, 0.2));
}

.hero-title {
  margin-top: 11px;
  font-size: clamp(30px, 4vw, 54px);
}

.hero-meta,
.action-row,
.legend-row,
.toggle-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-meta {
  margin-top: 14px;
}

.hero-progress {
  margin-top: 16px;
}

.pill,
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 700;
}

.pill,
.status.soft {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
}

.progress-shell {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(47, 42, 45, 0.1);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
}

.cards-4,
.grid-2,
.field-grid,
.snapshot-grid {
  display: grid;
  gap: 14px;
}

.cards-4 {
  margin-top: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cards-4.compact .stat-card {
  padding: 16px;
}

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

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

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

.stat-card,
.panel {
  padding: 18px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  margin-top: 8px;
  font-size: clamp(24px, 2.7vw, 42px);
}

.stat-value.tiny {
  font-size: clamp(18px, 2vw, 24px);
}

.stat-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.week-card {
  margin-top: 12px;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(197, 131, 160, 0.13), rgba(240, 186, 140, 0.13));
  border: 1px solid rgba(197, 131, 160, 0.25);
  display: grid;
  gap: 10px;
  grid-template-columns: 78px 1fr;
  align-items: center;
}

.week-big {
  width: 78px;
  height: 78px;
  border-radius: 18px;
  font-size: 28px;
  font-weight: 700;
  color: #7e4d66;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(197, 131, 160, 0.25);
}

.kick-stage {
  display: flex;
  align-items: center;
  gap: 14px;
}

.kick-ring {
  width: 106px;
  height: 106px;
  border-radius: 50%;
  background:
    radial-gradient(circle closest-side, #fff 72%, transparent 73%),
    conic-gradient(var(--accent) var(--pct), rgba(47, 42, 45, 0.12) 0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
}

.kick-ring span {
  font-weight: 700;
  color: #7d4862;
}

.kick-meta small,
.list-item small {
  color: var(--muted);
}

.timer-display {
  font-family: Consolas, monospace;
  font-size: 42px;
  margin: 8px 0 12px;
  color: #90556f;
}

.status-banner {
  margin-top: 12px;
  border-radius: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
}

.status-banner.good {
  border-color: rgba(93, 143, 116, 0.35);
  background: rgba(93, 143, 116, 0.14);
}

.status-banner.watch {
  border-color: rgba(176, 138, 87, 0.35);
  background: rgba(176, 138, 87, 0.14);
}

.status-banner.plain p {
  margin-top: 6px;
  color: var(--muted);
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.list-item small {
  display: block;
  margin-top: 4px;
}

.visuals .panel {
  overflow: hidden;
}

.donut-wrap {
  display: flex;
  justify-content: center;
}

.donut-wrap.compact {
  max-width: 188px;
  margin: 0 auto;
}

.legend-row {
  margin-top: 10px;
  justify-content: center;
}

.legend-row span {
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.chart-donut,
.chart-bars,
.chart-line {
  width: 100%;
  height: auto;
}

.chart-center {
  font-size: 13px;
  fill: #6f5e64;
  font-weight: 700;
}

.chart-sub {
  font-size: 10px;
  fill: #8d8185;
}

.chart-label {
  font-size: 10px;
  fill: #8c8185;
}

.chart-value {
  font-size: 10px;
  fill: #7d6f73;
}

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

.snapshot-grid.compact .snapshot-item {
  padding: 11px;
}

.snapshot-grid.compact .snapshot-item strong {
  font-size: 18px;
}

.snapshot-item {
  border-radius: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  display: grid;
  gap: 5px;
}

.snapshot-item span {
  font-size: 12px;
  color: var(--muted);
}

.snapshot-item strong {
  font-size: 20px;
}

.timeline-list {
  display: grid;
  gap: 9px;
}

.timeline-item {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  padding: 10px;
  display: grid;
  grid-template-columns: 170px 1fr auto;
  gap: 10px;
  align-items: center;
}

.timeline-item .timeline-time {
  font-size: 12px;
  color: var(--muted);
}

.timeline-item .timeline-body p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.timeline-item.type-feed {
  border-left: 5px solid #f29d8b;
}

.timeline-item.type-diaper {
  border-left: 5px solid #f6c875;
}

.timeline-item.type-sleep_start,
.timeline-item.type-sleep_end {
  border-left: 5px solid #86b3d9;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 15px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.66);
}

.toggle-row {
  margin-top: 12px;
}

.toggle-row label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  min-width: 220px;
  max-width: 380px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  transform: translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1220px) {
  .cards-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell.active {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 16px;
  }

  .welcome-grid,
  .grid-2,
  .field-grid,
  .field-grid.three,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    gap: 6px;
  }
}

@media (max-width: 720px) {
  .welcome-card {
    padding: 24px;
  }

  .cards-4,
  .snapshot-grid {
    grid-template-columns: 1fr;
  }
}


/* Installable browser PWA additions */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body.drawer-open {
  overflow: hidden;
}

.mobile-topbar,
.mobile-drawer,
.mobile-drawer-scrim,
.mobile-tabbar {
  display: none;
}

.mobile-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 35;
  align-items: center;
  gap: 10px;
  min-height: calc(68px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.mobile-title {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.mobile-title strong,
.mobile-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-title span {
  color: var(--muted);
  font-size: 12px;
}

.mobile-topbar .btn,
.mobile-drawer .btn {
  min-width: 0;
  padding: 10px 12px;
}

.mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.mobile-tab-btn {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 9px 4px;
  font-size: 12px;
  font-weight: 800;
}

.mobile-tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(197, 131, 160, 0.3);
}

.mobile-drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 38;
  background: rgba(23, 37, 31, 0.38);
}

.mobile-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 39;
  width: min(390px, 92vw);
  max-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 50px rgba(23, 37, 31, 0.18);
}

.mobile-drawer-header,
.mobile-drawer-actions {
  display: grid;
  gap: 10px;
}

.mobile-drawer-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 14px;
}

.mobile-drawer-actions {
  margin-bottom: 14px;
}

.app-shell.drawer-open .mobile-drawer,
.app-shell.drawer-open .mobile-drawer-scrim {
  display: block;
}

@media (pointer: coarse), (max-width: 980px) {
  html,
  body {
    height: 100% !important;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: hidden !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  body:not(.drawer-open) {
    position: static !important;
    overflow-y: hidden !important;
  }

  .app-shell {
    width: 100%;
    max-width: 100%;
  }

  .main,
  .page-stack,
  .page.active {
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
  }

  .welcome-screen {
    position: fixed;
    inset: 0;
    min-height: 0;
    height: 100dvh !important;
    align-items: flex-start;
    padding: calc(18px + var(--safe-top)) 14px calc(18px + var(--safe-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .welcome-card {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 980px) {
  .app-shell.active {
    display: block;
    position: fixed !important;
    inset: 0 !important;
    width: 100%;
    max-width: 100%;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0;
    padding-top: calc(74px + var(--safe-top));
    padding-bottom: calc(78px + var(--safe-bottom));
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }

  .mobile-topbar {
    display: flex;
  }

  .mobile-tabbar {
    display: grid;
  }

  .sidebar {
    display: none;
  }

  .main {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    padding: 16px;
  }

  .welcome-grid,
  .today-hero,
  .today-visual-grid,
  .grid-2,
  .grid-3,
  .cards-3,
  .cards-4,
  .field-grid,
  .field-grid.three,
  .mobile-drawer-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel,
  .stat-card,
  .mini-card,
  .med-card,
  .welcome-panel {
    padding: 16px;
    border-radius: 16px;
  }

  .page-header h1 {
    font-size: 34px;
    line-height: 1;
  }

  .panel-header,
  .list-item,
  .med-header,
  .action-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .tag-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .table-wrap {
    overflow-x: auto;
    max-width: 100%;
  }
}


@media (display-mode: standalone) and (min-width: 981px) {
  html,
  body {
    height: auto !important;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto !important;
  }

  body:not(.drawer-open) {
    overflow-y: auto !important;
  }

  .app-shell.active {
    display: flex;
    position: static !important;
    inset: auto !important;
    width: 100%;
    min-height: 100vh;
    height: auto !important;
    max-height: none !important;
    padding-top: 0;
    padding-bottom: 0;
    overflow: visible !important;
  }

  .main {
    margin-left: 292px;
    width: calc(100% - 292px);
    padding: 28px;
    overflow: visible !important;
  }

  .sidebar {
    display: block;
    position: fixed;
    inset: 0 auto 0 0;
  }

  .mobile-topbar,
  .mobile-tabbar {
    display: none !important;
  }
}
