/* Little Moments v3.3.0-rc2 — consolidated mobile-first responsive CSS system. */
:root {
  color-scheme: light;
  --canvas: #efecea;
  --bg: #fffaf8;
  --surface: #fffefd;
  --surface-soft: #faf7f5;
  --surface-muted: #f3efed;
  --ink: #18223a;
  --muted: #858997;
  --muted-2: #a7a8ae;
  --line: #eee8e4;
  --line-strong: #e4dcd7;
  --field-bg: #fff;
  --field-muted: #faf8f7;
  --dialog-bg: #fff;
  --control-bg: #f2eeec;
  --control-selected: #fff;
  --scrim: rgba(27,24,29,.30);
  --feed: #e4536c;
  --feed-deep: #c73551;
  --feed-soft: #fde4e8;
  --sleep: #7460c9;
  --sleep-deep: #5641ad;
  --sleep-soft: #e9e5fb;
  --success: #4c725d;
  --wake: #63b486;
  --wake-deep: #3f815d;
  --wake-soft: #e7f5ec;
  --s6: 24px;
  --s7: 28px;
  --r-sheet: 28px;
  --shadow-sheet: 0 18px 55px rgba(18,14,17,.20),0 2px 10px rgba(18,14,17,.08);
  --shadow-float: 0 12px 30px rgba(49,39,44,.14);
  --app-width: 430px;
  --page-pad: 26px;
  --nav-height: 82px;

  /* Canonical UI geometry — v3.1.6 consistency pass */
  --tap-min: 44px;
  --control-h: 48px;
  --button-h: 52px;
  --button-h-session: 56px;
  --button-h-primary-large: 62px;
  --icon-inline: 20px;
  --icon-control: 24px;
  --icon-shell: 44px;
  --home-action-glyph: 38px;
  --home-action-shell: 62px;
  --stat-icon-slot: 30px;
  --stat-pictogram: 20px;
  --chart-total-sleep: #9c27b0;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0f0e12;
  --bg: #17161b;
  --surface: #201e25;
  --surface-soft: #242128;
  --surface-muted: #302d34;
  --ink: #f5f0f2;
  --muted: #aaa3ad;
  --muted-2: #77717d;
  --line: #39353e;
  --line-strong: #403b44;
  --field-bg: #1b191f;
  --field-muted: #29262e;
  --dialog-bg: #242128;
  --control-bg: #1e1c22;
  --control-selected: #3a3540;
  --scrim: rgba(0,0,0,.52);
  --wake: #77c99b;
  --wake-deep: #91d7ad;
  --wake-soft: #20362a;
  --feed: #f1788d;
  --feed-deep: #ff8ca0;
  --feed-soft: #43262f;
  --sleep: #9d8bea;
  --sleep-deep: #b5a7f5;
  --sleep-soft: #332f4c;
  --success: #9bd1ae;
  --shadow-sheet: 0 18px 55px rgba(0,0,0,.36),0 2px 10px rgba(0,0,0,.22);
  --shadow-float: 0 14px 34px rgba(0,0,0,.28);
  --chart-total-sleep: #9c27b0;
}

@media (prefers-color-scheme:dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
  }

}

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

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.icon {
  width: 24px;
  height: 24px;
  display: block;
  flex: 0 0 auto;
  color: currentColor;
  overflow: visible;
}

.icon-sm {
  width: 20px;
  height: 20px;
}

.icon-md {
  width: 24px;
  height: 24px;
}

.icon-lg {
  width: 32px;
  height: 32px;
}

.state-dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: currentColor;
}

html,body {
  margin: 0;
  min-height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Display","SF Pro Text","Segoe UI",sans-serif;
}

html {
  overscroll-behavior: none;
}

body {
  overscroll-behavior-y: none;
}

/* Keep scrolling available while hiding visual scrollbars on the primary content views. */
html.hide-page-scrollbar,
body.hide-page-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html.hide-page-scrollbar::-webkit-scrollbar,
body.hide-page-scrollbar::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

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

input,select,textarea {
  min-width: 0;
  max-width: 100%;
}

textarea {
  resize: none;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: .55;
}

input::placeholder,textarea::placeholder {
  color: var(--muted-2);
  opacity: 1;
}

button,[role="button"],.action,.tracking-leaflet,.timeline-item {
  touch-action: manipulation;
}

button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible {
  outline: 2px solid color-mix(in srgb,var(--sleep) 55%,transparent);
  outline-offset: 2px;
}

.form-control {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field-bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
}

input.form-control {
  min-height: 48px;
  padding: 11px 13px;
}

.form-textarea {
  padding: 12px 14px;
  overflow: auto;
  resize: none;
  -webkit-overflow-scrolling: touch;
}

#noteInput {
  height: 120px;
  min-height: 120px;
  max-height: 120px;
  margin: 0;
}

.form-control:focus {
  border-color: color-mix(in srgb,var(--sleep) 48%,var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb,var(--sleep) 10%,transparent);
  outline: none;
}

.form-select {
  min-height: 48px;
  padding: 0 36px 0 13px;
}

.control-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.control-label {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.015em;
}

.section-description,
.section-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.feedback-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

html.dialog-open,body.dialog-open {
  overflow: hidden;
  height: 100%;
  overscroll-behavior: none;
}

body.dialog-open {
  position: fixed;
  width: 100%;
}

/* ---------- App shell / shared page layout ---------- */
.app-shell {
  position: relative;
  width: min(100%,var(--app-width));
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
  background: linear-gradient(180deg,var(--bg) 0%,var(--surface) 100%);
  box-shadow: 0 0 60px rgba(52,39,43,.12);
}

.view {
  display: none;
  min-height: calc(100dvh - var(--nav-height));
  padding: 0 var(--page-pad) var(--s7);
}

.view.active {
  display: block;
}

.page-header,.home-header {
  padding-top: max(50px,calc(env(safe-area-inset-top) + 22px));
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s6);
}

.page-header h2,.home-header h1 {
  margin: 0;
  letter-spacing: -.04em;
  color: var(--ink);
}

.page-header h2 {
  font-size: 28px;
  line-height: 1.12;
  font-weight: 720;
}

.round-icon {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: none;
}

.round-icon svg {
  width: 23px;
  height: 23px;
}

/* ---------- Home ---------- */
#homeView {
  position: relative;
  padding-left: 28px;
  padding-right: 28px;
  padding-bottom: 20px;
  overflow: hidden;
}

#homeView .home-header {
  position: relative;
  z-index: 2;
  display: block;
  padding-top: max(48px,calc(env(safe-area-inset-top) + 20px));
}

.greeting-wrap {
  display: block;
  position: relative;
}

.greeting-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  position: relative;
  width: max-content;
  max-width: 100%;
}

#homeView .home-header h1 {
  font-size: 34px;
  line-height: 1.02;
  font-weight: 760;
  letter-spacing: -.045em;
}

#homeView .home-header p {
  margin: 8px 0 0;
  color: #8390a4;
  font-size: 20px;
  line-height: 1.15;
  font-weight: 540;
  letter-spacing: -.018em;
}

.greeting-icon {
  position: static;
  display: grid;
  place-items: center;
  width: var(--tap-min);
  height: var(--tap-min);
  margin-top: -8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.greeting-icon .icon {
  width: 30px;
  height: 30px;
}

.night-sky {
  position: absolute;
  left: 0;
  right: 0;
  top: max(4px,env(safe-area-inset-top));
  height: 180px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .45s ease,transform .45s ease;
  z-index: 0;
}

.night-sky::before {
  content: "";
  position: absolute;
  left: -10%;
  right: -10%;
  top: 0;
  height: 160px;
  background: radial-gradient(circle at 18% 24%, rgba(255,198,112,.18), transparent 22%), radial-gradient(circle at 34% 12%, rgba(168,225,255,.14), transparent 18%), radial-gradient(circle at 72% 18%, rgba(242,162,212,.16), transparent 21%), radial-gradient(circle at 84% 30%, rgba(194,178,255,.15), transparent 20%), linear-gradient(180deg, rgba(122,106,190,.08) 0%, rgba(122,106,190,0) 100%);
  filter: blur(3px);
}

.night-sky .star {
  position: absolute;
  display: block;
  width: 1em;
  height: 1em;
  line-height: 1;
  font-size: 16px;
  opacity: 0;
  color: #fff0cb;
  filter: drop-shadow(0 0 7px currentColor);
  animation: starPulse 5.8s ease-in-out infinite,starDrift 12s ease-in-out infinite;
}

.night-sky .star::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: .42em;
  height: .42em;
  background: currentColor;
  transform: translate(-50%,-50%) rotate(45deg);
  border-radius: 1px;
}

.night-sky .star-1 {
  top: 18px;
  left: 34px;
  font-size: 14px;
  color: #ffe29c;
  animation-delay: 0s,0s;
}

.night-sky .star-2 {
  top: 34px;
  left: 110px;
  font-size: 12px;
  color: #ffd1ea;
  animation-delay: 1.4s,-2.8s;
}

.night-sky .star-3 {
  top: 18px;
  right: 88px;
  font-size: 15px;
  color: #c9c0ff;
  animation-delay: .6s,-1.2s;
}

.night-sky .star-4 {
  top: 58px;
  right: 36px;
  font-size: 13px;
  color: #9fe3ff;
  animation-delay: 2.2s,-4.4s;
}

.night-sky .star-5 {
  top: 78px;
  left: 54px;
  font-size: 11px;
  color: #fff5d8;
  animation-delay: 1.1s,-2s;
}

.night-sky .star-6 {
  top: 86px;
  left: 44%;
  font-size: 14px;
  color: #ffcfb3;
  animation-delay: 2.8s,-3.8s;
}

.night-sky .star-7 {
  top: 70px;
  right: 118px;
  font-size: 12px;
  color: #d8d0ff;
  animation-delay: 3.4s,-5s;
}

.night-sky .star-8 {
  top: 108px;
  right: 58px;
  font-size: 10px;
  color: #ffc7da;
  animation-delay: 4.2s,-6s;
}

:root[data-theme="dark"].night-ambience .night-sky {
  opacity: 1;
  transform: translateY(0);
}

:root[data-theme="dark"] .night-sky .star {
  filter: drop-shadow(0 0 6px currentColor);
}

/* Evening: warmer, sparse, sunset-like sparkle. */
:root[data-theme="dark"].night-evening .night-sky::before {
  background: radial-gradient(circle at 18% 22%, rgba(255,196,112,.26), transparent 22%), radial-gradient(circle at 38% 10%, rgba(255,171,191,.18), transparent 19%), radial-gradient(circle at 72% 17%, rgba(213,168,255,.16), transparent 20%), linear-gradient(180deg, rgba(114,76,116,.15) 0%, rgba(70,62,112,.05) 58%, rgba(70,62,112,0) 100%);
}

:root[data-theme="dark"].night-evening .star-1 {
  left: 42px;
  top: 22px;
  color: #ffd88a;
}

:root[data-theme="dark"].night-evening .star-2 {
  left: 132px;
  top: 40px;
  color: #ffbfd7;
}

:root[data-theme="dark"].night-evening .star-3 {
  right: 106px;
  top: 26px;
  color: #e0c5ff;
}

:root[data-theme="dark"].night-evening .star-4 {
  right: 48px;
  top: 66px;
  color: #ffd2a8;
}

:root[data-theme="dark"].night-evening .star-5 {
  left: 74px;
  top: 88px;
  color: #fff0c8;
}

:root[data-theme="dark"].night-evening .star-6 {
  left: 48%;
  top: 92px;
  color: #ffc4b8;
}

:root[data-theme="dark"].night-evening .star-7 {
  opacity: .35;
}

:root[data-theme="dark"].night-evening .star-8 {
  opacity: .24;
}

/* Night: cooler, slightly denser and brighter. */
:root[data-theme="dark"].night-deep .night-sky::before {
  background: radial-gradient(circle at 16% 20%, rgba(137,190,255,.18), transparent 22%), radial-gradient(circle at 35% 10%, rgba(191,174,255,.20), transparent 18%), radial-gradient(circle at 70% 15%, rgba(255,165,215,.17), transparent 20%), radial-gradient(circle at 86% 28%, rgba(133,224,255,.18), transparent 19%), linear-gradient(180deg, rgba(62,57,112,.24) 0%, rgba(55,49,91,.10) 58%, rgba(55,49,91,0) 100%);
}

:root[data-theme="dark"].night-deep .star-1 {
  left: 28px;
  top: 18px;
  color: #bfe7ff;
}

:root[data-theme="dark"].night-deep .star-2 {
  left: 104px;
  top: 48px;
  color: #e6d8ff;
}

:root[data-theme="dark"].night-deep .star-3 {
  right: 92px;
  top: 16px;
  color: #c7bdff;
}

:root[data-theme="dark"].night-deep .star-4 {
  right: 28px;
  top: 58px;
  color: #9fe3ff;
}

:root[data-theme="dark"].night-deep .star-5 {
  left: 52px;
  top: 86px;
  color: #fff3cf;
}

:root[data-theme="dark"].night-deep .star-6 {
  left: 43%;
  top: 104px;
  color: #ffc7e4;
}

:root[data-theme="dark"].night-deep .star-7 {
  right: 118px;
  top: 72px;
  color: #d6ceff;
}

:root[data-theme="dark"].night-deep .star-8 {
  right: 54px;
  top: 118px;
  color: #a9e9ff;
}

@keyframes starPulse {
  0%,100% {
    opacity: .22;
    transform: scale(.92);
  }
  45% {
    opacity: .78;
    transform: scale(1.05);
  }
  65% {
    opacity: .48;
    transform: scale(.98);
  }

}

@keyframes starDrift {
  0%,100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -3px;
  }

}

.baby-hero {
  position: relative;
  z-index: 1;
  width: min(268px,68vw);
  margin: 0 auto;
  overflow: hidden;
  touch-action: pan-y;
  border-radius: 34px;
}

.baby-hero-track {
  display: flex;
  width: 100%;
  transform: translate3d(0,0,0);
  will-change: transform;
}

.baby-hero-slide {
  flex: 0 0 100%;
  min-width: 100%;
}

.baby-hero img {
  display: block;
  width: 100%;
  height: auto;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 14px 30px rgba(236,190,198,.19));
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.baby-hero-dots {
  position: absolute;
  left: 50%;
  bottom: 4px;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 7px;
  z-index: 2;
}

.baby-hero-dot {
  width: 7px;
  height: 7px;
  min-width: 7px;
  min-height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--muted);
  opacity: .42;
  transition: width .18s ease,background-color .18s ease,opacity .18s ease,transform .18s ease;
}

.baby-hero-dot.selected {
  width: 18px;
  background: var(--ink);
  opacity: .68;
}

.baby-hero-dot:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* Home boot skeleton keeps first paint stable while local state, the time-based
   Sleep card and the selected hero illustration are reconciled. */
.home-loading .greeting-line h1,
.home-loading #encouragement,
.home-loading .prompt {
  color: transparent !important;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.home-loading .greeting-line h1 {
  width: 156px;
  min-height: 28px;
}

.home-loading #encouragement {
  width: 132px;
  min-height: 17px;
}

.home-loading .prompt {
  width: 148px;
  min-height: 23px;
  margin-left: auto;
  margin-right: auto;
}

.home-loading .baby-hero-track,
.home-loading .baby-hero-dots {
  opacity: 0;
}

.home-loading .baby-hero::before {
  content: "";
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 38%;
  background: var(--surface-muted);
}

.home-loading .baby-hero-track {
  position: absolute;
  inset: 0;
}

.home-loading .home-action-card,
.home-loading .last-event {
  background: var(--surface-muted) !important;
  color: transparent !important;
  box-shadow: none;
}

.home-loading .home-action-card > *,
.home-loading .last-event > * {
  visibility: hidden;
}

.home-loading .greeting-line h1::after,
.home-loading #encouragement::after,
.home-loading .prompt::after,
.home-loading .baby-hero::after,
.home-loading .home-action-card::after,
.home-loading .last-event::after {
  content: "";
  position: absolute;
  inset: 0;
  translate: -110% 0;
  background: linear-gradient(90deg,transparent,rgba(255,255,255,.54),transparent);
  animation: homeSkeletonShimmer 1.15s ease-in-out infinite;
  pointer-events: none;
}

.home-loading .greeting-line h1,
.home-loading #encouragement,
.home-loading .prompt,
.home-loading .home-action-card,
.home-loading .last-event {
  position: relative;
}

@keyframes homeSkeletonShimmer {
  to { translate: 110% 0; }
}

@media (prefers-reduced-motion:reduce) {
  .home-loading .greeting-line h1::after,
  .home-loading #encouragement::after,
  .home-loading .prompt::after,
  .home-loading .baby-hero::after,
  .home-loading .home-action-card::after,
  .home-loading .last-event::after {
    animation: none;
  }
}

.prompt {
  position: relative;
  z-index: 1;
  text-align: center;
  margin: 0 0 15px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.15;
  font-weight: 720;
  letter-spacing: -.025em;
}

.quick-actions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 10px;
  margin: 0 auto;
}

.home-action-card {
  --card-pad-x: 18px;
  --art-top: 18px;
  --art-w: 96px;
  --art-h: 82px;
  position: relative;
  height: 180px;
  min-width: 0;
  overflow: hidden;
  border: 0;
  border-radius: 28px;
  padding: 0;
  text-align: left;
  isolation: isolate;
  box-shadow: 0 7px 20px rgba(41,44,74,.055);
  transition: transform .12s ease,filter .12s ease;
}

.home-action-card:active {
  transform: scale(.985);
  filter: saturate(.96);
}

.home-action-card.feed {
  background: #ffe3e9;
  color: #cf3156;
}

.home-action-card.sleep {
  background: #ebe8ff;
  color: #5a49cb;
}

.home-action-card.sleep[data-sleep-kind="day"] {
  background: #e2f3fa;
  color: #3080cf
}

.home-action-card.sleep[data-sleep-kind="night"] {
  background: #ebe8ff;
  color: #5a49cb;
}

.action-visual {
  position: absolute;
  top: var(--art-top);
  left: 50%;
  width: var(--art-w);
  height: var(--art-h);
  transform: translateX(-50%);
  display: block;
}

.feed-visual,.sleep-visual {
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-feed-indicator {
  width: var(--home-action-shell);
  height: var(--home-action-shell);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--feed-soft);
  color: var(--feed);
}

.home-action-glyph {
  width: var(--home-action-glyph);
  height: var(--home-action-glyph);
}

/* Home action artwork uses tight SVG viewBoxes so the painted Sun/Moon
   fills the same 38px optical footprint as the solid Feed state dot. */
.sun-illustration,.moon-illustration {
  overflow: visible;
}

.home-illustration {
  display: block;
  color: currentColor;
}

.action-copy {
  position: absolute;
  left: var(--card-pad-x);
  right: var(--card-pad-x);
  bottom: 16px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.action-copy strong,.action-copy small {
  display: block;
  white-space: nowrap;
}

.action-copy small {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.08;
  letter-spacing: -.01em;
}

.action-copy strong {
  font-size: 24px;
  font-weight: 760;
  line-height: 1.02;
  letter-spacing: -.035em;
}

.action-cta-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-arrow {
  width: var(--icon-inline);
  height: var(--icon-inline);
  margin-top: 2px;
  color: currentColor;
}

.last-events {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 14px;
}

.last-event {
  width: 100%;
  min-height: 72px;
  border: 0;
  border-radius: 25px;
  background: linear-gradient(135deg,rgba(255,255,255,.96) 0%,rgba(251,249,248,.92) 48%,rgba(246,243,241,.88) 100%);
  display: grid;
  grid-template-columns: 48px minmax(0,1fr) 20px;
  align-items: center;
  gap: 13px;
  padding: 10px 16px;
  text-align: left;
  color: var(--ink);
  box-shadow: 0 11px 28px rgba(52,39,43,.065),inset 0 1px 0 rgba(255,255,255,.92);
}

.last-event.last-feed {
  background: linear-gradient(135deg,rgba(255,255,255,.97) 0%,rgba(255,249,250,.94) 58%,rgba(253,244,246,.90) 100%);
}

.last-event.last-sleep {
  background: linear-gradient(135deg,rgba(255,255,255,.97) 0%,rgba(249,248,255,.94) 58%,rgba(244,242,252,.91) 100%);
}

.last-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-muted);
}

.feed-last-icon {
  color: #d93f5e;
  background: #ffe1e7;
}

.feed-last-icon .state-dot {
  width: 14px;
  height: 14px;
}

.sleep-last-icon {
  color: #4e3bcc;
  background: #e8e4ff;
}

.sleep-last-icon .icon {
  width: 27px;
  height: 27px;
}

.last-copy {
  min-width: 0;
}

.last-copy small,.last-copy strong {
  display: block;
}

.last-copy small {
  margin-bottom: 3px;
  color: #8591a4;
  font-size: 12px;
  font-weight: 520;
}

.last-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 720;
  line-height: 1.22;
  white-space: nowrap;
  text-overflow: ellipsis;
  letter-spacing: -.012em;
}

.chevron {
  width: 20px;
  height: 20px;
  color: #94a3bd;
}

.last-event.is-empty {
  opacity: .72;
}

.last-event.is-empty .chevron {
  visibility: hidden;
}

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 100;
  width: min(var(--app-width),100%);
  min-height: var(--nav-height);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4,1fr);
  padding: 10px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,254,253,.91);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(227,220,216,.8);
}

.nav-btn {
  min-height: 52px;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #748096;
  font-size: 11px;
  padding: 4px 0;
}

.nav-btn.active {
  color: var(--feed-deep);
  font-weight: 700;
}

.nav-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
}

.nav-icon .icon {
  width: 24px;
  height: 24px;
}

/* ---------- Active session ---------- */
.active-session-view {
  position: fixed;
  inset: 0;
  z-index: 80;
  width: min(100%,var(--app-width));
  max-width: var(--app-width);
  margin: auto;
  padding: 0 24px 28px;
  min-height: 100dvh;
  background: linear-gradient(180deg,var(--bg),var(--surface));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.active-session-view:not(.active) {
  display: none;
}

.close-active {
  position: absolute;
  left: 22px;
  top: max(42px,calc(env(safe-area-inset-top) + 16px));
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: grid;
  place-items: center;
}

.close-active .icon {
  width: 30px;
  height: 30px;
}

.active-content {
  height: 100%;
  padding-top: max(125px,calc(env(safe-area-inset-top) + 100px));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.active-orb {
  --orb-size: min(278px,calc(100vw - 48px));
  width: var(--orb-size);
  height: var(--orb-size);
  flex: 0 0 var(--orb-size);
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.active-orb.feed-mode {
  background: radial-gradient(circle at 35% 25%,#fff8f8 0%,#fbdde2 100%);
}

.active-orb.sleep-mode {
  background: radial-gradient(circle at 35% 25%,#fbfaff 0%,#dfdaf8 100%);
}

.active-orb.day-sleep-mode {
  background: radial-gradient(circle at 35% 25%,#fbfdff 0%,#e2f3fa 100%);
}

.active-orb.day-sleep-mode .active-symbol {
  color: #e1a331;
}

.active-symbol {
  order: 1;
  margin-bottom: 10px;
  color: var(--feed);
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
}

.active-symbol .active-session-icon {
  width: 66px;
  height: 66px;
}

.active-symbol .active-feed-dot {
  width: 38px;
  height: 38px;
}

.active-orb.night-sleep-mode .active-symbol {
  color: var(--sleep-deep);
}

.timer {
  order: 2;
  margin: 8px 0 6px;
  font-size: 42px;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.active-label {
  order: 3;
  font-size: 18px;
  font-weight: 600;
}

.active-help {
  display: none;
  order: 4;
}

.sleep-kind-notice {
  width: 100%;
  margin-top: 20px;
  margin-bottom: 20px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 25px;
}

.sleep-kind-notice[hidden] {
  display: none;
}

.sleep-kind-notice-copy {
  min-width: 0;
}

.sleep-kind-notice-copy strong,
.sleep-kind-notice-copy span {
  display: block;
}

.sleep-kind-notice-copy strong {
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 680;
  color: var(--ink);
}

.sleep-kind-notice-copy span {
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}

.sleep-kind-toggle {
  min-height: var(--tap-min);
  min-width: 117px;
  padding: 0 12px;
  border: 0;
  border-radius: 13px;
  background: var(--sleep-soft);
  color: var(--sleep-deep);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.sleep-kind-notice + .session-tools.single-tool {
  margin-top: 12px;
}

.session-tools {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
  margin-top: 37px;
}

.secondary {
  height: 57px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.secondary>span {
  margin: 0;
}

.tool-note {
  color: #555d6b;
  background: #f7f6f5;
  border-color: var(--line);
}

.tool-side {
  color: #555173;
  background: #faf9ff;
}

.ml-control {
  min-width: 0;
}

.tool-ml {
  width: 100%;
  height: 57px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: #fff;
  color: var(--feed-deep);
  font-size: 14px;
}

.tool-ml.has-value {
  background: #fff7f8;
  border-color: #f5d8dd;
  font-weight: 650;
}

.session-tools.single-tool {
  grid-template-columns: 1fr;
}

.session-tools.single-tool .tool-note {
  width: 100%;
}

/* Visibility state must never redefine the component's visible layout. */
.bottom-nav[hidden],
.secondary[hidden],
.ml-control[hidden] {
  display: none;
}

.stop-btn {
  width: 100%;
  height: 62px;
  margin-top: 15px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(135deg,#e95a72,#da405e);
  color: #fff;
  font-size: 17px;
  font-weight: 650;
  box-shadow: 0 10px 25px rgba(225,74,100,.20);
  flex-shrink: 0;
}

.stop-btn.sleep-stop {
  background: linear-gradient(135deg,#806bd4,#6750bc);
  box-shadow: 0 10px 25px rgba(102,80,188,.20);
}

/* ---------- Active-session leaflet ---------- */
.tracking-leaflet {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 120;
  width: min(412px,calc(100vw - 28px));
  min-height: 64px;
  transform: translateX(-50%);
  display: none;
  grid-template-columns: 42px minmax(0,1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(120,110,120,.10);
  border-radius: 20px;
  background: rgba(255,250,248,.96);
  color: var(--ink);
  box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  text-align: left;
  pointer-events: auto;
}

.tracking-leaflet.visible {
  display: grid;
}

.tracking-leaflet-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--feed-soft);
  color: var(--feed);
}

.tracking-leaflet-icon .state-dot {
  width: 13px;
  height: 13px;
}

.tracking-leaflet-icon .icon {
  width: 24px;
  height: 24px;
}

.tracking-leaflet.sleep .tracking-leaflet-icon {
  background: var(--sleep-soft);
  color: var(--sleep-deep);
}

.tracking-leaflet.day-sleep .tracking-leaflet-icon {
  background: #e2f3fa;
  color: #e3a51e;
}

.tracking-leaflet-copy {
  min-width: 0;
}

.tracking-leaflet-copy small,.tracking-leaflet-copy strong {
  display: block;
}

.tracking-leaflet-copy small {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
}

.tracking-leaflet-copy strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}

.tracking-leaflet-open {
  width: var(--icon-inline);
  height: var(--icon-inline);
  color: #aaa4aa;
}

/* ---------- Timeline ---------- */
.timeline {
  position: relative;
  padding-bottom: 20px;
}

.timeline-group {
  margin-bottom: 26px;
}

.timeline-day {
  margin-bottom: 15px;
  color: #545b6f;
  font-size: 15px;
  font-weight: 600;
}

.timeline-items {
  position: relative;
}

.timeline-items::before {
  content: "";
  position: absolute;
  left: 20.5px;
  top: 18px;
  bottom: 18px;
  width: 1px;
  background: #e7e2df;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) max-content;
  gap: 30px;
  align-items: start;
  width: 100%;
  min-height: 75px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.timeline-time {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
  min-width: 0;
  padding-top: 9px;
  color: #818795;
  font-size: 11.5px;
  line-height: 1.3;
  text-align: right;
  white-space: nowrap;
  box-sizing: border-box;
}

.timeline-time-separator {
  color: color-mix(in srgb,#818795 72%,transparent);
}

.timeline-dot {
  position: relative;
  z-index: 1;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.timeline-dot>span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.timeline-dot.feed>span {
  background: var(--feed);
  box-shadow: 0 0 0 1px rgba(199,53,81,.04);
}


.timeline-dot.wake>span {
  background: var(--wake);
  box-shadow: 0 0 0 1px rgba(63,129,93,.04);
}

.timeline-dot.feed {
  background: var(--feed-soft);
  color: var(--feed);
}

.timeline-dot.sleep {
  background: var(--sleep-soft);
  color: var(--sleep-deep);
}

.timeline-dot.sleep.night-sleep .icon {
  width: 27px;
  height: 27px;
}

.timeline-dot.sleep.day-sleep {
  background: #e2f3fa;
  color: #3080cf;
}

.timeline-day-sleep-icon {
  width: 25px;
  height: 25px;
}

.timeline-dot.wake {
  background: var(--wake-soft);
  color: var(--wake-deep);
}

.timeline-main .timeline-meta {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.timeline-main {
  min-width: 0;
  padding-top: 6px;
}

.timeline-main strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.timeline-current-wake {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr);
  gap: 30px;
  align-items: start;
  margin-bottom: var(--s6);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.timeline-current-wake-marker {
  background: var(--wake-soft) !important;
  color: var(--wake-deep) !important;
}

.timeline-current-wake-marker>span {
  background: var(--wake) !important;
  box-shadow: 0 0 0 1px rgba(63,129,93,.04) !important;
}

.timeline-current-wake-copy.timeline-main {
  padding-top: 5px;
}

.timeline-current-wake-copy .timeline-meta {
  color: var(--wake-deep);
  font-weight: 560;
}

@media (max-width: 360px) {

  .action-cta-row {
    gap: 5px;
  }

  .home-action-card {
    height:160px;
  }


  .timeline-item {
    grid-template-columns: 42px minmax(0,1fr) auto;
    gap: 30px;
  }

  .timeline-time {
    gap: 2px;
    font-size: 10.5px;
  }
}

@media (max-width: 390px) {
  .home-action-card {
    --card-pad-x: 12px;
  }

  .action-cta-row {
    gap: 5px;
  }

  .action-copy strong {
    font-size: 20px;
  }
}

@media (max-width: 345px) {
  .home-action-card {
    --card-pad-x: 10px;
  }

  .action-cta-row {
    gap: 4px;
  }

  .action-copy strong {
    font-size: 19px;
  }
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 50px 20px;
}

.timeline-archive {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.timeline-archive-title {
  margin: 16px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
}

.archive-panel {
  margin: 0 0 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(250,248,247,.78);
}

.archive-panel summary {
  list-style: none;
  min-height: 66px;
  padding: 0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.archive-panel summary::-webkit-details-marker {
  display: none;
}

.archive-panel summary span:first-child {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.archive-panel summary strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 620;
}

.archive-panel summary small {
  color: var(--muted);
  font-size: 11px;
}

.archive-content {
  padding: 15px 12px 0;
  border-top: 1px solid var(--line);
}

.archive-content .timeline-group {
  margin-bottom: 19px;
}

.archive-content .timeline-group:last-child {
  margin-bottom: 5px;
}

.archive-content .timeline-day {
  margin: 0 0 12px 4px;
  font-size: 13px;
}

/* ---------- Timeline hierarchy / archive ---------- */
.timeline-today-empty {
  margin-bottom: 24px;
}

.timeline-today-empty-copy {
  padding: 16px 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.timeline-recent-history {
  margin-top: 4px;
}

.day-panel summary {
  min-height: 62px;
}

.day-panel-content {
  padding: 14px 12px 2px;
}

.day-panel-content .timeline-items {
  margin-bottom: 0;
}

.archive-chevron {
  width: var(--icon-inline);
  height: var(--icon-inline);
  color: #a5a1a8;
  transition: transform .18s ease;
  flex: 0 0 auto;
}

.archive-panel[open] .archive-chevron {
  transform: rotate(180deg);
}

/* ---------- Stats ---------- */
.period-tabs {
  margin-bottom: 20px;
}

.date-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  margin-bottom: 16px;
  text-align: center;
}

.date-row button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: #7d8190;
  display: grid;
  place-items: center;
}

.date-row button .icon {
  width: 24px;
  height: 24px;
}

.date-row strong {
  font-size: 15px;
}

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

.stat-wake {
  grid-column: 1/-1;
  height: 86px;
}

.stat {
  height: 99px;
  border-radius: 19px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stat .mini {
  height: var(--stat-icon-slot);
  display: grid;
  place-items: center;
}

.stat-pictogram {
  width: var(--stat-pictogram);
  height: var(--stat-pictogram);
}

.stat .stat-marker {
  width: var(--stat-icon-slot);
  height: var(--stat-icon-slot);
  flex: 0 0 var(--stat-icon-slot);
}

.stat .stat-marker.feed>span,.stat .stat-marker.wake>span {
  width: 10px;
  height: 10px;
}

.stat-day-sleep-icon {
  width: var(--stat-pictogram);
  height: var(--stat-pictogram);
}

.sleep-mini {
  color: var(--sleep);
}

.neutral-mini {
  color: #586073;
}

.stat strong {
  margin-top: 3px;
  font-size: 20px;
}

.stat small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.day-chart-wrap {
  margin: 18px 0 20px;
}

.day-chart {
  height: 47px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 2px;
}

.hour-slot {
  position: relative;
  flex: 1;
  height: 32px;
  overflow: hidden;
  border-radius: 3px;
  background: #f2edeb;
}

.hour-slot.has-feed {
  background: #f7b8c2;
}

.hour-slot.has-day-sleep {
  background: #f2c862;
}

.hour-slot.has-night-sleep {
  background: #bfb5ef;
}

.hour-slot.has-wake {
  background: #79c79a;
}

.day-chart.week-view {
  gap: 5px;
}

.day-chart.week-view .hour-slot {
  height: 40px;
  border-radius: 6px;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: #9a9aa2;
  font-size: 9px;
}


/* ---------- Month analytics ---------- */
.month-insights {
  margin-top: 20px;
  padding-bottom: 12px;
}

.month-trend-card {
  padding-top: 2px;
}

.month-trend-heading {
  margin-bottom: 14px;
}

.month-trend-tabs {
  margin-bottom: 18px;
}

.month-trend-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 12px;
}

.month-trend-summary strong {
  color: var(--ink);
  font-size: 30px;
  font-weight: 740;
  line-height: 1.05;
  letter-spacing: -.035em;
}

.month-trend-summary span {
  margin-top: 4px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.month-trend-summary small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.month-trend-chart {
  position: relative;
  width: 100%;
  min-height: 166px;
  margin-top: 4px;
}

.month-trend-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.month-trend-svg.total {
  color: var(--chart-total-sleep);
}

.month-trend-svg.night {
  color: var(--sleep-deep);
}

.month-trend-svg.day {
  color: #3080cf;
}

.month-trend-area {
  fill: url(#monthTrendGradient);
  pointer-events: none;
}

.month-trend-gridline {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.month-trend-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.month-trend-last {
  fill: currentColor;
  stroke: var(--surface);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.month-trend-point {
  fill: currentColor;
  stroke: var(--surface);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.month-trend-axis {
  position: relative;
  height: 18px;
  margin-top: -20px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.month-trend-axis span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-variant-numeric: tabular-nums;
}

.month-trend-empty {
  min-height: 145px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 5px;
  padding: 0;
  text-align: center;
}

.month-trend-empty strong,
.month-trend-empty span {
  display: block;
}

.month-trend-empty strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

.month-trend-empty span {
  max-width: 250px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.month-patterns {
  margin-top: 26px;
}

.month-pattern-list {
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.month-pattern-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.month-pattern-row div {
  min-width: 0;
}

.month-pattern-row strong,
.month-pattern-row small {
  display: block;
}

.month-pattern-row strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
}

.month-pattern-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.month-pattern-row > span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- More ---------- */
.more-list {
  border-top: 1px solid var(--line);
}

.more-screen-list {
  margin-top: 10px;
}

.more-list button {
  width: 100%;
  min-height: 74px;
  display: grid;
  grid-template-columns: 36px minmax(0,1fr) var(--icon-inline);
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.more-list button>.more-menu-icon {
  font-size: 0;
}

.more-list strong,.more-list small {
  display: block;
}

.more-list strong {
  font-size: 16px;
  font-weight: 550;
}

.more-list small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.more-chevron {
  width: var(--icon-inline);
  height: var(--icon-inline);
  color: #bbb9bd;
  justify-self: end;
}

.more-menu-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
}

.more-menu-icon .icon {
  width: var(--icon-control);
  height: var(--icon-control);
}

/* ---------- Dialog system ---------- */
dialog {
  position: fixed;
  inset: auto 0 0 0;
  width: min(var(--app-width),100%);
  max-width: var(--app-width);
  max-height: calc(100dvh - 24px);
  margin: 0 auto;
  padding: 0 10px max(10px,env(safe-area-inset-bottom));
  border: 0;
  background: transparent;
  overflow: visible;
  transform: none;
}

dialog[open] {
  animation: sheet-rise .30s cubic-bezier(.2,.82,.24,1) both;
}

dialog::backdrop {
  background: var(--scrim);
  -webkit-backdrop-filter: blur(8px) saturate(1.08);
  backdrop-filter: blur(8px) saturate(1.08);
  animation: backdrop-fade-in .20s ease-out both;
}

.dialog-card {
  position: relative;
  width: 100%;
  min-width: 0;
  max-height: min(82dvh,720px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 28px 20px 18px;
  border-radius: var(--r-sheet) var(--r-sheet) 24px 24px;
  background: var(--dialog-bg);
  color: var(--ink);
  box-shadow: var(--shadow-sheet);
}

.dialog-card::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  width: 38px;
  height: 5px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #d9d3d0;
}

.dialog-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.dialog-title h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 720;
  letter-spacing: -.02em;
}

.dialog-title button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f5f1ef;
  color: var(--muted);
}

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

.dialog-title button:active {
  transform: scale(.94);
}

.dialog-copy {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.dialog-actions.single-action {
  justify-content: flex-end;
}

.primary,.btn-primary,.btn-secondary,.btn-danger,.settings-ok,.detail-close {
  min-height: var(--button-h);
  border: 0;
  border-radius: 17px;
  padding: 0 18px;
  font-size: 16px;
  font-weight: 650;
}

.primary {
  width: 100%;
  margin-top: 13px;
  background: var(--ink);
  color: #fff;
}

.btn-primary {
  flex: 1;
  background: var(--ink);
  color: #fff;
}

.btn-secondary {
  flex: 1;
  background: var(--surface-muted);
  color: var(--ink);
}

.btn-danger {
  flex: 1;
  background: #fff;
  color: #d13d57;
  border: 1px solid #f3dfe3;
}

.primary,.btn-primary,.btn-secondary,.btn-danger,.detail-close,.dialog-title button {
  transition: transform .12s ease,opacity .12s ease,background .12s ease;
}

.primary:active,.btn-primary:active,.btn-secondary:active,.btn-danger:active,.detail-close:active {
  transform: scale(.985);
  opacity: .88;
}

/* Feed type dialog */
.feed-type-sheet {
  padding-left: 18px;
  padding-right: 18px;
}

.feed-type-help {
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.feed-type-options {
  display: grid;
  gap: 9px;
}

.feed-type-options button {
  min-height: 68px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--field-muted);
  color: var(--ink);
  text-align: left;
}

.feed-type-options strong,.feed-type-options small {
  display: block;
}

.feed-type-options strong {
  font-size: 16px;
}

.feed-type-options small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}


.solids-sheet {
  padding-left:18px;
  padding-right:18px;
}
.solid-other-wrap {
  margin-top:14px;
}
.solid-other-wrap .control-label {
  margin-bottom:7px;
}
.solid-other-wrap .form-control {
  min-height:52px;
}
.solid-other-save {
  width:100%;
  min-height:var(--button-h);
  margin-top:10px;
}
.manual-solid-other {
  display:block;
  margin-top:12px;
}
.manual-solid-other .form-control {
  margin-top:7px;
}

/* Manual event dialog */
#manualDialog {
  height: min(90dvh,760px);
  max-height: 90dvh;
  overflow: hidden;
}

#manualDialog .manual-sheet {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  padding: 0;
  overflow: hidden;
}

#manualDialog .manual-sheet::before {
  position: absolute;
  z-index: 5;
}

.manual-dialog-title {
  flex: 0 0 auto;
  margin: 0;
  padding: 28px 18px 13px;
  background: var(--dialog-bg);
}

.manual-scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 18px 8px;
}

.manual-scroll-body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.manual-sheet-footer {
  flex: 0 0 auto;
  padding: 10px 18px max(18px,calc(12px + env(safe-area-inset-bottom)));
  border-top: 1px solid var(--line);
  background: var(--dialog-bg);
}

#manualForm,#manualForm * {
  max-width: 100%;
}

.manual-fieldset {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.manual-fieldset legend,.manual-label {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.manual-fieldset legend {
  margin-bottom: 7px;
}

.segmented-control {
  display: grid;
  gap: 4px;
  padding: 3px;
  border-radius: 14px;
  background: var(--control-bg);
}

.segmented-control.two-up {
  grid-template-columns: repeat(2,1fr);
}

.segmented-control.three-up {
  grid-template-columns: repeat(3,1fr);
}

.segmented-control button {
  min-height: 48px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: #747581;
  font-size: 15px;
  font-weight: 600;
}

.segmented-control button.selected {
  background: var(--control-selected);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(53,40,44,.08);
}

.manual-start-grid {
  width: 100%;
  min-width: 0;
  display: flex;
  gap: 10px;
}

.manual-start-cell {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field-bg);
}

.manual-start-cell:focus-within {
  border-color: color-mix(in srgb,var(--sleep) 48%,var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb,var(--sleep) 10%,transparent);
}

.manual-start-cell input.form-control {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 11px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 16px;
}

.manual-start-cell input.form-control:focus {
  border: 0;
  box-shadow: none;
}

/* Older iOS Safari gives native date/time controls an intrinsic width. The
   wrapper owns the visible border while clipping native overflow internally. */
@supports (-webkit-touch-callout: none) {
  .manual-start-cell input[type="date"],
  .manual-start-cell input[type="time"] {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    inline-size: 100%;
    min-inline-size: 0;
  }

  .manual-start-cell input[type="date"]::-webkit-date-and-time-value,
  .manual-start-cell input[type="time"]::-webkit-date-and-time-value {
    text-align: center;
  }
}

.manual-duration-fieldset {
  margin-bottom: 16px;
}

.manual-duration-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.manual-duration-control {
  display: block;
  min-width: 0;
  color: var(--muted);
}

.manual-duration-control > span {
  display: block;
  margin: 0 0 7px 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.manual-duration-control .form-control {
  width: 100%;
  min-width: 0;
  font-size: 16px;
}

.manual-label {
  margin: 0 0 16px;
}

.manual-label input {
  margin-top: 6px;
}

#manualFoodField[hidden],#manualSleepField[hidden],#manualMlField[hidden] {
  display: none;
}

.manual-note-disclosure {
  margin: 0 0 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--field-bg);
}

.manual-note-toggle {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
}

.manual-note-chevron {
  width: var(--icon-inline);
  height: var(--icon-inline);
  flex: 0 0 auto;
  margin-right: 0;
  color: var(--muted);
  transition: transform .18s ease;
}

.manual-note-toggle[aria-expanded="true"] .manual-note-chevron {
  transform: rotate(180deg);
}

.manual-note-panel {
  padding: 0 12px 12px;
}

.manual-note-panel textarea {
  height: 84px;
  min-height: 84px;
  max-height: 84px;
  margin: 0;
}

#manualForm .primary {
  width: 100%;
  min-height: 52px;
  margin: 0;
}

/* Notes */
.notes-sheet {
  max-height: min(78dvh,720px);
  padding: 28px 18px 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notes-title {
  align-items: flex-start;
  margin: 0 0 12px;
}

.notes-title>div:first-child {
  min-width: 0;
}

.notes-title h3 {
  margin: 0;
}

.notes-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.notes-list {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 calc(10px + env(safe-area-inset-bottom));
}

.note-card {
  width: 100%;
  margin-bottom: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--field-muted);
  color: var(--ink);
  text-align: left;
}

.note-card:active {
  transform: scale(.992);
}

.note-card-head {
  display: grid;
  grid-template-columns: 40px minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
}

.note-card-head.no-event-icon {
  grid-template-columns: minmax(0,1fr) auto;
}


.note-meta {
  min-width: 0;
}

.note-meta strong,.note-meta span {
  display: block;
}

.note-meta strong {
  font-size: 14px;
  font-weight: 650;
}

.note-meta span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.note-chevron {
  width: var(--icon-inline);
  height: var(--icon-inline);
  color: #bbb7bd;
}

.note-text {
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.notes-empty {
  text-align: center;
  padding: 34px 16px 24px;
  color: var(--muted);
}

.notes-empty-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-muted);
  color: #7d8190;
}

.notes-empty-icon .icon {
  width: 30px;
  height: 30px;
}

.notes-empty strong {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 16px;
}

.notes-empty span {
  display: block;
  max-width: 270px;
  margin: 0 auto;
  font-size: 13px;
  line-height: 1.5;
}

/* Event details */
.event-detail {
  text-align: center;
  padding-top: 30px;
}

.detail-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.detail-icon .icon {
  width: 31px;
  height: 31px;
}

.detail-icon .state-dot {
  width: 15px;
  height: 15px;
}

.detail-icon.feed {
  background: var(--feed-soft);
  color: var(--feed);
}

.detail-icon.sleep {
  background: var(--sleep-soft);
  color: var(--sleep-deep);
}

.event-detail h3 {
  margin: 0;
  font-size: 22px;
}

.detail-date {
  margin-top: 7px;
  color: var(--muted);
}

.detail-box {
  margin: 20px 0 12px;
  padding: 5px 15px;
  border-radius: 18px;
  background: var(--surface-soft);
  text-align: left;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.detail-row:last-child {
  border: 0;
}

.detail-row span:first-child {
  color: var(--muted);
}

.detail-close {
  width: 100%;
  background: var(--surface-muted);
  color: var(--ink);
  font-weight: 600;
}

.detail-delete {
  width: 100%;
  min-height: 44px;
  margin: 2px 0 8px;
  padding: 9px;
  border: 1px solid color-mix(in srgb,#c94f62 42%,var(--line));
  border-radius: 14px;
  background: transparent;
  color: #c94f62;
  font-weight: 600;
}

/* Settings */
.settings-sheet {
  padding: 28px 20px 18px;
  text-align: left;
}

.settings-section {
  margin: 0 0 28px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.settings-section + .settings-section {
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.settings-section-title {
  margin: 0;
  padding: 0 0 12px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.015em;
  text-transform: none;
}

.theme-picker {
  margin: 0;
}

.settings-help {
  margin: 0;
  padding: 10px 2px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.settings-row-static {
  min-height: 20px;
  margin-bottom: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-row-static strong,.settings-row-static small {
  display: block;
}

.settings-row-static strong {
  font-size: 15px;
}

.settings-row-static small {
  margin-top: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.settings-about-row {
  min-height: 40px;
}

.privacy-badge {
  padding: 5px 8px;
  border-radius: 999px;
  background: #e9f4ed;
  color: var(--success);
  font-size: 10px;
  font-weight: 700;
}

.settings-action {
  width: 100%;
  min-height: 56px;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  text-align: left;
}

.settings-chevron {
  width: var(--icon-inline);
  height: var(--icon-inline);
  color: #b9b5bb;
  flex: 0 0 auto;
}

.settings-danger-inline {
  color: #c64d61;
}

.settings-ok {
  width: 100%;
  min-height: var(--button-h);
  margin-top: 4px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
}

/* ---------- Custom ml overlay ---------- */
.ml-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.ml-overlay[hidden] {
  display: none;
}

.ml-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(8px) saturate(1.08);
  backdrop-filter: blur(8px) saturate(1.08);
}

.ml-overlay .ml-sheet {
  position: relative;
  z-index: 1;
  width: min(350px,calc(100vw - 32px));
  max-width: 350px;
  max-height: none;
  margin: 0 auto;
  padding: 20px 18px 17px;
  border-radius: 24px;
  overflow: visible;
  background: var(--dialog-bg);
  box-shadow: var(--shadow-sheet);
  transform: translateY(5%);
  transform:translateY(7%);
  transform:translateY(7%);
}

.ml-overlay .ml-sheet::before {
  display: none;
}

.ml-overlay .dialog-title {
  margin-bottom: 8px;
}

.ml-dialog-help {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.ml-dialog-input {
  min-height: 54px;
  padding: 0 16px;
  border-radius: 17px;
  font-size: 20px;
  text-align: center;
}

.ml-overlay .dialog-actions {
  margin-top: 10px;
}

.ml-overlay .btn-primary,.ml-overlay .btn-secondary {
  min-height: var(--button-h);
}

/* ---------- Dark theme component adjustments ---------- */
:root[data-theme="dark"] .bottom-nav {
  background: rgba(28,26,32,.92);
  border-top-color: #38343c;
}

:root[data-theme="dark"] .home-action-card.feed {
  background: #40272f;
  color: #ff96aa;
  box-shadow: 0 8px 22px rgba(0,0,0,.16);
}

:root[data-theme="dark"] .home-feed-indicator {
  background: #5a2f3a;
  color: #ff8ca2;
}

:root[data-theme="dark"] .home-action-card.sleep {
  background: #322e47;
  color: #d0c7ff;
  box-shadow: 0 8px 22px rgba(0,0,0,.16);
}

:root[data-theme="dark"] .home-action-card.sleep[data-sleep-kind="day"] {
  background: #25363e;
  color: #f0bd4e;
}

:root[data-theme="dark"] .home-action-card.sleep[data-sleep-kind="night"] {
  background: #322e47;
  color: #d0c7ff;
}

:root[data-theme="dark"] .sleep-kind-notice {
  background: #29262e;
  border-color: #403b44;
}

:root[data-theme="dark"] .sleep-kind-toggle {
  background: #37324d;
  color: #cfc5ff;
}

:root[data-theme="dark"] .last-event {
  background: linear-gradient(135deg,#302c34 0%,#29262e 62%,#252229 100%);
  box-shadow: 0 10px 26px rgba(0,0,0,.24),inset 0 1px 0 rgba(255,255,255,.035);
}

:root[data-theme="dark"] .last-event.last-feed {
  background: linear-gradient(135deg,#332b31 0%,#2c272d 62%,#29242a 100%);
}

:root[data-theme="dark"] .last-event.last-sleep {
  background: linear-gradient(135deg,#302e39 0%,#2b2833 62%,#27242e 100%);
}

:root[data-theme="dark"] .last-event .last-copy small {
  color: #9da6b9;
}

:root[data-theme="dark"] .last-event .last-copy strong {
  color: #f4f1f7;
}

:root[data-theme="dark"] .last-event .chevron {
  color: #97a5bf;
}

:root[data-theme="dark"] .feed-last-icon {
  background: #472831;
  color: #ff8da3;
}

:root[data-theme="dark"] .sleep-last-icon {
  background: #37324d;
  color: #bdb2ff;
}

:root[data-theme="dark"] .active-orb.feed-mode {
  background: radial-gradient(circle at 35% 25%,#34252a 0%,#40242c 100%);
}

:root[data-theme="dark"] .active-orb.sleep-mode {
  background: radial-gradient(circle at 35% 25%,#2c293b 0%,#35304d 100%);
}

:root[data-theme="dark"] .active-orb.day-sleep-mode {
  background: radial-gradient(circle at 35% 25%,#283237 0%,#25363e 100%);
}

:root[data-theme="dark"] .timeline-dot.sleep.day-sleep {
  background: #263b4d;
  color: #3080cf;
}

:root[data-theme="dark"] .timeline-dot.sleep.day-sleep>span {
  background: #3080cf;
}

:root[data-theme="dark"] .secondary,:root[data-theme="dark"] .tool-ml {
  background: #242128;
  border-color: #3e3942;
}

:root[data-theme="dark"] .tool-note {
  background: #29262e;
  border-color: #403b44;
  color: var(--ink);
}

:root[data-theme="dark"] .tool-side {
  background: #292633;
}

:root[data-theme="dark"] .tool-ml.has-value {
  background: #382329;
  border-color: #56313c;
}

:root[data-theme="dark"] .tracking-leaflet {
  background: rgba(32,30,37,.96);
  border-color: #3a3540;
}

:root[data-theme="dark"] .timeline-items::before {
  background: #403b43;
}

:root[data-theme="dark"] .archive-panel {
  background: #242128;
  border-color: #39353e;
}

:root[data-theme="dark"] .hour-slot {
  background: #302d34;
}

:root[data-theme="dark"] .dialog-card,:root[data-theme="dark"] .ml-overlay .ml-sheet {
  background: var(--dialog-bg);
  color: var(--ink);
}

:root[data-theme="dark"] .dialog-card::before {
  background: #5a535e;
}

:root[data-theme="dark"] .dialog-title button {
  background: #35313a;
  color: #c7c0ca;
}

:root[data-theme="dark"] input,:root[data-theme="dark"] select,:root[data-theme="dark"] textarea {
  background: var(--field-bg);
  color: var(--ink);
  border-color: var(--line-strong);
}

:root[data-theme="dark"] .primary,:root[data-theme="dark"] .btn-primary {
  background: #f5f0f2;
  color: #17161b;
}

:root[data-theme="dark"] .btn-secondary,:root[data-theme="dark"] .detail-close {
  background: #353139;
  color: var(--ink);
}

:root[data-theme="dark"] .btn-danger {
  background: #242128;
  border-color: #4d3038;
  color: #ff8298;
}

:root[data-theme="dark"] .feed-type-options button,:root[data-theme="dark"] .manual-note-disclosure {
  background: var(--field-muted);
  border-color: var(--line-strong);
}

:root[data-theme="dark"] .segmented-control button.selected,:root[data-theme="dark"] .theme-picker button.selected {
  color: var(--ink);
  box-shadow: none;
}

:root[data-theme="dark"] .note-card {
  background: #29262e;
  border-color: #403b44;
}

:root[data-theme="dark"] .privacy-badge {
  background: #24372d;
  color: #9bd1ae;
}

:root[data-theme="dark"] .settings-danger-inline {
  color: #ff8da0;
}

:root[data-theme="dark"] .settings-ok {
  background: #f5f0f2;
  color: #17161b;
}

:root[data-theme="dark"] #homeView .home-header p {
  color: var(--muted);
}

:root[data-theme="dark"] .baby-hero img {
  filter: drop-shadow(0 12px 26px rgba(0,0,0,.22)) saturate(.98) brightness(.98);
}

/* ---------- Responsive ---------- */
/* Active-session compact-height mode.
   Keeps the primary Stop CTA at its intended height instead of allowing flexbox
   to compress it on ~667–760px tall mobile viewports. */
@media (max-height:760px) and (max-width:430px) {
  .active-content {
    padding-top: max(92px,calc(env(safe-area-inset-top) + 68px));
  }

  .active-orb {
    --orb-size: min(250px,calc(100vw - 70px));
  }

  .timer {
    font-size: 38px;
  }

  .sleep-kind-notice {
    margin-top: 14px;
    margin-bottom: 14px;
  }

  .session-tools {
    margin-top: 22px;
  }

  .sleep-kind-notice + .session-tools.single-tool {
    margin-top: 8px;
  }

  .secondary,
  .tool-ml {
    height: 52px;
  }

  .stop-btn {
    height: var(--button-h-session);
    margin-top: 14px;
  }

  .close-active {
    top: max(28px,calc(env(safe-area-inset-top) + 8px));
  }
}

@media (max-height:620px) and (max-width:390px) {
  /* Compact-height mode: only changes that materially recover vertical space. */
  #homeView .home-header {
    padding-top: max(32px,calc(env(safe-area-inset-top) + 10px));
  }

  #homeView .home-header h1 {
    font-size: 27px;
  }

  #homeView .home-header p {
    margin-top: 4px;
    font-size: 15px;
  }

  .baby-hero {
    width: min(154px,48vw);
    margin-top: 2px;
    margin-bottom: -4px;
  }

  .prompt {
    margin: 2px 0 9px;
    font-size: 15px;
  }

  .home-action-card {
    --art-top: 4px;
    height: 132px;
  }

  .action-copy {
    bottom: 10px;
  }

  .last-event {
    min-height: 55px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .active-content {
    padding-top: max(82px,calc(env(safe-area-inset-top) + 62px));
  }

  .active-orb {
    --orb-size: 220px;
  }

  .timer {
    font-size: 36px;
  }

  /*

  .sleep-kind-notice {
    margin-top: 10px;
    padding-top: 9px;
    padding-bottom: 9px;
  }
    */

  .sleep-kind-toggle {
    min-height: var(--tap-min);
  }

  .session-tools {
    margin-top: 20px;
  }

  .sleep-kind-notice + .session-tools.single-tool {
    margin-top: 10px;
  }

  .secondary,
  .tool-ml {
    height: 50px;
  }

  .stop-btn {
    height: 56px;
    margin-top: 18px;
  }

  .close-active {
    top: max(26px,calc(env(safe-area-inset-top) + 8px));
  }

  #manualDialog {
    height: 90dvh;
  }

  #manualDialog .manual-sheet {
    height: 100%;
    max-height: none;
  }
}

@media (min-width:700px) {
  body {
    padding: 28px 0;
  }
  .app-shell {
    min-height: 850px;
    height: min(880px,calc(100vh - 56px));
    border-radius: 42px;
  }
  .app-shell>main {
    height: 100%;
    overflow: hidden;
  }
  .view {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }
  .view::-webkit-scrollbar {
    display: none;
  }
  .bottom-nav {
    bottom: 28px;
    border-radius: 0 0 42px 42px;
  }
  .tracking-leaflet {
    bottom: calc(116px + env(safe-area-inset-bottom));
    width: min(400px,calc(100vw - 40px));
  }
  .active-session-view {
    top: 28px;
    bottom: auto;
    height: min(880px,calc(100vh - 56px));
    min-height: 0;
    border-radius: 42px;
  }
  dialog {
    width: min(var(--app-width),calc(100vw - 32px));
    bottom: 18px;
  }
  #manualDialog {
    height: min(760px,calc(100dvh - 54px));
    max-height: min(760px,calc(100dvh - 54px));
  }
  #manualDialog .manual-sheet {
    height: 100%;
    max-height: 100%;
  }

}

@media (hover:hover) {
  .archive-panel summary:hover {
    background: rgba(0,0,0,.018);
  }
  :root[data-theme="dark"] .archive-panel summary:hover {
    background: rgba(255,255,255,.025);
  }

}

@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }

}

@keyframes sheet-rise {
  from {
    opacity: 0;
    transform: translateY(34px) scale(.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

}

@keyframes backdrop-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }

}


/* ---------- More drawers: canonical v2.9.3 system ---------- */
#settingsDialog,
#instantAlertsDialog,
#notesDialog {
  box-sizing: border-box;
  inset: auto 0 0 0;
  width: min(var(--app-width),100%);
  max-width: var(--app-width);
  height: 96dvh;
  max-height: 96dvh;
  margin: 0 auto;
  padding: 0 10px max(10px,env(safe-area-inset-bottom));
  border: 0;
  background: transparent;
  overflow: visible;
}

#settingsDialog[open],
#instantAlertsDialog[open],
#notesDialog[open] {
  animation: sheet-rise .30s cubic-bezier(.2,.82,.24,1) both;
}

#settingsDialog::backdrop,
#instantAlertsDialog::backdrop,
#notesDialog::backdrop {
  background: var(--scrim);
  -webkit-backdrop-filter: blur(8px) saturate(1.08);
  backdrop-filter: blur(8px) saturate(1.08);
  animation: backdrop-fade-in .20s ease-out both;
}

#settingsDialog .settings-sheet,
#instantAlertsDialog .instant-alerts-sheet,
#notesDialog .notes-sheet {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-height: 100%;
  padding: 28px 20px max(18px,calc(12px + env(safe-area-inset-bottom)));
  border-radius: var(--r-sheet) var(--r-sheet) 24px 24px;
  background: var(--dialog-bg);
  color: var(--ink);
  box-shadow: var(--shadow-sheet);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#settingsDialog .settings-sheet::-webkit-scrollbar,
#instantAlertsDialog .instant-alerts-sheet::-webkit-scrollbar,
#notesDialog .notes-sheet::-webkit-scrollbar { display: none; }

#settingsDialog .dialog-title,
#instantAlertsDialog .instant-alerts-title,
#notesDialog .notes-title {
  margin-bottom: 24px;
}

#instantAlertsDialog .instant-alerts-title {
  position: static;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 0;
  background: transparent;
}

#instantAlertsDialog .instant-alerts-title > div,
#notesDialog .notes-title > div:first-child { min-width: 0; }

#instantAlertsDialog .instant-alerts-title h3,
#notesDialog .notes-title h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
}

#instantAlertsDialog .instant-alerts-title p,
#notesDialog .notes-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

#instantAlertsDialog .instant-alerts-title button {
  flex: 0 0 var(--tap-min);
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
}

.telegram-people,
.activity-notification-list {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.telegram-person {
  min-height: 76px;
  padding: 12px 0;
  display: grid;
  grid-template-columns: 44px minmax(0,1fr) 100px;
  align-items: center;
  gap: 12px;
}
.telegram-person + .telegram-person { border-top: 1px solid var(--line); }
.telegram-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--feed-soft);
  color: var(--feed);
  font-size: 15px;
  font-weight: 800;
}
.telegram-avatar.partner { background: var(--sleep-soft); color: var(--sleep-deep); }
.telegram-person-copy { min-width: 0; }
.telegram-person-copy strong,
.telegram-person-copy small { display: block; }
.telegram-person-copy strong { font-size: 16px; }
.telegram-person-copy small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.telegram-connect {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
  min-height: 44px;
  padding: 0 10px;
  justify-self: end;
  border: 1px;
  border-radius: 13px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.telegram-connect:disabled { opacity: .4; }

.activity-notification-row {
  min-height: 84px;
  padding: 13px 0;
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(144px,.8fr);
  align-items: center;
  gap: 12px;
}
.activity-notification-row + .activity-notification-row { border-top: none; }
.activity-notification-copy { min-width: 0; }
.activity-notification-copy strong {
  display: block;
  font-size: 13px;
  line-height: 1.3;
}
.activity-target-select {
  box-sizing: border-box;
  width: 100%;
  height: var(--control-h);
  min-height: var(--control-h);
  border-radius: 14px;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 650;
}

.instant-alerts-feedback {
  min-height: 0;
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}
.instant-alerts-feedback[data-type="error"] { color: #c64d61; }
.instant-alerts-feedback[data-type="success"] { color: var(--success); }
.notification-service-notice {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid #ecdca8;
  border-radius: 14px;
  background: #fff8dc;
  color: #665527;
}
.notification-service-notice strong,
.notification-service-notice small { display: block; }
.notification-service-notice strong { font-size: 13px; }
.notification-service-notice small { margin-top: 3px; font-size: 11px; line-height: 1.4; }
:root[data-theme="dark"] .notification-service-notice { background: #393221; border-color: #5f5130; color: #eadcaa; }

#settingsDialog > .dialog-card .detail-close {
  width: 100%;
}

#instantAlertsRefreshBtn[hidden],
.instant-alerts-partner-invite-panel[hidden],
#settingsMainPanel[hidden],
#instantAlertsMainPanel[hidden] { display: none !important; }

/* ---------- Partner invite ---------- */
.instant-alerts-invite-title {
  display: grid;
  grid-template-columns: 44px minmax(0,1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.instant-alerts-invite-title > div { min-width: 0; }
.instant-alerts-invite-title h3 { margin: 0; font-size: 22px; }
.instant-alerts-invite-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.instant-alerts-invite-title button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
}
.instant-alerts-partner-invite-card { padding: 18px 14px; text-align: center; }
.partner-qr-wrap { display: flex; justify-content: center; margin: 4px 0 12px; }
.partner-invite-qr {
  width: min(230px,72vw);
  aspect-ratio: 1;
  padding: 14px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow-float);
}
.partner-invite-qr img,
.partner-invite-qr svg { display: block; width: 100%; height: 100%; object-fit: contain; }
.partner-qr-fallback { color: #333; font-size: 12px; line-height: 1.4; }
.partner-qr-fallback small { color: #666; }
.partner-invite-expiry { color: var(--muted); font-size: 13px; font-weight: 650; }
.partner-invite-help { max-width: 310px; margin: 12px auto 16px; color: var(--ink); font-size: 14px; line-height: 1.55; }
.partner-invite-actions { display: grid; gap: 10px; }
.partner-invite-actions button {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 15px;
  font-size: 15px;
  font-weight: 700;
}
.partner-share-btn { margin: 0; }
.partner-secondary-action { border: 1px solid var(--line); background: var(--field-bg); color: var(--ink); }
.partner-invite-feedback { margin-top: 10px; }

/* ---------- Instant alerts ---------- */
#instantAlertsDialog {
  height: auto;
  max-height: 96dvh;
}
#instantAlertsDialog .instant-alerts-sheet {
  height: auto;
  max-height: calc(96dvh - max(10px,env(safe-area-inset-bottom)));
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#instantAlertsDialog .instant-alerts-sheet::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
#instantAlertsDialog .instant-alerts-title {
  margin-bottom: 24px;
}
.instant-alerts-section {
  margin: 0 0 26px;
  padding: 0;
  border: 0;
  background: transparent;
}
.instant-alerts-section + .instant-alerts-section {
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.instant-alerts-section[hidden],
.instant-alerts-partner-invite-panel[hidden],
#instantAlertsMainPanel[hidden] {
  display: none !important;
}
.instant-alerts-section-head {
  margin-bottom: 10px;
}
.instant-alerts-telegram-people,
.instant-alerts-activity-list {
  margin: 0;
}
.instant-alerts-help {
  margin: 8px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.telegram-person.is-connected {
  grid-template-columns: 44px minmax(0,1fr);
}
.telegram-person .telegram-connect[hidden] {
  display: none !important;
}
#instantAlertsDialog .notification-service-notice {
  margin: 0 0 10px;
}
#instantAlertsDialog .instant-alerts-feedback {
  margin: 8px 0 2px;
}
#instantAlertsDialog .instant-alerts-done {
  width: 100%;
  margin-top: 8px;
}
/* ---------- Notes ---------- */
#notesDialog .notes-sheet { overflow: hidden; display: flex; flex-direction: column; }
#notesDialog .notes-list {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 2px 0 calc(10px + env(safe-area-inset-bottom));
}
#notesDialog .notes-list::-webkit-scrollbar,
#instantAlertsDialog .instant-alerts-sheet::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
#notesDialog .note-card {
  margin: 0;
  padding: 16px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
#notesDialog .note-card + .note-card { border-top: 1px solid var(--line); }
#notesDialog .note-meta strong { font-size: 15px; }
#notesDialog .note-meta span { font-size: 12px; }
#notesDialog .note-text { margin-top: 5px; font-size: 15px; line-height: 1.55; }
.notes-empty { text-align: center; padding: 34px 16px 24px; }
.notes-empty-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-muted);
  color: #7d8190;
}
.notes-empty-icon .icon { width: 30px; height: 30px; }
.notes-empty strong { display: block; margin-bottom: 7px; color: var(--ink); font-size: 16px; }
.notes-empty span { display: block; max-width: 270px; margin: 0 auto; font-size: 13px; line-height: 1.5; }

/* ---------- More index ---------- */
.more-screen-list { margin-top: 16px; border-top: 0; }

@media (max-width:390px) {
  .activity-notification-row { grid-template-columns: 1fr; gap: 9px; }
  .activity-target-select { width: 100%; }
}

@media (min-width:700px) {
  #settingsDialog,
  #notesDialog {
    top: auto;
    bottom: 0;
    height: 96dvh;
    max-height: 96dvh;
  }
}


