/* MyView — app styles. Friendly but polished; touch-first, mobile-ready.
 * Design tokens up top; dark mode + time-of-day tints at the bottom. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  /* page */
  --bg-top: #f3f5fb;
  --bg-bottom: #f7f3fa;
  /* ink */
  --ink: #1d2233;
  --ink-soft: #5b6175;
  --ink-faint: #8a90a6;
  /* surfaces */
  --card: #ffffff;
  --surface: #ffffff;
  --border: #e5e8f3;
  --border-strong: #d4d9ea;
  /* brand */
  --accent: #4361ee;
  --accent-dark: #3650cf;
  --accent-soft: rgba(67, 97, 238, 0.10);
  --brand-1: #4356e0;
  --brand-2: #7c4dbe;
  --on-brand: #ffffff;
  --success: #2e9e5b;
  --danger: #d64550;
  /* shape & elevation */
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 14px rgba(16, 24, 40, 0.06);
  --shadow-lift: 0 4px 8px rgba(16, 24, 40, 0.08), 0 14px 36px rgba(16, 24, 40, 0.14);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom)) fixed;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .btn, .brand {
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.01em;
}

.noscript-msg {
  margin: 2rem auto;
  max-width: 28rem;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.page {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  animation: page-in 0.18s ease both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-header { text-align: center; margin-bottom: 1rem; position: relative; }
.page-header h1 { margin: 0.25rem 0; font-size: 1.7rem; }
.subtitle { color: var(--ink-soft); margin: 0.25rem 0 0; }

.back-link {
  position: absolute;
  left: 0;
  top: 0.4rem;
  text-decoration: none;
  color: var(--accent-dark);
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
}
.back-link:hover { background: var(--accent-soft); }

/* ---------- fields & buttons ---------- */

.field { display: block; margin: 1rem auto; max-width: 24rem; }
.field span { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.field input[type="text"], .field input[type="email"] {
  width: 100%;
  font-size: 1.1rem;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--accent); }

.field-check { display: flex; align-items: center; gap: 0.5rem; }
.field-check span { margin: 0; }
.field-check input { width: 22px; height: 22px; accent-color: var(--accent); }

.actions { text-align: center; margin: 1.5rem 0 0.5rem; }

.btn {
  display: inline-block;
  font-size: 1.02rem;
  font-weight: 700;
  padding: 0.8rem 1.7rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1), 0 6px 16px rgba(67, 97, 238, 0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 2px 4px rgba(16, 24, 40, 0.12), 0 10px 22px rgba(67, 97, 238, 0.42); }
.btn-primary:disabled { background: #b9c0d8; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-subtle {
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.3rem;
  box-shadow: none;
}
.btn-subtle:hover { color: var(--ink); background: var(--surface); }
.btn-small { padding: 0.5rem 1.1rem; font-size: 0.92rem; }

/* family & friends editor */
.hint { font-size: 0.88rem; color: var(--ink-soft); margin: 0.2rem 0 0.6rem; }
.people-list { margin: 0.5rem 0; }
.person-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.45rem 0; }
.person-name {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  padding: 0.55rem 0.8rem;
  border: 2px solid var(--line, #d8dcee);
  border-radius: 12px;
  background: var(--surface, #fff);
  color: var(--ink);
}
.person-name:focus { outline: none; border-color: var(--accent); }
.person-remove {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 0.4rem 0.55rem;
  border-radius: 50%;
  line-height: 1;
}
.person-remove:hover { background: var(--surface); color: var(--danger, #d64550); }

/* ---------- character creator ---------- */

.creator {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 1.25rem;
  align-items: start;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-top: 1rem;
}

.creator-preview {
  position: sticky;
  top: 1rem;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, #eef4ff, #fdf3ff);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.avatar-large { width: 100%; max-width: 220px; height: auto; }
.avatar-medium { width: 90px; height: auto; }
.avatar-small { width: 64px; height: auto; }

.creator-section { margin-bottom: 0.85rem; }
.creator-section h3 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--ink-soft); }
.section-hint { font-size: 0.8rem; font-weight: normal; opacity: 0.75; margin-left: 0.35rem; }

.about-me-section { margin-bottom: 1.25rem; }
.about-me-section > h2 { font-size: 1.15rem; margin: 0 0 0.6rem; }

.opt-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.opt-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0.35rem 0.6rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.opt-btn:hover { border-color: var(--accent); }
.opt-btn.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

.opt-btn.locked { opacity: 0.55; cursor: not-allowed; position: relative; }
.lock-mark { margin-right: 0.3rem; font-size: 0.85rem; }

.opt-text { font-weight: 600; font-size: 0.95rem; }

.swatch {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.hair-preview { width: 44px; height: 46px; }

.parent-info {
  max-width: 34rem;
  margin: 1.5rem auto 0;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.8rem 1.1rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}
.parent-info summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.parent-info ul { margin: 0.6rem 0 0.2rem; padding-left: 1.2rem; }
.parent-info li { margin-bottom: 0.4rem; }

/* ---------- setup wizard ---------- */

.wizard { max-width: 42rem; display: flex; flex-direction: column; min-height: 88vh; }
.wizard-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.wizard-exit {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; color: var(--ink-soft); font-size: 1.1rem;
  border: 1px solid var(--border); background: var(--surface);
}
.wizard-exit:hover { color: var(--ink); border-color: var(--accent); }

.wizard-dots {
  display: flex; gap: 0.4rem; justify-content: center;
  margin: 0.25rem 0 1.5rem;
}
.wdot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border-strong); transition: all 0.2s;
}
.wdot.active { background: var(--accent); width: 26px; border-radius: 5px; }
.wdot.done { background: var(--accent); opacity: 0.5; }

.wizard-body { flex: 1; }
.wizard-step { animation: page-in 0.22s ease both; }
.wizard-step > h1 { text-align: center; font-size: 1.65rem; margin: 0.2rem 0 0.3rem; }
.wizard-step > .subtitle { text-align: center; margin-bottom: 1.4rem; }

.big-field { max-width: 26rem; }
.big-field span { font-size: 1.05rem; text-align: center; }
.big-field input { font-size: 1.15rem; padding: 0.85rem 1rem; text-align: center; }

.closet-choice { justify-content: center; gap: 1rem; }
.closet-opt {
  flex-direction: column; padding: 0.7rem; gap: 0.5rem;
  width: 13.5rem; max-width: 44%;
}
.closet-preview {
  display: block; width: 100%; border-radius: 12px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
}
.closet-preview-svg { width: 100%; height: auto; display: block; }
.closet-opt .opt-text { font-weight: 700; }

.wizard-ready { text-align: center; padding: 1rem 0 0; }
.wizard-ready-avatar {
  width: 130px; height: 130px; margin: 0 auto 0.5rem;
  display: flex; align-items: flex-end; justify-content: center;
  background: radial-gradient(circle at 50% 38%, var(--accent-soft), transparent 70%);
  border-radius: 50%;
}
.wizard-ready-avatar .avatar-medium { width: 110px; }
.wizard-ready h1 { font-size: 1.7rem; margin: 0.3rem 0; }

.wizard-nav {
  display: flex; gap: 0.75rem; align-items: center;
  margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.wizard-nav .btn { flex: 1; }
#wiz-back { flex: 0 0 auto; min-width: 6.5rem; }

@media (max-width: 559px) {
  .wizard { min-height: 92vh; }
  .closet-opt { max-width: 47%; width: auto; }
  .wizard-nav {
    position: sticky; bottom: 0; margin: 1.5rem -0.9rem 0;
    padding: 0.75rem 0.9rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--bg-bottom) 88%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
}

/* ---------- profile picker ---------- */

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  max-width: 36rem;
  margin: 1rem auto;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  font-family: inherit;
  transition: transform 0.1s ease;
}
.profile-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.profile-name { font-weight: 800; font-size: 1.05rem; }
.profile-new { justify-content: center; color: var(--ink-soft); }
.profile-plus { font-size: 2.6rem; line-height: 1; color: var(--accent); }

/* ---------- home ---------- */

.home-page { max-width: 64rem; }

/* slim top app bar: wordmark + settings */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.2rem 0.9rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.18rem;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(67, 97, 238, 0.35);
}
.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 1.15rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.icon-btn:hover { border-color: var(--accent); color: var(--ink); }
.icon-btn { cursor: pointer; font: inherit; }
.appbar-actions { display: inline-flex; gap: 0.5rem; }

/* ---------- inline icon set ---------- */
.ic {
  width: 1.05em; height: 1.05em;
  vertical-align: -0.16em; flex: none;
}
.btn .ic { width: 1.1em; height: 1.1em; margin-right: 0.15em; vertical-align: -0.18em; }
.icon-btn .ic { width: 21px; height: 21px; }
.streak .ic { vertical-align: -0.14em; }
.history-go .ic { width: 1.25em; height: 1.25em; vertical-align: -0.28em; }
.lock-mark .ic { width: 0.95em; height: 0.95em; vertical-align: -0.1em; }
.lock-mark { display: inline-flex; }

/* brand hero: avatar + greeting + streak */
.hero {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background:
    radial-gradient(circle, rgba(255,255,255,0.11) 1px, transparent 1px),
    linear-gradient(135deg, var(--brand-1), var(--brand-2));
  background-size: 22px 22px, 100% 100%;
  color: var(--on-brand);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(67, 86, 224, 0.28), 0 2px 6px rgba(16, 24, 40, 0.08);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.6rem;
  position: relative;
  overflow: hidden;
}
.hero::after {            /* soft decorative glow */
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}
.hero-avatar {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.65), 0 4px 10px rgba(16, 24, 40, 0.18);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
}
.hero-avatar .avatar-small { width: 58px; margin-top: 6px; }
.hero-text { flex: 1 1 auto; min-width: 0; }
.hero-text h1 { margin: 0; font-size: 1.65rem; line-height: 1.15; }
.hero-text .subtitle { color: rgba(255, 255, 255, 0.82); margin: 0.25rem 0 0; font-size: 1rem; }

.streak {
  flex: 0 0 auto;
  font-size: 1.05rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  backdrop-filter: blur(4px);
}

/* section header + progress */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0.2rem 0.8rem;
}
.section-row h2 { margin: 0; font-size: 1.18rem; }

/* progress dots (replaces the chip) */
.progress-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
}
.pdot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 0.25s ease, transform 0.25s ease;
  flex: none;
}
.pdot.pdot-done {
  background: var(--success);
  transform: scale(1.18);
}
.pdot-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-left: 0.35rem;
}

/* scene cards */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.scene-card {
  display: block;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  position: relative;
  animation: card-in 0.3s ease both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.scene-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--border-strong); }
.scene-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.scene-card.done { border-color: var(--success); border-width: 2px; }
.scene-card.done .scene-thumb { position: relative; }
.scene-card.done .scene-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(46, 158, 91, 0.08);
  z-index: 1;
  pointer-events: none;
}

.scene-thumb {
  background: #eef1f9;
  line-height: 0;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.scene-thumb-svg { display: block; width: 100%; height: auto; }
.scene-thumb-svg .seat-marker { display: none; }

.scene-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.98rem;
  padding: 0.65rem 0.9rem;
}
.scene-label-inner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.scene-emoji { font-size: 1rem; flex: none; }
.scene-done-mark {
  color: var(--success);
  font-weight: 800;
  font-size: 1rem;
  flex: none;
}
.scene-arrow {
  color: var(--ink-faint);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  flex: none;
}

.scene-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 2px 8px rgba(46, 158, 91, 0.4);
}

/* primary action area; becomes a sticky bar on phones */
.cta-bar {
  text-align: center;
  margin: 1.6rem 0 0.5rem;
}

.home-footer {
  margin-top: 1.8rem;
  text-align: center;
  color: var(--ink-soft);
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.25rem;
}
.home-footer-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 14px;
  transition: color 0.1s, background 0.1s;
}
.home-footer-item:hover { color: var(--ink); background: var(--surface); }
.footer-icon { font-size: 1.25rem; line-height: 1; }
.footer-label { font-size: 0.82rem; }

/* ---------- scene view ----------
 * The scene is a full-bleed stage: the illustration gets the entire viewport
 * and the only chrome — the Back pill and the whole-scene chip — floats over
 * the art as frosted-glass pills, distinct but not competing with the scene. */

.scene-page {
  position: relative;
  padding: 0;
  max-width: none;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* floating chrome: Back on the left, whole-scene chip on the right */
.scene-overlay-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: calc(0.6rem + env(safe-area-inset-top, 0px)) 0.6rem 0;
  pointer-events: none; /* taps between the pills fall through to the scene */
}
.scene-overlay-bar > * { pointer-events: auto; }

.scene-back,
.whole-chip {
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: 0 2px 12px rgba(12, 12, 36, 0.25);
  color: var(--ink);
}

.scene-back {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.45rem 0.9rem;
}
.scene-back:hover { background: color-mix(in srgb, var(--card) 95%, transparent); }

.whole-chip {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-family: inherit;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.whole-chip:hover { border-color: var(--accent); }

/* the stage itself fills everything under the floating pills */
.scene-page .scene-svg-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.scene-svg-wrap {
  background: var(--card);
  position: relative;
  overflow: hidden;
}
/* Unified scene lighting: the same soft top-light + grounded vignette over
 * every scene, so the five hand-painted scenes read as one world. */
.scene-svg-wrap::after, .scene-thumb::after {
  content: ""; position: absolute; pointer-events: none;
  background:
    radial-gradient(115% 75% at 50% -8%, rgba(255, 255, 255, 0.16), transparent 42%),
    radial-gradient(125% 100% at 50% 118%, rgba(22, 20, 46, 0.20), transparent 56%);
  mix-blend-mode: soft-light;
}
.scene-svg-wrap::after { inset: 0; }
.scene-svg { display: block; width: 100%; height: auto; }

/* Tablet/desktop: the scene scales to fit the viewport — full width when the
 * window is tall enough, otherwise height-bound and centered (no cropping,
 * no scroll). */
@media (min-width: 560px) {
  .scene-page .scene-svg-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .scene-page .scene-svg {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
  }
}

.scene-svg .item { cursor: pointer; }
.scene-svg .item:hover, .scene-svg .item:focus { filter: brightness(1.08) saturate(1.1); outline: none; }
.scene-svg .item:focus-visible { filter: brightness(1.12); }
.item-badge { pointer-events: none; }

.scene-svg .seat { cursor: pointer; }
.scene-svg .seat:hover, .scene-svg .seat:focus { filter: brightness(1.08); outline: none; }
.scene-svg .seat.occupied .seat-marker { display: none; }
.seat-marker { animation: seat-pulse 2.2s ease-in-out infinite; }
@keyframes seat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.avatar-layer, .placed-avatar { pointer-events: none; }
/* the child's own character is a tappable "Me" item wherever it appears
   (fixed spot or a chosen seat); re-enable hits on the wrapper + hit rect,
   which inherit pointer-events:none from .avatar-layer / the placed avatar */
.scene-svg .self-item { pointer-events: auto; cursor: pointer; }

/* rating feedback */
.badge-pop {
  transform-box: fill-box;
  transform-origin: center;
  animation: badge-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes badge-pop {
  from { transform: scale(0.2); }
  to { transform: scale(1); }
}
.item-pulse {
  animation: item-pulse 0.45s ease;
}
@keyframes item-pulse {
  0% { filter: brightness(1); }
  35% { filter: brightness(1.25) saturate(1.25); }
  100% { filter: brightness(1); }
}

/* ---------- living scenes (ambient) ---------- */

.amb-cloud, .amb-cloud-slow, .amb-steam, .amb-tail, .av-eye, .av-breathe {
  transform-box: fill-box;
  transform-origin: center;
}
.amb-cloud { animation: cloud-drift 9s ease-in-out infinite alternate; }
.amb-cloud-slow { animation: cloud-drift 14s ease-in-out infinite alternate-reverse; }
@keyframes cloud-drift {
  from { transform: translateX(-14px); }
  to { transform: translateX(14px); }
}

.amb-steam { animation: steam-rise 2.8s ease-in-out infinite; }
@keyframes steam-rise {
  0% { transform: translateY(4px); opacity: 0.1; }
  40% { opacity: 0.55; }
  100% { transform: translateY(-14px); opacity: 0; }
}

.amb-tail { transform-origin: left bottom; animation: tail-wag 0.7s ease-in-out infinite alternate; }
@keyframes tail-wag {
  from { transform: rotate(-8deg); }
  to { transform: rotate(14deg); }
}

.av-eye { animation: eye-blink 4.6s infinite; }
@keyframes eye-blink {
  0%, 95.5%, 99.5%, 100% { transform: scaleY(1); }
  96.5%, 98.5% { transform: scaleY(0.12); }
}

.av-breathe { animation: breathe 3.4s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* lamp glow appears in the evening/night */
.lamp-glow { opacity: 0; transition: opacity 0.6s ease; }
body.time-evening .lamp-glow, body.time-night .lamp-glow {
  opacity: 0.9;
  animation: glow-pulse 3.5s ease-in-out infinite;
}
@keyframes glow-pulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.65; }
}

/* ---------- reaction icon strip ---------- */

/* invisible click-catcher: tap anywhere outside the strip to dismiss */
.popover-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 40;
}

.popover {
  position: fixed;
  z-index: 50;
  background: var(--card);
  border-radius: 999px;
  box-shadow: var(--shadow-lift);
  padding: 0.35rem;
  text-align: center;
  animation: strip-pop 0.16s ease both;
}
.popover.note-open { border-radius: 18px; }
@keyframes strip-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .popover { animation: none; }
}

.popover-reactions { display: flex; justify-content: center; gap: 0.35rem; }

.reaction-btn {
  font-size: 1.5rem;
  width: 50px;
  height: 50px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
}
.reaction-btn:hover { border-color: var(--accent); }
.reaction-btn.selected { border-color: var(--accent); background: var(--accent-soft); }

.note-btn { font-weight: 700; color: var(--ink-soft); }

.popover-note-row { padding: 0.45rem 0.25rem 0.15rem; width: 232px; }
.popover-note {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.95rem;
  resize: vertical;
  background: var(--surface);
  color: var(--ink);
}
.popover-note:focus { outline: none; border-color: var(--accent); }

/* phones: slightly bigger touch targets */
@media (max-width: 600px) {
  .reaction-btn { width: 56px; height: 56px; font-size: 1.7rem; }
}

/* ---------- snackbar ---------- */

.snackbar {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translate(-50%, 150%);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: #2d3142;
  color: #fff;
  border-radius: 999px;
  padding: 0.6rem 1.2rem;
  box-shadow: var(--shadow-lift);
  z-index: 70;
  transition: transform 0.25s ease;
  max-width: 90vw;
}
.snackbar.show { transform: translate(-50%, 0); }
.snackbar-text { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snackbar-undo {
  background: none;
  border: none;
  color: #9db8ff;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0.2rem 0.4rem;
}

/* ---------- coach marks ---------- */

.coach-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 49, 66, 0.45);
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1.5rem;
}
.coach-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 1.3rem 1.5rem;
  max-width: 22rem;
  text-align: center;
  animation: page-in 0.2s ease both;
}
.coach-icon { font-size: 2.2rem; }
.coach-card p { font-size: 1.05rem; }
.coach-dots { display: flex; justify-content: center; gap: 0.4rem; margin-bottom: 0.9rem; }
.coach-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.coach-dots span.on { background: var(--accent); }

/* ---------- scene card / finish / summary ---------- */

.summary-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  max-width: 30rem;
  margin: 1rem auto;
}
.summary-card h3 { margin: 0 0 0.6rem; }
.optional-tag { font-weight: 400; font-size: 0.85rem; color: var(--ink-soft); }

.summary-table { width: 100%; border-collapse: collapse; }
.summary-table td { padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--border); }
.summary-table td:first-child { font-weight: 700; }
.summary-table tr:last-child td { border-bottom: none; }

.mood-row { display: flex; justify-content: center; gap: 0.5rem; }
.mood-btn {
  font-size: 1.7rem;
  width: 54px;
  height: 54px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
}
.mood-btn:hover { border-color: var(--accent); }
.mood-btn.selected { border-color: var(--accent); background: var(--accent-soft); }

.saved-card {
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 1.5rem;
  max-width: 26rem;
  margin: 3rem auto;
}
.saved-emoji { font-size: 3rem; }

.saved-avatar {
  width: 132px; height: 132px; margin: 0 auto 0.3rem;
  display: flex; align-items: flex-end; justify-content: center;
  border-radius: 50%;
  animation: avatar-pop 0.5s cubic-bezier(0.18, 0.9, 0.3, 1.3) both;
}
.saved-avatar .avatar-medium { width: 112px; }
.saved-avatar.mood-happy { background: radial-gradient(circle at 50% 40%, rgba(46,158,91,0.18), transparent 70%); }
.saved-avatar.mood-okay  { background: radial-gradient(circle at 50% 40%, var(--accent-soft), transparent 70%); }
.saved-avatar.mood-low   { background: radial-gradient(circle at 50% 40%, rgba(124,77,190,0.16), transparent 70%); }
@keyframes avatar-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.reflection { font-size: 1.05rem; color: var(--ink-soft); margin: 0.3rem auto 0; max-width: 20rem; }

.saved-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1.2rem 0;
}
.saved-note { color: var(--ink-soft); font-size: 0.9rem; }

/* World poster overlay */
.poster-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 24, 40, 0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
  animation: page-in 0.2s ease both; overflow: auto;
}
.poster-box { max-width: 24rem; width: 100%; }
.poster-art {
  border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lift);
  background: #fff;
}
.poster-art svg { width: 100%; height: auto; display: block; }
.poster-actions { display: flex; gap: 0.6rem; margin-top: 0.9rem; }
.poster-actions .btn { flex: 1; }

.unlock-note {
  background: #fff4dd;
  color: #7a4f12;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
}
.unlock-note a { color: var(--accent-dark); }

/* ---------- confetti ---------- */

.confetti-host {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}
.confetti-piece {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.9;
  animation: confetti-fall 2.8s linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(105vh) rotate(560deg); opacity: 0.65; }
}

/* ---------- history / sparkline / day detail ---------- */

.spark-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem;
  max-width: 30rem;
  margin: 0 auto 1rem;
}
.spark-card h3 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--ink-soft); }
.sparkline { width: 100%; height: auto; display: block; }

.history-list { list-style: none; padding: 0; max-width: 30rem; margin: 0 auto; }
.history-row {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.8rem 1.1rem;
  margin-bottom: 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.1s ease;
}
.history-row:hover { transform: translateY(-2px); }
.history-date { font-weight: 700; }
.history-time { font-weight: 400; color: var(--ink-soft); font-size: 0.9rem; }
.history-counts { color: var(--ink-soft); }
.history-go { color: var(--accent); font-weight: 800; margin-left: 0.3rem; }

.empty-note { text-align: center; color: var(--ink-soft); }

.day-detail { max-width: 30rem; margin: 0 auto; }
.day-scene {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.2rem;
  margin-bottom: 0.9rem;
}
.day-scene h3 { margin: 0 0 0.5rem; }
.day-seat { color: var(--ink-soft); font-size: 0.95rem; margin: 0.2rem 0 0.5rem; }
.day-entries { list-style: none; padding: 0; margin: 0; }
.day-entry {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.day-entry:last-child { border-bottom: none; }
.day-rating { font-size: 1.1rem; }
.day-label { font-weight: 700; }
.day-note { color: var(--ink-soft); font-style: italic; }

/* ---------- settings ---------- */

.data-zone {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  max-width: 28rem;
  margin: 1rem auto;
  text-align: center;
}
.data-zone h3 { margin-top: 0; }
.data-zone p { color: var(--ink-soft); font-size: 0.92rem; }
.data-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}
.data-status { min-height: 1.2em; font-weight: 600; color: var(--accent-dark); }

.danger-zone {
  background: #fff4f4;
  border: 1px solid #f3c8cc;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  max-width: 28rem;
  margin: 1rem auto;
  text-align: center;
}
.danger-zone h3 { margin-top: 0; }

.storage-note { text-align: center; color: var(--ink-soft); font-size: 0.85rem; }

hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ---------- time of day ----------
 * The page stays calm & neutral; the hero gradient carries the time mood. */

body.time-morning { --bg-top: #f1f7fa; --bg-bottom: #faf6ee; --brand-1: #2f7fc2; --brand-2: #4fa3a8; }
body.time-day     { --bg-top: #f3f5fb; --bg-bottom: #f7f3fa; --brand-1: #4356e0; --brand-2: #7c4dbe; }
body.time-evening { --bg-top: #f9f3ec; --bg-bottom: #f3eef8; --brand-1: #d96941; --brand-2: #9a4f9e; }
body.time-night   { --bg-top: #161a2b; --bg-bottom: #211d34; --brand-1: #36418f; --brand-2: #5a3f86; }

body.time-night {
  color: #e8eaf6;
  --ink: #e8eaf6;
  --ink-soft: #aab0c8;
  --ink-faint: #7d83a0;
  --card: #232838;
  --surface: #2c3247;
  --border: #3a415e;
  --border-strong: #4a5271;
  --accent-soft: rgba(108, 146, 255, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 10px 30px rgba(0, 0, 0, 0.6);
}
body.time-night .scene-thumb { background: #1d2233; }

body.time-evening .scene-svg { filter: sepia(0.10) brightness(0.97); }
body.time-night .scene-svg { filter: brightness(0.88) saturate(0.92); }

/* ---------- clinician report ---------- */

.report-toolbar { text-align: center; margin-bottom: 1.25rem; }

.report-sheet {
  max-width: 48rem;
  margin: 0 auto;
  background: #ffffff;
  color: #1d2233;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 2rem 2.2rem 1.6rem;
}

.rpt-head { border-bottom: 2px solid #e5e8f3; padding-bottom: 1rem; margin-bottom: 1.2rem; }
.rpt-brand {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: ui-rounded, -apple-system, sans-serif; font-weight: 800;
  color: #4356e0; font-size: 1rem; margin-bottom: 0.35rem;
}
.rpt-brand .brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, #4356e0, #7c4dbe); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem;
}
.rpt-head h1 { font-size: 1.5rem; margin: 0.1rem 0 0.4rem; color: #1d2233; }
.rpt-meta { margin: 0.1rem 0; color: #3a4056; }
.rpt-generated { margin: 0.1rem 0; color: #8a90a6; font-size: 0.85rem; }

.rpt-card { margin: 1.2rem 0; }
.rpt-card h2 {
  font-size: 1.05rem; color: #1d2233; margin: 0 0 0.5rem;
  border-left: 4px solid #4361ee; padding-left: 0.6rem;
}
.rpt-sub { font-weight: 500; color: #8a90a6; font-size: 0.82rem; }
.rpt-stat { margin: 0.4rem 0 0; color: #3a4056; }

.rpt-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.rpt-table th {
  text-align: left; padding: 0.4rem 0.55rem; color: #8a90a6;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1.5px solid #e5e8f3;
}
.rpt-table td { padding: 0.42rem 0.55rem; border-bottom: 1px solid #eef0f7; color: #1d2233; }
.rpt-table tr:last-child td { border-bottom: none; }
.rpt-num { white-space: nowrap; text-align: center; width: 3.4rem; }

.rpt-flips { list-style: none; padding: 0; margin: 0; }
.rpt-flips li {
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
  padding: 0.45rem 0; border-bottom: 1px solid #eef0f7; font-size: 0.92rem;
}
.rpt-flips li:last-child { border-bottom: none; }
.rpt-when { color: #8a90a6; font-size: 0.82rem; min-width: 3.4rem; font-variant-numeric: tabular-nums; }
.rpt-where { flex: 1; min-width: 10rem; color: #1d2233; }
.rpt-arrow { white-space: nowrap; }
.rb { font-size: 0.95rem; }

.rpt-notes { list-style: none; padding: 0; margin: 0; }
.rpt-notes li { padding: 0.55rem 0; border-bottom: 1px solid #eef0f7; }
.rpt-notes li:last-child { border-bottom: none; }
.rpt-note-meta { font-size: 0.82rem; color: #8a90a6; margin-bottom: 0.2rem; }
.rpt-notes blockquote {
  margin: 0; padding: 0.4rem 0.8rem; border-left: 3px solid #d4d9ea;
  color: #2c3140; font-style: italic; background: #f7f8fc; border-radius: 0 6px 6px 0;
}

.rpt-foot {
  margin-top: 1.4rem; padding-top: 0.9rem; border-top: 1px solid #e5e8f3;
  color: #8a90a6; font-size: 0.78rem; line-height: 1.5;
}

/* the report sheet is always light, even in dark/night mode (it's a print artifact) */
body.time-night .report-sheet,
.report-sheet { color: #1d2233; }
.report-sheet .spark-card {
  background: #f7f8fc; color: #1d2233; box-shadow: none;
  border: 1px solid #e5e8f3;
}

/* ---------- dark mode ----------
 * Driven by html[data-theme="dark"], set by JS (toggle on home + Settings).
 * Default is dark; choice is saved on the device. */

html[data-theme="light"] { color-scheme: light; }

html[data-theme="dark"] {
  color-scheme: dark;
  --bg-top: #161a2b;
  --bg-bottom: #211d34;
  --ink: #e8eaf6;
  --ink-soft: #aab0c8;
  --ink-faint: #7d83a0;
  --card: #232838;
  --surface: #2c3247;
  --border: #3a415e;
  --border-strong: #4a5271;
  --accent: #6c92ff;
  --accent-dark: #5b7df0;
  --accent-soft: rgba(108, 146, 255, 0.18);
  --brand-1: #3d4ec4;
  --brand-2: #6f48ab;
  --success: #3db870;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 10px 30px rgba(0, 0, 0, 0.6);
}
html[data-theme="dark"] body.time-morning,
html[data-theme="dark"] body.time-day,
html[data-theme="dark"] body.time-evening { --bg-top: #161a2b; --bg-bottom: #211d34; }
html[data-theme="dark"] .creator-preview { background: linear-gradient(180deg, #2a3046, #332a4a); }
html[data-theme="dark"] .scene-thumb { background: #1d2233; }
html[data-theme="dark"] .scene-card.done .scene-thumb::before { background: rgba(46, 158, 91, 0.12); }
html[data-theme="dark"] .unlock-note { background: #3d3322; color: #ffd99a; }
html[data-theme="dark"] .danger-zone { background: #3a2528; border-color: #5c363c; }
html[data-theme="dark"] .btn-primary:disabled { background: #4a5169; }
html[data-theme="dark"] .popover-backdrop { background: rgba(0, 0, 0, 0.45); }
html[data-theme="dark"] .snackbar { background: #11141f; }
html[data-theme="dark"] .home-footer-item:hover { background: var(--surface); }

/* ---------- responsive ---------- */

/* tablets / small laptops: 3-column grid */
@media (max-width: 979px) {
  .scene-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
  .creator { grid-template-columns: 1fr; }
  .creator-preview { position: static; }
  .avatar-large { max-width: 160px; }
}

/* phones: 2-up grid, full-width feature card, sticky bottom CTA */
@media (max-width: 559px) {
  .page { padding: 0.9rem 0.9rem 2.2rem; }

  .scene-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .scene-card { grid-column: auto; }
  .scene-card:nth-child(4) { grid-column: auto; }
  .scene-card:nth-child(5) { grid-column: 1 / -1; }
  .scene-label { font-size: 1rem; padding: 0.6rem 0.85rem; }
  .scene-emoji { font-size: 1.1rem; }

  .hero { padding: 1.1rem 1.2rem; gap: 0.9rem; }
  .hero-avatar { width: 70px; height: 70px; }
  .hero-avatar .avatar-small { width: 54px; margin-top: 5px; }
  .hero-text h1 { font-size: 1.45rem; }
  .hero-text .subtitle { font-size: 0.93rem; }
  .streak { font-size: 0.95rem; padding: 0.42rem 0.82rem; }

  /* footer as a visual nav row */
  .home-footer { gap: 0; margin-top: 1.4rem; }
  .home-footer-item { flex: 1; padding: 0.45rem 0.3rem; border-radius: 12px; }
  .footer-icon { font-size: 1.4rem; }
  .footer-label { font-size: 0.74rem; }

  /* the day's main action stays under the thumb */
  .home-page .cta-bar {
    position: sticky;
    bottom: 0;
    z-index: 30;
    margin: 1.1rem -0.9rem 0;
    padding: 0.75rem 0.9rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--bg-bottom) 86%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
  }
  .home-page .cta-bar .btn-primary {
    display: block;
    width: 100%;
    padding: 0.95rem 1rem;
    font-size: 1.08rem;
  }
  .home-page .cta-bar .btn-subtle { margin-top: 0.15rem; }

  .popover-reactions { gap: 0.8rem; }
}

/* ---------- full-page scene on phones ----------
 * Each scene is a wide 3:2 illustration. On a portrait phone the scene fills
 * the screen height and spills past the width, so the child swipes sideways
 * to explore; the floating pills stay put at the top. Covers portrait phones
 * and short landscape phones; the scene's fill axis flips by orientation
 * (see the landscape override below). */
@media (max-width: 559px), (max-height: 500px) and (orientation: landscape) {
  .scene-page .scene-svg-wrap {
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .scene-page .scene-svg-wrap::-webkit-scrollbar { display: none; }
  .scene-page .scene-svg {
    display: block;
    height: 100%;
    width: auto;
    max-height: none;
    max-width: none;
  }

  /* tighter pills on small screens */
  .scene-overlay-bar { padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 0.5rem 0; }
  .scene-back { padding: 0.4rem 0.7rem; }
  .whole-chip { font-size: 0.95rem; padding: 0.4rem 0.85rem; }
}

/* landscape phones are wider than the scene, so instead the scene fills the
 * width and the child pans up/down — still full-bleed, no empty bands. */
@media (max-height: 500px) and (orientation: landscape) {
  .scene-page .scene-svg-wrap {
    overflow-x: hidden;
    overflow-y: auto;
  }
  .scene-page .scene-svg {
    width: 100%;
    height: auto;
    max-width: none;
    max-height: none;
  }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .page, .coach-card, .popover { animation: none !important; }
  .seat-marker, .amb-cloud, .amb-cloud-slow, .amb-steam, .amb-tail,
  .av-eye, .av-breathe, .badge-pop, .item-pulse, .lamp-glow { animation: none !important; }
}

/* ---------- print (clinician report → PDF) ---------- */

@media print {
  body { background: #fff !important; color: #000; }
  body.time-night, body.time-morning, body.time-evening, body.time-day { color: #1d2233; }
  .no-print { display: none !important; }
  .page { padding: 0; margin: 0; max-width: none; animation: none; }
  .report-sheet {
    box-shadow: none; border: none; border-radius: 0;
    max-width: none; padding: 0; margin: 0;
  }
  .rpt-card, .rpt-flips li, .rpt-notes li, .rpt-table tr { break-inside: avoid; }
  .rpt-card h2 { break-after: avoid; }
  .spark-card { box-shadow: none; border: 1px solid #e5e8f3; }
  a[href]::after { content: ""; }   /* don't print URL noise */
}

/* ---------- demo mode banner + about page ---------- */

.demo-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.45rem 1rem;
  padding-top: calc(0.45rem + env(safe-area-inset-top));
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
  color: var(--on-brand);
  font-size: 0.92rem;
  box-shadow: var(--shadow);
}
.demo-banner-text strong { font-weight: 800; }
.demo-exit-btn {
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.15rem 0.85rem;
  cursor: pointer;
}
.demo-exit-btn:hover { background: rgba(255, 255, 255, 0.28); }
body.demo-active #app { padding-top: 2.6rem; }
@media print { .demo-banner { display: none !important; } }

.alt-links {
  text-align: center;
  margin: 1.4rem 0 0.4rem;
  color: var(--ink-faint);
  font-size: 0.95rem;
}
.alt-links a { color: var(--ink-soft); }
.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--accent-dark); }
.link-btn:disabled { color: var(--ink-faint); cursor: default; text-decoration: none; }

.about-page { max-width: 44rem; }
.about-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1rem;
}
.about-card h3 { margin: 0 0 0.5rem; }
.about-card p { margin: 0.5rem 0; line-height: 1.55; color: var(--ink-soft); }
.about-card p strong { color: var(--ink); }
.about-card code {
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 0.05rem 0.35rem;
  font-size: 0.88em;
}
.about-card .hint { font-size: 0.88rem; color: var(--ink-faint); }
