:root {
  color-scheme: dark;
  --ink: #f8f5ff;
  --muted: #bcb3cb;
  --base: #100e16;
  --panel: #1a1723;
  --line: #393245;
  --accent: #d0b7ff;
  --accent-ink: #211331;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse at 17% 0%, #281b36 0, transparent 48rem), var(--base);
}
h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
button {
  min-height: 44px;
  padding: .52rem .78rem;
  border: 1px solid var(--line);
  border-radius: .72rem;
  background: #292335;
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: #7e669a; background: #372b49; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.shell { width: min(100% - 3rem, 1340px); margin-inline: auto; }
.masthead { border-bottom: 1px solid #372e41; background: #15111ddd; }
.masthead .shell { min-height: 75px; display: flex; align-items: center; gap: .8rem; }
.mark {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  width: 40px; height: 40px; flex: none; border-radius: 13px;
  color: #2c174a; background: linear-gradient(145deg, #ead5ff, #a77cf1);
}
.mark i { width: 3px; height: 11px; background: currentColor; border-radius: 1rem; }
.mark i:nth-child(2), .mark i:nth-child(4) { height: 15px; }
.mark i:nth-child(3) { height: 23px; }
.brand { font-size: clamp(1.15rem, 2.5vw, 1.48rem); font-weight: 800; line-height: 1.25; }
.header-actions { margin-left:auto; display:flex; align-items:center; gap:.45rem; }
#room-open, #queue-play { background:var(--accent); color:var(--accent-ink); font-weight:750; white-space:nowrap; }
#room-open:hover, #queue-play:hover { background:#e8d6ff; }
.queue-actions { display:flex; flex-wrap:wrap; gap:.38rem; margin:.2rem 0 .75rem; }
.admin-link {
  margin-left: auto; display: inline-flex; align-items: center; min-height: 44px;
  padding: .55rem .85rem; border: 1px solid var(--line); border-radius: .72rem;
  color: var(--ink); text-decoration: none; font-size: .9rem; white-space: nowrap;
}
.admin-link:hover { border-color: #7e669a; background: #2b2338; }
main { padding: 1.55rem 0 2.5rem; }
.columns { display: grid; grid-template-columns: minmax(0, 1.95fr) minmax(345px, 1fr); gap: 1.15rem; align-items: start; }
.card { overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 1.15rem; box-shadow: 0 12px 32px #07050c55; }
.stage { padding: 1rem; }
.now-playing { display: flex; align-items: center; gap: .78rem; padding: .14rem .2rem .95rem; }
.now-icon {
  display: grid; place-items: center; width: 46px; height: 46px; flex: none;
  border: 1px solid #624e7b; border-radius: .85rem;
  color: #e5d1ff; background: #30233f; font-size: 1.24rem;
}
.now-label, .artist, .muted, .feedback { color: var(--muted); }
.now-label { display: block; font-size: .78rem; line-height: 1.2; }
.now-playing h2 { margin-top: .2rem; font-size: clamp(1.18rem, 2.7vw, 1.52rem); line-height: 1.35; overflow-wrap: anywhere; }
.stream-format { margin-left: auto; border: 1px solid var(--line); border-radius: .5rem; padding: .22rem .46rem; color: var(--muted); font-size: .75rem; }
#current-artist { margin-top: .12rem; font-size: .88rem; }
.screen {
  position: relative; display: grid; isolation: isolate; place-items: center;
  aspect-ratio: 16 / 9; overflow: hidden; background: #0a080d;
  border: 1px solid #332843; border-radius: .95rem;
}
.screen.youtube-active { min-height: 200px; }
.youtube-mount, .youtube-mount iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.source-buttons { display: flex; gap: .42rem; margin-bottom: .65rem; }
.source-buttons button[aria-pressed="true"] { background: #d0b7ff; color: #211331; font-weight: 750; }
.room-panel { margin: .7rem 0; padding: .8rem; border: 1px solid var(--line); border-radius: .7rem; }
.room-panel label, .room-panel small { display: block; margin: .4rem 0; }
.room-panel input { width: 100%; padding: .55rem; margin-bottom: .45rem; color: var(--ink); background: var(--base); border: 1px solid var(--line); border-radius: .5rem; }
.room-panel canvas { display: block; max-width: 100%; height: auto; margin: .55rem auto; }
.room-panel a { display: block; overflow-wrap: anywhere; color: var(--accent); margin-bottom: .5rem; }
.queue-source { display: block; margin-top: .2rem; color: var(--muted); font-size: .76rem; }
video { width: 100%; height: 100%; position: absolute; inset: 0; display: block; }
.start {
  position: absolute; z-index: 1; inset: 0; display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 50% 44%, #65448a 0, #3c275c 32%, transparent 68%),
    linear-gradient(140deg, #291d3e, #141021 65%, #251c37);
}
.start::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .7;
  background:
    repeating-radial-gradient(ellipse at 50% 46%, transparent 0 2.55rem, #d9bdff22 2.58rem 2.63rem, transparent 2.68rem 3.55rem),
    linear-gradient(132deg, transparent 23%, #b38bef23 42%, transparent 58%);
}
.start button {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: .65rem;
  min-height: 44px; padding: .4rem .8rem; border: 0; background: transparent;
  color: #fbf4ff; font-size: 1.02rem; font-weight: 750;
}
.start button:hover:not(:disabled) { background: transparent; }
.play-icon {
  display: grid; place-items: center; width: clamp(58px, 9vw, 92px); aspect-ratio: 1;
  border-radius: 50%; border: 1px solid #ead9ff; background: linear-gradient(145deg, #f0ddff, #bd95fb);
  box-shadow: 0 0 0 .65rem #e1bdff26, 0 0 0 1.3rem #dab7ff12, 0 10px 30px #10072070;
}
.play-icon::after { content: ""; border-block: .58rem solid transparent; border-left: .9rem solid #2b1944; margin-left: .18rem; }
.start button:hover .play-icon { background: #f3e5ff; }
.player-bar { display: flex; align-items: center; gap: .75rem; padding: .92rem .08rem 0; flex-wrap: wrap; }
.player-bar strong { color: var(--muted); font-size: .85rem; }
.audio-buttons { display: flex; flex-wrap: wrap; gap: .38rem; }
.audio-buttons button { border-radius: 999px; padding-inline: .86rem; font-size: .85rem; }
.audio-buttons button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 750; }
.audio-buttons button[aria-pressed="true"]:hover { background: #e8d6ff; }
.feedback { margin: .6rem .2rem 0; font-size: .88rem; }
.feedback:empty { display: none; }
.side { display: grid; gap: 1.05rem; }
.panel { padding: 1rem; }
.panel-top { display: flex; align-items: center; justify-content: space-between; gap: .65rem; margin-bottom: .88rem; }
.panel-top h2 { font-size: 1.16rem; }
.panel-top .muted { white-space: nowrap; font-size: .84rem; }
.search { display: flex; align-items: center; gap: .48rem; }
.search-field { flex: 1; min-width: 0; position: relative; }
.search-field::before {
  content: ""; position: absolute; pointer-events: none; left: .85rem; top: 14px;
  width: 10px; height: 10px; border: 2px solid #b7a5ce; border-radius: 50%;
}
.search-field::after {
  content: ""; position: absolute; pointer-events: none; left: 24px; top: 25px;
  width: 7px; height: 2px; background: #b7a5ce; transform: rotate(45deg);
}
.search input {
  color: var(--ink); background: #100e18; border: 1px solid var(--line); border-radius: .7rem;
}
.search input { width: 100%; min-height: 46px; padding: .58rem .65rem .58rem 2.3rem; font-size: .9rem; }
.search input::placeholder { color: #b6acc4; }
.search button { min-height: 46px; background: #d0b7ff; color: var(--accent-ink); border-color: #d0b7ff; font-weight: 750; }
.search button:hover:not(:disabled) { background: #ebdbff; }
.song-list, .queue { list-style: none; margin: .7rem 0 0; padding: 0; }
.song-row, .queue-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.song-row { margin-top: .37rem; padding: .42rem .45rem .42rem .65rem; border: 1px solid #373044; border-radius: .72rem; background: #211c2b; }
.song-row[aria-current="true"] { border-color: #9876c4; background: #332544; }
.song-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .94rem; font-weight: 750; line-height: 1.35; }
.artist { display: block; margin-top: .23rem; font-size: .78rem; font-weight: 400; }
.row-actions { display: flex; gap: .28rem; flex-shrink: 0; flex-wrap:wrap; justify-content:flex-end; max-width:53%; }
.row-actions button { min-height: 44px; font-size: .82rem; padding-inline: .52rem; background: #30263e; }
.row-actions button:first-child { color: #e8d8ff; }
.queue-row { padding: .4rem 0; border-top: 1px solid var(--line); }
.queue-row > span { min-width: 0; overflow-wrap: anywhere; }
.queue-row button, #next-song { font-size: .84rem; }
.empty { padding: .85rem .7rem; color: var(--muted); background: #13101a; border: 1px dashed #443950; border-radius: .7rem; text-align: center; font-size: .9rem; }
#no-results { margin-top: .65rem; }
.pagination { display: flex; align-items: center; gap: .45rem; margin-top: .65rem; flex-wrap: wrap; font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 875px) {
  .shell { width: min(100% - 1.4rem, 660px); }
  .columns { grid-template-columns: minmax(0, 1fr); }
  .masthead .shell { min-height: 65px; }
  main { padding-top: .9rem; }
  .stage, .panel { padding: .75rem; }
}
@media (max-width: 420px) {
  .masthead .shell { flex-wrap:wrap; padding:.6rem 0; }
  .header-actions { width:100%; }
  .song-row { padding-left: .44rem; }
  .row-actions button { padding-inline: .38rem; }
  .player-bar { gap: .4rem; }
  .audio-buttons button { padding-inline: .58rem; }
}
.playlist-panel { padding:.9rem; border:1px solid #423551; border-radius:.85rem; background:#1a1723; margin:0 0 .85rem; }
.playlist-panel summary { cursor:pointer; font-weight:750; }
.playlist-body { margin-top:.75rem; }
.playlist-body label, .playlist-body select { display:block; width:100%; }
.playlist-body select, .playlist-form input { padding:.45rem; border:1px solid #4e4160; border-radius:.6rem; background:#110e17; color:#f8f5ff; min-height:44px; }
.playlist-form, .playlist-actions { display:flex; flex-wrap:wrap; gap:.35rem; margin:.55rem 0; }
.playlist-form input { width:auto; min-width:0; flex:1 1 9rem; }
.playlist-play { background:#d0b7ff; color:#211331; font-weight:750; }
.playlist-status:empty { display:none; }
.playlist-tracks { margin:.45rem 0 0; padding:0; list-style:none; }
.playlist-tracks li { display:flex; align-items:center; justify-content:space-between; gap:.5rem; padding:.4rem 0; border-top:1px solid #423551; }
.playlist-tracks span { min-width:0; overflow-wrap:anywhere; }
.playlist-song-actions { display:flex; gap:.35rem; flex-wrap:wrap; justify-content:flex-end; }
.tv-mode { font-size: 1.15rem; }
.tv-mode .shell { max-width: 1680px; }
.tv-mode button, .tv-mode input, .tv-mode summary, .tv-mode .admin-link { min-height: 46px; }
.tv-mode :focus { outline: 3px solid #fff; outline-offset: 3px; }
