@font-face {
  font-family: "Neue Haas Unica Pro";
  src: url("/fonts/NeueHaasUnicaPro-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Neue Haas Unica Pro";
  src: url("/fonts/NeueHaasUnicaPro-Heavy.ttf") format("truetype");
  font-weight: 800;
  font-display: swap;
}

:root {
  --bg: #120e0b;
  --surface: #1d1714;
  --surface-2: #2a211d;
  --line: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.62);
  --pink: #ff2d6f;
  --red: #e3172d;
  --gold: #f5b324;
  --ok: #3ddc84;
  --danger: #ff5a5a;
  --radius: 18px;
  --grad: linear-gradient(135deg, var(--pink), var(--red));
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: "Neue Haas Unica Pro", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* Remove the blue/gray flash mobile browsers paint on tapped elements */
  -webkit-tap-highlight-color: transparent;
}

/* Tappable controls: no text selection on long-press, no double-tap zoom delay */
button,
.choice,
.recent-item {
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Keep a visible focus ring for keyboard users only */
button:focus {
  outline: none;
}
button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.script {
  color: var(--gold);
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}

.muted {
  color: var(--muted);
}

/* ---------- Buttons & inputs ---------- */
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  background: var(--grad);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 24px rgba(255, 45, 111, 0.28);
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn.secondary {
  background: transparent;
  border: 1.5px solid var(--line);
  box-shadow: none;
}
.btn.small {
  padding: 8px 16px;
  font-size: 0.875rem;
}
.btn.block {
  width: 100%;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}

input[type="password"],
input[type="text"],
input[type="search"],
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  padding: 14px 16px;
  outline: none;
}
input:focus,
textarea:focus {
  border-color: var(--pink);
}
textarea {
  resize: vertical;
  min-height: 110px;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--pink);
  animation: spin 0.8s linear infinite;
  flex: none;
}
.spinner.big {
  width: 44px;
  height: 44px;
  border-width: 4px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   HOST (seller) screen
   ========================================================= */
.host-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  /* Align with the centered 1120px content while the border stays full width */
  padding: 20px max(32px, calc((100% - 1120px) / 2 + 32px));
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.4rem;
}
.brand strong {
  font-weight: 800;
  letter-spacing: 0.08em;
}
.brand .script {
  font-size: 1.6rem;
}

.center-screen {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  text-align: center;
}
.login-card h1 {
  font-size: 1.8rem;
}

.home {
  width: min(720px, 100%);
  display: grid;
  gap: 24px;
}
.home-hero {
  text-align: center;
  display: grid;
  gap: 12px;
}
.home-hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
}
.new-session-form {
  display: flex;
  gap: 12px;
}
.new-session-form input {
  flex: 1;
}
.recent {
  display: grid;
  gap: 8px;
}
.recent h2 {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 400;
}
.recent-item {
  min-height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.recent-item:hover,
.recent-item:focus-visible {
  border-color: var(--pink);
  outline: none;
}
.recent-right {
  display: grid;
  justify-items: end;
  align-items: center;
  flex: none;
}
/* Info and button share the same grid cell, so swapping them doesn't shift the row */
.recent-right > * {
  grid-area: 1 / 1;
}
.recent-close {
  visibility: hidden;
  padding: 6px 14px;
}
.recent-item.active:hover .recent-close,
.recent-item.active:focus-within .recent-close {
  visibility: visible;
}
.recent-item.active:hover .recent-info,
.recent-item.active:focus-within .recent-info {
  visibility: hidden;
}
/* Touch screens have no hover: always show the button on active sessions */
@media (hover: none) {
  .recent-item.active .recent-close {
    visibility: visible;
  }
  .recent-item.active .recent-info {
    visibility: hidden;
  }
}
.btn.danger {
  background: transparent;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  box-shadow: none;
}
.btn.danger:hover {
  background: rgba(255, 90, 90, 0.12);
}

.session-layout {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 640px);
  justify-content: center;
  gap: 40px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 32px;
  align-items: start;
}
.qr-panel {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 16px;
  text-align: center;
}
.qr-panel h2 {
  font-size: 1.6rem;
}
.qr-frame {
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 0 0 6px rgba(255, 45, 111, 0.35),
    0 20px 60px rgba(255, 45, 111, 0.25);
}
.qr-frame img {
  display: block;
  width: 100%;
  height: auto;
}
.qr-frame.expired {
  opacity: 0.25;
  filter: grayscale(1);
}
.qr-url {
  font-size: 1.05rem;
  word-break: break-all;
}
.qr-url b {
  color: var(--gold);
  letter-spacing: 0.12em;
}
.countdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.countdown.expired {
  color: var(--danger);
}

.songs-panel {
  display: grid;
  gap: 16px;
}
.songs-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.songs-head h2 {
  font-size: 1.8rem;
}
.empty {
  text-align: center;
  padding: 56px 24px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  display: grid;
  gap: 8px;
}
.empty .big-emoji {
  font-size: 2.6rem;
}

.song {
  display: grid;
  gap: 14px;
  animation: pop-in 0.35s ease;
}
.song.flash {
  animation: flash 1.6s ease;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@keyframes flash {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 45, 111, 0.9);
    border-color: var(--pink);
  }
  100% {
    box-shadow: 0 0 0 18px rgba(255, 45, 111, 0);
  }
}
.song-top {
  display: flex;
  align-items: center;
  gap: 14px;
}
.song-num {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--grad);
  flex: none;
}
.song-meta {
  flex: 1;
  min-width: 0;
}
.song-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tag {
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.song-message {
  margin-top: 6px;
  color: var(--muted);
  font-style: italic;
  overflow-wrap: anywhere;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}
.status.done {
  color: var(--ok);
}
.status.failed {
  color: var(--danger);
}
.song audio {
  width: 100%;
}
.song-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.lyrics {
  white-space: pre-wrap;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 16px;
  font-size: 0.95rem;
  max-height: 340px;
  overflow: auto;
}

@media (max-width: 900px) {
  .host-header {
    padding: 16px;
  }
  .session-layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .qr-panel {
    position: static;
  }
  .new-session-form {
    flex-direction: column;
  }
}

/* =========================================================
   GUEST (scan) screen — mobile first
   ========================================================= */
.guest {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.guest-hero {
  position: relative;
  aspect-ratio: 696 / 520;
  background: url("/img/full-mobile.jpg") top center / cover no-repeat;
  flex: none;
}
.guest-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 55%, var(--bg));
}
.guest-hero.compact {
  aspect-ratio: 696 / 300;
}
.guest-body {
  padding: 8px 16px 32px;
  display: grid;
  gap: 22px;
  flex: 1;
  align-content: start;
}
.guest-title {
  text-align: center;
  display: grid;
  gap: 6px;
}
.guest-title h1 {
  font-size: 1.7rem;
}
.step {
  display: grid;
  gap: 12px;
}
.step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
}
.step-label span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--grad);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
}
.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.choice {
  appearance: none;
  font: inherit;
  font-weight: 800;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.choice[aria-pressed="true"] {
  border-color: var(--pink);
  background: rgba(255, 45, 111, 0.16);
}

.recorder {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 22px 16px;
  text-align: center;
}
.rec-btn {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 0;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(255, 45, 111, 0.35);
  transition: transform 0.12s;
}
.rec-btn svg {
  width: 38px;
  height: 38px;
}
.rec-btn.recording {
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 45, 111, 0.6);
  }
  50% {
    box-shadow: 0 0 0 18px rgba(255, 45, 111, 0);
  }
}
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.3rem;
}
.recorder audio {
  width: 100%;
}
.row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.result {
  text-align: center;
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 28px 18px;
}
.result .big-emoji {
  font-size: 3rem;
  line-height: 1;
}
.result h2 {
  font-size: 1.5rem;
}

.guest-form {
  display: grid;
  gap: 22px;
}
.fineprint {
  text-align: center;
  font-size: 0.8rem;
}

/* Inline SVG icon inside buttons: inherits the button's text color (white) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
}

/* ---------- Session search ---------- */
.recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.icon-btn {
  appearance: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.icon-btn:hover,
.icon-btn[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--pink);
}
.icon-btn[aria-expanded="true"] {
  background: rgba(255, 45, 111, 0.16);
}
/* Expanding search: the field grows leftwards out of the magnifier button */
.recent-head h2 {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.search-field {
  position: relative;
  width: 0;
  opacity: 0;
  visibility: hidden;
  transition: width 0.25s ease, opacity 0.2s ease, visibility 0s linear 0.25s;
}
.search-box.open .search-field {
  width: min(320px, 55vw);
  opacity: 1;
  visibility: visible;
  transition: width 0.25s ease, opacity 0.2s ease, visibility 0s;
}
.search-field input[type="search"] {
  height: 38px;
  padding: 0 40px 0 16px;
  border-radius: 999px;
  font-size: 0.9rem;
}
/* Hide the browser's tiny native clear button; we render a larger one */
.search-field input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
.search-clear {
  position: absolute;
  top: 50%;
  right: 3px;
  transform: translateY(-50%);
  /* 32px hitbox around a 14px icon */
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.search-clear svg {
  width: 14px;
  height: 14px;
}
.search-clear:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}
.recent-empty {
  text-align: center;
  padding: 18px;
}

/* Grid tracks default to min-content; let them shrink so the one-line
   title truncates instead of widening the page on mobile */
.home,
.recent {
  grid-template-columns: minmax(0, 1fr);
}

/* Home: anchor content to the top so the hero doesn't jump
   when the session list grows or shrinks (e.g. while searching) */
.center-screen.top {
  align-items: start;
  padding-top: clamp(32px, 8vh, 96px);
}

.status.streaming {
  color: var(--gold);
}

/* Platform login */
.user-name {
  font-size: 0.9rem;
  align-self: center;
}
.login-password {
  display: grid;
  gap: 16px;
}
.recent-by {
  font-size: 0.85rem;
}
