@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Nunito:wght@600;700;800;900&display=swap');

:root {
  /* Cartoon palette: one dark outline color, candy fills, night-stage backdrop. */
  --ink: #2a1d40;
  --paper: #fffaf3;
  --pink: #ff8fbf;
  --pink-soft: #ffd6e8;
  --yellow: #ffd84d;
  --mint: #7fdcc0;
  --sky: #9fd8ff;
  --purple: #9a7bff;
  --purple-deep: #6c4fd9;
  --night: #2c2160;
  --lyric: #fff;
  --lyric-sung: #ffd84d;
  --lyric-next: #a8e9ff;

  --line: 3px solid var(--ink);
  --pop: 0 4px 0 var(--ink);
  --display: 'Baloo 2', Nunito, 'Arial Rounded MT Bold', Arial, sans-serif;

  font-family: Nunito, 'Arial Rounded MT Bold', Arial, sans-serif;
  font-synthesis: none;
  color: var(--ink);
  /* Night stage: two soft spotlights over twinkling dots. */
  background:
    radial-gradient(circle, #ffffff30 1.5px, transparent 2.5px) 0 0 / 30px 30px,
    radial-gradient(ellipse at 15% 0%, #ff8fbf55, transparent 55%),
    radial-gradient(ellipse at 85% 0%, #7fdcc045, transparent 55%),
    linear-gradient(#3a2b7a, #1d1542);
  background-color: var(--night);
}

/* ---- Base ---- */

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  border: 0;
  font-weight: 800;
  color: var(--ink);
  transition:
    background 0.18s,
    transform 0.18s,
    box-shadow 0.18s;
}

button:hover {
  transform: translateY(-2px);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px dashed var(--yellow);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

h1,
h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  line-height: 1.2;
}

.pill {
  padding: 8px 16px;
  border: var(--line);
  border-radius: 999px;
  box-shadow: var(--pop);
  background: #fff;
  font-size: 14px;
  white-space: nowrap;
}

.round {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: var(--line);
  border-radius: 50%;
  box-shadow: var(--pop);
  background: #fff;
  font-size: 18px;
  line-height: 1;
}

.primary {
  min-height: 48px;
  padding: 12px 24px;
  border: var(--line);
  border-radius: 999px;
  box-shadow: var(--pop);
  background: var(--pink);
  font-family: var(--display);
  font-size: 16px;
}

/* ---- Top bar ---- */

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
}

.brand span {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  color: var(--pink);
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
}

.brand small {
  display: block;
  margin-top: 3px;
  font-family: Nunito, sans-serif;
  font-size: 8px;
  letter-spacing: 2.5px;
  color: #d9ccff;
  -webkit-text-stroke: 0;
}

.bunny {
  width: 50px;
  height: 52px;
  overflow: visible;
}

/* Outline the body shapes for a hand-drawn cartoon look. */
.bunny [fill='#fffdf6'] {
  stroke: var(--ink);
  stroke-width: 8;
}

.rabbit-body {
  transform-origin: 170px 310px;
  animation: breathe 2.4s ease-in-out infinite;
}

.playing .rabbit-body {
  animation: bounce 0.5s ease-in-out infinite;
}

/* Pops out of the bunny for a few seconds when something happens, tail pointing up at it. */
.speech {
  position: absolute;
  top: calc(100% - 4px);
  left: 14px;
  max-width: min(280px, 80vw);
  padding: 8px 16px;
  border: var(--line);
  border-radius: 18px;
  box-shadow: var(--pop);
  background: #fff;
  font-size: 14px;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px) scale(0.6);
  transform-origin: 24px 0;
  transition:
    opacity 0.2s,
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.speech::before,
.speech::after {
  content: '';
  position: absolute;
  border-style: solid;
  border-color: transparent;
}

.speech::before {
  top: -12px;
  left: 18px;
  border-width: 0 9px 12px;
  border-bottom-color: var(--ink);
}

.speech::after {
  top: -7px;
  left: 20px;
  border-width: 0 7px 9px;
  border-bottom-color: #fff;
}

.speech.show {
  opacity: 1;
  transform: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* Matching chips: same height, emoji sits in a little round badge. */
.topbar-actions .pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 16px 0 5px;
  font-family: var(--display);
  font-size: 16px;
  line-height: 1;
}

.pill-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: #ffffffb3;
  font-size: 16px;
}

.pill-label {
  padding-top: 2px;
}

.pill-edit {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.4;
  transition: opacity 0.18s;
}

.name-button:hover .pill-edit {
  opacity: 1;
}

.name-button {
  max-width: 200px;
}

.name-button .pill-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.name-button .pill-icon {
  background: var(--pink-soft);
}

.library-button {
  background: var(--yellow);
}

/* ---- Stage: the karaoke TV takes all remaining space ---- */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 18px 14px;
}

.stage:fullscreen {
  padding: 14px;
  background: inherit;
  background-color: var(--night);
}

.screen-area {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}

/* Largest 16:9 box that fits the area. */
.screen {
  position: relative;
  width: min(100cqw, 100cqh * 16 / 9);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 5px solid var(--ink);
  border-radius: 26px;
  background: #000;
  box-shadow:
    0 0 0 4px var(--pink),
    0 0 0 9px var(--ink),
    0 0 50px 10px #ff8fbf55;
  container-type: inline-size;
}

#videoHost,
#videoHost iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.screen-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 2cqw;
  pointer-events: none;
}

/* YouTube shows its own title before playback starts, so ours appears once playing. */
body:not(.playing) .song-chip {
  visibility: hidden;
}

.song-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 60%;
  padding: 4px 16px 4px 6px;
  border: var(--line);
  border-radius: 999px;
  box-shadow: var(--pop);
  background: var(--yellow);
}

.song-chip h1 {
  overflow: hidden;
  font-size: clamp(15px, 2.2cqw, 30px);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.song-chip-icon {
  display: grid;
  place-items: center;
  width: 2em;
  height: 2em;
  flex: none;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  font-size: clamp(13px, 1.8cqw, 24px);
}

.status-chip {
  margin: 0;
  padding: 5px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-size: clamp(11px, 1.4cqw, 18px);
  font-weight: 800;
  white-space: nowrap;
}

.screen-message {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: 0;
  padding: 10px 20px;
  border: var(--line);
  border-radius: 18px;
  box-shadow: var(--pop);
  background: #fff;
  font-weight: 800;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Lyrics sit on the bottom of the video, like a karaoke TV. */
.lyrics {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 7cqw 4cqw 2.6cqw;
  background: linear-gradient(transparent, #160f34cc 45%, #160f34ee);
  color: var(--lyric);
  text-align: center;
  pointer-events: none;
}

.float-note {
  position: absolute;
  bottom: 3cqw;
  font-size: clamp(18px, 3cqw, 44px);
  animation: bob 3s ease-in-out infinite;
}

.n1 {
  left: 3cqw;
  color: var(--pink);
}

.n2 {
  right: 3cqw;
  color: var(--mint);
  animation-delay: -1.5s;
}

#videoLyricsLines .current {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0 0.3em;
  min-height: 1.35em;
  margin: 0 0 0.15em;
  font-family: var(--display);
  font-size: clamp(22px, 5.4cqw, 92px);
  font-weight: 800;
  line-height: 1.35;
  /* Thick cartoon outline that also works with the gradient-clipped active word. */
  filter: drop-shadow(3px 0 0 var(--ink)) drop-shadow(-3px 0 0 var(--ink)) drop-shadow(0 3px 0 var(--ink))
    drop-shadow(0 -3px 0 var(--ink)) drop-shadow(0 5px 0 #000a);
  animation: lyric-in 0.2s ease-out;
}

#videoLyricsLines .upcoming {
  min-height: 1.5em;
  margin: 0;
  font-size: clamp(14px, 2.7cqw, 46px);
  font-weight: 900;
  line-height: 1.5;
  color: var(--lyric-next);
  text-shadow:
    0 2px 0 var(--ink),
    0 0 6px var(--ink);
}

.syllable {
  display: inline-block;
  color: var(--lyric);
  transition: transform 0.12s;
}

.syllable.sung {
  color: var(--lyric-sung);
}

/* Classic karaoke wipe: the word fills with color as it is sung. */
.syllable.active {
  background: linear-gradient(90deg, var(--lyric-sung) var(--wipe, 0%), var(--lyric) var(--wipe, 0%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transform: scale(1.1);
}

/* ---- Recording ---- */

/* The child's camera, mirrored like a looking glass. */
.camera-preview {
  position: absolute;
  right: 2cqw;
  top: calc(2cqw + clamp(30px, 3.6cqw, 44px));
  width: 24%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 0 0 3px var(--yellow);
  background: #000;
  transform: scaleX(-1);
}

.rec-badge {
  position: absolute;
  left: 50%;
  top: 2cqw;
  margin: 0;
  padding: 4px 14px;
  border: var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: clamp(12px, 1.5cqw, 20px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
}

.rec-badge span {
  color: #ff3b5c;
  animation: blink 1s steps(2) infinite;
}

.countdown {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: clamp(110px, 18cqw, 220px);
  aspect-ratio: 1;
  margin: 0;
  border: 6px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 8px 0 var(--ink);
  background: var(--yellow);
  font-family: var(--display);
  font-size: clamp(64px, 11cqw, 140px);
  font-weight: 800;
  line-height: 1;
  transform: translate(-50%, -50%);
  animation: pop 1s ease-out infinite;
}

.record-button {
  color: #ff3b5c;
}

.recording .record-button {
  background: #ff3b5c;
  color: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}

/* Singer card: live preview of the avatar and the badge shown on recordings. */
.name-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 12px 16px;
  border: var(--line);
  border-radius: 22px;
  background:
    radial-gradient(circle, #ffffff30 1.5px, transparent 2.5px) 0 0 / 22px 22px,
    linear-gradient(#3a2b7a, #1d1542);
}

.name-card-avatar {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: var(--line);
  border-radius: 50%;
  box-shadow: var(--pop);
  background: var(--pink-soft);
  font-size: 40px;
  line-height: 1;
}

.name-card-badge {
  max-width: 100%;
  padding: 6px 14px;
  border: var(--line);
  border-radius: 999px;
  background: var(--pink);
  font-family: var(--display);
  font-size: 18px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-dialog:not(.has-name) .name-card-badge {
  opacity: 0.6;
}

.avatar-picker {
  margin: 16px 0 0;
  padding: 0;
  border: 0;
}

.avatar-picker legend {
  margin: 0 auto 8px;
  font-size: 13px;
  font-weight: 800;
}

.avatar-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.avatar-option {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid #2a1d4033;
  border-radius: 50%;
  background: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.15s,
    border-color 0.15s,
    background 0.15s;
}

.avatar-option:hover {
  transform: translateY(-2px);
}

.avatar-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.avatar-option:has(input:checked) {
  border: var(--line);
  box-shadow: 0 3px 0 var(--ink);
  background: var(--yellow);
  transform: scale(1.1);
}

.avatar-option:has(input:focus-visible) {
  outline: 3px dashed var(--purple);
  outline-offset: 2px;
}

.name-field {
  position: relative;
  margin-top: 16px;
}

.name-field input {
  width: 100%;
  padding: 12px 48px;
  border: var(--line);
  border-radius: 999px;
  background: #fff;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}

.name-field input::placeholder {
  color: #2a1d4059;
}

.clear-name {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 30px;
  height: 30px;
  margin-top: -15px;
  border-radius: 50%;
  background: #2a1d401a;
  font-size: 13px;
}

.clear-name:hover {
  transform: none;
  background: var(--pink-soft);
}

.name-dialog:not(.has-name) .clear-name {
  visibility: hidden;
}

.name-form .review-actions {
  margin-top: 16px;
}

.name-form .review-actions .pill {
  min-height: 48px;
  padding: 0 22px;
  font-size: 15px;
}

.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--pop);
}

.name-button.pop {
  animation: name-pop 0.5s ease;
}

@keyframes name-pop {
  40% {
    transform: scale(1.12) rotate(-3deg);
  }
}

.review-dialog {
  width: min(720px, 94vw);
}

.review-dialog video {
  display: block;
  width: 100%;
  max-height: 60dvh;
  border: var(--line);
  border-radius: 18px;
  background: #000;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.review-actions .primary {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

/* ---- Control bar ---- */

.control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 10px 18px;
  border: var(--line);
  border-radius: 26px;
  box-shadow: 0 5px 0 var(--ink);
  background: var(--paper);
}

.transport,
.extras {
  display: flex;
  gap: 8px;
}

.play-button {
  width: 56px;
  height: 56px;
  background: var(--pink);
  font-size: 20px;
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 220px;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

input[type='range'] {
  appearance: none;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink) var(--fill, 0%), #fff var(--fill, 0%));
  cursor: pointer;
}

#seek {
  flex: 1;
  min-width: 80px;
}

input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
}

input[type='range']::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
}

.mode-controls {
  display: flex;
  gap: 8px;
}

.mode-controls .selected {
  background: var(--pink);
}

.volume {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
}

#vocalVolume {
  width: 90px;
  --fill: 50%;
}

.volume output {
  min-width: 36px;
}

/* ---- Dialogs ---- */

dialog {
  border: 4px solid var(--ink);
  color: var(--ink);
}

dialog::backdrop {
  background: #160f3499;
  backdrop-filter: blur(4px);
}

.close {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 36px;
  height: 36px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--pink-soft);
}

/* Song library slides in from the right. */
.drawer {
  width: min(560px, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 20px 18px;
  border-width: 0 0 0 4px;
  background: var(--paper);
  animation: slide-in 0.22s ease-out;
}

.drawer[open] {
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 44px;
  margin-bottom: 14px;
}

.drawer-head h2 {
  font-size: 24px;
}

.count-chip {
  padding: 2px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--mint);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.library-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
}

.library-search:focus-within {
  outline: 3px solid var(--purple);
  outline-offset: 1px;
}

.library-search svg {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #7a6a8f;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.library-search input {
  flex: 1;
  min-width: 0;
  padding: 11px 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  /* 16px keeps iPhone Safari from zooming the page in when the field is tapped. */
  font-size: 16px;
  font-weight: 700;
  -webkit-appearance: none;
  appearance: none;
}

/* Our own clear button replaces Safari's tiny one, which iPad often doesn't show at all. */
.library-search input::-webkit-search-cancel-button,
.library-search input::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}

.clear-search {
  flex: none;
  width: 34px;
  height: 34px;
  margin-right: -8px;
  border: 0;
  border-radius: 50%;
  background: #2a1d401a;
  color: var(--ink);
  font-size: 14px;
  touch-action: manipulation;
}

.clear-search:hover {
  transform: none;
  background: var(--pink-soft);
}

.clear-search[hidden] {
  display: none;
}

.clear-search .control-icon {
  width: 16px;
  height: 16px;
}

/* One row per song: icon, title with channel, and a tag on songs without running lyrics. */
.song-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
  margin: 0 -6px;
  padding: 2px 6px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--purple) transparent;
}

.song-list[hidden] {
  display: none;
}

/* One section per language; its heading sticks to the top while that language scrolls by. */
.song-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.song-group + .song-group {
  margin-top: 14px;
}

.song-group-title {
  position: sticky;
  top: -2px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 8px 4px 6px;
  border-bottom: 2px dashed #d9cdea;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.song-group-count {
  padding: 1px 8px;
  border-radius: 999px;
  background: #ece4ff;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
}

.song-choice {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 8px 12px 8px 8px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: none;
  color: var(--ink);
  text-align: left;
  transition: background 0.12s;
}

.song-choice:hover {
  background: #fff;
  border-color: #eadff5;
}

.song-choice:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 1px;
}

.song-choice.selected {
  border-color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 3px 0 var(--ink);
}

.song-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #ece4ff;
  font-size: 22px;
}

.song-choice:nth-child(4n + 1) .song-icon {
  background: var(--pink-soft);
}

.song-choice:nth-child(4n + 2) .song-icon {
  background: #d7f5ec;
}

.song-choice:nth-child(4n + 3) .song-icon {
  background: #dcefff;
}

.song-choice.selected .song-icon {
  background: #fff;
}

.song-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.song-text strong {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.song-text small {
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  color: #7a6a8f;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.song-choice.selected small {
  color: var(--ink);
}

.song-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f0ebf5;
  color: #7a6a8f;
  font-size: 11px;
  font-weight: 800;
}

.song-choice.has-lyrics .song-tag {
  display: none;
}

.song-choice.selected .song-tag {
  background: #fff;
}

.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  font-weight: 700;
}

.library-empty[hidden] {
  display: none;
}

.library-empty p {
  margin: 0;
}

.card-dialog {
  width: min(460px, 92vw);
  padding: 30px 24px 26px;
  border-radius: 30px;
  box-shadow: 0 8px 0 var(--ink);
  background: var(--paper);
  text-align: center;
}

.card-dialog h2 {
  margin: 4px 0 16px;
  font-size: 26px;
}

.timing-control {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.timing-control .pill {
  padding: 5px 12px;
  background: var(--sky);
  font-size: 13px;
}

.timing-control output {
  min-width: 52px;
  font-variant-numeric: tabular-nums;
}

.lyric-import {
  position: relative;
  display: inline-block;
  margin-top: 18px;
  background: var(--mint);
  cursor: pointer;
}

/* The file input covers the label so the whole pill is clickable. */
.lyric-import input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.lyric-import:focus-within {
  outline: 3px dashed var(--purple-deep);
  outline-offset: 3px;
}

.hint {
  min-height: 1em;
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 700;
}

.video-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--purple-deep);
  text-underline-offset: 3px;
}

.eyebrow {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--purple-deep);
}

/* ---- Animation ---- */

@keyframes breathe {
  50% {
    transform: translateY(-5px) rotate(2deg);
  }
}

@keyframes bounce {
  50% {
    transform: translateY(-14px) rotate(-4deg);
  }
}

@keyframes hop {
  50% {
    transform: translateY(-3px) rotate(-4deg);
  }
}

@keyframes bob {
  50% {
    transform: translateY(-10px) rotate(10deg);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 6px #ff3b5c55;
  }
}

@keyframes pop {
  from {
    transform: translate(-50%, -50%) scale(1.25);
  }
  30% {
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes slide-in {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
}

@keyframes lyric-in {
  from {
    opacity: 0.3;
    transform: translateY(8px) scale(0.96);
  }
}

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

/* ---- Narrow and portrait screens: lyrics move below the video ---- */

@media (orientation: portrait) and (max-width: 900px) {
  body {
    height: auto;
    min-height: 100dvh;
  }

  .topbar {
    gap: 8px;
    padding: 8px 10px 6px;
  }

  .brand small {
    display: none;
  }

  .brand span {
    font-size: 20px;
  }

  .bunny {
    width: 40px;
    height: 42px;
  }

  .topbar-actions .pill {
    height: 36px;
    padding: 0 12px 0 4px;
    font-size: 14px;
  }

  .pill-icon {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }

  .stage {
    flex: none;
    padding: 4px 10px 14px;
  }

  .screen-area {
    display: block;
    container-type: normal;
  }

  .screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    aspect-ratio: auto;
    border-radius: 20px;
    box-shadow:
      0 0 0 3px var(--pink),
      0 0 0 7px var(--ink);
  }

  #videoHost {
    position: relative;
    aspect-ratio: 16 / 9;
  }

  .lyrics {
    position: relative;
    min-height: 168px;
    padding: 16px 10px 18px;
    background: linear-gradient(#2c2160, #160f34);
    border-top: 4px solid var(--ink);
  }

  .float-note {
    top: 8px;
    bottom: auto;
    font-size: 20px;
  }

  #videoLyricsLines .current {
    font-size: clamp(24px, 8cqw, 40px);
  }

  #videoLyricsLines .upcoming {
    font-size: clamp(15px, 4.6cqw, 22px);
  }

  .control-bar {
    gap: 10px;
    padding: 10px 12px;
    border-radius: 22px;
  }

  .progress {
    order: -1;
    flex-basis: 100%;
  }

  .mode-controls .pill {
    padding: 7px 12px;
    font-size: 13px;
  }

  .volume output {
    display: none;
  }

}

/* Phones held sideways: one compact row so the video keeps the height. */
@media (orientation: landscape) and (max-height: 520px) {
  .topbar {
    padding: 4px 12px 2px;
  }

  .brand span {
    display: none;
  }

  .bunny {
    width: 34px;
    height: 36px;
  }

  .topbar-actions .pill {
    height: 32px;
    padding: 0 10px 0 3px;
    font-size: 13px;
  }

  .pill-icon {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }

  .stage {
    gap: 8px;
    padding: 2px 12px 8px;
  }

  .screen {
    border-width: 3px;
    border-radius: 16px;
    box-shadow:
      0 0 0 3px var(--pink),
      0 0 0 6px var(--ink);
  }

  .control-bar {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 18px;
  }

  .round {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }

  .play-button {
    width: 42px;
    height: 42px;
  }

  .progress {
    flex: 1 1 100px;
    gap: 6px;
    font-size: 11px;
  }

  .mode-controls .pill {
    padding: 5px 10px;
  }

  .mode-controls .label,
  .volume output {
    display: none;
  }

  #vocalVolume {
    width: 60px;
  }
}

/* Very narrow phones: the bunny alone is the logo, leaving room for the buttons. */
@media (max-width: 420px) {
  .brand span {
    display: none;
  }
}

/* Link and QR sharing */
.share-qr { display: block; width: min(240px, 100%); height: auto; margin: 16px auto; background: white; border-radius: 12px; }
.share-dialog { max-height: 90dvh; overflow: auto; }
.share-dialog label { display: block; text-align: left; font-weight: 700; }
.share-url { width: 100%; min-width: 0; box-sizing: border-box; padding: 12px; margin: 8px 0 16px; border: 2px solid var(--ink); border-radius: 12px; font: inherit; font-size: 14px; }
.share-actions { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; }
/* The copy button, share button and download link look like one row of the same buttons. */
.share-actions > * { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 48px; padding: 0 20px; font-family: var(--display); font-size: 15px; font-weight: 800; white-space: nowrap; }
.share-actions a { text-decoration: none; color: var(--ink); }
.share-actions [hidden] { display: none; }
#shareStatus { min-height: 1.5em; font-size: 14px; }
@media (max-width: 600px) { .share-button .pill-label { display: none; } .topbar-actions .share-button { padding: 3px; } }

/* The language switch has no emoji badge, just the code of the other language. */
.topbar-actions .pill.lang-button {
  padding: 0 12px;
  background: #ffffffd9;
  letter-spacing: 0.04em;
}

/* Four chips on a phone: tighten the row and let the name shrink behind its ellipsis. */
@media (max-width: 600px) {
  .topbar-actions { min-width: 0; gap: 6px; }
  .topbar-actions .pill.lang-button { padding: 0 9px; }
  .name-button { min-width: 0; }
}


/* Draw controls instead of relying on platform-specific Unicode/emoji glyphs. */
.control-icon {
  display: block;
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
button { -webkit-appearance: none; appearance: none; }
.round, .close, .clear-name, .clear-search { display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.mode-controls .pill { display: inline-flex; align-items: center; justify-content: center; gap: 0.35em; }

.volume-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--pink-soft);
  font-size: 18px;
  touch-action: manipulation;
}
.volume-step:disabled { opacity: 0.4; cursor: default; transform: none; }
/* Avoid repainting five chained SVG shadow filters for every lyric wipe on
   touch devices, where the video and two audio decoders share limited CPU. */
@media (pointer: coarse) {
  #videoLyricsLines .current {
    filter: none;
    text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink), 0 4px 0 #000a;
    animation: none;
  }
  /* Safari paints text-shadow over gradient-clipped text and scales the word as a blurry
     bitmap, so the word being sung gets a small filter outline of its own and no zoom. */
  #videoLyricsLines .current .syllable.active {
    text-shadow: none;
    transform: none;
    filter: drop-shadow(2px 0 0 var(--ink)) drop-shadow(-2px 0 0 var(--ink)) drop-shadow(0 2px 0 var(--ink))
      drop-shadow(0 -2px 0 var(--ink));
  }
  .rabbit-body, .playing .rabbit-body, .float-note { animation: none; }
  /* Animating the shapes inside the SVG repaints it every frame; moving the whole SVG
     is a composited transform, so the bunny can still hop while a song plays. */
  .bunny { transform-origin: 50% 90%; }
  .playing .bunny {
    will-change: transform;
    animation: hop 0.5s ease-in-out infinite;
  }
  dialog::backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* Keep the current value visible when adjusting with the step buttons. */
.volume output { display: inline; }
@media (orientation: landscape) and (max-height: 520px) {
  .control-bar { flex-wrap: wrap; }
}

/* Tablets (iPad): every button stays on one row. Landscape fits the seek bar on that
   row too; portrait gives the seek bar its own row above the buttons. */
@media (min-width: 700px) and (max-width: 1100px) and (min-height: 521px) {
  .control-bar { flex-wrap: nowrap; gap: 10px; padding: 8px 12px; }
  .control-bar .round { width: 40px; height: 40px; font-size: 16px; }
  .control-bar .play-button { width: 48px; height: 48px; }
  .transport, .extras, .mode-controls { gap: 6px; flex: none; }
  .mode-controls .pill { padding: 7px 10px; font-size: 13px; }
  .volume { gap: 4px; flex: 1 1 auto; min-width: 0; }
  .volume-step { width: 36px; height: 36px; }
  #vocalVolume { flex: 1 1 90px; width: auto; min-width: 48px; max-width: 120px; }
  .progress { flex: 1 1 160px; min-width: 0; }
}
@media (min-width: 700px) and (max-width: 1100px) and (min-height: 521px) and (orientation: portrait) {
  .control-bar { flex-wrap: wrap; }
  .progress { flex-basis: 100%; }
  .volume { flex: 1 1 0; }
}
