:root {
  --bg: #f4f1ff;
  --surface: #ffffff;
  --surface-2: #f0ecfb;
  --text: #1c1830;
  --muted: #6b6585;
  --border: #e2dcf2;
  --primary: #6c5ce7;
  --primary-2: #4a73e8;
  --primary-shadow: #4b3cc4;
  --primary-soft: #ece8ff;
  --gold: #ffb820;
  --gold-shadow: #d48f00;
  --gold-soft: #fff3d1;
  --good: #22b573;
  --good-shadow: #17885a;
  --good-soft: #dcf7ea;
  --bad: #ff5e6c;
  --bad-shadow: #d63b4a;
  --bad-soft: #ffe3e6;
  --pink: #ff7eb6;
  --glass: rgba(255, 255, 255, .93);
  --dialogue: rgba(255, 255, 255, .94);
  --shadow: 0 2px 4px rgba(40, 20, 120, .06), 0 12px 32px rgba(40, 20, 120, .10);
  --stage-bg: radial-gradient(ellipse at 50% 38%, #ffffff 0%, #e8e4ff 38%, #f4efe8 82%);
  --stage-bg-tall: radial-gradient(ellipse at 50% 26%, #ffffff 0%, #e8e4ff 45%, #f4efe8 90%);
  --radius: 20px;
  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --mood-happy: #ffb820;
  --mood-excited: #ff6fae;
  --mood-calm: #22b573;
  --mood-curious: #4a73e8;
  --mood-surprised: #9b6cff;
  --mood-sad: #6f86b0;
  --panel-w: clamp(260px, 24vw, 340px);
  --hearts-room: 150px; /* space kept beside the chat bar for the hearts counter */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0d1d;
    --surface: #1b1830;
    --surface-2: #26223f;
    --text: #f1eefc;
    --muted: #a59fc2;
    --border: #342e56;
    --primary: #8b7dff;
    --primary-2: #6f8dff;
    --primary-shadow: #5a4bd6;
    --primary-soft: #2a2550;
    --gold: #ffc83d;
    --gold-shadow: #c48c00;
    --gold-soft: #3a3018;
    --good: #3ddc97;
    --good-shadow: #20a46b;
    --good-soft: #173528;
    --bad: #ff6b7a;
    --bad-shadow: #c9404f;
    --bad-soft: #3d1d25;
    --glass: rgba(27, 24, 48, .93);
    --dialogue: rgba(27, 24, 48, .94);
    --shadow: 0 12px 32px rgba(0, 0, 0, .35);
    --stage-bg: radial-gradient(ellipse at 50% 38%, #3a2f78 0%, #1a1636 45%, #0d0b18 85%);
    --stage-bg-tall: radial-gradient(ellipse at 50% 26%, #3a2f78 0%, #1a1636 50%, #0d0b18 90%);
    --blend: screen;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f0d1d;
  --surface: #1b1830;
  --surface-2: #26223f;
  --text: #f1eefc;
  --muted: #a59fc2;
  --border: #342e56;
  --primary: #8b7dff;
  --primary-2: #6f8dff;
  --primary-shadow: #5a4bd6;
  --primary-soft: #2a2550;
  --gold: #ffc83d;
  --gold-shadow: #c48c00;
  --gold-soft: #3a3018;
  --good: #3ddc97;
  --good-shadow: #20a46b;
  --good-soft: #173528;
  --bad: #ff6b7a;
  --bad-shadow: #c9404f;
  --bad-soft: #3d1d25;
  --glass: rgba(27, 24, 48, .93);
  --dialogue: rgba(27, 24, 48, .94);
  --shadow: 0 12px 32px rgba(0, 0, 0, .35);
  --stage-bg: radial-gradient(ellipse at 50% 38%, #3a2f78 0%, #1a1636 45%, #0d0b18 85%);
  --stage-bg-tall: radial-gradient(ellipse at 50% 26%, #3a2f78 0%, #1a1636 50%, #0d0b18 90%);
  --blend: screen;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  touch-action: pan-y; /* horizontal swipes on Olla spin her instead of panning */
  display: flex; flex-direction: column; height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0; }
h2 { font-size: 1.1rem; }
h3 { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .5rem; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
code { font-size: .9em; padding: .05rem .3rem; border-radius: 6px; background: var(--surface-2); }

/* ---------- Background stage (Olla) ---------- */
#stage {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: var(--stage-bg);
}
/* A soft glow behind her in the colour of her mood. */
#stage::before {
  content: ""; position: absolute; left: 50%; top: 40%; width: min(70vw, 720px); aspect-ratio: 1;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--mood-color, var(--primary)) 28%, transparent), transparent 65%);
  transition: background .8s;
}
.stage-canvas { position: relative; display: block; width: 100%; height: 100%; }
html.over-olla, html.over-olla body { cursor: grab; }
html.spinning-olla, html.spinning-olla * { cursor: grabbing !important; user-select: none; }

html[data-mood="happy"] { --mood-color: var(--mood-happy); }
html[data-mood="excited"] { --mood-color: var(--mood-excited); }
html[data-mood="calm"] { --mood-color: var(--mood-calm); }
html[data-mood="curious"] { --mood-color: var(--mood-curious); }
html[data-mood="surprised"] { --mood-color: var(--mood-surprised); }
html[data-mood="sad"] { --mood-color: var(--mood-sad); }
[data-mood="happy"] { --m: var(--mood-happy); }
[data-mood="excited"] { --m: var(--mood-excited); }
[data-mood="calm"] { --m: var(--mood-calm); }
[data-mood="curious"] { --m: var(--mood-curious); }
[data-mood="surprised"] { --m: var(--mood-surprised); }
[data-mood="sad"] { --m: var(--mood-sad); }

/* ---------- Top bar ---------- */
.topbar {
  position: relative; z-index: 10; flex: none;
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 16px;
  padding-top: calc(.55rem + env(safe-area-inset-top, 0px));
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  background: transparent;
}
.brand { display: flex; align-items: center; gap: .55rem; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--pink)); color: #fff;
  font: 700 1rem var(--font-display); box-shadow: 0 3px 0 var(--primary-shadow);
}
.brand-name { font: 700 1.2rem var(--font-display); }
.live-badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem; border-radius: 999px;
  font: 700 .7rem var(--font-display); letter-spacing: .1em; color: #fff; background: var(--bad);
}
.live-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }
.topbar-tools { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.level-pick { display: flex; align-items: center; gap: .4rem; font: 600 .9rem var(--font-display); color: var(--muted); }
.level-pick select {
  height: 38px; padding: 0 .5rem; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer;
}
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 2px solid var(--border); border-radius: 12px; background: var(--surface);
  cursor: pointer; color: var(--text); font-size: 1rem;
}
.icon-btn:hover, .level-pick select:hover { border-color: var(--primary); }
.icon-btn[hidden] { display: none; }
.view-toggle { display: none; }
html.olla-ready .view-toggle { display: grid; } /* only once the 3D Olla is on stage */
.view-toggle svg { width: 20px; height: 20px; }
/* Chat hidden: the message list and input box fade out of the way. */
/* The Live (hands-free) button stays, so you can still talk to Olla by voice. */
.messages-panel, .composer > * { transition: opacity .25s ease, visibility .25s; }
html[data-chat="hidden"] .messages-panel,
html[data-chat="hidden"] .composer > :not(#live-toggle) { opacity: 0; visibility: hidden; pointer-events: none; }
.avatar-toggle { display: none; }
html.olla-3d .avatar-toggle { display: grid; } /* WebGL works, so avatars can be swapped */

/* ---------- Live layout: messages | Olla | mood, chat bar along the bottom ---------- */
.live {
  position: relative; z-index: 1; flex: 1; min-height: 0;
  display: grid; gap: 16px; padding: 16px;
  grid-template-columns: var(--panel-w) 1fr var(--panel-w);
  grid-template-rows: 1fr auto auto;
  grid-template-areas:
    "messages . ."
    "messages status ."
    "composer composer composer";
  pointer-events: none; /* the open middle belongs to Olla (drag to spin) */
}
.live > * { pointer-events: auto; }

.panel {
  display: flex; flex-direction: column; min-height: 0;
  background: transparent; /* Olla's stage shows through */
  border-radius: var(--radius);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem .5rem; }
.messages-panel { grid-area: messages; }

.link-button { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 0; font-size: .9rem; }
.link-button:hover { color: var(--primary); }

/* ---------- Messages ---------- */
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: .7rem; padding: .5rem 1.1rem 1rem; }
.msg { display: flex; flex-direction: column; max-width: 88%; animation: msg-in .25s ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } }
.msg.olla { align-self: flex-start; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg-bubble { padding: .55rem .85rem; border-radius: 16px; font-weight: 600; overflow-wrap: anywhere; }
.msg.olla .msg-bubble { background: var(--surface); border-bottom-left-radius: 4px; }
.msg.user .msg-bubble { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-bottom-right-radius: 4px; }
.msg-meta { margin-top: .2rem; padding: 0 .3rem; font-size: .75rem; font-weight: 700; color: var(--muted); }
.msg-bubble.typing { display: flex; gap: .3rem; padding: .8rem .9rem; }
.msg-bubble.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dots 1s ease-in-out infinite; }
.msg-bubble.typing span:nth-child(2) { animation-delay: .15s; }
.msg-bubble.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes dots { 50% { transform: translateY(-4px); opacity: .4; } }
.msg-error { align-self: center; padding: .4rem .8rem; border-radius: 12px; background: var(--bad-soft); color: var(--bad-shadow); font-size: .85rem; font-weight: 700; text-align: center; }
.chat-starters { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1.1rem 1rem; }
.chat-starters:empty { display: none; }
.chip {
  padding: .35rem .7rem; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: .88rem; text-align: left;
  background: var(--surface); border: 2px solid var(--border); border-bottom-width: 4px;
}
.chip:hover { border-color: var(--primary); }

/* ---------- Status under Olla ---------- */
.live-status {
  grid-area: status; justify-self: center; align-self: end;
  display: inline-flex; align-items: center; gap: .45rem; max-width: 100%;
  padding: .4rem .95rem; border-radius: 999px; font-weight: 700; font-size: .92rem; text-align: center;
  background: var(--glass); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.live-status:empty { visibility: hidden; }
.live-status[data-state="listening"], .live-status[data-state="hearing"] { color: var(--bad-shadow); border-color: var(--bad); }
.live-status[data-state="speaking"] { border-color: var(--primary); }
.live-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); animation: blink 1s ease-in-out infinite; }
.live-status[data-state="hearing"] .dot { animation-duration: .4s; }

/* ---------- Mood: a living orb in the top-right corner, her inner world in a popover ---------- */
.mood-wrap { position: relative; display: flex; }
.mood-btn {
  position: relative; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; flex: none;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
}
.mood-btn::before { /* soft glow in her colour */
  content: ""; position: absolute; inset: -4px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--mc1, var(--primary)) 35%, transparent), transparent 70%);
}
.mood-mini { position: relative; width: 52px; height: 52px; pointer-events: none; }
.mood-btn:hover .mood-mini, .mood-btn[aria-expanded="true"] .mood-mini { transform: scale(1.08); }
.mood-mini { transition: transform .2s; }
.mood-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* When her mood turns by itself, a ripple and a whisper. */
.mood-btn.stir::after {
  content: ""; position: absolute; inset: 4px; border-radius: 50%; pointer-events: none;
  border: 2px solid var(--mc1, var(--primary)); animation: mood-stir 1.4s ease-out forwards;
}
@keyframes mood-stir { to { transform: scale(1.9); opacity: 0; } }
.mood-whisper {
  position: absolute; right: 50px; top: 50%; translate: 0 -50%; white-space: nowrap; pointer-events: none;
  padding: .25rem .7rem; border-radius: 999px; font: 600 .85rem var(--font-display); font-style: italic;
  background: var(--glass); border: 1px solid var(--border); box-shadow: var(--shadow);
  opacity: 0; transform: translateX(8px); transition: opacity .4s, transform .4s;
}
.mood-whisper.is-shown { opacity: 1; transform: none; }

.mood-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: min(360px, calc(100vw - 24px)); max-height: calc(100dvh - 80px); overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem 1.1rem 1.1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: mood-pop-in .2s ease-out; transform-origin: top right;
}
.mood-pop[hidden] { display: none; }
@keyframes mood-pop-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
.mood-head { display: flex; align-items: center; gap: .9rem; }
.mood-orb { width: 118px; height: 118px; flex: none; margin: -10px -6px -10px -12px; }
.mood-text { min-width: 0; }
.mood-text h3 { margin-bottom: .1rem; }
.mood-label {
  font: 700 1.9rem var(--font-display); line-height: 1.05; letter-spacing: .02em;
  background: linear-gradient(90deg, var(--mc1, var(--primary)), var(--mc3, var(--pink))); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.mood-feeling { margin-top: .3rem; font-style: italic; font-weight: 600; font-size: .92rem; }
.mood-feeling:empty { display: none; }
.mood-since { margin-top: .3rem; color: var(--muted); font-size: .76rem; font-weight: 700; }
.mood-section { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--border); }
.mood-sec-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.mood-sec-head h3 { margin: 0; }
.mood-hint { color: var(--muted); font-size: .75rem; font-weight: 700; }
.mood-map { display: block; width: 100%; aspect-ratio: 1.25; }
.mood-spans { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--surface-2); }
.mood-spans button {
  padding: .15rem .55rem; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
  font: 700 .75rem var(--font-display); color: var(--muted);
}
.mood-spans button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.mood-river-wrap { position: relative; }
.mood-river { display: block; width: 100%; height: 104px; cursor: crosshair; touch-action: pan-y; }
.mood-tip {
  position: absolute; bottom: calc(100% - 6px); translate: -50% 0; z-index: 1; width: max-content; max-width: 220px; pointer-events: none;
  padding: .35rem .6rem; border-radius: 10px; font-size: .78rem; font-weight: 700; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.mood-tip[hidden] { display: none; }
.mood-tip b, .mood-moments b { color: var(--text); }
.mood-tip b i { display: inline-block; width: 8px; height: 8px; margin-right: .3rem; border-radius: 50%; background: var(--m); }
.mood-tip span { display: block; margin-top: .15rem; font-style: italic; font-weight: 600; color: var(--text); }
.mood-legend { display: flex; align-items: center; gap: .35rem; margin-top: .45rem; color: var(--muted); font-size: .72rem; font-weight: 700; }
.mood-legend span { width: 8px; height: 8px; border-radius: 50%; }
.mood-legend .lg-chat { background: var(--muted); }
.mood-legend .lg-self { margin-left: .5rem; border: 1.5px solid var(--muted); }
.mood-moments { list-style: none; margin: .7rem 0 0; padding: 0; display: grid; gap: .55rem; }
.mood-moments li { display: flex; gap: .55rem; align-items: flex-start; }
.mood-moments li > i { width: 9px; height: 9px; margin-top: .35rem; flex: none; border-radius: 50%; background: var(--m); box-shadow: 0 0 0 3px color-mix(in srgb, var(--m) 25%, transparent); }
.mood-moments b { font: 600 .92rem var(--font-display); }
.mood-moments small { margin-left: .4rem; color: var(--muted); font-size: .72rem; font-weight: 700; }
.mood-moments p { font-size: .84rem; font-style: italic; color: var(--muted); }

/* ---------- Chat bar ---------- */
.composer {
  grid-area: composer; justify-self: center; width: min(820px, calc(100% - 2 * var(--hearts-room)));
  display: flex; gap: .5rem; padding: .5rem;
  background: transparent; border-radius: 22px;
}
.chat-input {
  flex: 1; min-width: 0; padding: .7rem 1rem; border-radius: 16px; border: 2px solid var(--border);
  background: transparent; color: var(--primary); font-weight: 700; font-size: 1.02rem; /* the Send button's colour */
}
.chat-input::placeholder { color: color-mix(in srgb, var(--primary) 55%, transparent); }
.chat-input:focus { outline: none; border-color: var(--primary); }
.chat-input:disabled { opacity: .6; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; flex: none;
  padding: .55rem 1.05rem; border-radius: 16px; cursor: pointer;
  font: 600 1.02rem var(--font-display); color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-bottom-width: 5px;
  transition: transform .06s, filter .15s;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(3px); border-bottom-width: 2px; margin-bottom: 3px; }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: var(--primary-shadow); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.recording { color: #fff; background: var(--bad); border-color: var(--bad-shadow); animation: rec 1s ease-in-out infinite; }
@keyframes rec { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--bad) 30%, transparent); } }
#live-toggle.on { color: #fff; background: var(--good); border-color: var(--good-shadow); }
/* Mic buttons only appear when the server has Bailian ASR and the browser allows a microphone. */
.needs-asr { display: none; }
body.has-asr .needs-asr { display: inline-flex; }

/* ---------- Hearts: credits for talking, bottom left ---------- */
.hearts-wrap { grid-area: composer; justify-self: start; align-self: center; position: relative; z-index: 20; }
.hearts {
  position: relative;
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .4rem .8rem .4rem .6rem; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--border); box-shadow: var(--shadow);
  font: 700 1.1rem var(--font-display); font-variant-numeric: tabular-nums; color: var(--text); cursor: pointer;
}
.hearts:hover, .hearts[aria-expanded="true"] { border-color: var(--bad); }
.hearts-icon { width: 22px; height: 22px; fill: var(--bad); filter: drop-shadow(0 2px 0 var(--bad-shadow)); }
/* Days in a row you've talked with Olla. */
.hearts-streak { display: inline-flex; align-items: center; gap: .15rem; margin-left: .3rem; padding-left: .55rem; border-left: 1px solid var(--border); }
.streak-icon { width: 22px; height: 22px; fill: var(--gold); filter: drop-shadow(0 2px 0 var(--gold-shadow)); }
/* Before today's first chat, the heart beats softly to invite you in. */
.hearts.bonus-waiting .hearts-icon { animation: heartbeat 1.6s ease-in-out infinite; }
@keyframes heartbeat { 0%, 40%, 100% { transform: scale(1); } 20% { transform: scale(1.18); } }
.hearts.pop .hearts-icon { animation: heart-pop .5s ease-out; }
@keyframes heart-pop { 40% { transform: scale(1.45); } }
.hearts-gain {
  position: absolute; left: 50%; bottom: 100%; translate: -50% 0; white-space: nowrap; pointer-events: none;
  font: 700 .9rem var(--font-display); color: var(--bad); text-shadow: 0 1px 0 var(--surface);
  animation: heart-float 1.6s ease-out forwards;
}
@keyframes heart-float { from { opacity: 1; transform: translateY(4px); } to { opacity: 0; transform: translateY(-28px); } }

/* Popover above the heart: hearts gained per day, last 7 days. */
.hearts-trend {
  position: absolute; left: 0; bottom: calc(100% + 10px);
  width: min(280px, calc(100vw - 32px)); padding: .9rem 1rem .8rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: trend-in .18s ease-out;
}
.hearts-trend[hidden] { display: none; }
@keyframes trend-in { from { opacity: 0; transform: translateY(6px); } }
.hearts-trend h3 { margin-bottom: .2rem; }
.trend-head { display: flex; align-items: baseline; gap: .4rem; margin-bottom: .8rem; font-size: .85rem; font-weight: 700; color: var(--muted); }
.trend-head b { font: 700 1.6rem var(--font-display); color: var(--text); font-variant-numeric: tabular-nums; }
.trend-bars { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.trend-day { position: relative; display: flex; flex-direction: column; align-items: center; gap: .35rem; outline: none; cursor: default; }
.trend-track {
  position: relative; width: 100%; height: 96px; display: flex; align-items: flex-end; justify-content: center;
  border-bottom: 1px solid var(--border); /* baseline */
}
.trend-bar { width: 60%; max-width: 22px; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--bad) 55%, var(--surface)); transition: height .3s ease-out; }
.trend-day.is-today .trend-bar { background: var(--bad); }
.trend-day:hover .trend-bar, .trend-day:focus-visible .trend-bar { background: var(--bad-shadow); }
.trend-label { font-size: .72rem; font-weight: 700; color: var(--muted); }
.trend-day.is-today .trend-label { color: var(--text); }
.trend-tip {
  position: absolute; bottom: calc(100% + 4px); left: 50%; translate: -50% 0; z-index: 1;
  padding: .25rem .5rem; border-radius: 8px; white-space: nowrap; pointer-events: none;
  background: var(--text); color: var(--surface); font-size: .75rem; font-weight: 700;
  opacity: 0; transition: opacity .12s;
}
.trend-day:first-child .trend-tip { left: 0; translate: 0 0; }
.trend-day:last-child .trend-tip { left: auto; right: 0; translate: 0 0; }
.trend-day:hover .trend-tip, .trend-day:focus-visible .trend-tip { opacity: 1; }

/* ---------- Profile: Olla's personality and memory ---------- */
.profile {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0;
  border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.profile::backdrop { background: rgba(15, 10, 40, .45); }
.profile-body { display: flex; flex-direction: column; gap: 1.1rem; padding: 1rem 1.2rem 1.3rem; }
.profile-head { display: flex; align-items: center; justify-content: space-between; }
.profile-head h2 { margin: 0; font: 700 1.3rem var(--font-display); }
.profile-section { display: flex; flex-direction: column; gap: .5rem; }
.field-label { margin: 0; font: 600 1rem var(--font-display); }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.field-hint { margin: 0; font-size: .85rem; color: var(--muted); }
.field {
  width: 100%; padding: .6rem .8rem; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; resize: vertical;
}
.field:focus { outline: none; border-color: var(--primary); }
.persona-picks { display: flex; flex-wrap: wrap; gap: .4rem; }
.persona-picks .chip[aria-checked="true"] { color: #fff; background: var(--primary); border-color: var(--primary-shadow); }
.switch { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.switch input { accent-color: var(--primary); width: 16px; height: 16px; }
.memory-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; max-height: min(360px, 50dvh); overflow-y: auto; }
.memory-list li { display: flex; align-items: center; gap: .3rem; padding: .2rem .3rem .2rem .2rem; border-radius: 12px; background: var(--surface-2); border: 2px solid transparent; }
.memory-list li:focus-within { border-color: var(--primary); }
.memory-list .memory-text { flex: 1; min-width: 0; padding: .3rem .5rem; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; }
.memory-list .memory-text:focus { outline: none; }
.memory-list .forget { flex: none; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .95rem; padding: .2rem .4rem; border-radius: 8px; }
.memory-list .forget:hover { color: var(--bad); background: var(--bad-soft); }
.memory-list .empty { background: none; padding: 0; color: var(--muted); font-weight: 600; font-size: .9rem; }
.memory-add { display: flex; gap: .5rem; }
.memory-add .btn { padding: .45rem .9rem; }
.profile .link-button { align-self: flex-start; }

/* ---------- Avatar picker ---------- */
.avatars { width: min(680px, calc(100vw - 32px)); }
.phone-qr { width: min(380px, calc(100vw - 32px)); }
.qr-box { display: grid; place-items: center; align-self: center; width: min(260px, 100%); aspect-ratio: 1; padding: 12px; border-radius: 16px; background: #fff; color: #333; font-size: .9rem; text-align: center; }
.qr-box svg { display: block; width: 100%; height: 100%; }
.qr-url { align-self: center; font: 700 1rem var(--font-display); color: var(--primary); word-break: break-all; text-align: center; }
.qr-pick { align-self: stretch; }
.avatars .field-hint.is-error { color: var(--bad); font-weight: 700; }
.avatar-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem;
  max-height: min(560px, calc(100dvh - 200px)); overflow-y: auto; padding: 2px;
}
@media (max-width: 420px) { .avatar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.avatar-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .35rem .35rem .45rem; border-radius: 16px; cursor: pointer; font: inherit; color: var(--text);
  background: var(--surface-2); border: 2px solid var(--border); border-bottom-width: 4px;
}
.avatar-tile:hover, .avatar-tile:focus-visible { border-color: var(--primary); outline: none; }
.avatar-tile img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--border); }
.avatar-name { margin-top: .2rem; font-weight: 800; font-size: .9rem; line-height: 1.2; text-align: center; }
.avatar-size { font-size: .75rem; font-weight: 700; color: var(--muted); }
.avatar-tile[aria-checked="true"] { background: var(--primary-soft); border-color: var(--primary); border-bottom-color: var(--primary-shadow); }
.avatar-tile[aria-checked="true"]::after {
  content: "✓"; position: absolute; top: .55rem; right: .55rem; display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; font-size: .8rem;
}
.avatar-pic { position: relative; width: 100%; }
.avatar-tile.is-loading img { opacity: .45; }
.avatar-tile.is-loading .avatar-pic::after {
  content: ""; position: absolute; top: calc(50% - 16px); left: calc(50% - 16px);
  width: 32px; height: 32px; box-sizing: border-box; border-radius: 50%;
  border: 4px solid var(--primary-soft); border-top-color: var(--primary);
  animation: avatar-spin .8s linear infinite;
}
@keyframes avatar-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .avatar-tile.is-loading .avatar-pic::after { animation-duration: 2.4s; } }


/* ---------- Dock (bottom right): tape deck and backpack ---------- */
/* A vertical stack in the bottom-right corner. The dock itself is one button tall
   (bottom-aligned with the composer) and the stack grows upward out of it, so it
   doesn't stretch the composer row. Popovers open to the left, from the dock's base. */
.dock {
  grid-area: composer; justify-self: end; align-self: end; position: relative; z-index: 20;
  display: flex; flex-direction: column; justify-content: flex-end; gap: .55rem; height: 46px;
}
.dock > * { flex: none; }
.dock-slot { position: static; }
.dock-btn {
  display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border-radius: 14px; cursor: pointer;
  /* Transparent: just a white line icon floating over the scene, with a soft shadow to stay readable. */
  background: transparent; border: 0; color: #fff; box-shadow: none;
  filter: drop-shadow(0 1px 2px rgba(40, 20, 50, .55)) drop-shadow(0 0 6px rgba(40, 20, 50, .25));
  transition: transform .15s, background-color .15s;
}
.dock-btn:hover, .dock-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .16); transform: translateX(-2px); }
.dock-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.dock-btn svg.ln { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tape-btn .reel { transform-box: fill-box; transform-origin: center; stroke-dasharray: 3 1.2; }
.tape-btn.is-playing { color: var(--pink); }
.tape-btn.is-playing .reel { animation: reel 2.2s linear infinite; }
@keyframes reel { to { transform: rotate(360deg); } }

.dock-pop {
  position: absolute; right: calc(100% + 12px); bottom: 0; z-index: 30;
  width: min(360px, calc(100vw - 24px)); max-height: calc(100dvh - 150px); overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem 1.05rem 1.05rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: dock-in .2s ease-out; transform-origin: bottom right;
}
.dock-pop[hidden] { display: none; }
@keyframes dock-in { from { opacity: 0; transform: translateX(8px) scale(.97); } }

/* The cassette: its shell takes the current track's colour; reels turn while it plays. */
.cassette {
  --tape: #ffb3cb;
  position: relative; padding: 12px 14px 12px; border-radius: 16px; border: 2.5px solid #4b3346;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tape) 70%, #fff), var(--tape));
  box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--tape) 70%, #4b3346), 0 6px 16px color-mix(in srgb, var(--tape) 35%, transparent);
  transition: background .6s;
}
.tape-pop { --tape: #ffb3cb; }
.tape-pop .cassette { --tape: inherit; }
.cassette-label {
  float: left; width: 64px; height: 64px; margin-right: 10px; border-radius: 10px; overflow: hidden;
  border: 2px solid #4b3346; background: #fff; box-shadow: 0 2px 0 rgba(75, 51, 70, .25);
}
.tape-cover { display: block; width: 100%; height: 100%; }
.cassette-meta {
  display: flex; flex-direction: column; justify-content: center; min-height: 64px; padding: .3rem .6rem; border-radius: 10px;
  background: #fffaf2; border: 2px solid #4b3346; color: #4b3346;
  background-image: repeating-linear-gradient(transparent 0 17px, rgba(75, 51, 70, .12) 17px 18px);
}
.cassette-meta b { font: 700 1.05rem var(--font-display); line-height: 1.15; }
.cassette-meta span { font-size: .78rem; font-weight: 700; opacity: .7; }
.cassette-window {
  clear: both; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  margin: 10px auto 0; width: 72%; height: 38px; padding: 0 8px; border-radius: 20px;
  background: rgba(255, 255, 255, .55); border: 2px solid #4b3346;
}
.cassette-window .reel {
  width: 28px; height: 28px; flex: none; border-radius: 50%; border: 2px solid #4b3346;
  background: radial-gradient(circle, #fff 0 22%, transparent 23%), conic-gradient(#4b3346 0 8%, #fff 8% 25%, #4b3346 25% 33%, #fff 33% 50%, #4b3346 50% 58%, #fff 58% 75%, #4b3346 75% 83%, #fff 83%);
}
.tape-pop.is-playing .cassette-window .reel { animation: reel 2.4s linear infinite; }
.tape-band { flex: 1; height: 12px; border-radius: 6px; background: linear-gradient(#6b4a3a, #4a3226); }
.cassette-screw { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #fff; border: 1.5px solid #4b3346; }
.cassette-screw.s1 { left: 6px; top: 6px; } .cassette-screw.s2 { right: 6px; top: 6px; }
.cassette-screw.s3 { left: 6px; bottom: 9px; } .cassette-screw.s4 { right: 6px; bottom: 9px; }

.tape-controls { display: flex; align-items: center; gap: .45rem; margin: .85rem 0 .2rem; }
.tape-ctl {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
}
.tape-ctl:hover { border-color: var(--primary); }
.tape-ctl svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tape-play { width: 46px; height: 46px; border: 0; color: #fff; background: linear-gradient(135deg, var(--primary), var(--pink)); box-shadow: 0 3px 0 var(--primary-shadow); }
.tape-play svg { width: 22px; height: 22px; stroke: none; }
.tape-vol { display: flex; align-items: center; gap: .35rem; flex: 1; min-width: 0; margin-left: .3rem; color: var(--muted); }
.tape-vol svg { width: 20px; height: 20px; flex: none; fill: currentColor; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.tape-vol input { flex: 1; min-width: 0; accent-color: var(--pink); }
.tape-head { margin: .9rem 0 .5rem; }
.tape-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.tape-item { position: relative; }
.tape-pick {
  display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: .5rem; align-items: center;
  width: 100%; padding: .4rem; border-radius: 14px; cursor: pointer; text-align: left;
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
}
.tape-pick:hover { border-color: var(--primary); }
.tape-item.is-current .tape-pick { border-color: var(--pink); background: color-mix(in srgb, var(--pink) 10%, var(--surface)); }
.tape-thumb { grid-row: 1 / 3; width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid #4b3346; overflow: hidden; }
.tape-plus { display: grid; place-items: center; font: 700 1.5rem var(--font-display); color: var(--primary); border-style: dashed; border-color: var(--primary); background: var(--primary-soft); }
.tape-name { font: 600 .84rem var(--font-display); line-height: 1.12; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.tape-sub { font-size: .7rem; font-weight: 700; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tape-eq { position: absolute; left: 14px; top: 14px; width: 28px; height: 28px; display: none; align-items: flex-end; justify-content: center; gap: 2px; padding-bottom: 6px; border-radius: 8px; background: rgba(75, 51, 70, .35); }
.tape-item.is-playing .tape-eq { display: flex; }
.tape-eq i { width: 4px; height: 6px; border-radius: 2px; background: #fff; animation: eq .9s ease-in-out infinite; }
.tape-eq i:nth-child(2) { animation-delay: -.3s; } .tape-eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 50% { height: 15px; } }
.tape-del {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 800; line-height: 1;
}
.tape-del:hover { color: var(--bad); border-color: var(--bad); }
.tape-note { margin-top: .7rem; color: var(--muted); font-size: .74rem; font-weight: 700; }

/* Backpack */
.bag-pop h3 { margin-bottom: .15rem; }
.bag-hint { color: var(--muted); font-size: .8rem; font-weight: 600; margin-bottom: .7rem; }
.bag-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; }
.bag-item {
  display: flex; flex-direction: column; align-items: center; gap: .15rem; width: 100%; padding: .45rem .2rem .35rem;
  border-radius: 14px; border: 2px solid var(--border); border-bottom-width: 4px; background: var(--surface); color: var(--text);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.bag-item:hover { border-color: var(--primary); }
.bag-item:hover .bag-art { animation: wiggle .5s ease-in-out; }
@keyframes wiggle { 30% { transform: rotate(-8deg) scale(1.08); } 70% { transform: rotate(6deg) scale(1.08); } }
.bag-art { width: 54px; height: 54px; pointer-events: none; }
.bag-art img { display: block; width: 100%; height: 100%; }
.bag-item span { font: 600 .72rem var(--font-display); line-height: 1.1; text-align: center; pointer-events: none; }
.bag-pop.is-dragging { opacity: .3; pointer-events: none; transition: opacity .2s; }

.item-layer { position: fixed; inset: 0; z-index: 100; width: 100%; height: 100%; pointer-events: none; }
html.holding-item, html.holding-item * { cursor: grabbing !important; }

/* Scenes */
.scene-pop h3 { margin-bottom: .6rem; }
.scene-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.scene-card {
  display: flex; flex-direction: column; gap: .1rem; width: 100%; padding: .35rem .35rem .5rem; border-radius: 14px; cursor: pointer; text-align: left;
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
}
.scene-card:hover { border-color: var(--primary); }
.scene-card.is-current { border-color: var(--pink); background: color-mix(in srgb, var(--pink) 10%, var(--surface)); }
.scene-thumb { display: block; aspect-ratio: 16 / 10; margin-bottom: .3rem; border-radius: 10px; overflow: hidden; border: 1.5px solid #4b3346; background: var(--surface-2); }
.scene-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.scene-thumb.scene-plain { background: var(--stage-bg); }
.scene-card b { font: 600 .9rem var(--font-display); padding: 0 .2rem; }
.scene-card small { font-size: .72rem; font-weight: 700; color: var(--muted); padding: 0 .2rem; }
html[data-scene]:not([data-scene="plain"]) .brand-name,
html[data-scene]:not([data-scene="plain"]) .panel-head h2,
html[data-scene]:not([data-scene="plain"]) .msg-meta,
html[data-scene]:not([data-scene="plain"]) .link-button { text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg); }

/* Olla's little speech bubble, manga style */
.olla-bubble {
  position: fixed; z-index: 15; max-width: 230px; pointer-events: none;
  padding: .45rem .85rem; border-radius: 18px; border: 2.5px solid #4b3346; background: #fff; color: #4b3346;
  font: 600 1rem var(--font-display); line-height: 1.25;
  transform: translate(-12%, -100%) scale(.6); opacity: 0; transform-origin: 10% 100%;
  transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.olla-bubble::after {
  content: ""; position: absolute; left: 14px; bottom: -11px; width: 14px; height: 14px; background: #fff;
  border-right: 2.5px solid #4b3346; border-bottom: 2.5px solid #4b3346; transform: skewX(25deg) rotate(45deg);
}
.olla-bubble.is-shown { opacity: 1; transform: translate(-12%, -100%) scale(1); }
.fx { position: fixed; z-index: 16; width: 22px; height: 22px; margin: -11px 0 0 -11px; pointer-events: none; animation: fx-pop 1.2s ease-out forwards; }
.fx svg { width: 100%; height: 100%; fill: currentColor; stroke: #4b3346; stroke-width: 1.4; }
@keyframes fx-pop {
  0% { transform: translate(0, 0) scale(0); opacity: 1; }
  25% { transform: translate(calc(var(--dx) * .5), calc(var(--dy) * .5)) scale(var(--s)); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(calc(var(--s) * .8)); opacity: 0; }
}
.msg-event {
  align-self: center; padding: .25rem .75rem; border-radius: 999px; font-size: .8rem; font-weight: 700; color: var(--muted);
  background: color-mix(in srgb, var(--pink) 14%, var(--surface)); border: 1px dashed color-mix(in srgb, var(--pink) 50%, var(--border));
}
@media (prefers-reduced-motion: reduce) {
  .tape-btn.is-playing .c-reel, .tape-pop.is-playing .cassette-window .reel, .tape-eq i { animation-duration: 8s; }
}

/* ---------- Tall screens (phones): Olla's face on top, mood strip, messages below ---------- */
@media (max-aspect-ratio: 21/20) {
  #stage { background: var(--stage-bg-tall); }
  #stage::before { top: 30%; width: 110vw; }
  .live {
    gap: 10px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 1fr auto minmax(0, 36%) auto;
    grid-template-areas: "." "status" "messages" "composer";
  }
  .messages-panel .panel-head { padding: .6rem .9rem .2rem; }
  .chat-log { padding: .3rem .9rem .7rem; }
  .chat-starters { padding: 0 .9rem .7rem; flex-wrap: nowrap; overflow-x: auto; }
  .chip { flex: none; }
  .composer { justify-self: stretch; width: auto; margin-left: 0; border-radius: 18px; padding: .4rem; gap: .35rem; }
  /* Hearts sit in the bottom-left corner above the chat bar (mirroring the dock on
     the right), so the message box gets the full width. */
  .hearts-wrap { grid-area: auto; grid-row: 1; grid-column: 1; justify-self: start; align-self: end; }
  .hearts { justify-content: center; padding-inline: .5rem .65rem; font-size: 1rem; }
  .composer .btn { padding: .5rem .7rem; }
  .btn-label { display: none; }
  .dock { grid-area: auto; grid-row: 1; grid-column: 1; justify-self: end; align-self: end; height: 42px; }
  .dock-btn { width: 42px; height: 42px; }
  .dock-pop { position: fixed; left: 12px; right: 12px; bottom: 84px; width: auto; max-height: 72dvh; transform-origin: bottom center; }
}

@media (max-width: 640px) {
  .level-label, .brand-name { display: none; }
  .topbar { gap: .4rem; padding-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px)); }
  .topbar-tools { gap: .35rem; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .topbar-tools::-webkit-scrollbar { display: none; }
  .brand { flex: none; }
  .icon-btn, .level-pick select { width: 34px; height: 34px; border-radius: 10px; font-size: .9rem; }
  .mood-btn { width: 40px; height: 40px; }
  .mood-mini { width: 48px; height: 48px; }
  .mood-pop { position: fixed; top: 56px; right: 12px; }
  .level-pick select { width: auto; }
  .live-status { display: block; font-size: .8rem; line-height: 1.45; padding: .35rem .8rem; border-radius: 14px; }
  .live-status code { white-space: nowrap; }
  .dock { gap: .3rem; }
  /* Phones: fit every top-bar icon without sideways scrolling. */
  .live-badge { display: none; }
  .phone-toggle { display: none !important; }
  .topbar-tools { gap: .3rem; }
  .topbar-tools .icon-btn { width: 32px; height: 32px; }
  .topbar-tools .icon-btn svg.ln { width: 18px; height: 18px; }
}

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

/* ---------- Stage mode (show.js): three singers dance and sing ---------- */
.stage-toggle { display: none; }
html.olla-3d .stage-toggle { display: grid; } /* needs WebGL, like the avatar picker */
.stage-toggle svg { width: 20px; height: 20px; fill: currentColor; }

.show {
  --curtain: #a3123a;
  --curtain-dark: #5c0820;
  position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; overflow: hidden; color: #fff;
  background: radial-gradient(ellipse at 50% 30%, #3b1f6e 0%, #170c2e 55%, #07040f 100%);
  font-family: Nunito, system-ui, sans-serif;
}
.show::backdrop { background: #07040f; }
.show-stage { position: absolute; inset: 0; }
.show-stage canvas { display: block; width: 100%; height: 100%; }

/* Velvet curtains: closed while the singers get ready, then they part. */
.show-curtain {
  position: absolute; top: 0; bottom: 0; width: 51%; z-index: 2; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.28) 0 6px, rgba(255,255,255,.06) 14px, rgba(0,0,0,.28) 28px),
    linear-gradient(180deg, var(--curtain) 0%, var(--curtain-dark) 100%);
  box-shadow: 0 0 40px rgba(0,0,0,.6);
  transition: transform 1.3s cubic-bezier(.6,.05,.3,1);
}
.show-curtain.left { left: 0; transform-origin: left; }
.show-curtain.right { right: 0; transform-origin: right; }
.show.is-open .show-curtain.left { transform: translateX(-88%); }
.show.is-open .show-curtain.right { transform: translateX(88%); }

.show-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 16px;
}
.show-title { display: flex; flex-direction: column; line-height: 1.1; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.show-kicker { font: 700 .7rem var(--font-display); letter-spacing: .14em; text-transform: uppercase; color: #ffc83d; }
.show-title h2 { margin: 0; font: 700 1.3rem var(--font-display); }
.show-close {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  border: 2px solid rgba(255,255,255,.3); background: rgba(10,5,25,.55); color: #fff; font-size: 1rem;
}
.show-close:hover { border-color: #fff; }

.show-status {
  position: absolute; top: 50%; left: 50%; z-index: 3; margin: 0; transform: translate(-50%, -50%);
  max-width: calc(100% - 32px); text-align: center; font: 600 1.1rem var(--font-display);
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
}
.show-status:empty { display: none; }

.show-lyrics {
  position: absolute; left: 50%; bottom: max(10px, 1.5dvh); z-index: 3; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  display: flex; flex-direction: column; align-items: center; gap: .45rem; text-align: center;
}
.show-lyrics:empty { display: none; }
.show-who {
  padding: .15rem .7rem; border-radius: 999px; background: var(--who); color: #1c1830;
  font: 700 .78rem var(--font-display); letter-spacing: .06em; text-transform: uppercase;
}
.show-line, .show-caption {
  padding: .35rem 1rem; border-radius: 16px; background: rgba(10,5,25,.32); text-shadow: 0 2px 8px rgba(0,0,0,.7);
  font: 700 clamp(1.15rem, 3.4vw, 1.9rem) var(--font-display); line-height: 1.25;
}
.show-line span { color: rgba(255,255,255,.45); transition: color .12s; }
.show-line span.sung { color: var(--sung, #fff); text-shadow: 0 0 14px color-mix(in srgb, var(--sung, #fff) 60%, transparent); }
.show-caption { color: #fff6c9; }

.show-encore { position: absolute; left: 50%; bottom: calc(max(10px, 1.5dvh) + 110px); z-index: 3; transform: translateX(-50%); }
.show-encore[hidden] { display: none; }
.show-encore:active { transform: translateX(-50%) translateY(3px); }

/* Phones held sideways: keep the status note on one or two readable lines. */
@media (max-height: 500px) {
  .live-status { display: block; max-width: min(560px, 100%); font-size: .8rem; line-height: 1.45; padding: .3rem .8rem; border-radius: 14px; }
  .live-status code { white-space: nowrap; }
  .dock { gap: .2rem; }
  .dock-btn { width: 40px; height: 40px; }
}

@media (max-width: 640px) {
  .show-title h2 { font-size: 1.1rem; }
  .show-close { width: 36px; height: 36px; }
}

/* ---------- Sign-in gate (auth.js) ---------- */
html.auth-on .topbar, html.auth-on .live { visibility: hidden; } /* app.js hasn't started yet */
.auth {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
.auth[hidden] { display: none; }
.auth-card {
  display: flex; flex-direction: column; gap: .5rem; width: min(380px, 100%);
  padding: 1.6rem 1.5rem 1.3rem; border-radius: var(--radius);
  background: var(--dialogue); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text);
}
.auth-brand { display: flex; align-items: center; gap: .55rem; margin-bottom: .4rem; }
.auth-card h1 { margin: 0; font: 700 1.5rem var(--font-display); }
.auth-sub { margin: 0 0 .6rem; color: var(--muted); }
.auth-card .field-label { margin-top: .35rem; font-size: .92rem; }
.auth-card .field { width: 100%; }
.auth-error { min-height: 1.2em; margin: .2rem 0 0; color: var(--bad); font-weight: 700; font-size: .9rem; }
.auth-error:empty { min-height: 0; }
.auth-card .btn.primary { margin-top: .4rem; padding-block: .65rem; }
.auth-card .link-button { align-self: center; margin-top: .3rem; }
.account-section .field-label b { color: var(--primary); }

/* Top bar icons: one simple line set in the text colour (black on light, white on dark). */
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn svg.ln { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stage-toggle svg.ln { fill: none; }
