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

:root {
  --bg: #0d0d0d;
  --surface: #1c1c1e;
  --surface2: #2c2c2e;
  --accent: #ff3b5c;
  --accent-dim: rgba(255, 59, 92, 0.15);
  --text: #f2f2f7;
  --text-muted: #8e8e93;
  --radius: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── Header ─────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--surface2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.search-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}

.search-bar {
  display: flex;
  width: 100%;
  background: var(--surface);
  border-radius: 30px;
  overflow: hidden;
  border: 1.5px solid transparent;
  transition: border-color 0.2s;
}

.search-bar:focus-within {
  border-color: var(--accent);
}

/* ── Autocomplete dropdown ───────────────────────────── */
.autocomplete {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--surface2);
  border-radius: var(--radius);
  list-style: none;
  z-index: 50;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  max-height: 320px;
  overflow-y: auto;
}

.autocomplete__group {
  padding: 6px 12px 2px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.autocomplete__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.autocomplete__item:hover,
.autocomplete__item--active {
  background: var(--surface2);
}

.autocomplete__item--active .autocomplete__name {
  color: var(--accent);
}

.autocomplete__icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  opacity: 0.6;
}

.autocomplete__name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete__sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 35%;
}

#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: 12px 16px;
  font-size: 1rem;
  color: var(--text);
  min-width: 0;
  width: 100%;
}

#search-input::placeholder { color: var(--text-muted); }

#search-btn, #fullscreen-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 12px 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color 0.2s;
  flex-shrink: 0;
}

#search-btn:hover, #search-btn:active,
#fullscreen-btn:hover, #fullscreen-btn:active { color: var(--accent); }

/* ── Banners ─────────────────────────────────────────── */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  font-size: 0.9rem;
}

.banner--warning { background: rgba(255, 200, 0, 0.15); color: #ffd60a; }
.banner--error   { background: rgba(255, 59, 92, 0.15); color: #ff6b81; }

.banner__close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
  flex-shrink: 0;
}

[hidden] { display: none !important; }

/* ── Session view ────────────────────────────────────── */
#session-view {
  height: calc(100vh - 57px - 60px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px;
}

/* No-session start screen */
.session-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 0 32px;
}

.session-start__icon { font-size: 3rem; }

.session-start__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.session-start__btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 30px;
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.session-start__btn:active { filter: brightness(0.85); }

/* Past sessions */
.session-past {
  margin-top: 28px;
  width: 100%;
  max-width: 480px;
}

.session-past__heading {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.session-past__item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.session-past__name { font-size: 0.9rem; font-weight: 600; }
.session-past__meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* Active session header */
.session-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.session-header__name {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.session-header__date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.session-end-btn {
  background: var(--surface2);
  color: var(--text-muted);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.session-end-btn:hover { background: rgba(255,59,92,0.15); color: var(--accent); }

/* Join link card */
.session-join-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.session-join-card__label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.session-join-card__url {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.session-join-card__code {
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent);
  flex-shrink: 0;
  word-break: break-all;
  text-align: right;
}

/* Section headings */
.session-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Add singer form */
.session-add {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.session-add__input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--surface2);
  border-radius: 30px;
  padding: 10px 16px;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
  min-width: 0;
}

.session-add__input:focus { border-color: var(--accent); }
.session-add__input::placeholder { color: var(--text-muted); }

.session-add__btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 30px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: filter 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.session-add__btn:active { filter: brightness(0.85); }

/* Singer list */
.session-singers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  min-height: 36px;
}

.session-singer-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1.5px solid transparent;
  border-radius: 20px;
  padding: 7px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.session-singer-chip--active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
}

.session-singer-chip__mic {
  font-size: 0.85rem;
  opacity: 0.7;
}

.session-singer-chip__remove {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  margin-left: 4px;
  -webkit-tap-highlight-color: transparent;
  padding: 2px 0 2px 2px;
}

/* Request queue */
.session-requests {
  margin-bottom: 20px;
}

.session-request-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.session-request-item__info { flex: 1; min-width: 0; }

.session-request-item__name {
  font-size: 0.9rem;
  font-weight: 700;
}

.session-request-item__song {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.session-request-item__time {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.session-req-accept {
  background: #1db954;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.session-req-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

/* Song log */
.session-log-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--surface2);
}

.session-log-item__singer {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 70px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-log-item__song {
  font-size: 0.88rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-log-item__time {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.session-empty-note {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 8px 0 4px;
}

/* "Now singing" bar shown on karaoke tab when session active */
.now-singing-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: var(--accent-dim);
  border-bottom: 1px solid rgba(255,59,92,0.2);
  font-size: 0.85rem;
}

.now-singing-bar__label { color: var(--accent); font-weight: 700; }
.now-singing-bar__name  { color: var(--text); flex: 1; }

/* ── Tab Bar ─────────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--surface2);
  z-index: 20;
}

.tab-bar__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tab-bar__btn--active {
  color: var(--accent);
}

.tab-bar__icon {
  font-size: 1.3rem;
  line-height: 1;
}

.tab-bar__label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Soundboard ──────────────────────────────────────── */
#soundboard-view {
  height: calc(100vh - 57px - 60px);
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  overflow: hidden;
}

.soundboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(5, 1fr);
  gap: 10px;
  flex: 1;
  min-height: 0;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.sound-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 0;
  padding: 8px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, filter 0.1s;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.sound-btn:active {
  transform: scale(0.94);
  filter: brightness(0.85);
}

.sound-btn__emoji {
  font-size: clamp(1.4rem, 3.5vh, 2.2rem);
  line-height: 1;
}

.sound-btn__label {
  font-size: clamp(0.7rem, 1.8vh, 1rem);
  font-weight: 700;
  color: rgba(0, 0, 0, 0.75);
  text-align: center;
  line-height: 1.2;
}

/* ── Layout (sidebar + main) ─────────────────────────── */
.layout {
  display: flex;
  height: calc(100vh - 57px - 60px);
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────── */
#artist-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--surface2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#artist-sidebar:not([hidden]) { display: flex; }

.sidebar__header {
  padding: 16px 14px 10px;
  border-bottom: 1px solid var(--surface2);
  flex-shrink: 0;
}

.sidebar__artist-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.sidebar__label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.sidebar__tracks {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  list-style: none;
  overscroll-behavior: contain;
}

.sidebar__track {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.sidebar__track:hover,
.sidebar__track:active { background: var(--surface); }

.sidebar__track--active { background: var(--accent-dim); }
.sidebar__track--active .sidebar__track-name { color: var(--accent); }

.sidebar__track-num {
  font-size: 0.72rem;
  color: var(--text-muted);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}

.sidebar__track-name {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Main / States ───────────────────────────────────── */
main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  overscroll-behavior: contain;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

.empty-state__icon { font-size: 3rem; }

.loading {
  display: flex;
  justify-content: center;
  padding: 80px 20px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results Grid ────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  border: 1.5px solid transparent;
}

.card:hover, .card:active {
  transform: scale(1.02);
  border-color: var(--accent);
  background: var(--surface2);
}

.card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface2);
  overflow: hidden;
}

.card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card__duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.card__play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  background: rgba(0,0,0,0.4);
  transition: opacity 0.15s;
}

.card:hover .card__play-icon,
.card:active .card__play-icon { opacity: 1; }

.card__play-icon svg {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}

.card__info {
  padding: 10px 12px 12px;
}

.card__title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.card__channel {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Player Overlay ──────────────────────────────────── */
.player-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 102;
  background: rgba(0,0,0,0.7);
  border: 1.5px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.close-btn:hover { background: rgba(255,59,92,0.7); }

#player {
  position: absolute;
  inset: 0;
}

#player iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── "Watch on YouTube" badge ────────────────────────── */
.yt-badge {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 101;
  background: rgba(0,0,0,0.6);
  color: rgba(255,255,255,0.6);
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: color 0.2s;
}

.yt-badge:hover { color: #fff; }

/* ── Responsive ──────────────────────────────────────── */
@media (min-width: 768px) {
  header { padding: 16px 28px; }
  main { padding: 24px 28px; }
  #artist-sidebar { width: 240px; }
}

@media (max-width: 480px) {
  .logo { display: none; }
  .results-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  #artist-sidebar { width: 160px; }
  .layout { height: calc(100vh - 53px - 60px); }
  #soundboard-view { height: calc(100vh - 53px - 60px); padding: 8px; }
}
