/* True-black flat: elevation by lightness alone (#000 ground, #111 surface, #2a2a2a nested),
   no borders or shadows at rest, the primary action inverted to a white pill, and colour only on
   the lyric being sung. Controls are scaled up from the sheet's 36px to 60px for a car touchscreen
   read and tapped at arm's length. */

@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url(/fonts/inter-400.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url(/fonts/inter-500.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url(/fonts/inter-600.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url(/fonts/inter-700.woff2) format("woff2"); }

:root {
  --ground: #000000;
  --surface: #111111;
  --raised: #2a2a2a;
  --press: #3a3a3a;
  --text: #ffffff;
  --muted: #b4b4b4;
  --faint: #949494;
  --negative: #e5566f;
  --positive: #c6f24e;

  --accent: #ffffff; /* the viewer's highlight colour, set by app.js */
  --dim: rgba(255, 255, 255, 0.3);
  --size: 56px;

  --radius-sheet: 28px;
  --radius-card: 20px;
  --control: 64px; /* about 11mm on a Tesla screen at 1x */
  --gap: 14px;

  font-family: "Inter", system-ui, sans-serif;
  color: var(--text);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[data-size="s"] { --size: 40px; }
[data-size="m"] { --size: 56px; }
[data-size="l"] { --size: 72px; }
[data-size="xl"] { --size: 92px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ground); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: var(--control); padding: 0 32px; border-radius: 999px;
  font-size: 20px; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background-color 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--text); color: #000; }
.btn.primary:active { background: #d6d6d6; }
.btn.secondary { background: var(--raised); color: var(--text); }
.btn.secondary:active { background: var(--press); }
.btn.text { padding: 0 20px; color: var(--muted); }
.btn.text:active { background: var(--surface); }
.btn.danger { color: var(--negative); }

/* ---------- background ---------- */

#bg {
  position: fixed; inset: -10%;
  filter: blur(80px) saturate(1.4) brightness(0.35);
  transition: opacity 0.6s;
  z-index: 0;
}
.bg-layer {
  position: absolute; inset: 0; background: center / cover;
  opacity: 0; transition: opacity 1.2s ease;
}
.bg-layer.on { opacity: 1; }
[data-bg="black"] #bg { opacity: 0; }

.screen { position: relative; z-index: 1; height: 100%; }

/* ---------- sign in (car) ---------- */

#signin { display: grid; place-items: center; padding: 32px; overflow: auto; }
.signin { width: min(760px, 100%); text-align: center; }
.signin h1 { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.lede { font-size: 20px; line-height: 1.5; color: var(--muted); margin: 10px 0 36px; }

.pair { background: var(--surface); border-radius: var(--radius-card); padding: 36px 32px 28px; margin-bottom: 24px; }
.pair-step { font-size: 22px; line-height: 1.45; margin: 0; }
.pair-step strong { font-weight: 600; word-break: break-all; }
#pair-code {
  font-size: 104px; font-weight: 700; letter-spacing: 0.04em; line-height: 1;
  margin: 24px 0 18px; white-space: nowrap;
}
.pair-note { font-size: 16px; color: var(--faint); min-height: 1.5em; margin: 0; }

/* ---------- player ---------- */

#player { display: flex; flex-direction: column; }
#bar { display: flex; align-items: center; gap: 20px; padding: 24px 32px 12px; flex: none; }
#art { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--surface); flex: none; }
#art:not([src]) { visibility: hidden; }
.meta { flex: 1; min-width: 0; }
#title { margin: 0; font-size: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#artist { font-size: 18px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.progress { height: 4px; background: rgba(255, 255, 255, 0.14); border-radius: 2px; margin-top: 12px; overflow: hidden; }
#progress { height: 100%; width: 0; background: var(--text); }

.transport { display: flex; align-items: center; gap: 8px; flex: none; }
.transport button {
  width: var(--control); height: var(--control); border-radius: 999px;
  display: grid; place-items: center; color: var(--text);
  transition: background-color 0.15s, transform 0.1s, opacity 0.15s;
}
.transport button:active { background: var(--surface); transform: scale(0.94); }
.transport .play { width: 80px; height: 80px; background: var(--text); color: #000; }
.transport .play:active { background: #d6d6d6; }
.transport .i-play { display: none; }
.transport .play.paused .i-play { display: block; }
.transport .play.paused .i-pause { display: none; }
.transport button[aria-disabled="true"] { opacity: 0.4; }

.sync {
  display: flex; align-items: center; flex: none;
  height: var(--control); padding: 0 6px; border-radius: 999px; background: var(--surface);
}
.sync button {
  width: 56px; height: 56px; border-radius: 999px; display: grid; place-items: center;
  transition: background-color 0.15s;
}
.sync button:active { background: var(--raised); }
#offset { min-width: 76px; text-align: center; font-size: 18px; font-weight: 500; color: var(--muted); }
#offset.shifted { color: var(--text); }

.icon-btn {
  width: var(--control); height: var(--control); border-radius: 999px; flex: none;
  display: grid; place-items: center; background: var(--surface);
  transition: background-color 0.15s;
}
.icon-btn:active { background: var(--raised); }

#stage {
  flex: 1; position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  mask-image: linear-gradient(transparent, #000 18%, #000 70%, transparent); /* taste-skill-ignore: an alpha mask fading lyrics at the edges, not a fill */
  -webkit-mask-image: linear-gradient(transparent, #000 18%, #000 70%, transparent); /* taste-skill-ignore: same mask */
}
#lyrics {
  position: absolute; left: 0; right: 0; top: 0;
  padding: 0 64px;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
#lyrics.no-anim { transition: none; }
#lyrics.fresh { animation: lyrics-in 0.5s ease both; }
@keyframes lyrics-in { from { opacity: 0; } to { opacity: 1; } }

/* Between songs: the old one fades out, the new one fades in. */
#art, .meta, #stage { transition: opacity 0.28s ease; }
.swapping #art, .swapping .meta, .swapping #stage { opacity: 0; }

#resume {
  position: fixed; right: 32px; bottom: 28px; z-index: 4;
  height: 56px; font-size: 18px; padding: 0 26px;
}
.line {
  font-size: var(--size); font-weight: 700; line-height: 1.18; letter-spacing: -0.02em;
  margin: 0 0 0.45em; color: var(--dim);
  transform-origin: left center;
  transition: color 0.35s, opacity 0.35s, transform 0.35s;
}
.line.active { color: var(--accent); transform: scale(1.02); }
.seekable .line:not(.gap) { cursor: pointer; }
.seekable .line:not(.gap):active { opacity: 0.8; }
.line.past { opacity: 0.55; }
.line.gap { font-size: calc(var(--size) * 0.8); letter-spacing: 0.3em; }
.plain .line { font-size: calc(var(--size) * 0.6); font-weight: 600; color: rgba(255, 255, 255, 0.75); margin-bottom: 0.3em; }
.plain-note { font-size: 18px; color: var(--faint); margin-bottom: 24px; }

#status {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font-size: 30px; font-weight: 600; color: var(--faint); padding: 40px;
  pointer-events: none;
}

#toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 5; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 16px 26px; border-radius: 999px;
  background: var(--raised); color: var(--text); font-size: 18px; font-weight: 500; text-align: center;
}

/* ---------- settings sheet ---------- */

#settings {
  position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.72);
  display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 24px; overflow: auto;
}
.sheet {
  width: min(880px, 100%); min-width: 0; background: var(--surface); border-radius: var(--radius-sheet);
  padding: 28px 32px 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5); /* taste-skill-ignore: a dialog floating over the lyrics */
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.tabs { display: flex; gap: 4px; padding: 6px; background: var(--ground); border-radius: 999px; }
.tabs button {
  height: 52px; padding: 0 26px; border-radius: 999px;
  font-size: 20px; font-weight: 600; color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.tabs button:active { background: var(--raised); }
.tabs button[aria-selected="true"] { background: var(--text); color: #000; }

/* Both tabs share one grid cell so the sheet keeps its size when switching. */
.panels { display: grid; }
.panels > .panel { grid-area: 1 / 1; min-width: 0; }
.panels > .panel[hidden] { display: block !important; visibility: hidden; }

.devices-intro { font-size: 17px; line-height: 1.5; color: var(--muted); margin: 22px 0 16px; }
.device-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 340px; overflow-y: auto; overscroll-behavior: contain; }
.device {
  display: flex; align-items: center; gap: 12px;
  min-height: 76px; padding: 10px 10px 10px 22px; border-radius: 18px; background: var(--raised);
}
.device-main { flex: 1; min-width: 0; }
.device-name { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 600; }
.device-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-meta { font-size: 15px; color: var(--muted); margin-top: 4px; }
.pill { flex: none; height: 24px; padding: 0 10px; border-radius: 999px; display: inline-flex; align-items: center; font-size: 13px; font-weight: 600; background: var(--text); color: #000; }
.device .btn { height: 52px; padding: 0 18px; font-size: 17px; }
.device .btn.text { color: var(--text); }
.device .btn.text.danger { color: var(--negative); }
.device .btn.text:active { background: var(--press); }
.device.confirm .btn.text.remove { background: var(--negative); color: #000; }
.device input {
  flex: 1; min-width: 0; height: 52px; padding: 0 16px; border: 0; border-radius: 12px;
  background: var(--ground); color: var(--text); font: 600 19px "Inter", system-ui, sans-serif;
}
.device input:focus-visible { outline: 2px solid var(--text); outline-offset: 0; }
.device-status { font-size: 16px; color: var(--faint); min-height: 1.4em; margin: 10px 0 0; }
.foot-note { font-size: 15px; color: var(--faint); }

/* What the settings produce, on the chosen background, at 60% of the real size. */
.preview {
  margin: 24px 0 8px; padding: 26px 28px; border-radius: var(--radius-card);
  background: #000 center / cover; height: 168px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  position: relative; isolation: isolate;
}
.preview::before {
  content: ""; position: absolute; inset: -20%; z-index: -1;
  background: var(--art, none) center / cover;
  filter: blur(40px) saturate(1.4) brightness(0.35);
  transition: opacity 0.3s;
}
[data-bg="black"] .preview::before { opacity: 0; }
.pv-line {
  font-size: calc(var(--size) * 0.6); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15;
  color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: font-size 0.2s, color 0.2s;
}
.pv-line.on { color: var(--accent); }

.setting {
  display: grid; grid-template-columns: 200px 1fr; align-items: center; gap: 24px;
  padding: 18px 0;
}
.setting > * { min-width: 0; }
.setting-label { font-size: 20px; font-weight: 500; }
.setting-label .value { display: block; font-size: 16px; font-weight: 400; color: var(--muted); margin-top: 4px; }

.seg { display: flex; padding: 6px; gap: 4px; background: var(--ground); border-radius: 999px; }
.seg button {
  flex: 1; height: 52px; border-radius: 999px;
  font-size: 20px; font-weight: 600; color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.seg button:active { background: var(--raised); }
.seg button.on { background: var(--text); color: #000; }

.swatches { display: flex; justify-content: space-between; gap: 8px; }
.swatches button {
  width: 60px; height: 60px; border-radius: 999px; background: var(--c); flex: none;
  box-shadow: 0 0 0 0 var(--surface), 0 0 0 0 var(--text); /* taste-skill-ignore: selection ring, not a shadow */
  transition: box-shadow 0.15s, transform 0.1s;
}
.swatches button:active { transform: scale(0.92); }
.swatches button.on { box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--text); } /* taste-skill-ignore: selection ring */

.sheet-foot {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding-top: 24px;
  border-top: 1px solid #222;
}
.sheet-foot .danger { margin-left: auto; }
.screen-size { margin: 12px 0 0; font-size: 13px; color: var(--faint); text-align: right; }

/* Short windows: the Tesla browser often opens in a panel well under 800px tall. */
@media (max-height: 820px) and (min-width: 801px) {
  [data-size="s"] { --size: 34px; } [data-size="m"] { --size: 46px; }
  [data-size="l"] { --size: 60px; } [data-size="xl"] { --size: 76px; }
  #bar { padding: 16px 28px 8px; }
  #art { width: 64px; height: 64px; }
  #settings { padding: 12px; align-items: center; }
  .sheet { padding: 18px 26px 16px; }
  .tabs button { height: 46px; padding: 0 20px; font-size: 18px; }
  .devices-intro { margin: 12px 0 10px; }
  .device-list { max-height: 260px; }
  .device { min-height: 66px; }
  .preview { height: 104px; margin: 14px 0 4px; padding: 14px 24px; gap: 4px; }
  .pv-line { font-size: calc(var(--size) * 0.42); }
  .setting { padding: 8px 0; }
  .sheet-foot { margin-top: 8px; padding-top: 14px; }
  .screen-size { margin-top: 6px; }
}
@media (max-height: 640px) and (min-width: 801px) {
  .preview { display: none; }
  .sheet-head { margin-bottom: 8px; }
}

/* ---------- link page and messages ---------- */

body.message { display: grid; place-items: center; height: 100%; text-align: center; overflow: auto; padding: 24px; }
body.message main { width: min(640px, 100%); }
body.message h1 { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 12px; }
body.message p { font-size: 20px; line-height: 1.5; color: var(--muted); margin: 0 0 32px; word-break: break-word; }
body.message .btn { min-width: 160px; }
body.message > main > .btn { background: var(--text); color: #000; }

#form {
  display: flex; gap: 10px; padding: 8px; border-radius: 999px; background: var(--surface);
  max-width: 520px; margin: 0 auto;
}
#code {
  flex: 1; min-width: 0; height: 64px; padding: 0 24px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text);
  font: 700 34px "Inter", system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
#code::placeholder { color: var(--faint); }
#code:focus-visible { outline: none; }
#form:focus-within { box-shadow: 0 0 0 2px var(--text); } /* taste-skill-ignore: focus ring */
#form .btn { height: 64px; }
.result { min-height: 1.5em; margin: 24px 0 !important; }
.result.ok { color: var(--positive) !important; }
.result.err { color: var(--negative) !important; }
.back { display: inline-flex; align-items: center; height: 48px; padding: 0 16px; color: var(--muted); font-size: 18px; text-decoration: none; border-radius: 999px; }
.back:active { background: var(--surface); }

@media (prefers-reduced-motion: reduce) {
  #lyrics, .line, .bg-layer, #art, .meta, #stage { transition: none !important; }
  #lyrics.fresh { animation: none; }
}

/* ---------- narrow screens ---------- */

@media (max-width: 800px) {
  :root { --size: 34px; --control: 52px; }
  [data-size="s"] { --size: 26px; } [data-size="m"] { --size: 34px; }
  [data-size="l"] { --size: 44px; } [data-size="xl"] { --size: 56px; }
  #bar { padding: 16px; gap: 12px; flex-wrap: wrap; }
  #art { width: 56px; height: 56px; }
  .meta { flex-basis: calc(100% - 68px); }
  .transport { flex-basis: 100%; justify-content: center; gap: 28px; order: 3; }
  .transport .play { width: 64px; height: 64px; }
  #bar .icon-btn { margin-left: auto; }
  #lyrics { padding: 0 20px; }
  #pair-code { font-size: 56px; }
  .pair { padding: 28px 16px 22px; }
  .pair-step { font-size: 18px; }
  .btn { font-size: 17px; padding: 0 22px; }
  .sheet { padding: 22px 18px 18px; }
  .setting { grid-template-columns: 1fr; gap: 12px; padding: 14px 0; }
  #settings { padding: 12px; }
  .swatches { gap: 4px; }
  .swatches button { width: 38px; height: 38px; }
  .swatches button.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); } /* taste-skill-ignore: selection ring */
  .seg button { font-size: 17px; height: 46px; }
  .preview { height: 120px; padding: 18px; }
  .sheet-foot { flex-wrap: wrap; }
  .sheet-foot .btn.secondary { flex: 1; }
  .sheet-foot .danger { margin-left: 0; width: 100%; }
  .tabs button { padding: 0 16px; font-size: 17px; height: 44px; }
  .device { flex-wrap: wrap; padding: 12px 12px 12px 16px; }
  .device-main { flex-basis: 100%; }
  .foot-note { flex-basis: 100%; }
}
