:root {
  color-scheme: dark;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  background: #0b0b0d;
  color: #f4f4f5;
  --panel: #17171b;
  --panel-2: #222228;
  --edge: #2c2c33;
  --muted: #a1a1aa;
  --red: #ff3b3b;
  --rail: 132px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.5rem, 2.4vw, 2.2rem); letter-spacing: -.03em; line-height: 1.15; }
h2 { font-size: 1.3rem; letter-spacing: -.02em; }
img { display: block; }
.note { color: var(--muted); font-size: .95rem; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Buttons */
.accent, .pill, .link {
  min-height: 52px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent; font-weight: 700;
}
.accent { background: #fff; color: #0b0b0d; }
.accent:hover { background: #e4e4e7; }
.pill { background: var(--panel-2); border-color: var(--edge); }
.pill:hover { background: #2e2e36; }
.link { background: transparent; color: var(--muted); text-decoration: underline; padding: 0 6px; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 1.25rem; font-weight: 800; letter-spacing: -.03em; background: none; border: 0; padding: 0; min-height: 52px; white-space: nowrap; }
.brand.big { font-size: 1.6rem; margin-bottom: 28px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--red); color: #fff; font-size: .8rem; padding-left: 2px; }

/* Sign-in */
.gate { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(560px, 100%); padding: 36px; border-radius: 24px; background: var(--panel); border: 1px solid var(--edge); display: grid; gap: 16px; justify-items: start; }
.gate-card h1 { font-size: 1.6rem; margin-bottom: 4px; }
#google-signin { display: grid; gap: 14px; justify-items: start; width: 100%; }
#login { display: grid; gap: 12px; width: 100%; }
#login label { color: var(--muted); }
#login input { width: 100%; min-height: 58px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--edge); background: #0f0f12; }
.pending { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.pending p { line-height: 1.5; }
.qr { width: 188px; height: 188px; padding: 10px; background: #fff; border-radius: 16px; image-rendering: pixelated; }
.code { font-size: 2.2rem; font-weight: 800; letter-spacing: .12em; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }

/* App frame */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100svh; }
.rail {
  position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; gap: 8px;
  padding: 18px 12px; background: #0b0b0d; border-right: 1px solid #1c1c21; overflow-y: auto;
}
.rail button {
  display: grid; justify-items: center; gap: 8px; padding: 16px 6px; min-height: 96px;
  border: 0; border-radius: 18px; background: transparent; color: #d4d4d8; font-size: .85rem; font-weight: 700;
}
.rail button svg { width: 30px; height: 30px; fill: currentColor; }
.rail button:hover { background: #18181c; }
.rail button[aria-current="page"] { background: var(--panel-2); color: #fff; }
.rail .rail-bottom { margin-top: auto; color: var(--muted); }
.main { min-width: 0; padding: 0 28px 40px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 14px 0; background: linear-gradient(#0b0b0d 75%, #0b0b0d00); }
.find { flex: 1; max-width: 720px; margin-left: auto; display: flex; align-items: center; background: var(--panel); border: 1px solid var(--edge); border-radius: 999px; padding-left: 22px; }
.find input { flex: 1; min-width: 0; min-height: 56px; background: transparent; border: 0; outline: none; font-size: 1.05rem; }
.find input::placeholder { color: var(--muted); }
.find button { width: 64px; min-height: 56px; border: 0; background: transparent; border-radius: 0 999px 999px 0; }
.find button svg { width: 26px; height: 26px; fill: currentColor; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }

/* Home */
.hero { margin: 8px 0 30px; }
.hero-art {
  position: relative; display: block; width: min(100%, 980px); aspect-ratio: 16 / 7; padding: 0; border: 0;
  border-radius: 24px; overflow: hidden; background: var(--panel); text-align: left;
}
.hero-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 35%, #000000e0); }
.hero-label { position: absolute; z-index: 1; top: 22px; left: 26px; font-size: .8rem; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: #fffc; }
.hero-text { position: absolute; z-index: 1; left: 26px; right: 120px; bottom: 30px; display: grid; gap: 6px; }
.hero-text strong { font-size: clamp(1.3rem, 2.4vw, 2rem); line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hero-text small { color: #e4e4e7; font-size: 1rem; }
.hero-play { position: absolute; z-index: 1; right: 28px; bottom: 30px; display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: #fff; color: #000; font-size: 1.4rem; padding-left: 4px; }
.hero .progress { z-index: 1; height: 6px; }

.row { margin-bottom: 34px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.row-head .pill { min-height: 44px; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 26px 20px; }
.card { position: relative; min-width: 0; }
.card-open { display: grid; gap: 12px; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.card-art { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: var(--panel-2); }
.card-art img { width: 100%; height: 100%; object-fit: cover; }
.card-open:hover .card-art img { filter: brightness(1.08); }
.badge { position: absolute; right: 10px; bottom: 12px; padding: 3px 8px; border-radius: 7px; background: #000000d0; font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge.live { background: var(--red); letter-spacing: .06em; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: #ffffff40; }
.progress > span { display: block; height: 100%; background: var(--red); }
.card-text { display: grid; gap: 4px; padding-right: 52px; }
.card-text strong { font-size: 1.05rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card-text small { color: var(--muted); font-size: .9rem; }
.card-action {
  position: absolute; right: 0; bottom: 4px; width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--edge); background: var(--panel); font-size: 1.3rem; font-weight: 700;
}

/* Lists */
.list-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 20px; }
#list-refresh { margin-left: auto; font-size: 1.3rem; }
#list-status { margin-bottom: 14px; }
.connect { padding: 26px; border-radius: 22px; background: var(--panel); border: 1px solid var(--edge); margin-bottom: 30px; max-width: 760px; }
.connect h2 { margin-bottom: 6px; }
.connect .accent { margin-top: 16px; }

/* Player */
.player-view { padding-top: 4px; }
.stage { overflow: hidden; border-radius: 22px; background: #000; }
.picture { position: relative; aspect-ratio: 16 / 9; background: #000; max-height: calc(100svh - 210px); width: 100%; }
canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; }
.stage-mark { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: #ffffff1a; color: #fff; padding-left: 4px; }
.buffer { position: absolute; left: 18px; bottom: 18px; padding: 8px 14px; border-radius: 10px; background: #000000c0; }
.overlay-back { position: absolute; top: 14px; left: 14px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: #000000a0; font-size: 2rem; line-height: 1; padding-bottom: 4px; }
.controls { padding: 4px 16px 14px; background: #0f0f12; }
.seek { width: 100%; display: block; min-height: 44px; accent-color: var(--red); margin: 0; }
.transport { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.transport button { min-height: 52px; min-width: 56px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--edge); background: var(--panel-2); font-weight: 700; }
.transport button:disabled { color: #71717a; cursor: default; }
.play { min-width: 92px !important; background: #fff !important; color: #000; }
.play:disabled { background: var(--panel-2) !important; }
.time { color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 6px; white-space: nowrap; }
.volume { display: flex; align-items: center; gap: 10px; margin-left: auto; color: var(--muted); }
.volume input { width: clamp(80px, 10vw, 140px); accent-color: #fff; min-height: 44px; }
#fullscreen { font-size: 1.4rem; }
.stage.is-live .seek { opacity: .3; }
.stage.is-live .time { color: var(--red); font-weight: 800; }
.stage:fullscreen { border-radius: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.stage:fullscreen .picture { height: 100%; max-height: none; aspect-ratio: auto; }
.now { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 18px 4px 0; }
.now .pill { flex-shrink: 0; }
.status:not(:empty) { color: #fca5a5; margin-top: 10px; }

@media (max-width: 760px) {
  :root { --rail: 0px; }
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 10; flex-direction: row; padding: 6px; border-right: 0; border-top: 1px solid #1c1c21; overflow-x: auto; }
  .rail button { min-height: 64px; min-width: 76px; padding: 8px 4px; font-size: .72rem; }
  .rail .rail-bottom { margin-top: 0; }
  .main { padding: 0 14px 100px; }
  .topbar .brand { display: none; }
  .volume label { display: none; }
}

/* Tesla screen preview (computers only; see boot.js) */
.tesla-preview body { background: #3a3d42; overflow: hidden; }
.tp-stage { position: relative; height: 100svh; }
.tp-screen { position: absolute; top: 16px; left: 50%; display: flex; padding: 12px; border-radius: 28px; background: #000; box-shadow: 0 30px 80px #0008; transform-origin: top left; }
.tp-car { display: grid; grid-template-rows: auto 1fr auto; padding: 18px; border-radius: 18px 0 0 18px; background: linear-gradient(#f2f2f2, #d9dadc); color: #222; margin-right: 12px; }
.tp-car-top { font-size: 2rem; font-weight: 800; display: flex; gap: 14px; align-items: baseline; }
.tp-car-top .tp-dim { font-size: 1.1rem; }
.tp-dim { color: #9a9a9a; font-weight: 600; }
.tp-car-art { margin: 20px auto; width: 60%; max-width: 160px; aspect-ratio: 1 / 2.1; border-radius: 40% 40% 30% 30%; background: linear-gradient(#fdfdfd, #c7c9cc); box-shadow: inset 0 0 0 3px #b8babd; align-self: center; }
.tp-car-label { color: #8a8a8a; font-weight: 700; text-align: center; }
.tp-browser { display: grid; grid-template-rows: auto 1fr; border-radius: 0 18px 18px 0; overflow: hidden; background: #0b0b0d; }
.tp-bar { display: flex; align-items: center; gap: 20px; height: 150px; padding: 0 28px; background: #e9eaec; color: #333; font-size: 1.6rem; }
.tp-url { flex: 1; padding: 14px 22px; border-radius: 14px; background: #fff; font-size: 1.3rem; }
.tp-browser iframe { display: block; border: 0; background: #0b0b0d; }
.tp-note { position: absolute; left: 0; right: 0; top: calc(var(--tp-height, 0px) + 26px); text-align: center; color: #d4d4d8; font-size: .9rem; margin: 0; }
.tp-note a { color: #fff; }

/* Brand */
.brand-logo { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }
.brand.big .brand-logo { width: 52px; height: 52px; border-radius: 13px; }
.wordmark span { color: var(--red); }

/* Usage */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 30px; }
.stat { display: grid; gap: 6px; padding: 20px 22px; border-radius: 18px; background: var(--panel); border: 1px solid var(--edge); }
.stat strong { font-size: 1.9rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: .95rem; }
.section-title { margin: 8px 0 10px; }
.table-wrap { overflow-x: auto; margin: 12px 0 18px; border: 1px solid var(--edge); border-radius: 16px; }
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap th, .table-wrap td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--edge); vertical-align: top; }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap th { color: var(--muted); font-weight: 700; font-size: .9rem; background: var(--panel); }
.table-wrap td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap td.note { font-size: .88rem; }

.usage-page { max-width: 1100px; margin: 0 auto; padding: 24px 28px 48px; }
.usage-page .brand { text-decoration: none; color: inherit; margin-right: 12px; }

.button-link { display: inline-grid; place-items: center; text-decoration: none; }
