@font-face { font-family: "TeslaLogo"; src: url("/fonts/tesla.ttf") format("truetype"); font-display: swap; }
:root {
  --bg: #0a0b0e;
  --panel: #13151a;
  --panel-2: #1b1e25;
  --line: #262a33;
  --text: #eef0f4;
  --muted: #9aa1ad;
  --accent: #e8353b;
  --accent-2: #ff6b5e;
  --ok: #3ccf8e;
  --radius: 14px;
  --rail: 112px;
  --bar: 96px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 18px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif; }
body { overflow: hidden; user-select: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
img { display: block; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
#app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); grid-template-rows: 1fr auto; height: 100vh; }
#rail { grid-row: 1 / 3; background: #07080a; border-right: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: stretch; padding: 14px 10px; gap: 6px; overflow-y: auto; }
#rail .brand { font-weight: 800; letter-spacing: .02em; font-size: 15px; text-align: center; padding: 6px 0 14px; color: var(--accent-2); }
#rail a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 12px;
  text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600; }
#rail a svg { width: 30px; height: 30px; }
#rail a.on { background: var(--panel-2); color: var(--text); }
#rail .spacer { flex: 1; }
#rail .remote-btn { margin-top: 6px; }

#main { min-width: 0; overflow-x: hidden; overflow-y: auto; padding: 24px 28px 40px; position: relative; scroll-behavior: smooth; }
#main h1 { font-size: 30px; margin: 0 0 18px; display: flex; align-items: center; gap: 14px; }
#main h2 { font-size: 21px; margin: 28px 0 12px; color: var(--text); }
.sub { color: var(--muted); font-size: 16px; }

/* ---------- controls ---------- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; font-weight: 600;
  min-height: 52px; display: inline-flex; align-items: center; gap: 8px; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: #ff8a8a; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 15px; }
.btn svg { width: 22px; height: 22px; }
.input, select.input { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
  min-height: 52px; width: 100%; outline: none; }
.input:focus { border-color: #4a5160; }
.search { position: relative; flex: 1; min-width: 240px; max-width: 640px; }
.search .input { padding-left: 48px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px;
  font-size: 16px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.chip.on { background: var(--text); color: #111; border-color: var(--text); }
.chip .n { opacity: .55; font-weight: 500; margin-left: 6px; }

.tabs { display: flex; gap: 6px; background: var(--panel); border-radius: 14px; padding: 5px; width: max-content; margin-bottom: 14px; }
.tabs button { padding: 10px 20px; border-radius: 10px; font-weight: 600; color: var(--muted); min-height: 46px; }
.tabs button.on { background: var(--panel-2); color: var(--text); }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.list { grid-template-columns: 1fr; gap: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative;
  display: flex; flex-direction: column; text-align: left; padding: 0; min-height: 100%; }
.card:active { transform: scale(.985); }
.card .art { aspect-ratio: 16 / 9; background: #0e1014 center / contain no-repeat; display: grid; place-items: center;
  color: #3a404c; font-size: 38px; font-weight: 800; position: relative; }
.card.square .art { aspect-ratio: 1; background-size: cover; }
.card.cover .art { background-size: cover; }
.card .meta { padding: 10px 12px 12px; }
.card .t { font-weight: 650; font-size: 16px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .s { color: var(--muted); font-size: 14px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .live { position: absolute; left: 8px; top: 8px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800;
  padding: 2px 7px; border-radius: 6px; letter-spacing: .04em; }
.card .acts { position: absolute; right: 6px; top: 6px; display: flex; gap: 6px; }
.card .acts button { width: 44px; height: 44px; border-radius: 12px; background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
  display: grid; place-items: center; color: #fff; }
.card .acts button svg { width: 22px; height: 22px; }
.card .acts button.fav-on { color: #ffcc4d; }
.card.playing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.list .card { flex-direction: row; align-items: center; min-height: 76px; }
.list .card .art { width: 76px; height: 76px; aspect-ratio: auto; flex: none; background-size: cover; font-size: 22px; }
.list .card .meta { flex: 1; min-width: 0; }
.list .card .acts { position: static; padding-right: 10px; }
.list .card .acts button { background: var(--panel-2); }

.empty { color: var(--muted); padding: 28px; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.err { color: #ff9b9b; }
.spinner { width: 36px; height: 36px; border: 4px solid #2a2f39; border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 19px; }
.form { display: grid; gap: 12px; max-width: 620px; }
.form label { display: grid; gap: 6px; font-size: 15px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.kv:first-of-type { border-top: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; word-break: break-all; }

/* ---------- player ---------- */
#stage { position: fixed; inset: 0 0 var(--bar) var(--rail); background: #000; z-index: 20; display: none; }
#stage.show { display: block; }
#stage video, #stage #yt, #stage #yt iframe { width: 100%; height: 100%; background: #000; border: 0; }
#stage .top { position: absolute; left: 0; right: 0; top: 0; padding: 16px; display: flex; gap: 10px; justify-content: space-between;
  background: linear-gradient(#000c, #0000); transition: opacity .3s; }
#stage.idle .top { opacity: 0; pointer-events: none; }
#stage .top .title { font-size: 20px; font-weight: 700; padding: 10px; text-shadow: 0 1px 4px #000; }
#stage .road-cover { position: absolute; inset: 0; display: none; place-items: center; text-align: center; background: #000; }
#stage.road .road-cover { display: grid; }
#stage .road-cover .big { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
#stage .msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #000c; padding: 18px 24px;
  border-radius: 14px; max-width: 70%; text-align: center; }

#bar { grid-column: 2; height: var(--bar); background: #0d0f13; border-top: 1px solid var(--line); display: flex; align-items: center;
  gap: 14px; padding: 0 18px; position: relative; z-index: 30; }
#bar.empty-bar .np, #bar.empty-bar .ctl { opacity: .35; pointer-events: none; }
#bar .np { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
#bar .np .thumb { width: 64px; height: 64px; border-radius: 10px; background: #1a1d24 center / cover no-repeat; flex: none; }
#bar .np .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bar .np .s { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bar .ctl { display: flex; align-items: center; gap: 6px; }
#bar .ctl button { width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center; color: var(--text); }
#bar .ctl button:active { background: var(--panel-2); }
#bar .ctl button svg { width: 30px; height: 30px; }
#bar .ctl button.play { background: var(--text); color: #000; border-radius: 50%; }
#bar .ctl button.on { color: var(--accent-2); }
#bar .ctl .label { font-size: 11px; font-weight: 700; display: block; }
#bar .progress { position: absolute; left: 0; right: 0; top: -3px; height: 6px; background: transparent; }
#bar .progress .fill { height: 100%; background: var(--accent); width: 0; }
#bar .time { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; min-width: 110px; text-align: right; }
#bar input[type=range] { width: 120px; accent-color: var(--accent); }
#seek { position: absolute; left: 0; right: 0; top: -14px; width: 100%; height: 28px; opacity: 0; cursor: pointer; margin: 0; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: #000b; z-index: 100; display: grid; place-items: center; }
.modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px; width: min(560px, 92vw);
  max-height: 90vh; overflow: auto; }
.modal .qr { background: #fff; border-radius: 14px; padding: 14px; width: 300px; margin: 18px auto; }
.modal .qr svg { width: 100%; height: auto; }

.toast { position: fixed; left: 50%; bottom: calc(var(--bar) + 18px); transform: translateX(-50%); background: #23262e; padding: 14px 22px;
  border-radius: 12px; z-index: 200; box-shadow: 0 8px 30px #0008; max-width: 80vw; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.auth .box { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; }
.auth h1 { margin: 0 0 6px; font-size: 30px; }
.auth .logo { color: var(--accent-2); font-weight: 800; margin-bottom: 18px; }
.auth form { display: grid; gap: 14px; margin-top: 20px; }

@media (max-width: 900px) {
  :root { --rail: 84px; --bar: 84px; }
  #rail a { font-size: 12px; }
  #bar .time, #bar input[type=range] { display: none; }
}

/* ---------- brand wordmark (Tesla font by KAYOver/Dies, CC BY-SA 4.0) ---------- */
.wordmark { font-family: "TeslaLogo", system-ui, sans-serif; font-weight: 400; letter-spacing: .12em; text-transform: uppercase; }
#rail .brand.wordmark { font-size: 15px; line-height: 1.5; letter-spacing: .1em; padding: 8px 0 16px; }
.auth .logo.wordmark { font-size: 26px; margin-bottom: 22px; }
