:root {
  --bg: #0b1424; --panel: #121e33; --panel2: #18263f; --line: #24344f;
  --text: #eef2f8; --muted: #8b9bb5; --amber: #f5b342; --amber2: #ffcf73;
  --red: #ef6461; --green: #45c486; --blue: #5aa7f0; --violet: #a685f0;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Noto Sans Thai', 'Leelawadee UI', Tahoma, sans-serif; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: #0d182b; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--amber); }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 14px; resize: vertical; }
code { background: #0d182b; padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); } .sm { font-size: 13px; }
.hidden { display: none !important; }

.btn { color: var(--text); border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 9px 16px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background .15s, transform .05s; }
.btn:hover { background: #20324f; } .btn:active { transform: scale(.97); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #1a1205; font-weight: 600; }
.btn.primary:hover { background: var(--amber2); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 14px; }
.btn.big { padding: 13px; font-size: 18px; width: 100%; }
.btn.huge { padding: 22px 44px; font-size: 30px; border-radius: 18px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.icon { width: 46px; height: 46px; padding: 0; font-size: 20px; }
.btn.icon.sm { width: 34px; height: 34px; font-size: 15px; }
.btn.danger { color: var(--red); }
.big-play { width: 64px !important; height: 64px !important; font-size: 26px !important; background: var(--amber) !important; color: #1a1205; border-color: var(--amber) !important; border-radius: 50% !important; }

.brand-mark { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--amber); color: #1a1205; font-size: 30px; font-weight: 700; }
.brand-mark.sm { width: 30px; height: 30px; font-size: 17px; }
.brand-mark.xl { width: 120px; height: 120px; font-size: 64px; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100%; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 32px; width: 100%; max-width: 380px; text-align: center; display: grid; gap: 14px; }
.login-card h1 { margin: 4px 0 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card input { text-align: center; font-size: 22px; letter-spacing: 6px; }
.err { color: var(--red); min-height: 1.5em; }

/* control layout */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; white-space: nowrap; }
.brand b { color: var(--amber); }
.tabs { display: flex; gap: 6px; }
.tabs a { padding: 7px 18px; border-radius: 999px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); }
.tabs a.active { background: var(--amber); color: #1a1205; border-color: var(--amber); font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.conn { font-size: 13px; padding: 3px 10px; border-radius: 999px; }
.conn.on { background: rgba(69,196,134,.15); color: var(--green); }
.conn.off { background: rgba(239,100,97,.15); color: var(--red); }

.layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr); gap: 18px; padding: 18px 20px; max-width: 1500px; margin: 0 auto; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .brand { display: none; } }
.col { min-width: 0; }
.side-col { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head h3 { margin: 0; font-size: 17px; }
.badge { background: var(--panel2); border-radius: 999px; padding: 1px 9px; font-size: 13px; color: var(--amber); }

.searchbar { display: flex; gap: 10px; }
.searchbar input { font-size: 20px; padding: 14px 16px; }
.searchbar .btn { padding: 0 26px; font-size: 18px; }
.singer-row { display: flex; align-items: center; gap: 12px; margin: 10px 0 6px; }
.singer-row label { white-space: nowrap; font-size: 14px; }
.singer-row input { max-width: 280px; padding: 7px 12px; }
.sec { margin: 18px 0 8px; font-size: 14px; color: var(--muted); font-weight: 500; }
.loading { color: var(--muted); padding: 14px 4px; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.empty.sm { padding: 10px; font-size: 14px; }
.note { color: var(--amber2); font-size: 14px; margin: 6px 0; }

.row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; border: 1px solid transparent; }
.row:hover { background: var(--panel); border-color: var(--line); }
.thumb { width: 168px; color: transparent; font-size: 0; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #0d182b; flex: none; }
.thumb.sm { width: 112px; } .thumb.xs { width: 80px; }
.ri { flex: 1; min-width: 0; }
.rt { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rt.sm { font-size: 14px; font-weight: 500; }
.ra { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rb { display: flex; gap: 6px; align-items: center; flex: none; }
.kbs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.kb { font-size: 12px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); }
.kb.miss { color: #4b5b75; border-style: dashed; }
.kb.have { color: var(--text); }
.kb.have.k-original, .kt.k-original { border-color: var(--blue); color: var(--blue); }
.kb.have.k-karaoke, .kt.k-karaoke { border-color: var(--amber); color: var(--amber); }
.kb.have.k-instrumental, .kt.k-instrumental { border-color: var(--violet); color: var(--violet); }
.kb.have.k-lrc { border-color: var(--green); color: var(--green); }

.now { display: flex; gap: 14px; align-items: flex-start; }
.now .thumb { width: 150px; }
.now .label { color: var(--amber); font-size: 13px; font-weight: 600; }
.now .title { font-size: 20px; font-weight: 700; line-height: 1.3; }
.now .artist { color: var(--muted); margin-bottom: 6px; }
.now .empty { flex: 1; }
.controls { display: grid; gap: 12px; }
.ctl-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vol { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.vol span { min-width: 34px; text-align: center; font-weight: 600; }
.vol span::before { content: '🔊 '; font-size: 13px; }
.seg { display: flex; width: 100%; background: #0d182b; border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 11px; border-radius: 9px; cursor: pointer; font-size: 17px; color: var(--muted); }
.seg button.active { background: var(--amber); color: #1a1205; font-weight: 700; }
.pill { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; color: var(--muted); }
.pill.on { border-color: var(--green); color: var(--green); }
.offset { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

.queue ol { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow: auto; }
.queue li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-top: 1px solid var(--line); }
.queue li:first-child { border-top: 0; }
.qn { width: 26px; height: 26px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-size: 13px; flex: none; }
.qi { flex: 1; min-width: 0; }
.qt { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qb { display: flex; gap: 4px; flex: none; }

.modal { position: fixed; inset: 0; background: rgba(3,8,16,.72); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 760px; max-height: 90vh; overflow: auto; padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.grid2 label { font-size: 14px; color: var(--muted); display: grid; gap: 4px; }
.vrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.vrow select { width: auto; padding: 6px 8px; }
.vrow.bad { opacity: .55; }
.bad-t { color: var(--red); font-weight: 500; }
.find-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 10px 0; font-size: 14px; color: var(--muted); }
.modal-foot { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.spacer { flex: 1; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(30px); background: var(--green); color: #04150c; padding: 10px 22px; border-radius: 999px; font-weight: 600; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--red); color: #fff; }

/* TV */
body.tv { background: #000; overflow: hidden; cursor: none; }
#playerWrap, #playerWrap iframe { position: fixed; inset: 0; width: 100vw; height: 100vh; border: 0; }
.idle { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 30%, #1a2c4d 0%, #070d18 70%); text-align: center; }
.idle h1 { font-size: 64px; margin: 24px 0 0; letter-spacing: 1px; }
.idle-room { font-size: 36px; color: var(--amber); margin: 6px 0; font-weight: 600; }
.idle-hint { font-size: 26px; color: var(--muted); }
.song-tag { position: fixed; top: 18px; left: 22px; background: rgba(5,10,20,.72); padding: 8px 18px; border-radius: 999px; font-size: 22px; max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: fadeOut 1s 12s forwards; }
.kt { font-size: 15px; border: 1px solid; border-radius: 999px; padding: 0 10px; margin-left: 6px; vertical-align: middle; }
.up-next { position: fixed; top: 18px; right: 22px; background: rgba(5,10,20,.78); padding: 8px 18px; border-radius: 999px; font-size: 22px; max-width: 36vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-next span { color: var(--amber); font-weight: 700; margin-right: 6px; }
.up-next em { color: var(--muted); font-style: normal; }
.lyrics { position: fixed; left: 0; right: 0; bottom: 6vh; text-align: center; pointer-events: none; }
.ly-cur { display: inline-block; font-size: 5vh; font-weight: 700; color: #fff; text-shadow: 0 0 6px #000, 0 2px 10px #000, 0 0 2px #000; padding: 0 3vw; min-height: 1.4em; }
.ly-next { font-size: 3.4vh; color: rgba(255,255,255,.7); text-shadow: 0 0 6px #000, 0 2px 8px #000; min-height: 1.4em; }
.tv-notice { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: rgba(239,100,97,.92); color: #fff; padding: 12px 26px; border-radius: 999px; font-size: 22px; }
.start { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; background: rgba(4,8,16,.9); text-align: center; color: var(--muted); font-size: 20px; padding: 40px; cursor: default; }
@keyframes fadeOut { to { opacity: 0; } }
