/* Bedtime mini demo (#bedtime-demo). Phone-screen sizes use cqw so every demo
   screen scales exactly like the 900×1957 native captures it sits beside. */
.night-scene {
  --nd-orange: #ff6412;
  --nd-red: #e8434a;
  --nd-yellow: #ffe57f;
  --nd-cream: #fefbe8;
  --nd-ink: #2b3a34;
  --nd-brown: #8a6e3f;
  padding: clamp(42px,7vw,96px) 0;
  color: var(--nd-ink);
  background: #dce5b2;
  border-block: 1px solid rgb(43 58 52 / .22);
  scroll-margin-top: 72px;
}
.night-scene [hidden] { display: none !important; }
.night-scene h2 { max-width: 19ch; font-size: clamp(2rem,5vw,4rem); line-height: 1.04; }
.nd-lede { max-width: 40ch; margin: 12px 0 0; font-size: clamp(1.02rem,1.6vw,1.2rem); font-weight: 500; }
.night-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Stage: notes beside the phone on wide screens, under it on phones. */
.nd-stage {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center;
  gap: clamp(24px,5vw,72px); margin-top: 22px; padding: clamp(18px,4vw,48px);
  background: var(--nd-cream); border: 2px solid var(--nd-ink); border-radius: 26px;
  box-shadow: 0 5px 0 rgb(43 58 52 / .17);
}
.nd-side { min-width: 0; }
.nd-note h3 { font-size: clamp(1.5rem,3vw,2.4rem); max-width: 16ch; }
.nd-note p { max-width: 34ch; margin: 10px 0 0; }
.nd-action, .nd-restart {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px;
  margin-top: 18px; border-radius: 99px; cursor: pointer; touch-action: manipulation;
  font: 600 .98rem/1.2 Poppins, sans-serif;
}
.nd-action { padding: 10px 22px; color: var(--nd-cream); background: var(--nd-ink); border: 0; }
.nd-action::after { content: '→'; margin-left: 10px; }
.nd-action:hover { background: #3d5048; }
.nd-restart {
  display: flex; min-height: 44px; margin-top: 22px; padding: 6px 2px;
  color: var(--nd-ink); background: none; border: 0; text-decoration: underline; text-underline-offset: 4px;
}
.nd-action:focus-visible, .nd-restart:focus-visible { outline: 3px solid var(--nd-orange); outline-offset: 3px; }

/* Phone frame and display. */
.night-phone {
  --night-phone-w: min(300px, calc((78vh - 40px) * .46));
  width: var(--night-phone-w); min-width: 190px; justify-self: center;
  padding: 9px; background: var(--nd-ink); border-radius: 44px;
  box-shadow: 0 6px 0 rgb(43 58 52 / .18);
}
.night-phone img { display: block; width: 100%; height: auto; border-radius: 35px; background: var(--nd-cream); }
.nd-phone { --night-phone-w: min(320px, calc((88vh - 60px) * .46)); min-width: 230px; }
.nd-display {
  position: relative; aspect-ratio: 900 / 1957; overflow: hidden; border-radius: 35px;
  container-type: inline-size; background: var(--nd-cream); isolation: isolate;
}
.nd-screen { position: absolute; inset: 0; font-size: 4.2cqw; line-height: 1.3; }
.nd-ready .nd-screen { animation: nd-in .28s ease-out; }
.nd-display .nd-native { width: 100%; height: 100%; border-radius: 0; }
.nd-screen strong { font-weight: 700; }

/* Cropped native artwork (Leechy, the counter patch). */
.nd-display .nd-leechy > img, .nd-count > img {
  position: absolute; max-width: none; height: auto; border-radius: 0; background: none;
}
.nd-leechy { position: relative; overflow: hidden; flex: none; border-radius: 50%; background: var(--nd-yellow); }
.nd-leechy--sm { width: 13cqw; }
.nd-leechy--head { width: 14cqw; margin: 0 0 3cqw 5cqw; }
.nd-leechy--lg { width: 46cqw; }

/* Status bar on the site-made screens (the native captures carry their own). */
.nd-bar {
  position: absolute; inset: 0 0 auto; height: 11cqw; display: flex; align-items: flex-end;
  justify-content: space-between; padding: 0 9cqw 0 13cqw; font-weight: 600; font-size: 4.3cqw; line-height: 1;
}
.nd-bar-icons {
  width: 6.5cqw; height: 3cqw; border: .45cqw solid currentColor; border-radius: 1cqw; opacity: .8;
  background: linear-gradient(90deg, currentColor 70%, transparent 0) content-box; padding: .4cqw;
}
.nd-bar--light { color: #fff; }

/* Home screen: evening, with one tappable app. */
.nd-screen--home {
  padding: 15cqw 6cqw 0; color: #fff;
  background: linear-gradient(172deg, #2b3a34 0%, #3e5148 52%, #6d6b93 100%);
}
.nd-widget {
  display: flex; align-items: center; gap: 3.5cqw; padding: 3.5cqw 4cqw;
  color: var(--nd-ink); background: rgb(254 251 232 / .95); border-radius: 6cqw;
}
.nd-widget strong { display: block; font-size: 4.6cqw; }
.nd-widget span { display: block; font-size: 3.5cqw; color: var(--nd-brown); }
.nd-apps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6cqw 5cqw; margin-top: 8cqw; padding: 0 1cqw; }
.nd-app { display: flex; flex-direction: column; align-items: center; gap: 1.8cqw; }
.nd-app > i, .nd-app-icon { display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 4.6cqw; }
.nd-app-glyph { width: 58%; height: 58%; color: var(--nd-ink); }
.nd-app--orange .nd-app-glyph { color: #fff; }
.nd-app--leaf > i { background: #adbe70; }
.nd-app--lilac > i { background: #cccce8; }
.nd-app--butter > i { background: #ffe78d; }
.nd-app--orange > i { background: #f16f33; }
.nd-app--cream > i { background: #fefbe8; }
.nd-app--target {
  padding: 0; margin: 0; color: #fff; background: none; border: 0; border-radius: 4.6cqw;
  cursor: pointer; touch-action: manipulation; font: inherit;
}
.nd-app-icon { background: #111; box-shadow: 0 0 0 0 rgb(255 228 127 / .8); animation: nd-pulse 1.8s ease-out infinite; }
.nd-note-glyph { width: 52%; height: 52%; color: #fff; filter: drop-shadow(-.5cqw -.3cqw 0 #25f4ee) drop-shadow(.5cqw .3cqw 0 #fe2c55); }
.nd-app-name { font-size: 3.2cqw; font-weight: 600; line-height: 1; }
.nd-app--target:hover .nd-app-icon { transform: scale(1.05); }
.nd-app--target:focus-visible { outline: none; }
.nd-app--target:focus-visible .nd-app-icon { outline: 3px solid #ffe57f; outline-offset: 3px; }
.nd-dock { position: absolute; inset: auto 4cqw 4cqw; height: 19cqw; border-radius: 8cqw; background: rgb(255 255 255 / .16); }

/* Buttons laid over a native capture, exactly on top of the drawn button. */
.nd-hit {
  position: absolute; padding: 0; margin: 0; background: transparent; border: 0;
  border-radius: 99px; cursor: pointer; touch-action: manipulation;
}
.nd-hit::before { content: ''; position: absolute; inset: -6px; } /* comfortable touch target */
.nd-hit:hover { box-shadow: 0 0 0 .9cqw rgb(43 58 52 / .28); }
.nd-hit:focus-visible { outline: 3px solid var(--nd-ink); outline-offset: 3px; }

/* Live counter replacing only the native "8 s". */
.nd-count {
  position: absolute; overflow: hidden; display: flex; align-items: center; justify-content: center;
  gap: 4cqw; color: var(--nd-orange); font-weight: 700; line-height: 1; pointer-events: none;
}
.nd-count span { position: relative; font-variant-numeric: tabular-nums; }
.nd-count-num { font-size: 25.8cqw; letter-spacing: -.02em; }
.nd-count-unit { font-size: 8.5cqw; }

/* Screen Leech block card. */
.nd-screen--manage { padding-top: 15cqw; background: var(--nd-yellow); }
.nd-blocks-title { display: block; margin: 0 5cqw; font-size: 10cqw; line-height: 1.05; letter-spacing: -.02em; }
.nd-blocks-sub { margin: 1cqw 5cqw 0; font-size: 4cqw; color: var(--nd-brown); }
.nd-card {
  display: flex; flex-direction: column; gap: 1cqw; margin: 7cqw 5cqw 0; padding: 5cqw;
  background: var(--nd-cream); border-radius: 5.5cqw; box-shadow: 0 1.5cqw 4cqw rgb(138 110 63 / .16);
}
.nd-card-top { display: flex; justify-content: space-between; align-items: center; }
.nd-kind { font-weight: 700; font-size: 3.7cqw; color: #5b56a0; }
.nd-live { display: inline-flex; align-items: center; gap: 1.4cqw; font-size: 3.6cqw; }
.nd-live::before { content: ''; width: 2cqw; height: 2cqw; border-radius: 50%; background: #3fae4f; }
.nd-card-name { font-size: 6cqw; line-height: 1.15; }
.nd-card-hours { font-size: 4.1cqw; }
.nd-card-days { font-size: 3.7cqw; color: var(--nd-brown); }
.nd-chip {
  display: inline-flex; align-self: flex-start; align-items: center; gap: 1.5cqw; margin-top: 2cqw;
  padding: 1.4cqw 3cqw; font-size: 3.5cqw; background: #cccce8; border-radius: 99px;
}
.nd-chip-icon { width: 4cqw; height: 4cqw; }
.nd-card .nd-pill { margin-top: 5cqw; }

/* Pills used on the site-made screens, sized like the native ones. */
.nd-pill {
  display: block; width: 100%; min-height: max(44px, 13cqw); padding: 0 4cqw;
  border: 0; border-radius: 99px; cursor: pointer; touch-action: manipulation;
  font: 600 4.4cqw/1.2 Poppins, sans-serif;
}
.nd-pill--orange { color: #1f1a17; background: var(--nd-orange); }
.nd-pill--red { color: #fff; background: var(--nd-red); }
.nd-pill--ghost { color: var(--nd-ink); background: transparent; box-shadow: inset 0 0 0 .5cqw var(--nd-ink); }
.nd-pill:hover { filter: brightness(1.06); }
.nd-pill:focus-visible { outline: 3px solid var(--nd-ink); outline-offset: 3px; }

/* Sheet that rises when the wait is over; its shadow dims the rest of the screen. */
.nd-sheet {
  position: absolute; inset: auto 0 0; z-index: 2; padding: 7cqw 7cqw 9cqw;
  text-align: center; background: var(--nd-cream); border-radius: 8cqw 8cqw 0 0;
  box-shadow: 0 0 0 100vmax rgb(43 58 52 / .38);
  animation: nd-up .32s cubic-bezier(.2,.8,.3,1);
}
.nd-sheet-part { display: grid; gap: 3cqw; }
.nd-sheet-title { display: block; font-size: 5.8cqw; font-weight: 700; line-height: 1.15; }
.nd-sheet-sub { display: block; margin-bottom: 2cqw; font-size: 4cqw; color: var(--nd-brown); }
.nd-minutes { margin: 0; color: var(--nd-orange); font-weight: 700; font-size: 5.5cqw; line-height: 1; }
.nd-minutes-num { font-size: 15cqw; font-variant-numeric: tabular-nums; }
.nd-range { width: 100%; min-height: 44px; margin: 0; accent-color: var(--nd-orange); cursor: pointer; }
.nd-range:focus-visible { outline: 3px solid var(--nd-ink); outline-offset: 2px; border-radius: 8px; }

/* Endings. */
.nd-screen--kept { background: var(--nd-yellow); }
.nd-screen--unlocked { background: var(--nd-cream); }
.nd-end {
  position: absolute; inset: 11cqw 0 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3cqw; padding: 0 8cqw 10cqw; text-align: center;
}
.nd-end-title { font-size: 6.6cqw; line-height: 1.15; margin-top: 4cqw; }
.nd-end-sub { font-size: 4.2cqw; color: var(--nd-brown); }
.nd-end .nd-pill { margin-top: 7cqw; }

/* Without JavaScript: the two native moments with a line each. */
.nd-fallback { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(18px,4vw,48px); margin-top: 22px; }
.nd-fallback-item { display: grid; justify-items: center; gap: 14px; margin: 0; }
.nd-fallback-item figcaption { max-width: 30ch; text-align: center; }
.nd-fallback-item strong { display: block; font-size: 1.2rem; }

@keyframes nd-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nd-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes nd-pulse {
  0% { box-shadow: 0 0 0 0 rgb(255 228 127 / .8); }
  70%, 100% { box-shadow: 0 0 0 3.5cqw rgb(255 228 127 / 0); }
}
@media (prefers-reduced-motion: reduce) {
  .nd-ready .nd-screen, .nd-sheet { animation: none; }
  .nd-app-icon { animation: none; box-shadow: 0 0 0 1.2cqw rgb(255 228 127 / .9); }
  .nd-app--target:hover .nd-app-icon { transform: none; }
}

@media (max-width: 650px) {
  .nd-stage { grid-template-columns: 1fr; gap: 18px; margin-top: 16px; padding: 18px 16px 22px; }
  .night-phone.nd-phone { order: -1; --night-phone-w: min(78vw, 300px, calc((82vh - 40px) * .46)); min-width: 220px; padding: 7px; border-radius: 36px; }
  .nd-display { border-radius: 29px; }
  .nd-side { min-height: 9.5em; text-align: center; }
  .nd-note h3, .nd-note p { max-width: none; }
  .nd-note h3 { font-size: 1.4rem; }
  .nd-note p { margin-top: 6px; }
  .nd-restart { margin: 12px auto 0; }
  .nd-fallback { grid-template-columns: 1fr; }
  .night-phone { --night-phone-w: min(68vw, 270px, calc((80vh - 40px) * .46)); }
}
