:root {
  --bg: #f5f1e8;
  --paper: #fffdf7;
  --paper-soft: #f8f1e7;
  --ink: #382f27;
  --ink-soft: #665d53;
  --ink-dim: #948a7f;
  --rule: #ded3c4;
  --feed: #3f8a55;
  --feed-art: #55a56a;
  --future: #4d80af;
  --blush: #d36657;
  --nap: #8a6aac;
  --dream: #b06080;
  --shadow: 0 1px 0 #ded3c4, 0 24px 48px -32px rgba(80, 68, 48, 0.28);
  --pad: max(12px, env(safe-area-inset-top), env(safe-area-inset-left));
  --font: "Outfit", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.is-dusk {
  --bg: #5a4838;
  --paper: #6b5542;
  --paper-soft: #604b3a;
  --ink: #f4ead0;
  --ink-soft: #d8c7a6;
  --ink-dim: #a99678;
  --rule: #80664e;
  --feed: #9ed98e;
  --feed-art: #a6df95;
  --future: #9ac7ec;
  --blush: #ef9379;
  --nap: #c4a0e8;
  --dream: #e090b0;
  --shadow: 0 1px 0 #80664e, 0 24px 48px -32px rgba(0, 0, 0, 0.55);
}

body.is-night {
  --bg: #211f1b;
  --paper: #35312a;
  --paper-soft: #2f2b25;
  --ink: #efe7d4;
  --ink-soft: #c8bda6;
  --ink-dim: #958a77;
  --rule: #554d42;
  --feed: #9bdc91;
  --feed-art: #a7e99b;
  --future: #95c5e8;
  --blush: #e08975;
  --nap: #b898d8;
  --dream: #d080a0;
  --shadow: 0 1px 0 #554d42, 0 24px 48px -32px rgba(0, 0, 0, 0.75);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.kiosk {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
}

.kiosk::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("/static/icons/pajama-scatter.svg?v=4");
  background-repeat: repeat;
  background-size: clamp(150px, 17vmin, 230px) auto;
  opacity: 0.075;
  pointer-events: none;
}

body.is-dusk .kiosk::before,
body.is-night .kiosk::before {
  filter: invert(1);
  opacity: 0.085;
}

.kiosk-card {
  position: absolute;
  inset: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(14px, 2vmin, 30px);
  padding: clamp(22px, 3.3vmin, 52px) clamp(22px, 4.8vmin, 76px) clamp(20px, 3.4vmin, 54px);
  /* Solid fallbacks first: older iOS Safari drops the color-mix() declarations
     entirely, which left the card transparent (the pulled-down quick-add sheet
     bled whatever sat beneath it). */
  border: clamp(2px, 0.35vmin, 4px) solid var(--rule);
  border: clamp(2px, 0.35vmin, 4px) solid color-mix(in oklch, var(--future) 24%, var(--rule));
  border-radius: clamp(26px, 4vmin, 48px);
  background: var(--paper);
  background:
    linear-gradient(135deg, color-mix(in oklch, var(--future) 6%, transparent), transparent 62%),
    var(--paper);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  backface-visibility: hidden;
  overflow: hidden;
}

.kiosk-card.is-active {
  opacity: 1;
  pointer-events: auto;
}

.card-title {
  position: relative;
  display: grid;
  justify-items: center;
  gap: clamp(10px, 1.5vmin, 18px);
  color: var(--ink-soft);
  text-align: center;
}

.card-title h1 {
  margin: 0;
  color: var(--ink-soft);
  font-size: clamp(56px, 7.6vmin, 116px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.95;
}

.card-gear {
  position: absolute;
  top: clamp(16px, 2.2vmin, 34px);
  right: clamp(16px, 2.6vmin, 42px);
  z-index: 4;
  display: grid;
  place-items: center;
  width: clamp(42px, 5vmin, 76px);
  height: clamp(42px, 5vmin, 76px);
  padding: 0;
  border: 1px solid color-mix(in oklch, var(--rule) 70%, transparent);
  border-radius: 999px;
  background: color-mix(in oklch, var(--ink) 8%, transparent);
  color: var(--ink-soft);
  font-size: clamp(22px, 2.9vmin, 44px);
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.card-gear:hover {
  color: var(--ink);
  background: color-mix(in oklch, var(--ink) 14%, transparent);
}

.card-gear svg {
  width: 58%;
  height: 58%;
  display: block;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(20, 16, 12, 0.45);
  background: color-mix(in oklch, var(--ink) 42%, transparent);
}

.settings-backdrop[hidden] {
  display: none;
}

.settings-panel {
  width: min(88vw, 440px);
  display: grid;
  gap: clamp(14px, 2vmin, 24px);
  padding: clamp(22px, 3.4vmin, 42px);
  border-radius: clamp(18px, 2.6vmin, 32px);
  border: 1px solid var(--rule);
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: var(--font);
}

.settings-panel h2 {
  margin: 0;
  font-size: clamp(24px, 3vmin, 42px);
  font-weight: 850;
}

.settings-row {
  display: grid;
  gap: clamp(6px, 1vmin, 12px);
}

.settings-row[hidden] {
  display: none;
}

.settings-row label {
  color: var(--ink-soft);
  font-size: clamp(15px, 1.9vmin, 24px);
  font-weight: 700;
}

.settings-kids,
.settings-units {
  display: flex;
  gap: clamp(8px, 1.2vmin, 14px);
}

.settings-kid,
.settings-unit {
  flex: 1;
  padding: clamp(10px, 1.4vmin, 18px);
  border: 1px solid var(--rule);
  border-radius: clamp(10px, 1.4vmin, 14px);
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
  font-size: clamp(18px, 2.2vmin, 30px);
  font-weight: 800;
  cursor: pointer;
}

.settings-kid.is-active,
.settings-unit.is-active {
  border-color: transparent;
  background: var(--feed);
  color: var(--paper);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.settings-btn {
  padding: clamp(8px, 1.2vmin, 16px) clamp(16px, 2vmin, 28px);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: clamp(15px, 1.9vmin, 26px);
  font-weight: 800;
  cursor: pointer;
}

.settings-btn.settings-done {
  border-color: transparent;
  background: var(--feed);
  color: var(--paper);
}

.status-main {
  min-height: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(10px, 1.35vmin, 20px);
}

.next-time {
  width: 100%;
  color: var(--ink);
  font-size: clamp(100px, min(30vmin, 18vw), 440px);
  font-weight: 900;
  line-height: 0.9;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.recent-feeds {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(4px, 0.6vmin, 10px);
}

.recent-feed-list {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
  gap: clamp(4px, 0.7vmin, 10px);
  min-height: 0;
}

.feed-history-row {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: clamp(2px, 0.6vmin, 10px);
  padding: clamp(6px, 1vmin, 16px) clamp(20px, 3vmin, 48px);
  border: 1px solid var(--rule);
  border: 1px solid color-mix(in oklch, var(--rule) 82%, transparent);
  border-radius: clamp(12px, 1.5vmin, 18px);
  background: var(--paper-soft);
  background: color-mix(in oklch, var(--paper-soft) 72%, var(--paper) 28%);
  cursor: pointer;
}

/* Subtle pencil in the corner: rows are tappable to edit or delete. */
.feed-edit-hint {
  position: absolute;
  top: clamp(8px, 1.2vmin, 16px);
  right: clamp(10px, 1.4vmin, 18px);
  color: var(--ink-soft);
  opacity: 0.55;
}

.feed-edit-hint svg {
  width: clamp(16px, 2.2vmin, 30px);
  height: clamp(16px, 2.2vmin, 30px);
  display: block;
}

/* Line 1 spans the frame: relative time on the left, amount on the right. */
.feed-line {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: clamp(14px, 2.4vmin, 40px);
}

.feed-amount {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: clamp(8px, 1.2vmin, 20px);
}

.feed-rel,
.feed-amount b {
  font-size: clamp(66px, 9.2vmin, 152px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.feed-rel {
  color: var(--ink);
}

.feed-amount b {
  color: var(--feed);
}

.feed-amount span {
  color: var(--ink-soft);
  font-size: clamp(36px, 5vmin, 78px);
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

/* Line 2: smaller clock time under the row. */
.feed-clock {
  color: var(--future);
  font-size: clamp(40px, 5.6vmin, 92px);
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.history-card {
  grid-template-rows: auto minmax(0, 1fr);
}

.recent-feed-list {
  grid-template-columns: 1fr;
}

.feed-history-row {
  min-height: clamp(96px, 12vmin, 156px);
}

.empty {
  display: grid;
  place-items: center;
  min-height: clamp(84px, 10vmin, 120px);
  color: var(--ink-dim);
  font-size: clamp(28px, 3.6vmin, 48px);
  font-weight: 850;
}

.l5h-body {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: stretch;
  gap: clamp(14px, 2.4vmin, 44px);
}

.l5h-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1 1 0;
  height: 100%;
  overflow: hidden;
}

.l5h-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Vertical fuel column sitting just to the right of the bar chart. The container
   hugs the tank's aspect ratio so there's no empty gutter between it and the bars. */
.l5h-gauge {
  flex: 0 0 auto;
  height: 90%;
  align-self: center;
  aspect-ratio: 150 / 300;
  max-width: 30%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.l5h-gauge svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Portrait (phone): stack the tank above the bar chart instead of side by side. */
@media (orientation: portrait) {
  .l5h-body {
    flex-direction: column;
    gap: clamp(8px, 2vh, 26px);
  }
  .l5h-stage {
    order: 2;
    width: 100%;
    height: auto;
    flex: 1 1 0;
  }
  .l5h-gauge {
    order: 1;
    flex: 0 0 auto;
    width: 88%;
    max-width: 560px;
    height: auto;
    aspect-ratio: 300 / 190;
    align-self: center;
  }
}

.l5h-gauge-track {
  fill: none;
  stroke: var(--rule);
  stroke: color-mix(in oklch, var(--rule) 80%, transparent);
  stroke-width: 22;
  stroke-linecap: round;
}

.l5h-gauge-arc {
  fill: none;
  stroke-width: 17;
  stroke-linecap: round;
}

.l5h-gauge-needle {
  fill: var(--ink);
}

.l5h-gauge-hub {
  fill: var(--ink);
  stroke: var(--paper);
  stroke-width: 3;
}

.l5h-gauge-end {
  fill: var(--ink-soft);
  font-family: var(--font);
  font-weight: 850;
  font-size: 26px;
}

.l5h-axis {
  fill: var(--ink-soft);
  font-family: var(--font);
  font-size: clamp(34px, 4.6vmin, 68px);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

/* Past 30-minute bars: solid fill on the green fullness scale (set inline). */
.l5h-bar {
  stroke: none;
}

/* Future (projected) bars: a translucent "ghost" of the same conditional color plus
   a crisp stroke, so the forecast reads clearly from across the room. */
.l5h-bar-future {
  fill-opacity: 0.4;
  stroke-width: clamp(2.5px, 0.55vmin, 7px);
  stroke-opacity: 0.9;
}

.l5h-ready-line {
  stroke: oklch(74% 0.13 75);
  stroke-width: 2.5;
  stroke-dasharray: 9 9;
  opacity: 0.75;
}

.l5h-ready-dot {
  fill: var(--paper);
  stroke: oklch(76% 0.14 75);
  stroke-width: clamp(3px, 0.5vmin, 6px);
}

.l5h-ready-time {
  fill: oklch(82% 0.13 75);
  font-family: var(--font);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  /* dark halo so the label stays legible where it crosses the bars */
  paint-order: stroke;
  stroke: var(--paper);
  stroke-linejoin: round;
}

/* Event markers above the bars: a star for planned feeds, a pointer for "now". */
.l5h-mark {
  font-family: var(--font);
}

.l5h-mark-feed {
  fill: oklch(80% 0.13 75);
}

.l5h-mark-label {
  fill: var(--ink-soft);
  font-family: var(--font);
  font-weight: 800;
  text-transform: lowercase;
  opacity: 0.9;
}

/* Solid arrow pointing down at the current ("now") 30-minute bar. Plain colors
   only: color-mix() styling here falls back to SVG's default black fill on
   older iOS Safari and used to read as a black box. */
.l5h-now-arrow {
  fill: var(--ink);
  stroke: var(--paper);
  stroke-width: 2;
  stroke-linejoin: round;
}

.l5h-card {
  grid-template-rows: auto minmax(0, 1fr);
  padding-left: clamp(10px, 1.6vmin, 22px);
  padding-right: clamp(10px, 1.6vmin, 22px);
}

.l5h-card .card-title {
  justify-items: start;
  align-items: baseline;
  text-align: left;
}

.l5h-card .card-title h1 {
  min-width: 0;
  white-space: nowrap;
  font-size: clamp(36px, 4.8vmin, 68px);
}

.routine-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Toggle removed — heatmap fills all space below the title. */
.routine-card {
  grid-template-rows: auto minmax(0, 1fr);
  padding-left: clamp(6px, 1vmin, 16px);
  padding-right: clamp(6px, 1vmin, 16px);
}

.routine-toggle {
  justify-self: end;
  display: flex;
  gap: clamp(4px, 0.6vmin, 8px);
  padding: clamp(3px, 0.5vmin, 6px);
  border-radius: 999px;
  background: var(--paper-soft);
  background: color-mix(in oklch, var(--ink) 8%, transparent);
  border: 1px solid var(--rule);
  border: 1px solid color-mix(in oklch, var(--rule) 70%, transparent);
  z-index: 3;
}

.routine-toggle-btn {
  min-width: clamp(34px, 4.4vmin, 64px);
  padding: clamp(4px, 0.8vmin, 12px) clamp(10px, 1.4vmin, 22px);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: clamp(22px, 3vmin, 46px);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
}

.routine-toggle-btn.is-active {
  background: var(--feed);
  color: var(--paper);
}

.routine-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

.routine-track {
  fill: var(--paper-soft);
  fill: color-mix(in oklch, var(--ink) 8%, transparent);
  stroke: var(--rule);
  stroke: color-mix(in oklch, var(--rule) 60%, transparent);
  stroke-width: 1.5;
}

/* Target feed-time guides (12a 4a 8a 12p 4p 8p) spanning every row. */
.routine-feedline {
  stroke: var(--ink-soft);
  stroke: color-mix(in oklch, var(--ink) 62%, transparent);
  stroke-width: 1.25;
}

/* Faint highlight over the typical nap windows; sits behind the strips. */
.routine-tip {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  display: none;
  background: oklch(18% 0 0 / 0.88);
  color: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

.routine-axis {
  fill: var(--ink-dim);
  font-family: var(--font);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.routine-row-label {
  fill: var(--ink-soft);
  font-family: var(--font);
  font-weight: 850;
}

/* On-target feeding alignment score, rendered inline with each row's day label. */
.routine-score {
  fill: var(--ink);
  font-family: var(--font);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.routine-score-head {
  fill: var(--ink-dim);
  font-family: var(--font);
  font-weight: 800;
  letter-spacing: 0.04em;
}

/* Per-target alignment dot on a green/orange/red stoplight scale. The exact
   score is on hover. All three states are solid-filled so they stay legible. */
.routine-mark {
  stroke: rgba(0, 0, 0, 0.28);
  stroke-width: 1.5;
}
.routine-mark.is-good { fill: oklch(68% 0.19 145); }
.routine-mark.is-near { fill: oklch(74% 0.18 60); }
.routine-mark.is-off { fill: oklch(62% 0.22 25); }

/* Daily intake pacing card: header mirrors the L5H layout (title left, current
   number right), with horizontal bars and a "by now" pace line in the stage. */
.pacing-card {
  grid-template-rows: auto minmax(0, 1fr);
}

.pacing-card .card-title {
  grid-auto-flow: column;
  grid-template-columns: 1fr auto;
  justify-items: start;
  align-items: baseline;
  text-align: left;
}

.pacing-card .card-title h1 {
  min-width: 0;
  white-space: nowrap;
  font-size: clamp(36px, 4.8vmin, 68px);
}

.pacing-now {
  justify-self: end;
  margin: 0;
  color: var(--feed);
  color: color-mix(in oklch, var(--feed) 84%, var(--ink) 16%);
  font-size: clamp(48px, 8vmin, 120px);
  font-weight: 900;
  line-height: 0.9;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.pacing-now.is-behind {
  color: oklch(70% 0.17 55);
}

.pacing-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.pacing-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

.pacing-grid {
  stroke: var(--rule);
  stroke: color-mix(in oklch, var(--rule) 60%, transparent);
  stroke-width: 2;
  stroke-dasharray: 2 12;
  opacity: 0.5;
}

.pacing-grid-zero {
  stroke: var(--ink-soft);
  stroke: color-mix(in oklch, var(--ink) 58%, var(--rule));
  stroke-width: clamp(3px, 0.5vmin, 5px);
  stroke-dasharray: none;
  opacity: 1;
}

/* Stacked daily bar: dark green through the current clock time, light green
   for the rest of the day. */
.pacing-rest {
  fill: var(--feed);
  fill: color-mix(in oklch, var(--feed) 30%, transparent);
}

.pacing-bar {
  fill: var(--feed);
}

.pacing-paceline {
  stroke: var(--future);
  stroke-width: clamp(3px, 0.5vmin, 6px);
  stroke-dasharray: 10 8;
  opacity: 0.9;
}

.pacing-pace-label {
  fill: var(--future);
  fill: color-mix(in oklch, var(--future) 80%, var(--ink-soft));
  font-family: var(--font);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  text-transform: lowercase;
}

.pacing-axis {
  fill: var(--ink-dim);
  font-family: var(--font);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.pacing-row-label {
  fill: var(--ink-soft);
  font-family: var(--font);
  font-weight: 850;
}

.pacing-value {
  fill: var(--ink);
  font-family: var(--font);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

/* The "through the current moment" figure on prior/avg rows: light gray, set
   above the full-day total. */
.pacing-value-now {
  fill: var(--ink-soft);
  fill: color-mix(in oklch, var(--ink) 40%, transparent);
  font-family: var(--font);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.pacing-delta {
  font-family: var(--font);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.pacing-delta.is-ahead {
  fill: var(--feed);
}

.pacing-delta.is-behind {
  fill: oklch(70% 0.17 55);
}

/* Per-day "feed size vs spacing" card: title, color-key legend, then a strip
   of two bars per day (green = % added per feed, blue = time between feeds). */
.feedtrend-card {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.feedtrend-card .card-title h1 {
  white-space: nowrap;
  font-size: clamp(34px, 4.6vmin, 66px);
}

.feedtrend-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(12px, 2.4vmin, 36px);
}

.feedtrend-key {
  display: inline-flex;
  align-items: center;
  gap: clamp(6px, 1vmin, 12px);
  color: var(--ink-soft);
  font-size: clamp(18px, 2.3vmin, 34px);
  font-weight: 850;
}

.feedtrend-key::before {
  content: "";
  width: clamp(16px, 2vmin, 28px);
  height: clamp(16px, 2vmin, 28px);
  border-radius: 6px;
}

.feedtrend-key-size::before {
  background: var(--feed);
}

.feedtrend-key-gap::before {
  background: var(--future);
}

.feedtrend-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.feedtrend-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

.feedtrend-track {
  fill: color-mix(in oklch, var(--ink) 8%, transparent);
  stroke: color-mix(in oklch, var(--rule) 60%, transparent);
  stroke-width: 1.5;
}

.feedtrend-bar-size {
  fill: var(--feed);
}

.feedtrend-bar-gap {
  fill: var(--future);
}

.feedtrend-label {
  fill: var(--ink-soft);
  font-family: var(--font);
  font-weight: 850;
}

.feedtrend-value {
  font-family: var(--font);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.feedtrend-value-size {
  fill: var(--feed);
  fill: color-mix(in oklch, var(--feed) 88%, var(--ink));
}

.feedtrend-value-gap {
  fill: var(--future);
  fill: color-mix(in oklch, var(--future) 88%, var(--ink));
}

.sync-banner {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border: 1px solid color-mix(in oklch, var(--rule) 86%, transparent);
  border-radius: 14px;
  background: var(--paper);
  background: color-mix(in oklch, var(--paper) 88%, transparent);
  color: var(--ink-soft);
  box-shadow: 0 18px 40px -28px oklch(0 0 0 / 0.72);
  font-size: 15px;
  font-weight: 760;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.sync-banner.is-visible {
  opacity: 0.92;
  transform: translateY(0);
}

.sync-banner[hidden] {
  display: none;
}

.sync-dot {
  width: 19px;
  height: 19px;
  background: currentColor;
  opacity: 0.78;
  -webkit-mask: url("/static/icons/orbit-sync.svg") center / contain no-repeat;
  mask: url("/static/icons/orbit-sync.svg") center / contain no-repeat;
}

@media (max-aspect-ratio: 4 / 5) {
  .kiosk-card {
    gap: clamp(12px, 2vmin, 22px);
    padding: clamp(18px, 3vmin, 34px);
  }

  .next-time {
    font-size: clamp(88px, 21vw, 168px);
  }
}

@media (max-height: 760px) {
  .next-time {
    font-size: clamp(110px, min(22vmin, 18vw), 300px);
  }

}

@media (prefers-reduced-motion: reduce) {
  .kiosk-card,
  .sync-banner {
    transition: none;
  }
}

/* Phone portrait: scale type to width so nothing clips on a narrow screen. */
@media (max-width: 600px) {
  .kiosk-card {
    gap: clamp(10px, 2.4vw, 22px);
    padding: clamp(16px, 5vw, 30px) clamp(16px, 5.2vw, 30px) clamp(16px, 4.6vw, 28px);
    border-radius: clamp(20px, 6vw, 34px);
  }

  .card-title {
    gap: clamp(8px, 2.4vw, 16px);
  }

  .card-title h1 {
    font-size: clamp(34px, 10vw, 72px);
  }

  .next-time {
    font-size: clamp(64px, 20vw, 200px);
  }

  .status-now h1 {
    gap: clamp(6px, 2vw, 16px);
  }

  .status-now-icon {
    font-size: clamp(28px, 8vw, 60px);
  }

  .status-now-sub {
    font-size: clamp(14px, 4vw, 28px);
  }

  .status-upcoming {
    gap: clamp(6px, 2vw, 14px);
  }

  .status-tile {
    padding: clamp(6px, 2vw, 14px) clamp(4px, 1.6vw, 10px);
    gap: clamp(2px, 0.8vw, 6px);
  }

  .status-tile-rank {
    font-size: clamp(9px, 2.4vw, 16px);
  }

  .status-tile-icon {
    font-size: clamp(20px, 6vw, 40px);
  }

  .status-tile-label {
    font-size: clamp(12px, 3.4vw, 22px);
  }

  .status-tile-time {
    font-size: clamp(14px, 4.2vw, 28px);
  }

  .status-tile-until {
    font-size: clamp(10px, 2.8vw, 18px);
  }

  .feed-history-row {
    min-height: clamp(60px, 16vw, 120px);
    padding: clamp(8px, 2.6vw, 16px) clamp(12px, 3.5vw, 20px);
    gap: clamp(2px, 1vw, 8px);
  }

  .feed-line {
    gap: clamp(6px, 1.8vw, 18px);
  }

  .feed-rel,
  .feed-amount b {
    font-size: clamp(22px, 6vw, 72px);
  }

  .feed-amount span {
    font-size: clamp(13px, 3vw, 38px);
  }

  .feed-clock {
    font-size: clamp(20px, 5.5vw, 44px);
  }

  .l5h-card .card-title h1,
  .pacing-card .card-title h1 {
    font-size: clamp(26px, 7vw, 52px);
  }

  .pacing-now {
    font-size: clamp(40px, 11vw, 104px);
  }

  /* Stack the title over the number so the long "DAILY PACING" heading and the
     "470 mL" total never collide on a narrow phone. */
  .pacing-card .card-title {
    grid-auto-flow: row;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    text-align: center;
  }

  .pacing-now {
    justify-self: center;
  }

  .l5h-axis {
    font-size: clamp(16px, 3.4vw, 30px);
  }

  .routine-card .card-title h1 {
    font-size: clamp(30px, 8vw, 60px);
  }

  .feedtrend-card .card-title h1 {
    font-size: clamp(26px, 7vw, 52px);
  }

  .feedtrend-key {
    font-size: clamp(14px, 3.6vw, 28px);
  }
}

/* Phone landscape: short viewport, scale type to height so a card fits one screen. */
@media (max-height: 540px) {
  .kiosk-card {
    gap: clamp(6px, 2vh, 16px);
    padding: clamp(10px, 3.5vh, 24px) clamp(16px, 4vw, 44px);
    border-radius: clamp(16px, 4vh, 30px);
  }

  .card-title h1 {
    font-size: clamp(28px, 9vh, 70px);
  }

  .next-time {
    font-size: clamp(72px, 32vh, 240px);
  }

  .status-now-icon {
    font-size: clamp(24px, 7vh, 56px);
  }

  .status-now-sub {
    font-size: clamp(14px, 3.6vh, 28px);
  }

  .status-upcoming {
    gap: clamp(6px, 1.4vh, 14px);
  }

  .status-tile {
    padding: clamp(4px, 1.2vh, 12px) clamp(4px, 1vw, 10px);
    gap: clamp(1px, 0.5vh, 5px);
  }

  .status-tile-rank {
    font-size: clamp(9px, 2.2vh, 16px);
  }

  .status-tile-icon {
    font-size: clamp(18px, 5vh, 40px);
  }

  .status-tile-label {
    font-size: clamp(12px, 3vh, 22px);
  }

  .status-tile-time {
    font-size: clamp(14px, 3.8vh, 28px);
  }

  .status-tile-until {
    font-size: clamp(10px, 2.6vh, 18px);
  }

  .history-card {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .feed-history-row {
    min-height: clamp(44px, 17vh, 110px);
    padding: clamp(4px, 1.4vh, 12px) clamp(12px, 3vw, 22px);
    gap: clamp(2px, 1vh, 8px);
  }

  .feed-line {
    gap: clamp(8px, 2vw, 20px);
  }

  .feed-rel,
  .feed-amount b {
    font-size: clamp(26px, 9vh, 64px);
  }

  .feed-amount span {
    font-size: clamp(18px, 5vh, 40px);
  }

  .feed-clock {
    font-size: clamp(18px, 5vh, 44px);
  }

  .l5h-card .card-title h1,
  .pacing-card .card-title h1 {
    font-size: clamp(24px, 7vh, 56px);
  }

  .pacing-now {
    font-size: clamp(36px, 12vh, 108px);
  }

  .l5h-axis {
    font-size: clamp(14px, 3.4vh, 28px);
  }

  .feedtrend-card .card-title h1 {
    font-size: clamp(22px, 6.5vh, 52px);
  }

  .feedtrend-key {
    font-size: clamp(13px, 3.2vh, 26px);
  }
}

/* ---- status card: schedule context + upcoming tiles ---- */

/* Carry the current schedule type's accent onto the whole card so the
   current activity reads at a glance from across the room. */
.status-card {
  border-color: color-mix(in oklch, var(--sc, var(--future)) 40%, var(--rule));
  background:
    linear-gradient(135deg, color-mix(in oklch, var(--sc, var(--future)) 12%, transparent), transparent 60%),
    var(--paper);
}

/* "Now" header: a tinted accent panel holding the current activity. */
.status-now {
  gap: clamp(6px, 1vmin, 14px);
  padding: clamp(12px, 1.8vmin, 28px) clamp(16px, 2.4vmin, 36px);
  border-radius: clamp(16px, 2.2vmin, 28px);
  background: var(--paper-soft);
  background: color-mix(in oklch, var(--sc, var(--future)) 14%, var(--paper-soft));
  border: clamp(2px, 0.4vmin, 5px) solid var(--rule);
  border: clamp(2px, 0.4vmin, 5px) solid color-mix(in oklch, var(--sc, var(--future)) 42%, var(--rule));
}

/* "Now" pill — labels the current item to mirror the Next/Then/Later tiles. */
.status-now-tag {
  font-size: clamp(13px, 1.7vmin, 26px);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sc, var(--future));
  background: var(--paper);
  background: color-mix(in oklch, var(--sc, var(--future)) 18%, var(--paper));
  border: 1px solid var(--rule);
  border: 1px solid color-mix(in oklch, var(--sc, var(--future)) 45%, transparent);
  padding: clamp(3px, 0.5vmin, 7px) clamp(10px, 1.4vmin, 18px);
  border-radius: 999px;
  line-height: 1;
}

.status-now h1 {
  display: inline-flex;
  align-items: center;
  gap: clamp(10px, 1.6vmin, 24px);
  color: var(--sc, var(--ink));
}

/* Icon sits in a filled colored disc for stronger, glanceable iconography. */
.status-now-icon {
  font-size: clamp(44px, 6.4vmin, 96px);
  line-height: 1;
  display: inline-grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  background: var(--paper);
  background: color-mix(in oklch, var(--sc, var(--future)) 24%, var(--paper));
  border: 0.05em solid var(--rule);
  border: 0.05em solid color-mix(in oklch, var(--sc, var(--future)) 55%, transparent);
  box-shadow: 0 0 0 0.05em color-mix(in oklch, var(--sc, var(--future)) 16%, transparent);
}

.status-now-sub {
  font-size: clamp(22px, 2.8vmin, 46px);
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.1;
}

.status-upcoming {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.4vmin, 22px);
  min-width: 0;
}

.status-tile {
  min-width: 0;
  display: grid;
  grid-template-rows: repeat(5, auto);
  justify-items: center;
  align-content: center;
  text-align: center;
  gap: clamp(2px, 0.5vmin, 8px);
  padding: clamp(10px, 1.7vmin, 24px) clamp(8px, 1.3vmin, 18px);
  border-radius: clamp(14px, 1.9vmin, 24px);
  background: var(--paper-soft);
  background: color-mix(in oklch, var(--sc, var(--future)) 15%, var(--paper-soft));
  border: clamp(1px, 0.25vmin, 3px) solid var(--rule);
  border: clamp(1px, 0.25vmin, 3px) solid color-mix(in oklch, var(--sc, var(--rule)) 42%, var(--rule));
}

/* The immediate next item gets a heavier, filled treatment so the very
   next thing on the schedule pops ahead of the two after it. */
.status-tile.is-next {
  background: var(--paper);
  background: color-mix(in oklch, var(--sc, var(--future)) 26%, var(--paper-soft));
  border-color: var(--ink-soft);
  border-color: color-mix(in oklch, var(--sc, var(--future)) 70%, var(--rule));
  box-shadow: 0 0 0 clamp(2px, 0.3vmin, 4px) color-mix(in oklch, var(--sc, var(--future)) 22%, transparent);
}

/* Sequence label: Next / Then / Later. */
.status-tile-rank {
  font-size: clamp(11px, 1.5vmin, 20px);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sc, var(--future));
  line-height: 1;
}

.status-tile-icon {
  font-size: clamp(28px, 4.4vmin, 64px);
  line-height: 1;
  display: inline-grid;
  place-items: center;
  width: 1.55em;
  height: 1.55em;
  border-radius: 50%;
  background: var(--paper);
  background: color-mix(in oklch, var(--sc, var(--future)) 22%, var(--paper));
  border: 0.05em solid var(--rule);
  border: 0.05em solid color-mix(in oklch, var(--sc, var(--future)) 50%, transparent);
}

.status-tile-label {
  font-size: clamp(16px, 2.3vmin, 34px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-tile-time {
  font-size: clamp(20px, 2.9vmin, 42px);
  font-weight: 850;
  color: var(--sc, var(--future));
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.status-tile-until {
  font-size: clamp(12px, 1.6vmin, 22px);
  font-weight: 600;
  color: var(--ink-dim);
  white-space: nowrap;
}

/* per-type accent colors (shared between status card now-header and tiles) */
.sc-type-feed      { --sc: var(--feed); }
.sc-type-nap       { --sc: var(--nap); }
.sc-type-overnight { --sc: var(--future); }
.sc-type-bath      { --sc: var(--blush); }
.sc-type-sleep     { --sc: var(--nap); }
.sc-type-dream     { --sc: var(--dream); }

/* click-to-pause */
.kiosk { cursor: pointer; }
.pause-badge {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  z-index: 6;
  display: none;
  align-items: center;
  gap: clamp(6px, 1vmin, 10px);
  padding: clamp(8px, 1.2vmin, 14px) clamp(13px, 1.9vmin, 22px);
  border-radius: 999px;
  background: var(--ink);
  background: color-mix(in oklch, var(--ink) 74%, transparent);
  color: var(--paper);
  font-family: var(--font);
  font-weight: 850;
  font-size: clamp(15px, 1.9vmin, 26px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.kiosk.is-paused .pause-badge {
  display: inline-flex;
}
.pause-badge svg {
  width: clamp(16px, 2vmin, 26px);
  height: clamp(16px, 2vmin, 26px);
  fill: currentColor;
}

/* Second carousel: pacing / routine / feed-trend live in a sheet that slides up
   over the main deck (swipe up), with chat stacked above it as a third layer.
   Only the main deck auto-rotates; these cards are browsed manually. */
.charts-sheet {
  position: absolute;
  inset: 0;
  z-index: 6;
  transform: translateY(110%);
  transition: transform 340ms cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
  will-change: transform;
}

.charts-sheet.is-open {
  transform: translateY(0);
  pointer-events: auto;
}

/* While a finger is on it, JS positions the sheet directly — no easing. */
.charts-sheet.is-dragging {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .charts-sheet {
    transition: none;
  }
}

/* The charts sheet's grabber sits just inside the top edge of its cards. */
.charts-sheet > .chat-grabber {
  position: absolute;
  top: max(22px, calc(env(safe-area-inset-top) + 10px));
  z-index: 2;
}

/* Hide the pause badge and the main deck's pill row under an open sheet. */
body.charts-open .pause-badge,
body.quickadd-open .pause-badge {
  display: none;
}

/* The main deck's bottom pills (Feed / Charts) share the peek-pill look but sit
   side by side in a centered row instead of self-positioning. */
.deck-pills {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: clamp(8px, 1.4vmin, 16px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.deck-pills .chat-peek {
  position: static;
  transform: none;
}

body.charts-open .deck-pills,
body.chat-open .deck-pills,
body.quickadd-open .deck-pills {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
}

/* Quick add — a TOP sheet for logging a bottle in a few taps: swipe down on the
   main deck (or tap the Feed pill) pulls it down over everything; swipe up or
   the grabber at its bottom edge pushes it away. */
.quickadd-card {
  z-index: 8;
  opacity: 1;
  transform: translateY(-110%);
  transition: transform 340ms cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}

/* Its grabber hangs at the bottom edge, where the dismiss gesture lives. */
.quickadd-card > .chat-grabber {
  top: auto;
  bottom: clamp(8px, 1.4vmin, 16px);
}

/* The Feed pill mirrors the gesture: it sits at the top edge, above the cards.
   Top-left, because the status card's Now tag owns top-center and the gear
   button owns top-right. */
.chat-peek.feed-peek {
  bottom: auto;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  transform: none;
  z-index: 5;
}

body.charts-open .feed-peek,
body.chat-open .feed-peek,
body.quickadd-open .feed-peek {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

.quickadd-card.is-open {
  transform: translateY(0);
  pointer-events: auto;
}

.quickadd-card.is-dragging {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .quickadd-card {
    transition: none;
  }
}

.quickadd-card .card-title h1 {
  font-size: clamp(30px, 4.6vmin, 64px);
}

.qa-stage {
  min-height: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(14px, 2.4vmin, 30px);
  width: min(100%, 760px);
  margin: 0 auto;
}

.qa-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(8px, 1.2vmin, 14px);
  width: 100%;
}

.qa-opt {
  flex: 1 1 auto;
  min-width: clamp(64px, 10vmin, 120px);
  padding: clamp(12px, 1.8vmin, 22px) clamp(14px, 2vmin, 26px);
  border: 1px solid var(--rule);
  border-radius: clamp(12px, 1.8vmin, 18px);
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
  font-size: clamp(20px, 2.6vmin, 36px);
  font-weight: 800;
  cursor: pointer;
}

.qa-opt.is-active {
  border-color: transparent;
  background: var(--feed);
  color: var(--paper);
}

.qa-type-row .qa-opt {
  font-size: clamp(24px, 3.2vmin, 44px);
  padding: clamp(14px, 2.2vmin, 28px);
}

.qa-amount-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vmin, 24px);
}

.qa-step {
  width: clamp(56px, 7.5vmin, 96px);
  height: clamp(56px, 7.5vmin, 96px);
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
  font-size: clamp(28px, 4vmin, 52px);
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.qa-amount {
  min-width: clamp(150px, 22vmin, 300px);
  text-align: center;
  color: var(--ink);
  font-family: var(--font);
  line-height: 1;
}

.qa-amount b {
  font-size: clamp(48px, 7vmin, 104px);
  font-weight: 900;
}

.qa-amount span {
  font-size: clamp(20px, 2.8vmin, 40px);
  font-weight: 800;
  color: var(--ink-soft);
}

.qa-amount small {
  display: block;
  margin-top: clamp(2px, 0.5vmin, 8px);
  font-size: clamp(14px, 1.8vmin, 24px);
  font-weight: 700;
  color: var(--ink-soft);
}

.qa-units {
  display: grid;
  gap: clamp(4px, 0.7vmin, 8px);
}

.qa-unit {
  padding: clamp(6px, 1vmin, 12px) clamp(10px, 1.4vmin, 18px);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: clamp(13px, 1.7vmin, 22px);
  font-weight: 800;
  cursor: pointer;
}

.qa-unit.is-active {
  border-color: transparent;
  background: var(--ink);
  color: var(--paper);
}

.qa-submit {
  width: 100%;
  padding: clamp(16px, 2.6vmin, 32px);
  border: 0;
  border-radius: clamp(14px, 2vmin, 22px);
  background: var(--feed);
  color: var(--paper);
  font-family: var(--font);
  font-size: clamp(22px, 3vmin, 42px);
  font-weight: 900;
  cursor: pointer;
}

.qa-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.qa-status {
  min-height: 1.4em;
  font-family: var(--font);
  font-size: clamp(16px, 2.2vmin, 30px);
  font-weight: 800;
  color: var(--ink-soft);
}

.qa-status.is-ok {
  color: var(--feed);
}

.qa-status.is-error {
  color: hsl(2 70% 48%);
}

/* Feed editor modal: menu -> edit -> confirm flow over the settings backdrop. */
.feedit-panel {
  display: grid;
  gap: clamp(14px, 2vmin, 24px);
  justify-items: center;
  text-align: center;
}

.feedit-summary {
  font-family: var(--font);
  font-size: clamp(20px, 2.6vmin, 36px);
  font-weight: 850;
  color: var(--ink);
  display: grid;
  gap: clamp(4px, 0.8vmin, 10px);
}

.feedit-note {
  font-family: var(--font);
  font-size: clamp(14px, 1.8vmin, 24px);
  font-weight: 700;
  color: var(--ink-soft);
}

.feedit-error {
  font-family: var(--font);
  font-size: clamp(14px, 1.8vmin, 24px);
  font-weight: 800;
  color: hsl(2 70% 48%);
}

.feedit-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(8px, 1.2vmin, 14px);
  width: 100%;
}

.feedit-actions .qa-opt {
  flex: 1 1 auto;
}

.feedit-danger {
  border-color: hsl(2 60% 50%);
  color: hsl(2 70% 44%);
}

body.is-dusk .feedit-danger,
body.is-night .feedit-danger {
  color: hsl(2 80% 66%);
}

.feedit-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1vmin, 12px);
  width: 100%;
}

.feedit-time .qa-opt {
  flex: 0 0 auto;
  min-width: 0;
  font-size: clamp(15px, 1.9vmin, 26px);
  padding: clamp(10px, 1.4vmin, 18px) clamp(10px, 1.4vmin, 18px);
}

.feedit-clock {
  min-width: clamp(96px, 13vmin, 180px);
  font-family: var(--font);
  font-size: clamp(22px, 3vmin, 42px);
  font-weight: 900;
  color: var(--ink);
}

/* chat tile — a bottom sheet that slides up over the carousel */
.chat-card {
  z-index: 7;
  opacity: 1;
  transform: translateY(110%);
  transition: transform 340ms cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}

.chat-card.is-open {
  transform: translateY(0);
  pointer-events: auto;
}

/* While a finger is on it, JS positions the sheet directly — no easing. */
.chat-card.is-dragging {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .chat-card {
    transition: none;
  }
}

/* Hide the carousel's pause badge while the chat sheet is up. */
body.chat-open .pause-badge {
  display: none;
}

.chat-grabber {
  position: absolute;
  top: clamp(8px, 1.4vmin, 16px);
  left: 50%;
  transform: translateX(-50%);
  width: clamp(44px, 9vmin, 72px);
  height: clamp(5px, 0.8vmin, 7px);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--rule);
  background: color-mix(in oklch, var(--ink) 26%, transparent);
  cursor: pointer;
  z-index: 1;
}

.chat-grabber:hover {
  background: color-mix(in oklch, var(--ink) 40%, transparent);
}

/* Peek affordance on the carousel — tap or swipe up to open chat. */
.chat-peek {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: clamp(5px, 0.8vmin, 9px);
  padding: clamp(6px, 1vmin, 11px) clamp(13px, 1.8vmin, 20px);
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  background: color-mix(in oklch, var(--paper) 86%, transparent);
  color: var(--ink-soft);
  font-family: var(--font);
  font-weight: 750;
  font-size: clamp(12px, 1.5vmin, 20px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.chat-peek svg {
  width: clamp(13px, 1.7vmin, 22px);
  height: clamp(13px, 1.7vmin, 22px);
}

.chat-peek:hover {
  color: var(--ink);
  border-color: color-mix(in oklch, var(--future) 45%, var(--rule));
}

body.chat-open .chat-peek {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
}

.chat-card .card-title h1 {
  font-size: clamp(30px, 4.6vmin, 64px);
}

.chat-stage {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: clamp(10px, 1.6vmin, 20px);
}

.chat-log {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  user-select: text;
  -webkit-user-select: text;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vmin, 16px);
  padding-right: 4px;
}

.chat-empty {
  margin: auto;
  max-width: 32ch;
  text-align: center;
  color: var(--ink-dim);
  font-size: clamp(15px, 2vmin, 26px);
  line-height: 1.35;
}

.chat-msg {
  max-width: 86%;
  padding: clamp(9px, 1.3vmin, 16px) clamp(12px, 1.7vmin, 20px);
  border-radius: clamp(14px, 2vmin, 22px);
  font-size: clamp(15px, 2vmin, 28px);
  line-height: 1.34;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}

.chat-msg-user {
  align-self: flex-end;
  background: var(--paper-soft);
  background: color-mix(in oklch, var(--future) 22%, var(--paper));
  color: var(--ink);
  border-bottom-right-radius: clamp(4px, 0.6vmin, 8px);
}

.chat-msg-assistant {
  align-self: flex-start;
  background: var(--paper-soft);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-bottom-left-radius: clamp(4px, 0.6vmin, 8px);
}

.chat-msg.is-thinking {
  color: var(--ink-dim);
  animation: chat-pulse 1.1s ease-in-out infinite;
}

.chat-msg.is-error {
  color: var(--blush);
  border-color: color-mix(in oklch, var(--blush) 50%, var(--rule));
}

@keyframes chat-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.9; }
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(6px, 1vmin, 12px);
  justify-content: center;
}

.chat-suggestion {
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--font);
  font-size: clamp(13px, 1.6vmin, 22px);
  font-weight: 600;
  padding: clamp(6px, 0.9vmin, 12px) clamp(11px, 1.5vmin, 18px);
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.1;
}

.chat-suggestion:hover {
  border-color: color-mix(in oklch, var(--future) 45%, var(--rule));
  color: var(--ink);
}

.chat-input-row {
  display: flex;
  gap: clamp(8px, 1.2vmin, 14px);
  align-items: stretch;
}

.chat-input-row input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font);
  font-size: clamp(16px, 2.1vmin, 28px);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: clamp(12px, 1.6vmin, 18px);
  padding: clamp(10px, 1.4vmin, 16px) clamp(13px, 1.8vmin, 20px);
  user-select: text;
  -webkit-user-select: text;
}

.chat-input-row input:focus {
  outline: none;
  border-color: color-mix(in oklch, var(--future) 55%, var(--rule));
}

.chat-input-row button {
  flex: 0 0 auto;
  font-family: var(--font);
  font-size: clamp(16px, 2.1vmin, 28px);
  font-weight: 800;
  color: var(--paper);
  background: var(--future);
  border: 0;
  border-radius: clamp(12px, 1.6vmin, 18px);
  padding: 0 clamp(18px, 2.6vmin, 34px);
  cursor: pointer;
}

.chat-input-row button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Markdown rendering inside the assistant bubble */
.chat-msg.is-markdown {
  white-space: normal;
}

.chat-msg.is-markdown > * {
  margin: 0;
}

.chat-msg.is-markdown > * + * {
  margin-top: clamp(6px, 1vmin, 12px);
}

.chat-msg.is-markdown .chat-h {
  font-weight: 800;
  font-size: clamp(16px, 2.3vmin, 30px);
  color: var(--ink);
}

.chat-msg.is-markdown .chat-list {
  padding-left: 1.4em;
}

.chat-msg.is-markdown .chat-list li {
  margin: clamp(2px, 0.4vmin, 6px) 0;
}

.chat-msg.is-markdown .chat-quote {
  border-left: 3px solid var(--rule);
  padding-left: 0.8em;
  color: var(--ink-soft);
}

.chat-msg.is-markdown .chat-inline-code,
.chat-msg.is-markdown .chat-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--paper-soft);
  background: color-mix(in oklch, var(--ink) 8%, transparent);
  border-radius: 4px;
}

.chat-msg.is-markdown .chat-inline-code {
  padding: 0 0.35em;
}

.chat-msg.is-markdown .chat-code {
  display: block;
  padding: clamp(8px, 1vmin, 14px);
  overflow-x: auto;
}

.chat-msg.is-markdown strong {
  font-weight: 800;
}

.chat-msg.is-markdown em {
  font-style: italic;
}

.chat-msg.is-markdown a {
  color: var(--future);
  text-decoration: underline;
}

/* Faint release tag in the bottom-left of the status card */
.version-tag {
  position: absolute;
  left: clamp(16px, 2.2vmin, 36px);
  bottom: clamp(8px, 1vmin, 16px);
  color: var(--ink-dim);
  font-family: var(--font);
  font-size: clamp(11px, 1.3vmin, 18px);
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
