/* 12:00 The rhythm - Bella's screen in the app (the dog's own screen):
   the prediction unlock, the 7-day rhythm chart filling in, the windows
   sharpening and the 14-day verdict; the Next Poop & Pee widget beside it
   when the stage is wide enough. Everything inside .x-rh-app is sized in
   iOS points (var(--pt)) like the app; the widget is 170 pt wide. */

#stage-rhythm { --stage-h: 620px; }
@media (max-width: 600px) { #stage-rhythm { --stage-h: 540px; } }

#stage-rhythm .x-rh {
  container: xrh / inline-size;
  position: relative;
  width: 100%;
  align-self: start;
  display: grid; justify-items: center;
  padding-top: 18px;
}
#stage-rhythm .x-rh-scene {
  position: relative;
  width: 100%;
  display: flex; align-items: flex-start; justify-content: center; gap: 22px;
}
#stage-rhythm .x-rh-main { width: min(100%, 440px); flex: none; display: grid; justify-items: center; }
#stage-rhythm .x-rh-app { width: 100%; }
#stage-rhythm .x-rh-side { display: none; flex: none; }
@container xrh (min-width: 600px) {
  #stage-rhythm .x-rh-main { width: 404px; }
  #stage-rhythm .x-rh-side { display: block; width: 176px; align-self: flex-start; margin-top: 196px; }
}

/* ---- The screen ------------------------------------------------------- */
#stage-rhythm .x-rh-screen {
  display: flex; flex-direction: column;
  padding: calc(12 * var(--pt)) calc(16 * var(--pt)) calc(16 * var(--pt));
  border-radius: calc(38 * var(--pt));
  background:
    radial-gradient(120% 60% at 100% 0%, color-mix(in srgb, #C9B8FF 22%, transparent), transparent 70%),
    linear-gradient(180deg, var(--scr-bg) 0%, var(--scr-bg-2) 100%);
  border: 1px solid var(--scr-glass-line);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
#stage-rhythm .x-rh-nav {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
}
#stage-rhythm .x-rh-round {
  width: calc(40 * var(--pt)); height: calc(40 * var(--pt));
  padding: 0; justify-content: center;
}
#stage-rhythm .x-rh-round svg { width: calc(20 * var(--pt)); height: calc(20 * var(--pt)); }
#stage-rhythm .x-rh-navtitle {
  text-align: center; font-weight: 600; font-size: calc(17 * var(--pt));
}
#stage-rhythm .x-rh-id { margin-top: calc(12 * var(--pt)); }

/* The verdict slot: collapsed (height 0) until the 14 days are in. */
#stage-rhythm .x-rh-vslot { overflow: hidden; }
#stage-rhythm .x-rh-vin { padding-top: calc(10 * var(--pt)); }
#stage-rhythm .x-rh-verdict { transform-origin: 30% 50%; }

/* ---- The chart (DogRhythmChart) ---------------------------------------- */
#stage-rhythm .x-rh-chart {
  --lab: calc(40 * var(--pt));
  margin-top: calc(16 * var(--pt));
  padding: calc(12 * var(--pt)) calc(12 * var(--pt)) calc(10 * var(--pt));
  border-radius: calc(16 * var(--pt));
  background: color-mix(in srgb, var(--scr-card) 78%, transparent);
  border: 1px solid color-mix(in srgb, var(--scr-sep) 70%, transparent);
}
#stage-rhythm .x-rh-plot { position: relative; padding-top: calc(4 * var(--pt)); }
#stage-rhythm .x-rh-lanes,
#stage-rhythm .x-rh-over {
  position: absolute; left: var(--lab); right: 0; top: calc(4 * var(--pt)); bottom: 0;
  pointer-events: none;
}
#stage-rhythm .x-rh-grid {
  position: absolute; top: 0; bottom: 0; width: 1px; margin-left: -0.5px;
  background: repeating-linear-gradient(180deg, var(--scr-sep) 0 2px, transparent 2px 5px);
}
#stage-rhythm .x-rh-grid.x-rh-g6 { background: var(--scr-sep); }
#stage-rhythm .x-rh-now {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 1.5px; margin-left: -0.75px;
  background: color-mix(in srgb, var(--scr-tint) 80%, transparent);
}
#stage-rhythm .x-rh-now::before {
  content: ""; position: absolute; left: 50%; top: calc(-4 * var(--pt));
  width: calc(5 * var(--pt)); height: calc(5 * var(--pt));
  transform: translateX(-50%); border-radius: 50%;
  background: var(--scr-tint);
}
#stage-rhythm .x-rh-empty {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: calc(3 * var(--pt)) calc(8 * var(--pt));
  border-radius: 99px; background: var(--scr-card);
  font-size: calc(12 * var(--pt)); color: var(--scr-ink-2); white-space: nowrap;
}
#stage-rhythm .x-rh-over { z-index: 3; }

/* Rows: zebra lanes, hairline separators, today tinted (the app's). */
#stage-rhythm .x-rh-rows.rhythm { gap: 0; }
#stage-rhythm .rh-row { grid-template-columns: var(--lab) 1fr; height: calc(21 * var(--pt)); }
#stage-rhythm .rh-day { font-size: calc(11 * var(--pt)); font-weight: 400; color: var(--scr-ink-2); }
#stage-rhythm .x-rh-today .rh-day { color: var(--scr-ink); }
#stage-rhythm .rh-track { border-radius: 0; }
#stage-rhythm .rh-track::before { display: none; }
#stage-rhythm .rh-row:nth-child(even) .rh-track { background: color-mix(in srgb, var(--scr-fill) 70%, transparent); }
#stage-rhythm .rh-row + .rh-row .rh-track { box-shadow: inset 0 0.5px 0 var(--scr-sep); }
#stage-rhythm .x-rh-today .rh-track { background: color-mix(in srgb, #5856D6 7%, transparent); }

/* Marks: poops in a filled consistency circle with a light rim (PoopMarker),
   pees as drops, meals faded. Today's marks are a size up. */
#stage-rhythm .rh-mark {
  width: calc(16 * var(--pt)); height: calc(16 * var(--pt));
  margin: calc(-8 * var(--pt)) 0 0 calc(-8 * var(--pt));
  z-index: 1;
}
#stage-rhythm .x-rh-chart { --rim: rgba(255, 255, 255, 0.8); }
@media (prefers-color-scheme: dark) { #stage-rhythm .x-rh-chart { --rim: rgba(0, 0, 0, 0.7); } }
#stage-rhythm .rh-mark.poop {
  background: var(--c, var(--s3));
  box-shadow: 0 0 0 1px var(--rim);
  font-size: calc(8 * var(--pt));
}
#stage-rhythm .rh-mark.pee { font-size: calc(11 * var(--pt)); z-index: 2; }
#stage-rhythm .rh-mark.meal { font-size: calc(10 * var(--pt)); opacity: 0.4; z-index: 0; }
#stage-rhythm .x-rh-today .rh-mark { width: calc(19 * var(--pt)); height: calc(19 * var(--pt)); margin: calc(-9.5 * var(--pt)) 0 0 calc(-9.5 * var(--pt)); }
#stage-rhythm .x-rh-today .rh-mark.poop { font-size: calc(9.5 * var(--pt)); }
#stage-rhythm .x-rh-today .rh-mark.pee { font-size: calc(13 * var(--pt)); }
#stage-rhythm .rh-mark.is-off { opacity: 0; }

/* Today's expected windows: kind colour, solid edges; rough = fainter,
   dashed edges. */
#stage-rhythm .x-rh-band {
  position: absolute; top: 8%; bottom: 8%;
  border-radius: calc(5 * var(--pt));
  background: color-mix(in srgb, var(--k) 16%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--k) 50%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--k) 50%, transparent);
  z-index: 0;
}
#stage-rhythm .x-rh-band.poop { --k: #8B5E3C; }
#stage-rhythm .x-rh-band.pee { --k: #3C9AD8; }
#stage-rhythm .x-rh-band.rough {
  background: color-mix(in srgb, var(--k) 8%, transparent);
  border-left-style: dashed; border-right-style: dashed;
  border-color: color-mix(in srgb, var(--k) 34%, transparent);
}
@media (prefers-color-scheme: dark) {
  #stage-rhythm .x-rh-band.poop { --k: #C08A5E; }
  #stage-rhythm .x-rh-band.pee { --k: #5DB2EA; }
}

#stage-rhythm .x-rh-axis {
  position: relative; height: calc(13 * var(--pt));
  margin: calc(5 * var(--pt)) 0 0 var(--lab);
  font-size: calc(11 * var(--pt)); color: var(--scr-ink-2);
  font-variant-numeric: tabular-nums;
}
#stage-rhythm .x-rh-axis span { position: absolute; top: 0; transform: translateX(-50%); line-height: 1; }
#stage-rhythm .x-rh-legend {
  display: flex; align-items: center; gap: calc(12 * var(--pt));
  margin-top: calc(9 * var(--pt));
  font-size: calc(11 * var(--pt)); color: var(--scr-ink-2); white-space: nowrap;
}
#stage-rhythm .x-rh-legend > span { display: inline-flex; align-items: center; gap: calc(4 * var(--pt)); }
#stage-rhythm .x-rh-legend i { font-style: normal; display: inline-grid; place-items: center; }
#stage-rhythm .x-rh-lpoop {
  width: calc(12 * var(--pt)); height: calc(12 * var(--pt)); border-radius: 50%;
  background: var(--s3); box-shadow: 0 0 0 1px var(--rim);
  font-size: calc(6 * var(--pt));
}
#stage-rhythm .x-rh-lpee { font-size: calc(10 * var(--pt)); }
#stage-rhythm .x-rh-lmeal { font-size: calc(10 * var(--pt)); opacity: 0.4; }
#stage-rhythm .x-rh-swatch {
  width: calc(14 * var(--pt)); height: calc(9 * var(--pt)); border-radius: calc(3 * var(--pt));
  background: rgba(139, 94, 60, 0.25);
}
#stage-rhythm .x-rh-l7 { margin-left: auto; color: var(--scr-ink-3); }
@container xrh (max-width: 380px) {
  #stage-rhythm .x-rh-l7 { display: none; }
}

/* The demo's own annotation (not app UI): a tip over a mark or a band. */
#stage-rhythm .x-rh-tip {
  position: absolute; z-index: 6; left: 0; top: 0;
  transform: translate(-50%, calc(-100% - 7px));
  display: grid; justify-items: center; gap: 1px;
  padding: 5px 9px 6px; border-radius: 10px;
  background: rgba(29, 16, 70, 0.92); color: #fff;
  font: 600 12px/1.25 var(--font-body); letter-spacing: 0;
  white-space: nowrap; text-align: center;
  box-shadow: 0 6px 18px rgba(29, 16, 70, 0.25);
  pointer-events: none; opacity: 0;
}
#stage-rhythm .x-rh-tip::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px;
  border: 5px solid transparent; border-bottom: 0; border-top-color: rgba(29, 16, 70, 0.92);
}
#stage-rhythm .x-rh-tip span { font-weight: 450; opacity: 0.82; }
#stage-rhythm .x-rh-tip span:empty { display: none; }
@media (prefers-color-scheme: dark) {
  #stage-rhythm .x-rh-tip { background: rgba(247, 243, 255, 0.95); color: #1D1046; }
  #stage-rhythm .x-rh-tip::after { border-top-color: rgba(247, 243, 255, 0.95); }
}

/* ---- The prediction row: the kit's .predict (CompactPredictionRow) ------
   One carrier for the row's two forms, stacked in one cell so the change
   between them cross-fades in place: the unlock hint, then the windows
   (.pr-col x2, as on the hero's card; the dog's screen has no heads-up
   line). The panel keeps the windows' height, the hint centred in it. */
#stage-rhythm .x-rh-pred {
  grid-template-columns: minmax(0, 1fr);
  margin-top: calc(12 * var(--pt));
}
#stage-rhythm .x-rh-pred > * { grid-area: 1 / 1; min-width: 0; }
#stage-rhythm .x-rh-wins { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
#stage-rhythm .x-rh-seg { min-width: 0; }
/* NOW sits beside the label, where the app puts it (CompactPredictionRow's
   segment), so "11:55-13:05" keeps the kit's size in one column of a
   390 pt screen. */
#stage-rhythm .x-rh-seg .pr-k { opacity: 1; display: flex; align-items: center; gap: calc(5 * var(--pt)); min-width: 0; white-space: nowrap; }
#stage-rhythm .x-rh-kt { opacity: 0.85; overflow: hidden; text-overflow: ellipsis; }
#stage-rhythm .x-rh-seg .pr-now { flex: none; line-height: 1.2; }
#stage-rhythm .x-rh-seg .pr-now[hidden] { display: none; }
#stage-rhythm .x-rh-seg.rough .pr-v { font-weight: 400; color: rgba(255, 255, 255, 0.85); }
#stage-rhythm .x-rh-hint { display: flex; align-items: center; gap: calc(10 * var(--pt)); align-self: center; }
#stage-rhythm .x-rh-spark {
  position: relative; flex: none;
  width: calc(17 * var(--pt)); height: calc(17 * var(--pt));
  color: rgba(255, 255, 255, 0.85);
}
#stage-rhythm .x-rh-spark svg { width: 100%; height: 100%; }
#stage-rhythm .x-rh-spark i {
  position: absolute; left: 50%; top: 50%;
  width: calc(5 * var(--pt)); height: calc(5 * var(--pt)); margin: calc(-2.5 * var(--pt));
  border-radius: 50%; background: #fff; opacity: 0;
  box-shadow: 0 0 calc(5 * var(--pt)) rgba(255, 255, 255, 0.7);
}
#stage-rhythm .x-rh-spark i:nth-child(odd) { background: #FFE9A8; }
#stage-rhythm .x-rh-htext { flex: 1; min-width: 0; display: grid; gap: calc(1 * var(--pt)); }
#stage-rhythm .x-rh-htext b { font-size: calc(12 * var(--pt)); font-weight: 700; line-height: 1.25; white-space: nowrap; }
#stage-rhythm .x-rh-htext small { font-size: calc(11 * var(--pt)); line-height: 1.25; color: rgba(255, 255, 255, 0.85); text-wrap: balance; }
#stage-rhythm .x-rh-count {
  display: inline-block; vertical-align: top;
  height: 1.25em; line-height: 1.25; overflow: hidden; font-variant-numeric: tabular-nums;
}
#stage-rhythm .x-rh-n { display: inline-block; font-weight: inherit; }
#stage-rhythm .x-rh-prog {
  flex: none; width: calc(52 * var(--pt)); height: calc(4 * var(--pt));
  border-radius: 9px; overflow: hidden;
  background: rgba(255, 255, 255, 0.3);
}
#stage-rhythm .x-rh-prog i { display: block; height: 100%; background: #fff; border-radius: inherit; transform-origin: 0 50%; transform: scaleX(0); }

/* Without scripts: the finished week (static rows in the fragment), the
   windows and the verdict; no unlock hint, no empty-chart pill, no chip. */
html:not(.js) #stage-rhythm .x-rh-hint,
html:not(.js) #stage-rhythm .x-rh-empty { visibility: hidden; }
html:not(.js) #stage-rhythm .x-rh-prog i { transform: none; }

/* ---- The Next Poop & Pee widget (small) --------------------------------- */
#stage-rhythm .x-rh-widget { width: 100%; }
#stage-rhythm .x-rh-wscreen {
  --pt: calc(100cqw / 170);
  aspect-ratio: 1;
  display: grid; align-content: center;
  padding: calc(16 * var(--pt));
  border-radius: calc(22 * var(--pt));
  background: var(--scr-card);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
@media (prefers-color-scheme: dark) { #stage-rhythm .x-rh-wscreen { background: #000; box-shadow: var(--shadow-2), inset 0 0 0 1px rgba(255, 255, 255, 0.08); } }
#stage-rhythm .x-rh-wbody { display: grid; gap: calc(6 * var(--pt)); }
#stage-rhythm .x-rh-whead { display: flex; align-items: center; gap: calc(4 * var(--pt)); font-weight: 700; font-size: calc(12 * var(--pt)); }
#stage-rhythm .x-rh-whead svg { width: calc(11 * var(--pt)); height: calc(11 * var(--pt)); color: #5856D6; }
#stage-rhythm .x-rh-wrow {
  position: relative;
  display: flex; align-items: center; gap: calc(6 * var(--pt));
  min-height: calc(34 * var(--pt));
  padding: calc(2 * var(--pt)) calc(4 * var(--pt));
  border-radius: calc(10 * var(--pt));
  background: color-mix(in srgb, #5856D6 6%, transparent);
}
@media (prefers-color-scheme: dark) { #stage-rhythm .x-rh-wrow { background: color-mix(in srgb, #7D7AFF 14%, transparent); } }
#stage-rhythm .x-rh-wrow img { flex: none; width: calc(18 * var(--pt)); height: calc(18 * var(--pt)); object-fit: contain; }
#stage-rhythm .x-rh-wnone { font-size: calc(11 * var(--pt)); color: var(--scr-ink-2); }
#stage-rhythm .x-rh-wsome { display: grid; gap: calc(1 * var(--pt)); flex: 1; min-width: 0; }
#stage-rhythm .x-rh-wv { font-size: calc(11 * var(--pt)); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
#stage-rhythm .x-rh-wc { font-size: calc(11 * var(--pt)); color: var(--scr-ink-2); line-height: 1.2; }
#stage-rhythm .x-rh-wdot { flex: none; width: calc(7 * var(--pt)); height: calc(7 * var(--pt)); border-radius: 50%; background: var(--dot, #4CAF50); }
#stage-rhythm .x-rh-wrow.rough .x-rh-wv { font-weight: 400; color: var(--scr-ink-2); }
#stage-rhythm .x-rh-wrow.active .x-rh-wc { color: var(--scr-ink); }
#stage-rhythm .x-rh-wrow[data-state="none"] .x-rh-wsome,
#stage-rhythm .x-rh-wrow[data-state="none"] .x-rh-wdot { display: none; }
#stage-rhythm .x-rh-wrow:not([data-state="none"]) .x-rh-wnone { display: none; }
#stage-rhythm .x-rh-wcap { margin-top: 10px; text-align: center; font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* ---- The control: Pause while the story plays, Replay once stopped -------- */
#stage-rhythm .x-rh-ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 14px; min-width: 44px; height: 44px; padding: 0 17px 0 13px;
  border-radius: var(--r-pill);
  background: var(--glass-strong); color: var(--ink);
  border: 1px solid var(--glass-line); box-shadow: var(--shadow-1);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  font: 650 14px/1 var(--font-body); cursor: pointer;
  transition: transform 0.45s var(--spring-pop);
}
#stage-rhythm .x-rh-ctl[hidden] { display: none; }
#stage-rhythm .x-rh-ctl svg { width: 16px; height: 16px; flex: none; }
#stage-rhythm .x-rh-ctl[data-state="playing"] .x-rh-ic-replay,
#stage-rhythm .x-rh-ctl[data-state="stopped"] .x-rh-ic-pause { display: none; }
#stage-rhythm .x-rh-ctl:hover { transform: scale(1.04); }
#stage-rhythm .x-rh-ctl:active { transform: scale(0.96); transition-duration: 0.12s; }
@media (prefers-reduced-motion: reduce) { #stage-rhythm .x-rh-ctl { transition: none; } }
#stage-rhythm .x-rh-app { cursor: default; }
