/* Shared console for the library player and every tablet orientation. The record room's console
   (crate.css) carries a set of its own, drawn in clay. */
.player-console {
  --control-ink: #090a0b; --control-line: #343a4060; --control-mark: #fafafa;
  --control-dial-size: 124px; --control-cell-height: 72px;
  color: var(--control-ink); min-width: 0;
}
html[data-tablet-theme="night"] .tablet .player-console {
  --control-ink: #eceeef; --control-line: #cbd0d64d; --control-mark: #17191c;
}
.tablet-button-grids { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr 1fr; min-width: 0; }
.tablet-control-options { border-left: 0; }
.tablet-timeline {
  --tablet-fill: var(--tablet-secondary, #7a8289);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-column: 1 / -1;
  align-items: center; gap: 10px; padding: 0 12px; min-width: 0; flex: none;
}
.tablet-timeline output { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--tablet-muted, var(--fg-3)); }
.player-console .tablet-timeline input[type="range"] { height: 32px; min-width: 0; }
.player-console .tablet-timeline input::-webkit-slider-thumb { width: 6px; height: 6px; margin-top: -2px; box-shadow: none; }
.player-console .tablet-timeline input::-moz-range-thumb { width: 6px; height: 6px; box-shadow: none; }
.player-console .tablet-timeline input:disabled { opacity: .28; cursor: default; }
@media (pointer: coarse) {
  .player-console .tablet-timeline input[type="range"] { height: 44px; }
}
.tablet-dials { display: grid; grid-template-columns: minmax(0, 1fr); }
.tablet-dial-cell { position: relative; padding: 26px 12px 12px; display: flex; justify-content: center; }
.tablet-dial-cell > label { position: absolute; top: 1px; left: 12px; font-size: 12px; font-weight: 400; }
.tablet-dial-cell > output { position: absolute; top: 1px; right: 12px; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--tablet-muted, var(--fg-3)); }
.tablet-dial { position: relative; width: var(--control-dial-size); max-width: 100%; aspect-ratio: 1; align-self: center; }
.tablet-dial-scale { position: absolute; inset: 0; pointer-events: none; }
.tablet-dial-scale i { position: absolute; inset: 0; transform: rotate(var(--tick)); }
.tablet-dial-scale i::before { content: ''; position: absolute; top: 0; left: calc(50% - .5px); width: 1px; height: 6px; background: var(--control-ink); }
.tablet-dial-scale i:nth-child(4n + 1)::before { height: 8px; }
.tablet-dial-face { position: absolute; inset: 12px; background: var(--control-ink); border-radius: 50%; transform: rotate(var(--angle)); pointer-events: none; }
.tablet-dial-face > span { position: absolute; top: 8px; left: calc(50% - 1.5px); width: 3px; height: 9px; background: var(--control-mark); }
.player-console .tablet-dial input[type="range"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; touch-action: none; cursor: grab; }
.player-console .tablet-dial input:active { cursor: grabbing; }
.tablet-dial:has(input:focus-visible) { outline: 2px solid var(--tablet-focus, var(--fg-2)); outline-offset: 4px; border-radius: 50%; }
.tablet-dial:has(input:disabled) { opacity: .28; }
.tablet-control-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.player-console .tablet-control-grid.tablet-control-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.player-console .tablet-control-grid button {
  position: relative; display: grid; place-items: center; height: var(--control-cell-height); width: 100%;
  padding: 14px 0 0; margin: 0; border: 0; border-top: 1px solid var(--control-line); border-radius: 0;
  color: var(--control-ink); background: none; box-shadow: none; transform: none;
}
.player-console .tablet-control-grid button + button { border-left: 1px solid var(--control-line); }
.tablet-control-grid button > span:first-child { position: absolute; top: 6px; left: 12px; font-size: 12px; line-height: 1; font-weight: 400; }
.tablet-control-grid [data-symbol] { display: flex; }
.tablet-control-grid svg { width: clamp(34px, 5.5dvh, 48px); height: clamp(34px, 5.5dvh, 48px); }
.player-console .tablet-control-grid button:hover { background: #8080800a; }
.player-console .tablet-control-grid button:active { background: #80808018; }
.player-console .tablet-control-grid button:disabled { opacity: 1; cursor: default; }
.tablet-control-grid button:disabled > span { opacity: .28; }
.tablet-control-grid button[aria-busy="true"] [data-symbol] { opacity: .4; }
.player-console .tablet-control-grid button:focus-visible { outline-offset: -4px; }
.player-console .tablet-control-grid.tablet-control-options svg { width: 26px; height: 26px; stroke-width: 1.5; }
.player-console .tablet-control-options button { color: var(--tablet-muted, var(--fg-3)); }
.player-console .tablet-control-options button[aria-pressed="true"] { color: var(--control-ink); }
.tablet-control-options button[aria-pressed="true"]::after { content: ''; position: absolute; width: 3px; height: 3px; border-radius: 50%; background: currentColor; bottom: 6px; }
.tablet-control-options button[data-control="like"]::after { display: none; }
.tablet-mode-switch { position: relative; width: 32px; height: 18px; border: 1.5px solid currentColor; border-radius: 10px; }
.tablet-mode-switch::before { content: ''; position: absolute; width: 10px; height: 10px; top: 2.5px; left: 3px; border-radius: 50%; background: currentColor; }
.player-console .tablet-control-options [role="switch"] { touch-action: manipulation; }
.player-console .tablet-control-options [aria-checked="true"] { color: var(--control-ink); }
.tablet-control-options [aria-checked="true"] .tablet-mode-switch::before { transform: translateX(13px); }

/* Shared player layout and console. */
.tablet .tablet-body { grid-template-rows: minmax(0, 1fr) auto; row-gap: 8px; }
.tablet .tablet-listening, .tablet .tablet-playlist { display: block; }
.tablet .tablet-listening > .tablet-progress,
.tablet .tablet-listening > .tablet-transport,
.tablet .tablet-playlist > .tablet-volume { display: none; }
.tablet .tablet-portrait-controls {
  display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 1.2fr);
  grid-column: 1 / -1; width: 100%; max-width: 1200px; justify-self: center;
  border-top: 1px solid var(--control-line);
  opacity: 1; visibility: visible; transition: opacity .18s ease, visibility 0s;
}
.tablet-portrait-controls .tablet-button-grids { border-left: 1px solid var(--control-line); }
.tablet-portrait-controls .tablet-control-grid:not(.tablet-control-options) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tablet-portrait-controls .tablet-control-grid button { height: 100%; }
.tablet.is-ui-hidden .tablet-portrait-controls {
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .45s ease, visibility 0s .45s;
}
.tablet.has-karaoke.is-karaoke-focus .tablet-body { grid-template-rows: minmax(0, 1fr) auto; }
.tablet.is-karaoke-focus .tablet-listening { display: none; }
.tablet.is-karaoke-focus .tablet-portrait-controls { grid-row: 2; }
.tablet.is-karaoke-focus .tablet-playlist { grid-row: 1; }

/* Desktop: the visualizer fills the left column; controls sit below the queue. */
@media (aspect-ratio > 9/10) {
  .tablet:not(.is-karaoke-focus) .tablet-body {
    grid-template-columns: minmax(0, 1.14fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto; gap: 12px clamp(20px, 3.5vw, 64px);
  }
  .tablet:not(.is-karaoke-focus) .tablet-listening { grid-column: 1; grid-row: 1 / -1; }
  .tablet:not(.is-karaoke-focus) .tablet-playlist { grid-column: 2; grid-row: 1; }
  .tablet:not(.is-karaoke-focus) .tablet-portrait-controls {
    grid-column: 2; grid-row: 2; display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
    align-self: end; max-width: none;
    --control-dial-size: clamp(112px, 9vw, 148px); --control-cell-height: clamp(72px, 10dvh, 96px);
  }
  .tablet:not(.is-karaoke-focus) .tablet-dials { border-top: 1px solid var(--control-line); }
  .tablet:not(.is-karaoke-focus) .tablet-dial-cell { padding: 28px 12px 12px; align-items: center; }
  .tablet:not(.is-karaoke-focus) .tablet-dial-cell > label { top: 8px; }
  .tablet:not(.is-karaoke-focus) .tablet-dial-cell > output { top: 8px; right: 12px; white-space: nowrap; }
  .tablet:not(.is-karaoke-focus) .tablet-control-grid:not(.tablet-control-options) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tablet:not(.is-karaoke-focus) .tablet-control-grid button {
    height: 100%; min-height: var(--control-cell-height); border-top: 1px solid var(--control-line);
  }
  .tablet:not(.is-karaoke-focus) .tablet-control-grid:not(.tablet-control-options) svg { width: 38px; height: 38px; }
}

@media (max-aspect-ratio: 9/10) {
  .tablet .player-console {
    --control-dial-size: clamp(112px, 13dvh, 160px);
    --control-cell-height: clamp(68px, 10dvh, 112px);
  }
  .tablet { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .tablet:not(.is-karaoke-focus) .tablet-body {
    grid-template-rows: minmax(110px, 1.3fr) minmax(80px, .75fr) auto; gap: 0;
  }
  .tablet .tablet-listening { display: block; }
  .tablet .tablet-visual { margin-inline: auto; }
  .tablet .tablet-listening > .tablet-progress,
  .tablet .tablet-listening > .tablet-transport,
  .tablet .tablet-playlist > .tablet-volume { display: none; }
  .tablet .tablet-playlist { display: block; }
  .tablet .tablet-portrait-controls {
    display: block; width: 100%; max-width: 700px; justify-self: center;
    color: var(--control-ink); border-top: 1px solid var(--control-line);
    opacity: 1; visibility: visible; transition: opacity .18s ease, visibility 0s;
  }
  .tablet.is-ui-hidden .tablet-portrait-controls {
    opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .45s ease, visibility 0s .45s;
  }
  .tablet-portrait-controls .tablet-control-grid:not(.tablet-control-options) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tablet-portrait-controls .tablet-button-grids { border-left: 0; }
  .tablet .tablet-portrait-controls .tablet-control-grid button { height: var(--control-cell-height); border-top: 1px solid var(--control-line); }
  .tablet .tablet-portrait-controls .tablet-control-grid button + button { border-left: 1px solid var(--control-line); }
  .tablet.has-karaoke.is-karaoke-focus .tablet-body { grid-template-rows: minmax(0, 1fr) auto; }
  .tablet.is-karaoke-focus .tablet-listening { display: none; }
  .tablet.is-karaoke-focus .tablet-portrait-controls { grid-row: 2; }
  .tablet.is-karaoke-focus .tablet-playlist { grid-row: 1; }
}
@media (max-aspect-ratio: 9/10) and (max-height: 720px) {
  .tablet .player-console { --control-dial-size: 92px; --control-cell-height: 56px; }
  .tablet-dial-cell { padding-top: 22px; padding-bottom: 8px; }
  .tablet-control-grid svg { width: 30px; height: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .tablet .tablet-portrait-controls, .tablet.is-ui-hidden .tablet-portrait-controls { transition: none; }
}
/* Phone landscape: circle, queue, console. Keep all three in the viewport. */
@media (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {
  .tablet { padding: max(56px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .tablet:not(.is-karaoke-focus) .tablet-body {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr) minmax(192px, .75fr);
    grid-template-rows: minmax(0, 1fr); gap: clamp(8px, 1.6vw, 20px);
  }
  .tablet:not(.is-karaoke-focus) .tablet-listening { grid-column: 1; grid-row: 1; }
  .tablet:not(.is-karaoke-focus) .tablet-playlist { grid-column: 2; grid-row: 1; }
  .tablet:not(.is-karaoke-focus) .tablet-portrait-controls {
    grid-column: 3; grid-row: 1; display: flex; flex-direction: column;
    min-height: 0; align-self: stretch; border-top: 0; border-left: 1px solid var(--control-line);
    --control-dial-size: clamp(64px, 18dvh, 104px);
  }
  .tablet:not(.is-karaoke-focus) .tablet-button-grids { flex: 1; min-height: 88px; border-left: 0; }
  .tablet:not(.is-karaoke-focus) .tablet-dials { flex: none; border-block: 1px solid var(--control-line); }
  .tablet:not(.is-karaoke-focus) .tablet-dial-cell { padding: 24px 8px 6px; }
  .tablet:not(.is-karaoke-focus) .tablet-dial-cell > label { top: 4px; left: 8px; }
  .tablet:not(.is-karaoke-focus) .tablet-dial-cell > output { top: 4px; right: 8px; font-size: 10px; white-space: nowrap; }
  .tablet:not(.is-karaoke-focus) .tablet-control-grid { min-height: 44px; grid-template-rows: 1fr; }
  .tablet:not(.is-karaoke-focus) .tablet-control-grid button { height: 100%; min-height: 44px; border: 0; padding-top: 18px; }
  .tablet:not(.is-karaoke-focus) .tablet-control-grid button + button { border-left: 1px solid var(--control-line); }
  .tablet:not(.is-karaoke-focus) .tablet-control-options button { border-top: 1px solid var(--control-line); }
  .tablet:not(.is-karaoke-focus) .tablet-control-grid:not(.tablet-control-options) svg { width: clamp(24px, 7dvh, 32px); height: clamp(24px, 7dvh, 32px); }
  .tablet:not(.is-karaoke-focus) .tablet-control-options svg { width: 22px; height: 22px; }
  .tablet:not(.is-karaoke-focus) .tablet-control-grid button > span:first-child { left: 8px; font-size: 11px; }
  .tablet-row { padding-inline: 4px; }
  .tablet-row-copy { gap: 5px; }
  .tablet-track-icon { flex-basis: 20px; width: 20px; height: 20px; }
  .tablet-empty p { font-size: 15px; }
}
/* Karaoke gives the lyrics the screen, with a small playback strip below. */
.tablet.has-karaoke.is-karaoke-focus .tablet-body {
  grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 8px;
}
.tablet.is-karaoke-focus .tablet-portrait-controls {
  display: block; grid-column: 1; grid-row: 2; max-width: 440px;
}
.tablet.is-karaoke-focus .tablet-portrait-controls :is(.tablet-dials, .tablet-control-options) { display: none; }
.tablet.is-karaoke-focus .tablet-button-grids { display: block; border-left: 0; }
.tablet.is-karaoke-focus .tablet-portrait-controls .tablet-control-grid { grid-template-columns: repeat(4, 1fr); }
.tablet.is-karaoke-focus .tablet-portrait-controls .tablet-control-grid button {
  height: 52px; padding: 0; border-top: 0; border-left: 1px solid var(--control-line);
}
.tablet.is-karaoke-focus .tablet-portrait-controls .tablet-control-grid button:first-child { border-left: 0; }
.tablet.is-karaoke-focus .tablet-control-grid button > span:first-child { display: none; }
.tablet.is-karaoke-focus .tablet-control-grid svg { width: 30px; height: 30px; }

@media (max-aspect-ratio: 9/10) {
  .tablet.is-karaoke-combined .tablet-body { grid-template-rows: minmax(110px, 1fr) minmax(160px, 1.15fr) auto; }
  .tablet.is-karaoke-combined .player-console { --control-dial-size: 80px; --control-cell-height: 56px; }
  .tablet.is-karaoke-combined .tablet-control-grid:not(.tablet-control-options) svg { width: 28px; height: 28px; }
}
.tablet.is-ui-hidden .tablet-portrait-controls { display: none; }
@media (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {
  .tablet.is-ui-hidden:not(.is-karaoke-focus) .tablet-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Mobile karaoke keeps playback controls until the user hides them. */
@media (hover: none), (pointer: coarse), (max-width: 600px), (max-width: 1024px) and (max-height: 600px) {
  .tablet.has-karaoke.is-karaoke-focus .tablet-body { grid-template-rows: minmax(0, 1fr) auto; gap: 0; }
}
