:root {
  /* Canonical Atune brand — src/theme/colors.ts (BRAND_NAVY, BRAND_GOLD, neutrals) */
  --atune-navy: #0d1326;
  --atune-navy-2: #111827;
  --atune-navy-3: #070b14;
  --atune-gold: #cfb87c;
  --atune-gold-2: #dec98e;
  --atune-text: #f3f4f6;
  --atune-muted: #9ca3af;
  --atune-faint: rgba(243, 244, 246, 0.55);
  --atune-card: rgba(13, 19, 38, 0.72);
  --atune-card-strong: rgba(13, 19, 38, 0.88);
  --atune-border: rgba(207, 184, 124, 0.22);
  --atune-gold-wash-10: rgba(207, 184, 124, 0.1);
  --atune-gold-wash-14: rgba(207, 184, 124, 0.14);
  --atune-gold-wash-42: rgba(207, 184, 124, 0.42);
  --atune-gold-wash-32: rgba(207, 184, 124, 0.32);
  --atune-bg-art-opacity: 0.45;
  --atune-bg-art-opacity-fallback: 0.2;
  --overscan-x: clamp(16px, 5vw, 72px);
  --overscan-y: clamp(12px, 4.5vh, 56px);
  --grid-gap-x: clamp(16px, 2.8vw, 44px);
  --grid-gap-y: clamp(12px, 2vh, 28px);
  /* Brand row tracks artist/subtitle scale; title stays larger via .title */
  --atune-artist-size: clamp(16px, 2vw, 38px);
  --atune-brand-name-size: clamp(15px, 1.95vw, 36px);
  --atune-brand-site-size: clamp(14px, 1.82vw, 33px);
  --atune-brand-icon-size: clamp(30px, 2.75vw, 46px);
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--atune-navy-3);
  color: var(--atune-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Suppress CAF-injected viewport controls/scrubber overlays (not #atune-root) */
body > tv-overlay,
body > cast-overlay,
cast-controls,
cast-media-player,
.controls-overlay,
.player-controls,
.controls-progress,
[class*="ControlBar"],
[class*="control-bar"],
[class*="controls-overlay"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* CAF audio engine — offscreen; #atune-root is the only full-screen visual layer */
.atune-media-engine {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
}

.atune-media-engine audio {
  display: block;
  width: 0;
  height: 0;
}

.atune-root {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: auto;
  isolation: isolate;
  background:
    radial-gradient(circle at 18% 18%, rgba(207, 184, 124, 0.18), transparent 34%),
    radial-gradient(circle at 86% 78%, rgba(13, 19, 38, 0.65), transparent 38%),
    var(--atune-navy-3);
}

.atune-bg {
  position: absolute;
  inset: -12%;
  z-index: 0;
  opacity: 1;
  overflow: visible;
  pointer-events: none;
}

.atune-bg-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  filter: blur(36px) saturate(1.12);
  transform: scale(1.06);
  opacity: var(--atune-bg-art-opacity);
  transition: opacity 360ms ease;
}

.atune-bg[data-fallback-artwork="true"] .atune-bg-art {
  opacity: var(--atune-bg-art-opacity-fallback);
}

.atune-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(13, 19, 38, 0.78), rgba(13, 19, 38, 0.42) 48%, rgba(13, 19, 38, 0.68)),
    linear-gradient(180deg, rgba(13, 19, 38, 0.26), rgba(13, 19, 38, 0.82));
}

/* Stable 2×2 grid: artwork | now-playing / queue | lyrics */
.atune-shell {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding:
    max(var(--overscan-y), env(safe-area-inset-top, 0px))
    max(var(--overscan-x), env(safe-area-inset-right, 0px))
    max(var(--overscan-y), env(safe-area-inset-bottom, 0px))
    max(var(--overscan-x), env(safe-area-inset-left, 0px));
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  grid-template-rows: minmax(0, 1.65fr) minmax(0, 1fr);
  grid-template-areas:
    "artwork nowplaying"
    "queue   lyrics";
  gap: var(--grid-gap-y) var(--grid-gap-x);
  min-height: 0;
  min-width: 0;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.art-cell {
  grid-area: artwork;
  container-type: size;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.art-wrap {
  position: relative;
  width: min(100cqw, 100cqh);
  aspect-ratio: 1 / 1;
  max-width: 100%;
  max-height: 100%;
  border-radius: clamp(12px, 3.6vh, 44px);
  overflow: hidden;
  box-shadow: 0 34px 88px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--atune-border);
  background: linear-gradient(145deg, var(--atune-gold-wash-14), rgba(13, 19, 38, 0.94));
}

.artwork {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.artwork[data-fallback-artwork="true"] {
  object-fit: cover;
  object-position: center;
  padding: 0;
  box-sizing: border-box;
}

.artwork[hidden],
.artwork-empty[hidden] {
  display: none;
}

.artwork-empty {
  position: absolute;
  inset: 0;
  display: block;
  background:
    radial-gradient(circle at 34% 22%, rgba(207, 184, 124, 0.22), transparent 36%),
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(7, 11, 20, 0.98));
}

.info-card,
.lyrics-card,
.queue-card {
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--atune-border);
  border-radius: clamp(12px, 2.8vh, 36px);
  background: var(--atune-card);
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

.info-card {
  grid-area: nowplaying;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(14px, 3.2vh, 36px) clamp(14px, 2.8vw, 36px);
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.lyrics-card {
  grid-area: lyrics;
  padding: clamp(10px, 2vh, 24px) clamp(12px, 2vw, 28px);
  background: var(--atune-card-strong);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.queue-card {
  grid-area: queue;
  padding: clamp(10px, 2vh, 24px) clamp(12px, 2vw, 28px);
  background: var(--atune-card-strong);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.brand-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: clamp(8px, 1.1vw, 18px);
  min-width: 0;
  margin-bottom: clamp(2px, 0.4vh, 6px);
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-icon {
  width: var(--atune-brand-icon-size);
  height: var(--atune-brand-icon-size);
  border-radius: 0.42em;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 0 28px rgba(207, 184, 124, 0.28);
}

.brand-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--atune-text);
  font-size: var(--atune-brand-name-size);
  line-height: 1.12;
  font-weight: 800;
}

.brand-site {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--atune-gold);
  font-size: var(--atune-brand-site-size);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: lowercase;
  white-space: nowrap;
}

.source-badge {
  margin-left: auto;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 40%;
  padding: 0.44em 0.72em;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: var(--atune-muted);
  font-size: 0.75em;
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title {
  margin: clamp(8px, 1.8vh, 22px) 0 0;
  font-size: clamp(28px, 4.8vw, 88px);
  line-height: 0.98;
  letter-spacing: -0.06em;
  font-weight: 850;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.subtitle,
.album {
  margin: clamp(6px, 1.1vh, 14px) 0 0;
  color: var(--atune-muted);
  font-size: var(--atune-artist-size);
  line-height: 1.18;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album {
  color: var(--atune-faint);
  font-size: clamp(14px, 1.4vw, 28px);
}

.progress-block {
  margin-top: clamp(10px, 2.8vh, 32px);
  flex-shrink: 0;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  color: var(--atune-muted);
  font-size: clamp(13px, 1.2vw, 22px);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  margin-top: clamp(6px, 0.9vh, 12px);
  height: clamp(8px, 0.9vh, 14px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--atune-gold), var(--atune-gold-2));
  box-shadow: 0 0 24px rgba(207, 184, 124, 0.45);
  transition: width 260ms linear;
}

.transport-row {
  margin-top: clamp(10px, 2.2vh, 26px);
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  gap: 0;
  align-items: center;
  justify-content: space-evenly;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  pointer-events: auto;
  max-width: 100%;
}

/* Favorite heart glyph — larger than transport arrows; button size unchanged. */
.transport-btn.favorite-btn .transport-icon {
  width: 50%;
  height: 50%;
}

.transport-btn.favorite-btn[data-favorited="true"] .transport-icon {
  width: 52%;
  height: 52%;
}

/* Favorite / Radio share secondary transport circle with Previous / Next. */
.transport-btn.favorite-btn[data-favorited="true"] {
  color: var(--atune-gold-2);
  border-color: var(--atune-gold-wash-42);
  background: var(--atune-gold-wash-14);
}

.transport-btn.favorite-btn[data-enabled="false"] {
  opacity: 0.38;
  cursor: default;
  pointer-events: none;
}

.transport-btn.favorite-btn[data-inflight="true"] {
  opacity: 0.72;
}

.transport-btn.radio-btn[data-enabled="false"] {
  opacity: 0.38;
  cursor: default;
  pointer-events: none;
}

.transport-btn.radio-btn[data-enabled="true"] {
  cursor: pointer;
  pointer-events: auto;
}

.transport-btn.radio-btn[data-building="true"],
.transport-btn.radio-btn[data-inflight="true"] {
  cursor: wait;
  pointer-events: none;
}

.transport-btn.radio-btn .transport-icon {
  width: 48%;
  height: 48%;
}

.transport-btn {
  width: clamp(52px, 6vw, 120px);
  height: clamp(52px, 6vw, 120px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  color: var(--atune-text);
  background: rgba(255, 255, 255, 0.09);
  cursor: pointer;
  backdrop-filter: blur(14px);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 4;
}

.transport-icon {
  width: 40%;
  height: 40%;
  display: block;
  flex: 0 0 auto;
}

.transport-btn.play {
  width: clamp(62px, 7vw, 140px);
  height: clamp(62px, 7vw, 140px);
  color: var(--atune-navy-3);
  background: linear-gradient(145deg, var(--atune-gold), var(--atune-gold-2));
  box-shadow: 0 16px 40px rgba(207, 184, 124, 0.28);
}

.transport-btn.play .transport-icon {
  width: 36%;
  height: 36%;
}

.transport-btn:disabled {
  opacity: 0.34;
  cursor: default;
  pointer-events: none;
}

.transport-btn:not(:disabled):active {
  transform: scale(0.96);
}

.section-heading {
  flex-shrink: 0;
  color: var(--atune-faint);
  font-size: clamp(12px, 1.1vw, 20px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lyrics {
  margin-top: clamp(6px, 1vh, 12px);
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  font-size: clamp(18px, 2.3vw, 48px);
  line-height: 1.2;
  font-weight: 720;
  display: grid;
  gap: clamp(3px, 0.55vh, 10px);
  align-content: start;
  -webkit-mask-image: linear-gradient(180deg, #000 82%, transparent);
  mask-image: linear-gradient(180deg, #000 82%, transparent);
}

.lyrics-plain {
  align-content: start;
  text-align: left;
  -webkit-mask-image: linear-gradient(180deg, #000 82%, transparent);
  mask-image: linear-gradient(180deg, #000 82%, transparent);
}

.lyrics-synced {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(2px, 0.45vh, 7px);
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  overflow-y: hidden;
  -webkit-mask-image: none;
  mask-image: none;
  flex-shrink: 1;
}

.lyric-line-plain {
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--atune-muted);
}

.lyric-line-neighbor {
  color: var(--atune-muted);
  font-size: clamp(14px, 1.75vw, 34px);
  font-weight: 500;
  line-height: 1.12;
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  flex-shrink: 1;
  min-height: 0;
}

.lyric-line-active {
  color: var(--atune-gold-2);
  font-size: clamp(17px, 2.15vw, 44px);
  font-weight: 750;
  line-height: 1.1;
  opacity: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  flex-shrink: 0;
  padding: clamp(2px, 0.3vh, 5px) clamp(6px, 0.85vw, 14px);
  border-radius: 6px;
  background: var(--atune-gold-wash-14);
}

.lyric-line {
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lyric-line:first-child {
  opacity: 1;
  color: var(--atune-gold-2);
}

.lyrics-empty {
  color: var(--atune-faint);
  font-size: clamp(15px, 1.65vw, 30px);
  font-weight: 600;
  overflow: hidden;
  -webkit-mask-image: none;
  mask-image: none;
}

.queue-preview-list {
  list-style: none;
  margin: clamp(6px, 1vh, 12px) 0 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.queue-preview-item {
  display: flex;
  flex-direction: column;
  gap: clamp(1px, 0.2vh, 3px);
  padding: clamp(6px, 0.75vh, 10px) clamp(8px, 0.85vw, 12px);
  border-radius: 8px;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  outline: none;
  border: 1px solid transparent;
}

.queue-preview-item--current {
  cursor: default;
  background: var(--atune-gold-wash-14);
}

.queue-preview-item--inflight {
  opacity: 0.72;
  border-color: var(--atune-gold-wash-42);
  cursor: wait;
}

.queue-preview-item:hover:not(.queue-preview-item--current):not(.queue-preview-item--inflight),
.queue-preview-item:focus-visible:not(.queue-preview-item--current) {
  background: rgba(255, 255, 255, 0.08);
}

.queue-preview-item + .queue-preview-item {
  margin-top: clamp(2px, 0.35vh, 4px);
}

.queue-preview-title {
  font-weight: 750;
  color: var(--atune-text);
  font-size: clamp(13px, 1.15vw, 22px);
  line-height: 1.18;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-preview-item--current .queue-preview-title {
  color: var(--atune-gold-2);
}

.queue-preview-artist {
  color: var(--atune-muted);
  font-size: clamp(11px, 0.95vw, 18px);
  font-weight: 650;
  line-height: 1.16;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-preview-empty {
  margin: 0;
  color: var(--atune-faint);
  font-size: clamp(12px, 1.05vw, 20px);
  font-weight: 650;
  line-height: 1.28;
}

.up-next {
  margin-top: clamp(6px, 1vh, 12px);
  color: var(--atune-faint);
  font-size: clamp(12px, 1.1vw, 20px);
  font-weight: 650;
  line-height: 1.24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hide domain when brand row is tight */
@media (max-width: 1100px), (max-height: 680px) {
  .brand-site {
    display: none;
  }
}

/* Short viewports: give bottom row a bit more room */
@media (max-height: 720px) {
  .atune-shell {
    grid-template-rows: minmax(0, 1.45fr) minmax(0, 1fr);
    --grid-gap-y: clamp(8px, 1.4vh, 18px);
  }

  .title {
    -webkit-line-clamp: 1;
  }
}

/* Narrow browser: stack into a single scroll-safe column */
@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .atune-root {
    position: relative;
    min-height: 100%;
  }

  .atune-shell {
    height: auto;
    min-height: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "artwork"
      "nowplaying"
      "queue"
      "lyrics";
    overflow: visible;
  }

  .art-cell {
    min-height: min(72vw, 320px);
  }

  .art-wrap {
    width: min(72vw, 320px);
  }

  .info-card {
    min-height: 0;
  }

  .lyrics-card,
  .queue-card {
    min-height: clamp(80px, 14vh, 140px);
  }

  .transport-row {
    justify-content: center;
    gap: clamp(14px, 2.4vw, 40px);
  }
}
