/* Palette taken from the invitation: paper, olive ink, gold arch, iris purple, sage leaves.
   Friends nod: the three dots (red, yellow, blue). */
:root {
  /* home page (light, invitation) */
  --paper: #f7f5ef;
  --olive: #4a5a2c;
  --olive-soft: #6e7a55;
  --gold: #d6b47a;
  --iris: #7d6bc2;
  --sage: #6f9a82;

  /* stage: same paper as the invitation, dark olive ink for reading */
  --bg: #f7f5ef;
  --panel: #fffdf8;
  --line: rgba(74, 90, 44, 0.2);
  --ink: #26301a;
  --soft: #6e7a55;

  /* speakers: label colour + translucent highlight */
  --hila: #6a57b5;              /* iris */
  --hila-hl: rgba(125, 107, 194, 0.24);
  --ben: #4c7c60;               /* sage */
  --ben-hl: rgba(111, 154, 130, 0.28);
  --both: #a5803a;              /* gold */
  --both-hl: rgba(214, 180, 122, 0.36);

  /* Friends dots */
  --f1: #e0473c;
  --f2: #f0c419;
  --f3: #3f86d0;

  --ok: #4f9a6c;
  --warn: #e8a54a;
  --size: 30px;
  --read: 33vh; /* the reading line: current sentence sits here */
  --ui: 'Assistant', system-ui, sans-serif;
  --serif: 'Frank Ruhl Libre', 'David', Georgia, serif;
  --script: 'Great Vibes', 'Snell Roundhand', cursive;
  --caps: 'Jost', 'Assistant', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior-y: none; }
body {
  margin: 0;
  font-family: var(--ui);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.home { background: var(--paper); color: var(--olive); color-scheme: light; }
body.stage { background: var(--bg); color: var(--ink); color-scheme: light; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
.stage button, .sheet button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
}
.stage button.primary, .sheet button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 700; }
button.danger { color: #b5483b; }
.hint { color: var(--soft); font-size: 14px; line-height: 1.5; }
[hidden] { display: none !important; }
.d1, .d2, .d3 { display: inline-block; width: .32em; height: .32em; border-radius: 50%; vertical-align: middle; }
.d1 { background: var(--f1); } .d2 { background: var(--f2); } .d3 { background: var(--f3); }

/* =========================================================
   Home page
   ========================================================= */
#pick {
  position: relative; overflow: hidden;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(14px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 80% at 50% 0%, #fbfaf6 0%, transparent 60%),
    var(--paper);
}
body.home { overflow: hidden; overscroll-behavior: none; }
.arch {
  position: absolute; z-index: 0; pointer-events: none;
  inset: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
  border: 2px solid var(--gold);
  border-bottom: none;
  border-radius: 50% 50% 0 0 / min(46vw, 240px) min(46vw, 240px) 0 0;
}
.iris { position: absolute; z-index: 1; pointer-events: none; width: min(50vw, 250px, 31vh); height: auto; }
.iris-top { top: -4px; right: -6px; }
#pick .iris { -webkit-user-drag: none; user-select: none; }
.iris { -webkit-mask-image: radial-gradient(120% 115% at 100% 0%, #000 58%, transparent 82%); mask-image: radial-gradient(120% 115% at 100% 0%, #000 58%, transparent 82%); }
.iris-bottom { bottom: -10px; left: -8px; transform: scaleX(-1); width: min(32.2vw, 161px, 19.6vh); opacity: .95; }
#sparkle { position: absolute; inset: 0; z-index: 3; pointer-events: none; width: 100%; height: 100%; }

/* One screen, no scrolling: three groups spread over the height; sizes follow the screen height. */
.pick-inner {
  position: relative; z-index: 2; flex: 1; min-height: 0;
  width: 100%; max-width: 340px; margin: 0 auto; text-align: center;
  display: flex; flex-direction: column; justify-content: space-evenly;
  padding-top: clamp(24px, 6vh, 60px);
  animation: rise .9s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.names {
  font-family: var(--script); font-weight: 400; color: var(--olive);
  font-size: clamp(36px, min(17vw, 9.4vh), 82px); line-height: .9; margin: 0;
  position: relative; z-index: 2;
  text-shadow: 0 0 6px var(--paper), 0 0 12px var(--paper), 0 0 18px rgba(247, 245, 239, .9);
  display: flex; flex-direction: column; align-items: center;
}
.names .amp { font-size: .55em; line-height: 1; margin: .05em 0 .08em; color: var(--olive-soft); }
.wedding {
  font-family: var(--caps); font-weight: 500; letter-spacing: .22em;
  font-size: 13px; margin: clamp(8px, 2vh, 18px) 0 0; color: var(--olive);
}
.rule { width: 110px; border: 0; border-top: 1.5px solid var(--olive); margin: clamp(6px, 1.4vh, 14px) auto; opacity: .7; }
.friends {
  font-family: var(--caps); font-weight: 500; letter-spacing: .08em;
  font-size: 18px; margin: 0; color: var(--olive);
  display: inline-flex; align-items: center; gap: .32em;
}
.friends i { width: .28em; height: .28em; }
.sub { margin: 4px 0 0; font-size: 16px; color: var(--olive-soft); }
.chuppah { cursor: pointer; -webkit-tap-highlight-color: transparent; position: relative; height: clamp(56px, 24vh, 220px); min-height: 48px; flex: 0 1 auto; display: flex; justify-content: center; }
.couple { display: block; height: 100%; width: auto; opacity: .9; }
/* Lit by the glitter: gold frame, purple garlands, green plants.
   The fade exists only while lighting up — Safari would otherwise run it backwards as the page
   first appears (colours visible, then fading out). No animated filters: they pixelate on some
   desktop graphics cards. */
.chuppah .lit { position: absolute; top: 0; left: 50%; height: 100%; width: auto; transform: translateX(-50%); opacity: 0; pointer-events: none; }
.chuppah.lit .lit { transition: opacity 1.4s ease; }
.chuppah.lit .lit-frame { opacity: 1; filter: drop-shadow(0 0 2px rgba(230, 190, 100, .8)); }
.chuppah.lit .lit-flowers { opacity: .55; transition-delay: .45s; filter: drop-shadow(0 0 1px rgba(150, 120, 230, .4)); }
.chuppah.lit .lit-plants { opacity: .5; transition-delay: .9s; }
.chuppah.no-anim .lit, .chuppah.no-anim { transition: none !important; animation: none !important; }
/* Breaking the glass (every 5th tap). The stage sits exactly over the drawing, in its pixel space. */
.scene-stage {
  position: absolute; top: 0; left: 50%; height: 100%; aspect-ratio: 272 / 264;
  transform: translateX(-50%); pointer-events: none;
}
.couple-alt { position: absolute; top: 0; left: 50%; height: 100%; width: auto; transform: translateX(-50%); opacity: 0; pointer-events: none; }
.groom-leg, .glass { position: absolute; opacity: 0; will-change: transform, opacity; }
.groom-leg { transform-origin: 50% 0; }
.glass { overflow: visible; }
.scene-stage .shards { position: absolute; inset: -40% -20% 0; width: 140%; height: 140%; pointer-events: none; }

.resume {
  display: block; width: 100%; margin: 0 0 10px;
  background: var(--olive); color: var(--paper); border: 0;
  border-radius: 999px; padding: clamp(12px, 1.9vh, 16px); font-size: 19px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(74, 90, 44, .25);
}
.who-q { font-family: var(--serif); font-size: 18px; margin: clamp(4px, 1vh, 10px) 0 clamp(6px, 1vh, 10px); color: var(--olive); }
.roles { display: grid; gap: clamp(6px, 1vh, 10px); }
.role {
  display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 12px;
  text-align: right; padding: clamp(7px, 1.2vh, 12px) 18px;
  background: rgba(255, 255, 255, .72); color: var(--olive);
  border: 1.5px solid rgba(74, 90, 44, .22); border-radius: 999px;
  font-size: 19px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  transition: transform .15s, border-color .2s, background-color .2s;
}
.role b { font-weight: 700; }
.role:active { transform: scale(.98); }
.role small { grid-column: 2; font-size: 13px; font-weight: 400; color: var(--olive-soft); }
.role .dot { grid-row: span 2; width: 14px; height: 14px; border-radius: 50%; }
.role.hila .dot { background: var(--iris); }
.role.ben .dot { background: var(--sage); }
.role.op .dot { background: var(--gold); }
.role.current { border-color: var(--olive); background: #fff; }
/* Once a role is chosen, "continue" is the main action and the roles shrink to one row of chips. */
#topic.has-role .roles { grid-template-columns: repeat(3, 1fr); }
#topic.has-role .role { grid-template-columns: auto auto; justify-content: center; column-gap: 6px; padding: 9px 6px; font-size: 16px; }
#topic.has-role .role small { display: none; }
#topic.has-role .role .dot { grid-row: auto; width: 10px; height: 10px; }
#topic .link { background: none; border: 0; padding: 6px; margin-top: 4px; color: var(--olive); text-decoration: underline; text-underline-offset: 3px; font-size: 15px; }
#pick .hint { color: var(--olive-soft); font-size: 13px; margin: 0; }

/* Round topic buttons under the chuppah: light, framed (gold ring + thin inner line), a line drawing inside. */
/* First visit: once the chuppah is coloured, a gold ring ripples from it and a short line where the
   buttons will be says to tap it. Both go away with the first tap. */
.menu-area { display: grid; }
.menu-area > * { grid-area: 1 / 1; }
.tap-hint {
  align-self: center; margin: 0; font-size: 16px; color: var(--olive-soft);
  opacity: 0; transition: opacity .9s ease; pointer-events: none;
}
#pick.hint .tap-hint { opacity: 1; }
#pick.menus .tap-hint { display: none; }
.tap-ring {
  position: absolute; z-index: 1; left: 50%; top: 52%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; border: 2px solid var(--gold); opacity: 0; pointer-events: none;
}
#pick.hint .tap-ring { animation: tap-ring 2.4s ease-out .3s infinite; }
@keyframes tap-ring {
  0% { opacity: 0; transform: scale(.5); }
  18% { opacity: .95; }
  100% { opacity: 0; transform: scale(2.3); }
}
/* The topic buttons appear only after the chuppah's first tap (the glass is broken): they fade in.
   Until then they keep their place, so nothing on the page moves. */
.topics { visibility: hidden; opacity: 0; }
#pick.menus .topics { visibility: visible; opacity: 1; }
#pick.menus-in .topics { animation: menus-in 1.1s ease both; }
@keyframes menus-in { from { opacity: 0; transform: translateY(8px); } }
.topics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; align-items: start; }
.topics button {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: 0; padding: 2px 0; color: var(--olive);
}
.ring {
  display: grid; place-items: center;
  width: clamp(48px, min(15vw, 8vh), 64px); aspect-ratio: 1; border-radius: 50%;
  background: rgba(255, 255, 255, .8); color: var(--olive);
  border: 1.5px solid var(--gold);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .8), inset 0 0 0 4px rgba(74, 90, 44, .18), 0 3px 10px rgba(74, 90, 44, .08);
  transition: transform .15s ease;
}
.ring svg { width: 62%; height: 62%; }
.topics b { font-size: clamp(12px, 3.4vw, 14px); font-weight: 600; white-space: nowrap; }
.topics button:active .ring { transform: scale(.94); }

/* A topic's own page: the invitation's paper, the small arch back button, the topic's round icon. */
body.topic-open { background: var(--paper); color: var(--olive); }
#topic {
  min-height: 100vh; min-height: 100dvh;
  padding: calc(8px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: radial-gradient(120% 60% at 50% 0%, #fbfaf6 0%, transparent 60%), var(--paper);
}
.topic-bar { display: flex; }
#topic button.back {
  display: grid; place-items: center; width: 52px; height: 44px; padding: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--olive);
}
#topic button.back:active { background: rgba(74, 90, 44, .1); }
.topic-page { max-width: 420px; margin: 0 auto; text-align: center; animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
.topic-head { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 4px 0 20px; }
.topic-head .ring { width: 84px; }
.topic-head h1 { font-family: var(--serif); font-weight: 500; font-size: 30px; margin: 0; color: var(--olive); }
.card {
  background: rgba(255, 255, 255, .7); border: 1.5px solid rgba(214, 180, 122, .7); border-radius: 20px;
  padding: 18px 16px; margin: 0 0 14px;
}
.card h2 { font-family: var(--serif); font-weight: 500; font-size: 21px; margin: 0 0 14px; }
.soon { color: var(--olive-soft); font-size: 16px; margin: 6px 0; }

/* Directions: the venue, navigation buttons, an abstract line map of the area, the evening's schedule */
.venue-title { font-family: var(--serif); font-weight: 500; font-size: 28px; margin: 0; }
.venue-place { margin: 2px 0 6px; font-size: 18px; }
.venue-when { margin: 0 0 16px; color: var(--olive-soft); font-size: 15px; }
.nav-buttons { display: grid; gap: 10px; }
.nav-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 16px; border-radius: 999px; text-decoration: none; font-weight: 700; font-size: 17px;
  color: var(--olive); background: rgba(255, 255, 255, .85); border: 1.5px solid rgba(74, 90, 44, .3);
}
.nav-btn.waze { background: var(--olive); color: var(--paper); border-color: var(--olive); box-shadow: 0 6px 18px rgba(74, 90, 44, .22); }
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn:active { transform: scale(.98); }
.map-card { padding: 10px; }
.venue-map { display: block; width: 100%; height: auto; border-radius: 12px; background: #fbfaf5; }
.venue-map .roads path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.venue-map .r-main { stroke: var(--gold); stroke-width: 5; }
.venue-map .r-mid { stroke: var(--olive); stroke-width: 2.4; opacity: .75; }
.venue-map .r-small { stroke: var(--olive); stroke-width: 1.3; opacity: .4; }
.venue-map text { font-family: var(--ui); fill: var(--olive); text-anchor: middle; }
.venue-map .town { font-size: 12px; fill: var(--olive-soft); }
.venue-map .shield rect { fill: #fffdf8; stroke: var(--olive); stroke-width: 1.2; }
.venue-map .shield text { font-size: 11px; font-weight: 700; }
.venue-map .junction circle { fill: #fffdf8; stroke: var(--gold); stroke-width: 2; }
.venue-map .junction text { font-size: 11px; text-anchor: start; paint-order: stroke; stroke: #fbfaf5; stroke-width: 4px; }
.venue-map .venue .dot { fill: var(--iris); stroke: #fff; stroke-width: 2; }
.venue-map .venue .pulse { fill: none; stroke: var(--iris); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: venue-pulse 2.4s ease-out infinite; }
@keyframes venue-pulse { from { opacity: .8; transform: scale(.7); } to { opacity: 0; transform: scale(2.4); } }
.venue-map .venue-name { font-family: var(--serif); font-size: 15px; font-weight: 700; text-anchor: end; paint-order: stroke; stroke: #fbfaf5; stroke-width: 4px; }
.venue-map .venue-sub { font-size: 11px; text-anchor: end; paint-order: stroke; stroke: #fbfaf5; stroke-width: 4px; }
.venue-map .compass path { fill: none; stroke: var(--olive); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.venue-map .compass text { font-size: 11px; }
.map-note { margin: 8px 4px 2px; font-size: 13px; color: var(--olive-soft); }
.schedule ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.schedule li { display: flex; justify-content: center; gap: 12px; font-size: 17px; }
.schedule time { font-family: var(--caps); font-weight: 500; letter-spacing: .04em; min-width: 3.2em; direction: ltr; }
@media (prefers-reduced-motion: reduce) { .venue-map .venue .pulse { animation: none; opacity: 0; } }

/* =========================================================
   Stage
   ========================================================= */
#bar {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  background: linear-gradient(var(--bg) 75%, transparent);
  font-size: 15px; color: var(--soft);
}
#where { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#clock { font-variant-numeric: tabular-nums; }
.net { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; }
.net.on { background: var(--ok); }
.stage button.icon { padding: 8px; border-radius: 50%; background: transparent; border-color: transparent; color: var(--soft); display: grid; place-items: center; }

/* Dark mode (settings switch): same layout and arch, dark olive night palette. */
body.stage.dark {
  --bg: #171a14; --panel: #22261d; --line: #3a4031; --ink: #f5f0e4; --soft: #b7b29f;
  --hila: #b2a3f0; --hila-hl: rgba(140, 120, 225, 0.40);
  --ben: #8fcaa6;  --ben-hl: rgba(95, 160, 120, 0.40);
  --both: #e2c48a; --both-hl: rgba(214, 180, 122, 0.36);
  --ok: #8fcaa6;
  color-scheme: dark;
}
body.stage.dark .s.cur { color: #fff; }
body.stage.dark .stage-head, body.stage.dark .stage-head .friends, body.stage.dark .finale-names { color: #e9dfc3; }
body.stage.dark .sh-names span, body.stage.dark .sh-sub { color: var(--soft); }
body.stage.dark .mic { background: rgba(34, 38, 29, .92) !important; box-shadow: none; }
body.stage.dark button.back { color: var(--both); }
body.stage.dark .op-btn.primary { background: var(--both); border-color: var(--both); color: #1d1a12; }
body.stage.dark .sheet { color-scheme: dark; }
body.stage.dark button.danger { color: #f19a8e; }

/* The script sits inside the invitation's gold arch; the logo lives under the arch's crown. */
#script {
  position: relative;
  max-width: 760px;
  margin: calc(66px + env(safe-area-inset-top)) 12px 0;
  padding: 0 18px 70vh;
  border: 2px solid rgba(214, 180, 122, .85);
  border-bottom: 0;
  border-radius: 50% 50% 0 0 / min(42vw, 220px) min(42vw, 220px) 0 0;
  font-family: var(--serif);
  font-size: var(--size);
  line-height: 1.55;
}
.part { margin: 0 0 1.4em; }
.part.hila { --c: var(--hila); --hl: var(--hila-hl); }
.part.ben { --c: var(--ben); --hl: var(--ben-hl); }
.part.both { --c: var(--both); --hl: var(--both-hl); }
.who {
  font-family: var(--ui); font-size: 15px; font-weight: 700; letter-spacing: .06em;
  display: flex; align-items: center; gap: 8px; margin-bottom: .3em; color: var(--c);
}
.who::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.part p { margin: 0 0 .6em; }

/* The live sentence gets its reader's colour; upcoming text steps back; partner's parts dimmer. */
.s {
  transition: opacity .3s, background-color .3s, color .3s;
  border-radius: 8px; padding: .04em .14em;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.part.mine .s { opacity: .8; }
.part:not(.mine) .s { opacity: .45; }
.s.past { opacity: .28 !important; }
.s.cur { opacity: 1 !important; color: #1b2410; background: var(--hl); }

.finale { text-align: center; padding: 1.2em 0 0; opacity: .85; }
.finale-names { font-family: var(--script); font-size: 1.6em; color: var(--olive); }
.finale-names span { font-size: .7em; }
.dots { display: inline-flex; gap: .5em; margin-top: .4em; font-size: 28px; }

/* Reading-line marker: appears while a speaker scrolls, shows where the highlight will land. */
#readline {
  position: fixed; z-index: 4; pointer-events: none; top: var(--read); right: 0; left: 0;
  height: 0; border-top: 1.5px dashed var(--both); opacity: 0; transition: opacity .2s;
}
body.stage.scrolling #readline { opacity: .55; }
body:not(.stage) #readline { display: none; }

/* Operator: everything readable, sentences tappable. */
body.op #script { padding-bottom: 75vh; }
@media (min-width: 784px) { #script { margin-left: auto; margin-right: auto; } }

.stage-head {
  /* fills the space above the reading line, so sentence 1 starts exactly on it */
  height: calc(var(--read) - 68px - env(safe-area-inset-top));
  min-height: 170px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--olive); font-family: var(--ui); position: relative;
}
.sh-names { font-family: var(--script); font-size: 44px; line-height: 1; }
.sh-names span { font-size: .6em; color: var(--olive-soft); }
.stage-head .friends { font-size: 14px; margin-top: 10px; }
.sh-sub { margin: 4px 0 0; font-size: 14px; color: var(--olive-soft); }
.stage-iris {
  position: absolute; top: -20px; right: -26px; width: 104px; height: auto; pointer-events: none;
  -webkit-mask-image: radial-gradient(120% 115% at 100% 0%, #000 58%, transparent 82%);
  mask-image: radial-gradient(120% 115% at 100% 0%, #000 58%, transparent 82%);
}

/* Back to the home page: a small arch (like the invitation) with an arrow through its doorway */
.stage button.back {
  display: grid; place-items: center; flex: none;
  width: 52px; height: 44px; padding: 0; border-radius: 12px;
  background: transparent; border: 0; color: var(--olive);
}
.stage button.back:active { background: var(--hl, rgba(74, 90, 44, .1)); }
body.op .part:not(.mine) .s { opacity: .85; }
body.op .s { cursor: pointer; touch-action: manipulation; }
body.op #script, #opbar, #mic, #bar, #pick { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* Mic toggle (speakers) */
.mic {
  position: fixed; z-index: 5; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px;
  border-radius: 999px !important; padding: 10px 16px 10px 14px !important;
  background: rgba(255, 253, 248, .95) !important; color: var(--soft); font-size: 14px; box-shadow: 0 4px 14px rgba(74, 90, 44, .15);
}
.mic[aria-pressed="true"] { color: var(--ink); border-color: var(--soft) !important; }
.mic.listening { border-color: var(--ok) !important; color: var(--ok); }
.mic.listening svg { animation: pulse 1.4s ease-in-out infinite; }
.mic.paused { border-color: var(--warn) !important; color: #9a5a12; }
body.stage.dark .mic.paused { color: var(--warn); }
@keyframes pulse { 50% { opacity: .4; } }

/* Operator controls */
#opbar {
  position: fixed; z-index: 5; inset: auto 0 0 0;
  display: grid; grid-template-columns: 1fr 2fr; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}
.stage .op-btn { font-size: 22px; padding: 22px 12px; border-radius: 18px; }
.stage .op-btn.primary { background: var(--olive); border-color: var(--olive); color: var(--paper); }

/* =========================================================
   Sheets (settings, editor) — always on the dark stage palette
   ========================================================= */
.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(38, 48, 26, .35); display: flex; align-items: flex-end; justify-content: center; color: var(--ink); color-scheme: light; }
.sheet-panel {
  width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--panel); border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet-panel.tall { max-height: 96vh; max-height: 96dvh; }
.sheet h2 { margin: 0 0 12px; font-size: 22px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row select { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.row input[type=range] { width: 50%; accent-color: var(--both); }
.row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--both); }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.buttons > * { flex: 1 1 140px; }
.wide { width: 100%; }
.edit-part { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 10px; }
.edit-part header { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.edit-part select { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.edit-part .grow { flex: 1; }
.edit-part button { padding: 6px 10px; font-size: 14px; }
.edit-part textarea {
  width: 100%; min-height: 140px; resize: vertical;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; font: 17px/1.5 var(--serif);
}

#toast {
  position: fixed; z-index: 20; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--olive); color: var(--paper); border-radius: 999px; padding: 8px 16px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Printed backup */
@media print {
  body { background: #fff !important; color: #000 !important; }
  #bar, #mic, #opbar, .sheet, #toast, #pick, .finale { display: none !important; }
  #script { display: block !important; padding: 0; font-size: 20pt; }
  .s, .part:not(.mine) .s { opacity: 1 !important; background: none !important; color: #000 !important; }
  .part { break-inside: avoid; }
  .part.hila .who { color: #5b47a8; } .part.ben .who { color: #3c6e52; } .part.both .who { color: #8a6a1c; }
}

