:root {
  color-scheme: dark;
  --bg: #101014;
  --panel: #171821;
  --panel-soft: #1e202b;
  --line: #303342;
  --text: #f2efe8;
  --muted: #aaa8b5;
  --accent: #80c7a4;
  --accent-strong: #a6f0c3;
  --warm: #dfb07b;
  --danger: #ef8d8d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(128, 199, 164, 0.12), transparent 32rem),
    linear-gradient(145deg, #101014 0%, #15151d 52%, #0e1015 100%);
  color: var(--text);
}

body[data-ui-size="compact"] {
  font-size: 14px;
}

body[data-ui-size="large"] {
  font-size: 18px;
}

button {
  border: 0;
  border-radius: 8px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

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

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.auth-card {
  width: min(100%, 420px);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(23, 24, 33, 0.96);
  box-shadow: var(--shadow);
}

.auth-logo {
  display: block;
  width: 112px;
  height: 112px;
  margin: 0 auto 16px;
  border-radius: 50%;
  object-fit: contain;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.35));
}

.auth-copy {
  margin: 12px 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-form input {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101119;
  color: var(--text);
  font: inherit;
}

.auth-submit {
  min-height: 48px;
  margin-top: 4px;
  background: linear-gradient(145deg, #6fb78f, #426f60);
  color: #08110d;
  font-weight: 800;
}

.auth-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--danger);
  font-size: 0.86rem;
}

.app-shell {
  width: min(100%, 860px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 30px;
}

.top-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 2px 14px;
}

.header-actions {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0;
}

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

h1 {
  font-size: clamp(1.35rem, 8vw, 2.3rem);
  line-height: 1;
}

h2 {
  font-size: 1rem;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.28));
}

.sync-toggle {
  min-width: 84px;
  padding: 10px 12px;
  background: rgba(128, 199, 164, 0.16);
  border: 1px solid rgba(128, 199, 164, 0.3);
  color: var(--accent-strong);
}

.sync-toggle.off {
  background: rgba(239, 141, 141, 0.13);
  border-color: rgba(239, 141, 141, 0.35);
  color: var(--danger);
}

.icon-button {
  padding: 7px 9px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.72rem;
}

.account-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: rgba(23, 24, 33, 0.7);
}

.account-panel span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.size-switcher {
  display: flex;
  gap: 4px;
}

.size-switcher button {
  padding: 7px 8px;
  background: #1a1b24;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
}

.size-switcher button.active {
  background: rgba(128, 199, 164, 0.17);
  border-color: rgba(128, 199, 164, 0.45);
  color: var(--accent-strong);
}

.child-switcher {
  display: flex;
  gap: 10px;
  margin: 2px -14px 12px;
  padding: 0 14px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.child-switcher::-webkit-scrollbar {
  display: none;
}

.child-pill {
  display: grid;
  min-width: 84px;
  gap: 5px;
  justify-items: center;
  padding: 8px 8px 9px;
  background: transparent;
  border: 1px solid transparent;
}

.child-pill.active {
  background: rgba(128, 199, 164, 0.1);
  border-color: rgba(128, 199, 164, 0.38);
}

.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(145deg, #6d4c3e, #9d755f);
  box-shadow: 0 0 0 3px rgba(215, 230, 255, 0.1);
  font-weight: 800;
}

.child-pill span:last-child {
  max-width: 76px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.child-pill.active span:last-child {
  color: var(--text);
}

.status-bar,
.quick-actions,
.timeline-panel {
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(23, 24, 33, 0.9);
  box-shadow: var(--shadow);
}

.status-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.status-bar article {
  min-height: 76px;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.025);
}

.status-bar span,
.panel-title span,
.timeline-time {
  color: var(--muted);
  font-size: 0.72rem;
}

.status-bar strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(0.82rem, 3.7vw, 1rem);
  line-height: 1.18;
}

.overview-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 12px 0;
}

.overview-switcher button {
  padding: 11px 8px;
  background: #1a1b24;
  border: 1px solid var(--line);
  color: var(--muted);
}

.overview-switcher button.active {
  background: rgba(128, 199, 164, 0.17);
  border-color: rgba(128, 199, 164, 0.48);
  color: var(--accent-strong);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 8px;
}

.quick-actions button {
  min-height: 48px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.quick-actions .primary {
  background: linear-gradient(145deg, #6fb78f, #426f60);
  color: #08110d;
  font-weight: 800;
}

.timeline-panel {
  min-height: 360px;
  border-radius: 8px;
  padding: 13px;
}

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

.timeline {
  position: relative;
  display: grid;
  align-content: start;
  align-items: start;
  gap: 10px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 52px;
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.timeline-entry {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  animation: lift-in 180ms ease both;
}

.timeline-card {
  min-height: 66px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: #1b1d27;
}

.timeline-card::before {
  content: "";
  position: absolute;
  left: 48px;
  top: 18px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warm);
  box-shadow: 0 0 0 4px var(--bg);
}

.timeline-card h3 {
  margin: 0 0 4px;
  font-size: 0.96rem;
}

.timeline-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@keyframes lift-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 680px) {
  .quick-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .app-shell {
    width: min(100%, 980px);
    padding: 26px 22px 42px;
  }

  .top-header {
    gap: 16px;
  }

  .brand-mark {
    width: 66px;
    height: 66px;
  }

  .child-pill {
    min-width: 104px;
    padding: 10px;
  }

  .avatar {
    width: 58px;
    height: 58px;
  }

  .status-bar article {
    min-height: 92px;
    padding: 16px 14px;
  }

  .status-bar strong {
    font-size: 1.12rem;
  }

  .quick-actions button {
    min-height: 58px;
  }

  .timeline-panel {
    padding: 18px;
  }

  .timeline-card {
    min-height: 78px;
    padding: 15px;
  }
}

/* Polish pass: larger touch UI, no page-level horizontal overflow, and sleep zones. */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-size: 20px;
}

body[data-ui-size="compact"] {
  font-size: 20px;
}

body[data-ui-size="normal"] {
  font-size: 22px;
}

body[data-ui-size="large"] {
  font-size: 26px;
}

.app-shell,
.auth-screen,
.auth-card,
.top-header,
.account-panel,
.status-bar,
.overview-switcher,
.quick-actions,
.timeline-panel,
.timeline,
.timeline-entry,
.timeline-card {
  max-width: 100%;
  min-width: 0;
}

.app-shell {
  overflow-x: hidden;
}

.top-header {
  grid-template-columns: auto minmax(0, 1fr) minmax(86px, auto);
}

.header-actions,
.size-switcher {
  min-width: 0;
}

.sync-toggle,
.icon-button,
.overview-switcher button,
.quick-actions button,
.size-switcher button {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.account-panel {
  flex-wrap: wrap;
}

.account-panel span {
  flex: 1 1 180px;
  font-size: 0.95rem;
  white-space: normal;
}

.size-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 1 1 260px;
}

.size-switcher button,
.icon-button,
.auth-form label,
.auth-error,
.eyebrow,
.status-bar span,
.panel-title span,
.timeline-time,
.child-pill span:last-child {
  font-size: 0.95rem;
}

.child-switcher {
  overflow-x: auto;
  overflow-y: hidden;
}

.child-pill {
  flex: 0 0 auto;
  min-width: 104px;
}

.avatar {
  overflow: hidden;
  background: rgba(128, 199, 164, 0.12);
}

.image-avatar img {
  width: 120%;
  height: 120%;
  object-fit: contain;
}

.status-bar strong {
  font-size: clamp(1rem, 4.5vw, 1.32rem);
}

.timeline {
  gap: 14px;
}

.timeline::before {
  left: 58px;
  width: 3px;
  border-radius: 999px;
  background: rgba(128, 199, 164, 0.22);
}

.timeline-entry {
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 20px;
}

.timeline-card {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.timeline-card::before {
  left: 53px;
}

.timeline-card h3 {
  font-size: 1.12rem;
}

.timeline-card p {
  font-size: 1rem;
}

.sleep-zone .timeline-card {
  border-color: rgba(128, 199, 164, 0.45);
  background:
    linear-gradient(90deg, rgba(128, 199, 164, 0.2), rgba(128, 199, 164, 0.07)),
    #1b1d27;
}

.sleep-zone .timeline-time {
  color: var(--accent-strong);
}

.running-sleep .timeline-card {
  animation: sleep-pulse 1800ms ease-in-out infinite;
}

.sleep-z {
  position: absolute;
  right: 12px;
  top: 10px;
  color: var(--accent-strong);
  font-weight: 900;
  opacity: 0;
  animation: z-float 1600ms ease-in-out infinite;
  pointer-events: none;
}

.nested-entry {
  grid-template-columns: 48px minmax(0, 1fr);
  margin-left: clamp(14px, 5vw, 38px);
}

.nested-entry .timeline-card {
  border-left: 5px solid rgba(128, 199, 164, 0.55);
}

.prediction-entry .timeline-card {
  border-style: dashed;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
}

.entry-modal {
  width: min(100%, 520px);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(23, 24, 33, 0.98);
  box-shadow: var(--shadow);
}

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

.modal-fields {
  display: grid;
  gap: 12px;
}

.modal-fields label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

.modal-fields input,
.modal-fields select,
.modal-fields textarea {
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101119;
  color: var(--text);
  font: inherit;
}

.modal-fields textarea {
  min-height: 118px;
  resize: vertical;
}

.date-combo {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.date-combo input[name="birthDate"] {
  min-width: 0;
}

.date-picker-button {
  min-height: 52px;
  padding: 0 12px;
  border: 1px solid rgba(128, 199, 164, 0.28);
  border-radius: 8px;
  background: rgba(128, 199, 164, 0.12);
  color: var(--text);
  font: inherit;
  font-weight: 800;
}

.native-date-input {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@keyframes sleep-pulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 1px rgba(128, 199, 164, 0.16);
  }

  50% {
    box-shadow: inset 0 0 0 1px rgba(166, 240, 195, 0.5), 0 0 28px rgba(128, 199, 164, 0.16);
  }
}

@keyframes z-float {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.9);
  }

  35% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-18px) scale(1.05);
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding-inline: 10px;
  }

  .top-header {
    gap: 8px;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
  }

  h1 {
    font-size: 1.55rem;
  }

  .status-bar article {
    padding: 10px 8px;
  }

  .overview-switcher {
    gap: 4px;
  }

  .timeline-entry,
  .nested-entry {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 16px;
  }
}

/* Timeline/modal refinement: keep the marker on the rail and pair modal actions. */
.timeline-card::before {
  content: none;
}

.timeline-entry::before {
  content: "";
  position: absolute;
  left: 52px;
  top: 20px;
  z-index: 1;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--warm);
  box-shadow: 0 0 0 5px var(--bg);
}

.timeline-entry:not(.nested-entry):not(.sleep-zone)::after {
  content: "";
  position: absolute;
  left: 56px;
  top: 32px;
  bottom: -14px;
  z-index: 0;
  width: 3px;
  border-radius: 999px;
  background: rgba(128, 199, 164, 0.2);
}

.timeline-entry:last-child::after {
  content: none;
}

.timeline::before {
  content: none;
}

.sleep-zone::before {
  background: var(--accent-strong);
}

.nested-entry::before {
  left: 14px;
  background: rgba(128, 199, 164, 0.86);
}

.timeline-note {
  margin-top: 8px !important;
  color: var(--text) !important;
  opacity: 0.86;
}

.timeline-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  text-align: left;
}

.entry-symbols {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entry-icon,
.entry-flag {
  display: inline-grid;
  width: 3.05em;
  height: 3.05em;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 1.16em;
  line-height: 1;
  white-space: nowrap;
}

.entry-flag {
  background: rgba(128, 199, 164, 0.16);
}

.diaper-icon {
  position: relative;
  display: block;
  width: 1.8em;
  height: 1.45em;
  border: 0.12em solid rgba(255, 255, 255, 0.9);
  border-top-width: 0.22em;
  border-radius: 0.34em 0.34em 0.7em 0.7em;
  background: linear-gradient(180deg, #ffffff 0%, #f6f3e9 100%);
  box-shadow: inset 0 -0.14em 0 rgba(0, 0, 0, 0.08);
}

.diaper-icon::before,
.diaper-icon::after {
  position: absolute;
  bottom: -0.15em;
  width: 0.52em;
  height: 0.52em;
  border-radius: 50%;
  background: #20212b;
  content: '';
}

.diaper-icon::before {
  left: -0.24em;
}

.diaper-icon::after {
  right: -0.24em;
}

.diaper-icon span {
  position: absolute;
  inset: 0.28em 0.34em 0.18em;
  border-radius: 999px 999px 0.52em 0.52em;
}

.diaper-wet span {
  background: radial-gradient(circle at 50% 78%, rgba(76, 164, 255, 0.9) 0 38%, transparent 40%);
}

.diaper-dirty span {
  background: radial-gradient(circle at 50% 78%, rgba(135, 87, 47, 0.92) 0 38%, transparent 40%);
}

.diaper-both span {
  background:
    radial-gradient(circle at 50% 78%, rgba(135, 87, 47, 0.92) 0 36%, transparent 38%),
    radial-gradient(circle at 50% 34%, rgba(76, 164, 255, 0.88) 0 30%, transparent 32%);
}

.diaper-dry span {
  background: rgba(255, 255, 255, 0.28);
}

.entry-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.entry-title {
  color: var(--text);
  font-size: 1.12rem;
  font-weight: 900;
}

.entry-description {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.28;
}

.temperature-normal .timeline-card {
  border-color: rgba(128, 199, 164, 0.38);
  background:
    linear-gradient(90deg, rgba(128, 199, 164, 0.15), rgba(128, 199, 164, 0.04)),
    #1b1d27;
}

.temperature-fever .timeline-card {
  border-color: rgba(230, 193, 101, 0.55);
  background:
    linear-gradient(90deg, rgba(230, 193, 101, 0.2), rgba(230, 193, 101, 0.05)),
    #1b1d27;
}

.temperature-high .timeline-card {
  border-color: rgba(239, 141, 141, 0.62);
  background:
    linear-gradient(90deg, rgba(239, 141, 141, 0.22), rgba(239, 141, 141, 0.06)),
    #1b1d27;
}

.modal-title {
  justify-content: flex-start;
}

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

.modal-button {
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  font-weight: 800;
}

.modal-button.primary {
  background: linear-gradient(145deg, #6fb78f, #426f60);
  color: #08110d;
}

.modal-button.secondary {
  background: #1a1b24;
  color: var(--text);
}

@media (max-width: 420px) {
  .timeline-entry::before {
    left: 49px;
  }

  .nested-entry::before {
    left: 12px;
  }
}
/* Night-use layout: fixed controls, large touch targets, scrollable timeline only. */
html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-size: 24px;
}

body[data-ui-size="compact"] {
  font-size: 24px;
}

body[data-ui-size="normal"] {
  font-size: 27px;
}

body[data-ui-size="large"] {
  font-size: 31px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 1120px);
  height: 100dvh;
  min-height: 0;
  padding: 10px 12px 12px;
  overflow: hidden;
}

.top-header,
.account-panel,
.baby-switch-row,
.status-bar,
.overview-switcher,
.quick-actions {
  flex: 0 0 auto;
}

.top-header {
  padding: 8px 0 10px;
}

.brand-mark {
  width: 68px;
  height: 68px;
}

h1 {
  font-size: clamp(1.9rem, 8vw, 3rem);
}

h2 {
  font-size: 1.28rem;
}

.eyebrow,
.account-panel span,
.size-switcher button,
.icon-button,
.status-bar span,
.panel-title span,
.timeline-time,
.child-pill span:last-child {
  font-size: 1rem;
}

.sync-toggle,
.icon-button,
.size-switcher button,
.overview-switcher button,
.quick-actions button,
.modal-button,
.child-manage-button {
  min-height: 64px;
  padding: 12px 16px;
}

.baby-switch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
}

.baby-switch-row .child-switcher {
  margin: 0;
  padding: 0 4px 4px 0;
}

.child-manage-button {
  display: grid;
  place-items: center;
  align-self: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1px solid rgba(128, 199, 164, 0.45);
  background: rgba(128, 199, 164, 0.14);
  color: var(--accent-strong);
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
}

.child-pill {
  min-width: 126px;
  padding: 10px 12px;
}

.avatar {
  width: 68px;
  height: 68px;
}

.child-pill span:last-child {
  max-width: 112px;
}

.status-bar article {
  min-height: 104px;
  padding: 14px 12px;
}

.status-bar strong {
  font-size: clamp(1.05rem, 4.7vw, 1.55rem);
}

.overview-switcher {
  gap: 8px;
  margin: 10px 0;
}

.quick-actions {
  gap: 10px;
  margin-bottom: 10px;
}

.quick-actions button {
  min-height: 78px;
  font-weight: 850;
}

.timeline-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.panel-title {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.date-controls {
  display: grid;
  grid-template-columns: 42px minmax(132px, 1fr) auto 42px;
  gap: 6px;
  align-items: center;
}

.date-controls button,
.date-controls input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1a1b24;
  color: var(--text);
  font: inherit;
  font-weight: 800;
}

.date-controls input {
  width: 100%;
  min-width: 0;
  padding: 0 8px;
  color-scheme: dark;
}

.timeline {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 4px 28px 0;
  overscroll-behavior: contain;
}

.timeline-card {
  min-height: 88px;
  padding: 18px;
}

.timeline-card h3 {
  font-size: 1.22rem;
}

.timeline-card p {
  font-size: 1.06rem;
}

.entry-modal {
  width: min(100%, 640px);
  padding: 22px;
}

.modal-fields input,
.modal-fields select,
.modal-fields textarea {
  min-height: 66px;
}

.modal-actions {
  gap: 12px;
}

.modal-button {
  min-height: 70px;
}

.baby-list-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.baby-list-item {
  display: grid;
  flex: 0 0 auto;
  min-width: 126px;
  gap: 6px;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1a1b24;
  color: var(--text);
}

.baby-list-item.active {
  border-color: rgba(128, 199, 164, 0.6);
  background: rgba(128, 199, 164, 0.16);
}

.baby-list-item img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.baby-list-item.new-baby {
  min-width: 150px;
  color: var(--accent-strong);
  font-weight: 850;
}

.baby-photo-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(128, 199, 164, 0.24);
  border-radius: 8px;
  background: rgba(128, 199, 164, 0.08);
}

.baby-photo-row img {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  background: #101119;
}

.baby-photo-row strong,
.baby-photo-row span {
  display: block;
}

.baby-photo-row span {
  color: var(--muted);
  font-size: 0.92rem;
}

.baby-photo-remove {
  width: 100%;
}

.photo-upload-control {
  cursor: pointer;
}

.photo-upload-control input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-upload-display {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(188, 226, 173, 0.32);
  border-radius: 8px;
  background: rgba(241, 247, 233, 0.08);
}

.photo-upload-display strong,
.photo-upload-display small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-upload-display strong {
  color: var(--text);
}

.photo-upload-display small {
  color: var(--muted);
}

.photo-crop-status {
  margin: -4px 0 2px;
  color: var(--muted);
  font-size: 0.92em;
}

.photo-crop-status.ready {
  color: #c4e8b5;
  font-weight: 800;
}

.crop-modal {
  width: min(100%, 560px);
}

.crop-preview {
  display: grid;
  place-items: center;
  width: min(70vw, 320px);
  aspect-ratio: 1;
  margin: 0 auto 16px;
  overflow: hidden;
  border: 2px solid rgba(188, 226, 173, 0.42);
  border-radius: 50%;
  background: #101119;
}

.crop-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  transform-origin: center;
  will-change: object-position, transform;
}

@media (max-width: 520px) {
  .app-shell {
    padding: 8px 8px 10px;
  }

  .account-panel {
    display: none;
  }

  .brand-mark {
    width: 56px;
    height: 56px;
  }

  h1 {
    font-size: 1.85rem;
  }

  .sync-toggle,
  .icon-button {
    min-height: 52px;
    padding: 8px 10px;
  }

  .child-manage-button {
    width: 62px;
    height: 62px;
    min-height: 62px;
  }

  .child-pill {
    min-width: 112px;
  }

  .avatar {
    width: 58px;
    height: 58px;
  }

  .status-bar article {
    min-height: 90px;
    padding: 10px 8px;
  }

  .quick-actions button {
    min-height: 70px;
  }
}

/* Ergonomic app shell: compact header, scroll-only timeline, thumb-friendly footer actions. */
body[data-ui-size="compact"] {
  font-size: 18px;
}

body[data-ui-size="normal"] {
  font-size: 20px;
}

body[data-ui-size="large"] {
  font-size: 22px;
}

.app-shell {
  width: min(100%, 1040px);
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
}

.top-header {
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 6px 0 8px;
}

.brand-mark {
  width: 54px;
  height: 54px;
}

h1 {
  font-size: clamp(1.45rem, 4.5vw, 2.25rem);
}

.account-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  padding: 6px 8px;
}

.account-panel span {
  flex: initial;
  font-size: 1rem;
  white-space: nowrap;
}

.account-menu-wrap {
  position: relative;
}

.account-menu-button {
  display: grid;
  width: 54px;
  height: 54px;
  min-height: 54px;
  place-items: center;
  border: 1px solid rgba(128, 199, 164, 0.4);
  border-radius: 50%;
  background: rgba(128, 199, 164, 0.12);
  color: var(--accent-strong);
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  width: min(78vw, 260px);
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(23, 24, 33, 0.98);
  box-shadow: var(--shadow);
}

.account-menu label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.95rem;
}

.account-menu select {
  min-height: 54px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101119;
  color: var(--text);
  font: inherit;
}

.account-menu .icon-button {
  min-height: 54px;
  background: #1a1b24;
  color: var(--text);
  font-size: 1rem;
}

.account-menu .icon-button[hidden] {
  display: none;
}

.user-list {
  display: grid;
  gap: 8px;
  max-height: min(28vh, 240px);
  overflow: auto;
}

.user-list-actions {
  display: grid;
  gap: 8px;
}

.user-list-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(128, 199, 164, 0.22);
  border-radius: 8px;
  background: rgba(128, 199, 164, 0.08);
  color: var(--text);
  text-align: left;
  font: inherit;
}

.user-list-item.active {
  border-color: rgba(128, 199, 164, 0.7);
  background: rgba(128, 199, 164, 0.18);
}

.user-list-item strong {
  display: block;
  color: var(--text);
  font-size: 1rem;
}

.user-list-item span,
.muted-list-text {
  color: var(--muted);
  font-size: 0.92rem;
}

.modal-button.danger {
  border-color: rgba(255, 120, 120, 0.35);
  background: rgba(255, 120, 120, 0.12);
  color: #ffb1b1;
}

.modal-button.danger span {
  margin-right: 6px;
}

.baby-switch-row {
  margin-bottom: 8px;
}

.child-manage-button {
  width: 58px;
  height: 58px;
  min-height: 58px;
}

.child-pill {
  min-width: 112px;
  padding: 8px 10px;
}

.avatar {
  width: 58px;
  height: 58px;
}

.status-bar article {
  min-height: 88px;
  padding: 10px 9px;
}

.status-bar strong {
  font-size: clamp(0.98rem, 2.2vw, 1.2rem);
}

.overview-switcher {
  margin: 8px 0;
}

.overview-switcher button,
.sync-toggle {
  min-height: 54px;
}

.timeline-panel {
  order: 10;
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 10px;
}

.timeline {
  flex: 1 1 auto;
  min-height: 0;
}

.stats-dashboard {
  display: grid;
  gap: 12px;
  align-content: start;
}

.stats-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 0 0 auto;
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(188, 226, 173, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.stats-tabs button {
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(241, 247, 233, 0.72);
  font: inherit;
  font-weight: 800;
}

.stats-tabs button.active {
  background: rgba(175, 218, 139, 0.18);
  color: #f7ffe9;
  box-shadow: inset 0 0 0 1px rgba(188, 226, 173, 0.22);
}

.stats-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(188, 226, 173, 0.18);
  border-radius: 8px;
  background: rgba(10, 22, 20, 0.66);
}

.stats-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.stats-heading span {
  font-weight: 850;
  color: #f1f7e9;
}

.stats-heading small,
.stat-card small,
.pie-legend small {
  color: rgba(241, 247, 233, 0.68);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-card,
.pie-card {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.065);
}

.stat-card span,
.pie-card > span {
  font-size: 0.78em;
  color: rgba(241, 247, 233, 0.74);
}

.stat-card strong {
  font-size: 1.22em;
  color: #ffffff;
}

.vertical-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: end;
  gap: 7px;
  min-height: 184px;
}

.vertical-bar-item {
  display: grid;
  grid-template-rows: auto minmax(96px, 1fr) auto;
  justify-items: center;
  gap: 6px;
  min-width: 0;
}

.vertical-bar-value {
  min-height: 2.2em;
  color: rgba(241, 247, 233, 0.74);
  font-size: 0.66em;
  line-height: 1.1;
  text-align: center;
}

.vertical-bar-track {
  position: relative;
  width: 100%;
  max-width: 34px;
  height: 100%;
  min-height: 104px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.vertical-bar-track i {
  position: absolute;
  inset: auto 0 0;
  display: block;
  border-radius: inherit;
  background: linear-gradient(0deg, rgba(79, 184, 106, 0.98), rgba(119, 226, 143, 0.92));
}

.food-chart .vertical-bar-track {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
}

.food-chart .vertical-bar-track i {
  position: static;
  inset: auto;
  width: 100%;
  min-height: 2px;
  border-radius: 0;
}

.food-chart .vertical-bar-track i:first-child {
  border-bottom-right-radius: 8px;
  border-bottom-left-radius: 8px;
}

.food-chart .vertical-bar-track i:last-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.food-chart .meal-segment {
  background: linear-gradient(0deg, #3fae5e, #73df8d);
}

.food-chart .bottle-segment {
  background: linear-gradient(0deg, #e8e8dc, #ffffff);
}

.food-chart .breastfeeding-segment {
  background: linear-gradient(0deg, #dc7394, #f2a1b8);
}

.food-chart .empty-segment {
  background: rgba(255, 255, 255, 0.16);
}

.sleep-chart .vertical-bar-track i {
  background: linear-gradient(0deg, rgba(121, 160, 255, 0.98), rgba(147, 207, 229, 0.92));
}

.monthly-trend {
  display: grid;
  overflow-x: auto;
  padding-bottom: 2px;
}

.monthly-trend svg {
  min-width: 100%;
  height: 190px;
}

.monthly-trend .trend-line {
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.monthly-trend .trend-grid {
  stroke: rgba(241, 247, 233, 0.2);
  stroke-width: 1.2;
}

.monthly-trend .trend-bar {
  opacity: 0.82;
}

.monthly-trend .meal-segment {
  fill: #4fb86a;
}

.monthly-trend .bottle-segment {
  fill: #f7f7ef;
}

.monthly-trend .breastfeeding-segment {
  fill: #f2a1b8;
}

.monthly-trend .empty-segment {
  fill: rgba(255, 255, 255, 0.16);
}

.monthly-trend circle {
  fill: #f7ffe9;
  stroke: rgba(8, 16, 15, 0.82);
  stroke-width: 2;
}

.monthly-trend .trend-x-label,
.monthly-trend .trend-y-label {
  fill: rgba(241, 247, 233, 0.7);
  font-size: 11px;
}

.vertical-bar-item > span {
  color: rgba(241, 247, 233, 0.78);
  font-size: 0.68em;
  line-height: 1;
}

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

.pie-card {
  justify-items: center;
  text-align: center;
}

.pie {
  display: grid;
  place-items: center;
  width: min(112px, 42vw);
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: inset 0 0 0 10px rgba(8, 16, 15, 0.62);
}

.pie b {
  display: grid;
  place-items: center;
  width: 48%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(8, 16, 15, 0.86);
  color: #ffffff;
}

.pie b small {
  margin-top: -0.8em;
  color: rgba(241, 247, 233, 0.68);
  font-size: 0.52em;
}

.pie-legend {
  display: grid;
  gap: 4px;
  justify-items: start;
  width: 100%;
}

.pie-legend small {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.pie-legend .meal {
  background: #4fb86a;
}

.pie-legend .bottle {
  background: #f7f7ef;
  box-shadow: inset 0 0 0 1px rgba(12, 20, 18, 0.35);
}

.pie-legend .breast {
  background: #f2a1b8;
}

@media (max-width: 560px) {
  .stats-section {
    padding: 10px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-pies {
    grid-template-columns: 1fr;
  }

  .vertical-chart {
    min-height: 164px;
    gap: 5px;
  }

  .vertical-bar-track {
    max-width: 28px;
    min-height: 92px;
  }
}

.quick-actions {
  order: 20;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

.quick-actions button {
  min-height: 76px;
  padding: 10px 8px;
  font-size: 1.06rem;
}

@media (min-width: 760px) {
  .app-shell {
    padding: 12px 18px 16px;
  }

  body[data-ui-size="large"] {
    font-size: 21px;
  }

  .quick-actions button {
    min-height: 68px;
  }
}

@media (max-width: 560px) {
  body[data-ui-size="compact"] {
    font-size: 21px;
  }

  body[data-ui-size="normal"] {
    font-size: 24px;
  }

  body[data-ui-size="large"] {
    font-size: 29px;
  }

  .app-shell {
    padding: 7px 8px calc(8px + env(safe-area-inset-bottom));
  }

  .top-header {
    gap: 7px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  h1 {
    font-size: 1.45rem;
  }

  .eyebrow {
    font-size: 0.72rem;
  }

  .account-panel {
    display: grid;
    margin-bottom: 7px;
  }

  .account-menu-button {
    width: 50px;
    height: 50px;
    min-height: 50px;
  }

  .baby-switch-row {
    grid-template-columns: minmax(0, 1fr) 54px;
    gap: 8px;
  }

  .baby-switch-row .child-switcher {
    padding-bottom: 3px;
  }

  .child-manage-button {
    width: 54px;
    height: 54px;
    min-height: 54px;
  }

  .child-pill {
    min-width: 104px;
  }

  .avatar {
    width: 52px;
    height: 52px;
  }

  .status-bar article {
    min-height: 94px;
    padding: 9px 7px;
  }

  .status-bar span,
  .panel-title span,
  .timeline-time,
  .child-pill span:last-child,
  .account-panel span {
    font-size: 0.82rem;
  }

  .status-bar strong {
    font-size: 0.9rem;
    line-height: 1.12;
  }

  .overview-switcher button,
  .sync-toggle {
    min-height: 50px;
    padding: 8px 9px;
  }

  .timeline-panel {
    min-height: 0;
    padding: 10px;
  }

  .quick-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .quick-actions button {
    min-height: 82px;
    padding: 8px 5px;
    font-size: 0.84rem;
    line-height: 1.05;
  }
}

@media (max-width: 370px) {
  .quick-actions button {
    font-size: 0.76rem;
  }

  .status-bar strong {
    font-size: 0.8rem;
  }
}


/* Size calibration v2: desktop compact stays shallow, phone large becomes night-friendly. */
body[data-ui-size="compact"] {
  font-size: 15px;
}

body[data-ui-size="normal"] {
  font-size: 19px;
}

body[data-ui-size="large"] {
  font-size: 21px;
}

body[data-ui-size="compact"] .top-header {
  padding: 3px 0 4px;
}

body[data-ui-size="compact"] .brand-mark {
  width: 40px;
  height: 40px;
}

body[data-ui-size="compact"] h1 {
  font-size: clamp(1.1rem, 2.4vw, 1.55rem);
}

body[data-ui-size="compact"] .account-panel {
  margin-bottom: 4px;
  padding: 4px 7px;
}

body[data-ui-size="compact"] .baby-switch-row {
  margin-bottom: 5px;
}

body[data-ui-size="compact"] .avatar {
  width: 42px;
  height: 42px;
}

body[data-ui-size="compact"] .child-pill {
  min-width: 86px;
  padding: 5px 8px;
}

body[data-ui-size="compact"] .child-manage-button,
body[data-ui-size="compact"] .account-menu-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
}

body[data-ui-size="compact"] .status-bar article {
  min-height: 60px;
  padding: 6px 8px;
}

body[data-ui-size="compact"] .status-bar strong {
  margin-top: 4px;
  font-size: clamp(0.78rem, 1.4vw, 0.95rem);
}

body[data-ui-size="compact"] .overview-switcher {
  margin: 5px 0;
}

body[data-ui-size="compact"] .overview-switcher button,
body[data-ui-size="compact"] .sync-toggle {
  min-height: 42px;
  padding: 6px 8px;
}

body[data-ui-size="compact"] .quick-actions button {
  min-height: 48px;
  font-size: 0.9rem;
}

.status-bar strong,
#ageState {
  overflow-wrap: anywhere;
  hyphens: auto;
}

.footer-action-wrap {
  position: relative;
  display: grid;
  min-width: 0;
}

.footer-action-wrap > button {
  width: 100%;
}

.footer-action-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 35;
  display: grid;
  width: min(72vw, 260px);
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(23, 24, 33, 0.98);
  box-shadow: var(--shadow);
}

.footer-action-menu button {
  min-height: 58px;
  background: #1a1b24;
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 800;
}

.checkbox-field {
  display: flex !important;
  min-height: 54px;
  flex-direction: row !important;
  align-items: center;
  gap: 12px !important;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.checkbox-field input {
  width: 24px !important;
  height: 24px;
  min-height: 24px !important;
  accent-color: var(--accent);
}

.number-stepper {
  display: grid;
  grid-template-columns: minmax(64px, auto) minmax(0, 1fr) minmax(64px, auto);
  gap: 8px;
  align-items: stretch;
}

.number-stepper button {
  min-height: 54px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #1a1b24;
  color: var(--text);
  font-weight: 900;
}

.feeding-field[hidden] {
  display: none;
}

@media (min-width: 760px) {
  body[data-ui-size="compact"] .app-shell {
    padding-top: 6px;
  }

  body[data-ui-size="compact"] .status-bar,
  body[data-ui-size="compact"] .overview-switcher,
  body[data-ui-size="compact"] .baby-switch-row,
  body[data-ui-size="compact"] .account-panel,
  body[data-ui-size="compact"] .top-header {
    max-height: 25vh;
  }
}

@media (max-width: 560px) {
  body[data-ui-size="compact"] {
    font-size: 29px;
  }

  body[data-ui-size="normal"] {
    font-size: 33px;
  }

  body[data-ui-size="large"] {
    font-size: 38px;
  }

  body[data-ui-size="compact"] .top-header,
  body[data-ui-size="normal"] .top-header,
  body[data-ui-size="large"] .top-header {
    padding: 7px 0 9px;
  }

  body[data-ui-size="compact"] .brand-mark {
    width: 46px;
    height: 46px;
  }

  body[data-ui-size="large"] .brand-mark {
    width: 64px;
    height: 64px;
  }

  body[data-ui-size="large"] h1 {
    font-size: 1.85rem;
  }

  body[data-ui-size="large"] .account-panel {
    padding: 9px 10px;
    margin-bottom: 10px;
  }

  body[data-ui-size="large"] .account-menu-button,
  body[data-ui-size="large"] .child-manage-button {
    width: 70px;
    height: 70px;
    min-height: 70px;
  }

  body[data-ui-size="large"] .baby-switch-row {
    grid-template-columns: minmax(0, 1fr) 70px;
    gap: 10px;
    margin-bottom: 12px;
  }

  body[data-ui-size="large"] .child-pill {
    min-width: 132px;
    padding: 12px 10px;
  }

  body[data-ui-size="large"] .avatar {
    width: 68px;
    height: 68px;
  }

  body[data-ui-size="large"] .status-bar article {
    min-height: 124px;
    padding: 14px 9px;
  }

  body[data-ui-size="large"] .status-bar strong {
    font-size: 1rem;
    line-height: 1.08;
  }

  body[data-ui-size="large"] .overview-switcher {
    margin: 12px 0;
  }

  body[data-ui-size="large"] .overview-switcher button,
  body[data-ui-size="large"] .sync-toggle {
    min-height: 66px;
  }

  body[data-ui-size="large"] .timeline-panel {
    padding: 10px;
  }

  body[data-ui-size="large"] .panel-title {
    grid-template-columns: 1fr;
  }

  body[data-ui-size="large"] .date-controls {
    grid-template-columns: 54px minmax(0, 1fr) auto 54px;
  }

  body[data-ui-size="large"] .date-controls button,
  body[data-ui-size="large"] .date-controls input {
    min-height: 62px;
  }

  body[data-ui-size="large"] .quick-actions {
    gap: 8px;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  body[data-ui-size="large"] .quick-actions button,
  body[data-ui-size="large"] .footer-action-wrap > button {
    min-height: 164px;
    font-size: 0.82rem;
    line-height: 1.05;
  }

  body[data-ui-size="large"] .footer-action-menu button {
    min-height: 92px;
  }
}


/* Timeline edit buttons and per-device scale polish. */
.timeline-card {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.timeline-card:focus-visible,
.child-manage-button:focus-visible,
.account-menu-button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

.child-manage-button,
.account-menu-button {
  padding: 0 !important;
  text-align: center;
  letter-spacing: 0;
  text-indent: 0;
}

.meta-fields {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

body[data-ui-size="compact"] .timeline {
  gap: 7px;
}

body[data-ui-size="compact"] .timeline-entry,
body[data-ui-size="compact"] .nested-entry {
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 14px;
}

body[data-ui-size="compact"] .timeline::before {
  left: 43px;
  width: 2px;
}

body[data-ui-size="compact"] .timeline-entry::before {
  left: 39px;
  top: 15px;
  width: 9px;
  height: 9px;
  box-shadow: 0 0 0 4px var(--bg);
}

body[data-ui-size="compact"] .timeline-entry:not(.nested-entry):not(.sleep-zone)::after {
  left: 42px;
  top: 25px;
  bottom: -7px;
  width: 2px;
}

body[data-ui-size="compact"] .nested-entry::before {
  left: 10px;
}

body[data-ui-size="compact"] .timeline-card {
  min-height: 46px;
  padding: 9px 11px;
}

body[data-ui-size="compact"] .entry-icon {
  width: 2.6em;
  height: 2.6em;
}

body[data-ui-size="compact"] .entry-flag {
  width: 2.6em;
  height: 2.6em;
}

body[data-ui-size="compact"] .entry-title {
  font-size: 0.94rem;
}

body[data-ui-size="compact"] .entry-description {
  font-size: 0.8rem;
}

body[data-ui-size="compact"] .timeline-card h3 {
  margin-bottom: 2px;
  font-size: 0.92rem;
}

body[data-ui-size="compact"] .timeline-card p {
  font-size: 0.78rem;
  line-height: 1.18;
}

body[data-ui-size="compact"] .timeline-time {
  font-size: 0.72rem;
}

body[data-ui-size="compact"] .timeline-note {
  margin-top: 4px !important;
}

@media (max-width: 560px) {
  body[data-ui-size="compact"] .timeline-card {
    min-height: 66px;
    padding: 13px;
  }

  body[data-ui-size="compact"] .entry-title {
    font-size: 1.06rem;
  }

  body[data-ui-size="compact"] .entry-description {
    font-size: 0.9rem;
  }

  body[data-ui-size="compact"] .timeline-card h3 {
    font-size: 1.06rem;
  }

  body[data-ui-size="compact"] .timeline-card p {
    font-size: 0.9rem;
  }

  body[data-ui-size="normal"] .timeline-card h3 {
    font-size: 1.16rem;
  }

  body[data-ui-size="normal"] .entry-title {
    font-size: 1.16rem;
  }

  body[data-ui-size="normal"] .entry-description {
    font-size: 1rem;
  }

  body[data-ui-size="normal"] .timeline-card p {
    font-size: 1rem;
  }

  body[data-ui-size="large"] .timeline-card {
    min-height: 104px;
    padding: 18px;
  }

  body[data-ui-size="large"] .entry-icon {
    width: 3.35em;
    height: 3.35em;
  }

  body[data-ui-size="large"] .entry-flag {
    width: 3.35em;
    height: 3.35em;
  }

  body[data-ui-size="large"] .entry-title {
    font-size: 1.25rem;
  }

  body[data-ui-size="large"] .entry-description {
    font-size: 1.08rem;
  }

  body[data-ui-size="large"] .timeline-card h3 {
    font-size: 1.25rem;
  }

  body[data-ui-size="large"] .timeline-card p {
    font-size: 1.08rem;
  }
}


/* Scale calibration v3: landscape/tablet has three clear steps, portrait phone has a much larger large mode. */
@media (orientation: landscape), (min-width: 700px) {
  body[data-ui-size="compact"] {
    font-size: 15px;
  }

  body[data-ui-size="normal"] {
    font-size: 18px;
  }

  body[data-ui-size="large"] {
    font-size: 22px;
  }

  body[data-ui-size="normal"] .brand-mark {
    width: 48px;
    height: 48px;
  }

  body[data-ui-size="normal"] .account-menu-button,
  body[data-ui-size="normal"] .child-manage-button {
    width: 52px;
    height: 52px;
    min-height: 52px;
  }

  body[data-ui-size="normal"] .avatar {
    width: 52px;
    height: 52px;
  }

  body[data-ui-size="normal"] .child-pill {
    min-width: 104px;
    padding: 7px 9px;
  }

  body[data-ui-size="normal"] .status-bar article {
    min-height: 78px;
    padding: 9px;
  }

  body[data-ui-size="normal"] .overview-switcher button,
  body[data-ui-size="normal"] .sync-toggle {
    min-height: 50px;
  }

  body[data-ui-size="normal"] .quick-actions button {
    min-height: 60px;
    font-size: 1rem;
  }

  body[data-ui-size="normal"] .timeline-card {
    min-height: 64px;
    padding: 13px;
  }

  body[data-ui-size="normal"] .timeline-card h3 {
    font-size: 1.03rem;
  }

  body[data-ui-size="normal"] .timeline-card p {
    font-size: 0.9rem;
  }

  body[data-ui-size="large"] .brand-mark {
    width: 58px;
    height: 58px;
  }

  body[data-ui-size="large"] .account-menu-button,
  body[data-ui-size="large"] .child-manage-button {
    width: 62px;
    height: 62px;
    min-height: 62px;
  }

  body[data-ui-size="large"] .avatar {
    width: 62px;
    height: 62px;
  }

  body[data-ui-size="large"] .status-bar article {
    min-height: 96px;
  }

  body[data-ui-size="large"] .quick-actions button {
    min-height: 76px;
    font-size: 1.06rem;
  }

  body[data-ui-size="large"] .timeline-card {
    min-height: 88px;
    padding: 18px;
  }
}

@media (orientation: portrait) and (max-width: 699px) {
  body[data-ui-size="compact"] {
    font-size: 14px;
  }

  body[data-ui-size="normal"] {
    font-size: 17px;
  }

  body[data-ui-size="large"] {
    font-size: 20px;
  }

  body[data-ui-size="compact"] .top-header {
    padding: 3px 0 4px;
  }

  body[data-ui-size="compact"] .brand-mark {
    width: 38px;
    height: 38px;
  }

  body[data-ui-size="compact"] h1 {
    font-size: 1.1rem;
  }

  body[data-ui-size="compact"] .account-panel {
    padding: 4px 6px;
    margin-bottom: 5px;
  }

  body[data-ui-size="compact"] .account-menu-button,
  body[data-ui-size="compact"] .child-manage-button {
    width: 44px;
    height: 44px;
    min-height: 44px;
  }

  body[data-ui-size="compact"] .baby-switch-row {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 6px;
    margin-bottom: 6px;
  }

  body[data-ui-size="compact"] .child-pill {
    min-width: 88px;
    padding: 6px 7px;
  }

  body[data-ui-size="compact"] .avatar {
    width: 42px;
    height: 42px;
  }

  body[data-ui-size="compact"] .status-bar article {
    min-height: 62px;
    padding: 7px 6px;
  }

  body[data-ui-size="compact"] .status-bar strong {
    font-size: 0.86rem;
  }

  body[data-ui-size="compact"] .overview-switcher button,
  body[data-ui-size="compact"] .sync-toggle {
    min-height: 44px;
  }

  body[data-ui-size="compact"] .quick-actions button,
  body[data-ui-size="compact"] .footer-action-wrap > button {
    min-height: 58px;
    font-size: 0.82rem;
  }

  body[data-ui-size="compact"] .timeline-card {
    min-height: 58px;
    padding: 9px;
  }

  body[data-ui-size="large"] .top-header {
    padding: 5px 0 7px;
  }

  body[data-ui-size="large"] .brand-mark {
    width: 58px;
    height: 58px;
  }

  body[data-ui-size="large"] h1 {
    font-size: 1.55rem;
  }

  body[data-ui-size="large"] .account-panel {
    padding: 8px;
    margin-bottom: 8px;
  }

  body[data-ui-size="large"] .account-menu-button,
  body[data-ui-size="large"] .child-manage-button {
    width: 60px;
    height: 60px;
    min-height: 60px;
  }

  body[data-ui-size="large"] .baby-switch-row {
    grid-template-columns: minmax(0, 1fr) 60px;
    gap: 8px;
    margin-bottom: 9px;
  }

  body[data-ui-size="large"] .child-pill {
    min-width: 118px;
    padding: 9px 8px;
  }

  body[data-ui-size="large"] .avatar {
    width: 58px;
    height: 58px;
  }

  body[data-ui-size="large"] .status-bar article {
    min-height: 96px;
    padding: 10px 8px;
  }

  body[data-ui-size="large"] .status-bar strong {
    font-size: 0.98rem;
  }

  body[data-ui-size="large"] .overview-switcher button,
  body[data-ui-size="large"] .sync-toggle {
    min-height: 58px;
  }

  body[data-ui-size="large"] .quick-actions button,
  body[data-ui-size="large"] .footer-action-wrap > button {
    min-height: 104px;
    font-size: 0.86rem;
  }

  body[data-ui-size="large"] .timeline-card {
    min-height: 80px;
    padding: 14px;
  }

  body[data-ui-size="large"] .timeline-card h3 {
    font-size: 1.1rem;
  }

  body[data-ui-size="large"] .timeline-card p {
    font-size: 0.96rem;
  }
}
