/*
 * Player window layout (hyd-player-layout.js and the layout code in hyd-world.js). Lays the player out as one
 * grid sized from the source media: hyd-world.js writes --media-width, --media-height, --tools-width and
 * --player-width on #cinema-view, with HydPlayerLayout.fit deciding the sizes. Also holds the bus-film note and
 * story dialog, the compact and touch layouts of the action row and transport controls, the expanded
 * (fullscreen) page and the photo editing sidebar.
 */

/* Source-sized media windows. Wallpaper remains visible outside the window. */
/* The bus film's small reading line belongs below the image, inside its chrome. */
@layer mapping-copy {
  /*
   * Opt-out from the site-wide lowercase rule (hyd-mapping.css). Important declarations inside a cascade layer
   * beat important declarations outside any layer, so this opt-out has to sit in the same mapping-copy layer
   * and out-rank that rule by specificity.
   */
  #world #bus-plate-note,
  #world #bus-story-dialog a {
    text-transform: none !important;
  }
}

/* --- Bus film note, story link and story dialog --- */
#world #bus-plate-note {
  margin: 0;
  padding: 5px 12px;
  border-top: 1px solid var(--paper-edge,#64717b);
  background: var(--paper-panel,#252b30);
  color: var(--paper-text,#eef0f3);
  font: calc(13 * var(--px))/1.5 var(--desktop-font,Tahoma,sans-serif);
  /*
   * !important: same opt-out as the layered rule at the top of the file. The layered copy is the one that beats
   * the site-wide lowercase rule.
   */
  text-transform: none !important;
}

#world #bus-plate-note[hidden] {
  display: none;
}

#world #bus-story-open {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  margin: 0;
  padding: 4px 5px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-transform: none;
  cursor: pointer;
}

#world #bus-story-dialog {
  width: min(560px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 3px;
  overflow: hidden;
  border: 1px solid;
  border-color: var(--metal-top,#eef3f5) var(--paper-edge,#64717b) var(--paper-edge,#64717b) var(--metal-top,#eef3f5);
  border-radius: 3px;
  background: var(--paper-surface,#252b30);
  color: var(--paper-text,#eef0f3);
  box-shadow: 3px 5px #0008;
  font: 15px/1.65 var(--desktop-font,Tahoma,sans-serif);
}

#world #bus-story-dialog[open] {
  display: flex;
  flex-direction: column;
}

#world #bus-story-dialog::backdrop {
  background: #10161b99;
}

#world #bus-story-dialog > header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 5px 3px 12px;
  border: 1px solid var(--paper-edge,#64717b);
  background: linear-gradient(var(--metal-top,#eef3f5),var(--metal-mid,#bac6d0) 48%,var(--metal-end,#d3dce3));
  color: var(--metal-ink,#243039);
}

#world #bus-story-title {
  margin: 0;
  font:
    400 15px/1.3 'Hyd Minar',var(--desktop-font,Tahoma,sans-serif);
  letter-spacing: 0;
  color: inherit;
}

#world #bus-story-dialog .dialog-close {
  position: static;
  display: grid;
  place-items: center;
  flex: none;
  min-width: 44px;
  width: 44px;
  min-height: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--paper-edge,#64717b);
  border-radius: 3px;
  background: linear-gradient(var(--metal-top,#eef3f5),var(--metal-mid,#bac6d0));
  box-shadow: inset 0 1px #fff8;
  color: inherit;
  font: 24px/1 var(--desktop-font,Tahoma,sans-serif);
  cursor: pointer;
}

#world #bus-story-dialog .bus-story-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px 20px 20px;
}

#world #bus-story-dialog .bus-story-draft {
  margin: 0 0 10px;
  color: var(--paper-muted,#bac7d0);
  font-size: 12px;
}

#world #bus-story-dialog .bus-story-copy {
  margin: 0 0 12px;
}

#world #bus-story-dialog a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--paper-text,#eef0f3);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  /* !important: same opt-out as the layered rule at the top of the file. */
  text-transform: none !important;
}

#world :is(#bus-story-open, #bus-story-dialog button, #bus-story-dialog a):focus-visible {
  outline: 2px solid var(--paper-accent,#8fc7f2);
  outline-offset: 2px;
}

@media (min-width: 621px) {
  #world #bus-plate-note {
    font-size: calc(12 * var(--px));
  }
}

/* --- Player grid --- */
html[data-theme] #world #cinema {
  --player-edge: 16px;
}

html[data-theme] #world #cinema #cinema-view {
  display: grid;
  grid-template-columns: minmax(0,var(--player-width,900px));
  justify-content: center;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
  gap: 0 14px;
  padding: 12px 16px;
  background: transparent;
  min-width: 0;
}

html[data-theme] #world #cinema .player-window-scroll {
  display: contents;
}

html[data-theme] #world #cinema #cinema-view.player-wide.player-with-location {
  grid-template-columns: minmax(0,var(--player-width,900px)) 232px;
}

html[data-theme] #world #cinema .cinema-chrome {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  min-width: 0;
  flex: none;
  margin: 0;
  padding: 3px;
  border-radius: 6px;
  overflow: hidden;
  box-sizing: border-box;
}

html[data-theme] #world #cinema .player-stage {
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-width: 0;
  gap: 0;
  background: transparent;
}

html[data-theme] #world #cinema .player-photo-editing {
  flex: 0 0 var(--tools-width,196px);
  width: var(--tools-width,196px);
  min-width: 0;
  max-height: var(--media-height,560px);
  overflow: auto;
  overscroll-behavior: contain;
  border-right: 1px solid #535a62;
  background: #2c3035;
}

html[data-theme] #world #cinema .player-photo-editing[hidden] {
  display: none;
}

/* --- Screen, sized by --media-width and --media-height --- */
html[data-theme] #world #cinema #big-screen {
  position: relative;
  isolation: isolate;
  flex: none;
  width: var(--media-width,800px);
  height: var(--media-height,450px);
  min-height: 0;
  max-width: none;
  aspect-ratio: auto;
  background: transparent;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
}

html[data-theme] #world #cinema:not(.photo-mode) #big-screen {
  background: #1b242b;
}

html[data-theme] #world #cinema #big-screen::before,
html[data-theme] #world #cinema #big-screen .screen-shade {
  display: none;
  content: none;
}

html[data-theme]
  #world
  #cinema
  #big-screen
  :is(#journey-video, #memory-photo, .photo-inline-canvas) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  z-index: 1;
  object-fit: contain;
  background: transparent;
  animation: none;
}

html[data-theme]
  #world
  #cinema
  #big-screen
  :is(.screen-corner, .screen-title, .screen-date, .screen-disclaimer, #play-preview) {
  z-index: 3;
}

/* --- Memory margin: location, title, description and facts --- */
html[data-theme] #world #cinema .memory-margin {
  position: static;
  display: block;
  margin: 0 0 10px;
  padding: 13px;
  border: 1px solid #717981;
  border-radius: 4px;
  background: #252b30;
  color: #eef0f3;
  font: calc(11 * var(--px))/1.5 var(--desktop-font,"Lucida Grande",sans-serif);
  box-shadow: 0 2px 8px #0003;
}

html[data-theme] #world #cinema .memory-margin .margin-location {
  font-size: calc(10 * var(--px));
  margin: 0 0 7px;
  color: #bac7d0;
}

html[data-theme] #world #cinema .memory-margin h2 {
  font: 600 calc(17 * var(--px))/1.25 var(--desktop-font,"Lucida Grande",sans-serif);
  letter-spacing: 0;
  margin: 0 0 10px;
  color: #f4f5f7;
}

html[data-theme] #world #cinema #margin-description {
  font-size: calc(11 * var(--px));
  color: #cdd2d7;
  margin: 0 0 13px;
}

html[data-theme] #world #cinema .memory-margin dl {
  margin: 0;
  display: grid;
  gap: 5px;
  border-top: 1px solid #515b65;
  padding-top: 10px;
  font-size: calc(10 * var(--px));
}

html[data-theme] #world #cinema .memory-margin dl div {
  display: grid;
  /* rem: the label column grows with the bigger text it holds (48px at the default size). */
  grid-template-columns: calc(48 * var(--px)) 1fr;
  gap: 6px;
}

html[data-theme] #world #cinema .memory-margin dt {
  color: #aebcc6;
}

html[data-theme] #world #cinema .memory-margin dd {
  margin: 0;
}

html[data-theme] #world #cinema .cinema-below {
  display: none;
}

/* --- Title bar, mode bar and transport controls --- */
html[data-theme] #world #cinema .player-modebar {
  min-height: 34px;
  padding: 5px 10px;
  gap: 8px;
  flex-wrap: wrap;
}

html[data-theme] #world #cinema .cinema-titlebar {
  min-height: 34px;
  padding: 4px 8px;
  gap: 8px;
  min-width: 0;
}

/* The title must yield to the window controls even on a 240px portrait player. */
html[data-theme] #world #cinema .player-app {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-theme] #world #cinema .player-app svg {
  display: inline-block;
  vertical-align: middle;
  margin-right: 5px;
}

html[data-theme] #world #cinema .player-window-buttons,
html[data-theme] #world #cinema .player-window-buttons button {
  flex: none;
}

html[data-theme] #world #cinema .transport {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 8px;
  min-width: 0;
  flex: none;
}

html[data-theme] #world #cinema .transport :is(#previous-memory, #skip-memory, #play-small) {
  width: 34px;
  min-width: 34px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 22px;
}

html[data-theme] #world #cinema .transport :is(#time-readout, #duration-readout) {
  font-size: calc(10 * var(--px));
  font-variant-numeric: tabular-nums;
  flex: none;
}

html[data-theme] #world #cinema .transport #note-toggle {
  font-size: calc(11 * var(--px));
  min-height: 30px;
  padding: 4px 8px;
}

html[data-theme] #world #cinema .transport .scrub-label {
  min-width: 25px;
}

/* --- Location dock: the recording-location map as a card beside or below the player --- */
html[data-theme] #world #cinema #player-location-dock {
  grid-column: 1;
  grid-row: 3;
  min-width: 0;
  padding-top: 10px;
}

html[data-theme] #world #cinema #cinema-view.player-wide #player-location-dock {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding-top: 0;
  position: sticky;
  top: 12px;
}

html[data-theme] #world #cinema #player-location-dock[hidden] {
  display: none;
}

html[data-theme] #world #cinema #player-location-dock .route-window {
  /*
   * !important: hyd-retro.css pins the route window in the corner of the expanded player with !important
   * (absolute position, offsets, width, transform, margin). In the location dock it has to be a plain in-flow
   * card again.
   */
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  max-width: none;
  transform: none !important;
  margin: 0 !important;
  border-radius: 4px;
  box-shadow: 0 3px 10px #0003;
}

html[data-theme] #world #cinema #player-location-dock #journey-map {
  /*
   * !important: hyd-retro.css sets the same map to 120px with !important in the expanded player; the dock keeps
   * its own height.
   */
  height: 140px !important;
}

html[data-theme] #world #cinema #player-location-dock .route-title {
  padding: 5px 7px;
  font-size: calc(11 * var(--px));
  min-height: 30px;
}

html[data-theme] #world #cinema #player-location-dock .route-caption {
  display: flex;
  padding: 7px;
  font-size: calc(10 * var(--px));
  line-height: 1.3;
}

html[data-theme] #world #cinema #player-location-dock .route-caption b {
  font-size: calc(11 * var(--px));
  white-space: normal;
}

html[data-theme] #world #cinema #player-location-dock .route-window small {
  display: block;
  font-size: calc(9 * var(--px));
  padding: 5px 7px;
}

/* --- Extras row: footer buttons and volume --- */
html[data-theme] #world #cinema .player-extras {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  width: 100%;
  margin: 0;
  padding: 7px 8px;
  min-width: 0;
  border: 0;
  background: transparent;
  box-sizing: border-box;
}

html[data-theme] #world #cinema .player-extras > button {
  font-size: calc(11 * var(--px));
  min-height: 30px;
  padding: 5px 7px;
}

html[data-theme] #world #cinema .player-extras .journey-volume {
  margin-left: auto;
  font-size: calc(10 * var(--px));
  gap: 6px;
}

html[data-theme] #world #cinema .player-extras .journey-volume input {
  width: 72px;
}

html[data-theme] #world #cinema #player-error {
  grid-column: 1;
  grid-row: 4;
}

html[data-theme] #world #cinema :is(.cinema-below, .chapters, .next-stop) {
  margin-inline: auto;
  max-width: 1000px;
  width: calc(100% - 32px);
  min-width: 0;
  box-sizing: border-box;
}

/* --- Compact player: transport buttons, then keep playing on the same row when it fits ---
   Compact only means the player is under 650px, not that the row is full, so the transport is a
   size container and keep playing is placed by the room the row really has. Columns are 8px
   apart, as in the roomy row. */
html[data-theme] #world #cinema.player-compact .transport {
  display: grid;
  grid-template-columns: 34px 34px 34px 1fr auto;
  gap: 5px 8px;
  container: player-transport / inline-size;
}

html[data-theme] #world #cinema.player-compact #previous-memory {
  grid-column: 1;
  grid-row: 1;
}

html[data-theme] #world #cinema.player-compact #play-small {
  grid-column: 2;
  grid-row: 1;
}

html[data-theme] #world #cinema.player-compact #skip-memory {
  grid-column: 3;
  grid-row: 1;
}

html[data-theme] #world #cinema.player-compact #note-toggle {
  grid-column: 5;
  grid-row: 1;
}

html[data-theme] #world #cinema.player-compact #time-readout {
  grid-column: 1;
  grid-row: 2;
}

html[data-theme] #world #cinema.player-compact .scrub-label {
  grid-column: 2 / 5;
  grid-row: 2;
}

html[data-theme] #world #cinema.player-compact #duration-readout {
  grid-column: 5;
  grid-row: 2;
}

/* Too narrow for one row: keep playing gets its own line, its checkbox left-aligned under
   previous (owner, 7 Oct 2026: never centred). */
html[data-theme] #world #cinema.player-compact .transport .auto-next {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: start;
  margin: 0;
  width: auto;
}

/* One row when previous, play, next, keep playing and info fit with 8px to spare, measured on
   the transport's content box. Mouse: 3 x 34px buttons + 4 x 8px gaps + 4px margin + 92px label
   + 72px info + 8px = 310px. The 4px margin matches the roomy row. */
@media not all and (pointer: coarse) {
  @container player-transport (min-width: 310px) {
    html[data-theme] #world #cinema.player-compact .transport .auto-next {
      grid-column: 4;
      grid-row: 1;
      margin-left: 4px;
    }
  }
}

/* Touch keeps its 12px column gap (the touch rule further down):
   3 x 34px + 4 x 12px + 4px + 92px + 72px + 8px = 326px. */
@media (pointer: coarse) {
  @container player-transport (min-width: 326px) {
    html[data-theme] #world #cinema.player-compact .transport .auto-next {
      grid-column: 4;
      grid-row: 1;
      margin-left: 4px;
    }
  }
}

/* --- Expanded player (fullscreen page) --- */
html[data-theme] body.cinema-expanded #world {
  /*
   * !important: hyd-retro.css and hyd-theme.css give .cinema-expanded #world a solid dark background. The
   * wallpaper layer drawn by #world::before below needs #world itself to be see-through.
   */
  background: transparent !important;
}

/* The header stays outside this static scroll body; media never changes parent. */
html[data-theme] body.cinema-expanded #world #cinema #cinema-view {
  position: fixed;
  inset: 0;
  height: 100dvh;
  width: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  justify-content: center;
  align-items: start;
  padding: 12px 16px;
  overflow: hidden;
  background: transparent;
  box-sizing: border-box;
}

html[data-theme] body.cinema-expanded #world #cinema #cinema-view > .cinema-titlebar {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  min-height: 34px;
  border-radius: 4px 4px 0 0;
}

html[data-theme] body.cinema-expanded #world #cinema .player-window-scroll {
  display: grid;
  grid-column: 1/-1;
  grid-row: 2;
  height: 100%;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  grid-template-columns: minmax(0,var(--player-width,900px));
  justify-content: center;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
  gap: 0 14px;
}

html[data-theme]
  body.cinema-expanded
  #world
  #cinema
  #cinema-view.player-wide.player-with-location
  .player-window-scroll {
  grid-template-columns: minmax(0,var(--player-width,900px)) 232px;
}

html[data-theme] body.cinema-expanded #world #cinema .cinema-chrome {
  flex: none;
  height: auto;
  min-height: 0;
}

@media (max-width: 620px) {
  /* Phone widths: the stage stacks vertically (reversed) and the photo tools take the full width. */
  html[data-theme] #world #cinema .player-stage {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  html[data-theme] #world #cinema .player-photo-editing {
    flex: 0 0 auto;
    width: 100%;
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-top: 1px solid #535a62;
  }

  html[data-theme] #world #cinema .photo-inline-sidebar .photo-inline-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  html[data-theme] #world #cinema .photo-inline-sidebar .photo-inline-export {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  html[data-theme] #world #cinema #cinema-view,
  html[data-theme] body.cinema-expanded #world #cinema #cinema-view {
    padding: 8px;
    align-content: start;
  }

  /* As on phones upright, the mode note gives its line to the column. */
  html[data-theme] #world #cinema #playback-mode-note {
    display: none;
  }

  html[data-theme] #world #cinema .player-app {
    font-size: 11px;
    gap: 5px;
  }

  html[data-theme] #world #cinema #memory-kind {
    display: none;
  }

  html[data-theme] #world #cinema .player-extras .journey-volume {
    margin-left: 0;
  }
}

/* Native fullscreen includes the chosen wallpaper and its treatment. */
html[data-theme] body.cinema-expanded #world::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--scene) center/cover;
}

html[data-wallpaper-effect='infrared'][data-wallpaper-renderer='css']
  body.cinema-expanded
  #world::before {
  filter: url(#hyd-infrared-photo);
}

html[data-wallpaper-renderer='canvas'] body.cinema-expanded #world::before {
  background-image: var(--wallpaper-infrared,var(--scene));
}

/* The wallpaper effect canvas, when present, is drawn above the scene layer (z-index 1 over 0). */
html[data-theme] body.cinema-expanded #world > #hyd-wallpaper-effect {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Extras row and location dock details, and the screen corner mark. */
html[data-theme]
  #world
  #cinema
  .player-extras
  > :is(button, .deck-launch, [data-random], [data-player-return], .collection-link) {
  width: auto;
  flex: 0 0 auto;
  grid-column: auto;
  grid-row: auto;
  margin: 0;
  order: 0;
  white-space: nowrap;
}

html[data-theme] #world #cinema .player-extras {
  background: #252b30;
  border: 1px solid #64717b;
  border-top: 0;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 3px 8px #0003;
  padding: 8px;
}

html[data-theme] #world #cinema #player-location-dock {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

html[data-theme] #world #cinema #player-location-dock[hidden] {
  display: none;
}

html[data-theme] #world #cinema #player-location-dock .memory-margin {
  order: 0;
}

html[data-theme] #world #cinema #player-location-dock .route-window {
  order: 1;
}

html[data-theme] #world #cinema .screen-corner {
  font-size: calc(9 * var(--px));
  padding: 4px 7px;
  top: 10px;
  left: 10px;
}

/* Keep the inspector's actions visible while its open adjustment sheets scroll. */
@media (min-width: 621px) {
  html[data-theme] #world #cinema .player-photo-editing {
    height: var(--media-height,560px);
    overflow: hidden;
  }

  html[data-theme] #world #cinema .photo-inline-editor.photo-inline-sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 6px;
  }

  html[data-theme] #world #cinema .photo-inline-sidebar .photo-inline-section {
    flex: 0 1 auto;
    min-height: 36px;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  html[data-theme] #world #cinema .photo-inline-sidebar .photo-inline-look {
    min-height: 46px;
    max-height: 40%;
  }

  html[data-theme] #world #cinema .photo-inline-sidebar .photo-inline-adjustments[open] {
    flex: 1 1 auto;
  }

  html[data-theme] #world #cinema .photo-inline-sidebar .photo-inline-actions {
    flex: none;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    margin-top: auto;
    padding-top: 5px;
  }

  html[data-theme] #world #cinema .photo-inline-editor.photo-inline-sidebar .photo-inline-export {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-top: 6px;
  }

  html[data-theme]
    #world
    #cinema
    .photo-inline-sidebar
    :is([data-inline-done], .photo-inline-status) {
    flex: none;
  }
}

/* A2: a narrow desktop player lays out its 32px actions in two columns in a narrow (portrait) window, as on the live
   site, and in one row of four in a wide one, so they take less height from the video. The volume always takes its own row,
   last. Touch pointers get the two-column 44px grid below. */
@media (min-width: 621px) {
  /* Exactly two columns while the footer's content box is under 438px, exactly four from there: never one, three (a lone
    button row) or five (the full-width volume keeps auto-fit from collapsing an empty track). */
  html[data-theme] #world #cinema.player-compact .player-extras {
    display: grid;
    grid-template-columns: repeat(
      auto-fit,
      minmax(max(calc(25% - 5px), min(calc(50% - 4px), calc((438px - 100%) * 999))), 1fr)
    );
    gap: 6px;
    padding: 6px;
  }

  html[data-theme]
    #world
    #cinema.player-compact
    .player-extras
    :is([data-random], [data-player-return], .collection-link, #radio-dock-chip) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: auto;
    grid-column: auto;
    grid-row: auto;
    padding: 3px 5px;
    gap: 4px;
    font-size: calc(11 * var(--px));
    line-height: 1.15;
    white-space: normal;
  }

  html[data-theme] #world #cinema.player-compact .player-extras .journey-volume {
    grid-column: 1/-1;
    grid-row: auto;
    order: 1;
    justify-content: center;
    min-height: 24px;
    margin: 0;
  }

  html[data-theme]
    #world
    #cinema.player-compact
    .player-extras
    :is([data-random], [data-player-return], .collection-link, .deck-launch, #radio-dock-chip) {
    height: 32px;
    min-height: 32px;
  }
}

/* Phones and touch screens: actions in a two-column grid proportional to their own channel. */
@media (max-width: 620px), (any-pointer: coarse) {
  html[data-theme] #world #cinema.player-compact .player-extras {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
  }

  html[data-theme]
    #world
    #cinema.player-compact
    .player-extras
    :is([data-random], [data-player-return], .collection-link, #radio-dock-chip) {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: auto;
    grid-column: auto;
    grid-row: auto;
    height: 32px;
    min-height: 32px;
    padding: 3px 5px;
    gap: 4px;
    font-size: calc(11 * var(--px));
    line-height: 1.15;
    white-space: normal;
  }

  html[data-theme] #world #cinema.player-compact .player-extras .journey-volume {
    grid-column: 1/-1;
    grid-row: 3;
    justify-content: center;
    min-height: 24px;
    margin: 0;
  }
}

@media (max-width: 620px), (any-pointer: coarse) {
  html[data-theme]
    #world
    #cinema.player-compact
    .player-extras
    :is([data-random], [data-player-return], .collection-link, #radio-dock-chip) {
    height: 44px;
    min-height: 44px;
  }
}

/* Touch: previous, play/pause and next get 44px press areas that meet without overlapping (icons
   are drawn by ::before). The 12px gap comes out of the transport's flexible column; buttons keep
   their size and the row keeps its height. */
@media (pointer: coarse) {
  html[data-theme] #world #cinema:is(.player-compact, :not(.player-compact)) .transport {
    column-gap: 12px;
  }

  html[data-theme]
    #world
    #cinema
    .transport
    :is(#previous-memory, #play-small, #skip-memory)::after {
    content: '';
    position: absolute;
    inset: -9px -7px -5px;
  }
}

/* At least a 24px press area for "hide recording location", invisible. */
#world #toggle-route {
  position: relative;
}

#world #toggle-route::after {
  content: '';
  position: absolute;
  inset: -5px;
}

/*
 * A phone on its side (the same media list as SIDEWAYS_PHONE_QUERY in hyd-world.js): the player is one window
 * that fits the screen. The title bar runs across the top, the clip takes the height below it on the left, and
 * the column on the right holds the mode bar, the transport and the location dock, which placeRouteWindow()
 * gives the extras and the empty-queue notice as well. The window frame (.cinema-chrome) is a subgrid of the
 * player grid, so its rows and the dock share one set of tracks; the dock has no size of its own (contain: size),
 * so the clip sets the window’s height and the dock scrolls in the room beside it, at least 64px (a clip kept
 * short by the width leaves frame below it instead). hyd-player-drag.js keeps the window 8px clear of the screen’s top and bottom,
 * and the menu bar is tucked away (hyd-menu-reveal.js) with its peek tab in the top right corner, so the title
 * bar keeps its buttons clear of that corner. Maximised, the title bar sits above the scroller instead
 * (hyd-world.js moves it) and the same areas start one row lower, in the scroller.
 */
@media (pointer: coarse) and (max-height: 450px) {
  /* Nothing under the window, so the page does not scroll. */
  html[data-theme] #world #cinema:has(#cinema-view.player-with-location) {
    padding-bottom: 0;
  }

  html[data-theme] #world #cinema #cinema-view.player-with-location {
    grid-template-rows: auto auto auto auto auto minmax(64px, 1fr);
    grid-template-areas:
      'title title'
      'media mode'
      'media transport'
      'media note'
      'media error'
      'media dock';
    padding-block: 0;
  }

  html[data-theme] body.cinema-expanded #world #cinema #cinema-view.player-with-location {
    padding: 8px 16px;
    grid-template-columns: minmax(0, calc(var(--player-width, 900px) + 246px));
  }

  html[data-theme] body.cinema-expanded #world #cinema #cinema-view.player-with-location > .cinema-titlebar {
    grid-area: auto;
    grid-column: 1;
  }

  html[data-theme]
    body.cinema-expanded
    #world
    #cinema
    #cinema-view.player-with-location
    .player-window-scroll {
    grid-template-rows: auto auto auto auto minmax(64px, 1fr);
    grid-template-areas:
      'media mode'
      'media transport'
      'media note'
      'media error'
      'media dock';
  }

  html[data-theme] #world #cinema #cinema-view.player-with-location .cinema-chrome {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    grid-template-rows: subgrid;
    margin: 0;
  }

  html[data-theme] #world #cinema #cinema-view.player-with-location .cinema-titlebar {
    grid-area: title;
  }

  html[data-theme] body:not(.cinema-expanded) #world.places-menu-reveal #cinema .cinema-titlebar {
    padding-right: 44px;
  }

  html[data-theme] body.cinema-expanded #world.places-menu-reveal .desktop-menu-peek {
    display: none;
  }

  html[data-theme] #world #cinema #cinema-view.player-with-location .player-stage {
    grid-area: media;
    align-self: start;
  }

  html[data-theme] #world #cinema #cinema-view.player-with-location .player-modebar {
    grid-area: mode;
  }

  /* As on phones upright, the mode note gives its line to the column. */
  html[data-theme] #world #cinema #playback-mode-note {
    display: none;
  }

  html[data-theme] #world #cinema #cinema-view.player-with-location .transport {
    grid-area: transport;
  }

  html[data-theme] #world #cinema #cinema-view.player-with-location #bus-plate-note {
    grid-area: note;
  }

  html[data-theme] #world #cinema #cinema-view.player-with-location #player-error {
    grid-area: error;
  }

  /* The dock is not inside the frame’s subgrid: it keeps clear of the frame’s 4px edge itself. */
  html[data-theme] #world #cinema #cinema-view.player-wide #player-location-dock {
    grid-area: dock;
    align-self: stretch;
    position: static;
    min-height: 0;
    margin: 0 4px 4px 0;
    padding-top: 6px;
    contain: size;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* The cards keep their size and the dock scrolls, as the wide player’s dock does with music open. */
  html[data-theme] #world #cinema #player-location-dock > * {
    flex-shrink: 0;
  }

  html[data-theme] #world #cinema #player-location-dock > .player-extras {
    margin-bottom: 10px;
  }

  html[data-theme] #world #cinema #player-location-dock > #queue-empty {
    margin: 0 0 10px;
  }
}
