/*
 * hyd-desktop-refinement.css
 *
 * Refinement layer for the Places (#places), player (#cinema) and desktop (#home) windows: one
 * shared aluminium look for toolbars, buttons and panels, plus the reveal bar that tucks the
 * site header away while Places is open. It is linked in hyd-world.html after
 * hyd-map-cleanup.css and before hyd-radio.css, and restyles earlier sheets such as
 * hyd-classic-desktop.css and hyd-mac-windows.css.
 *
 * How it wins: nearly every selector starts with html[data-theme] #world (attribute + id +
 * type), which outranks the older class-only rules, so source order rarely matters. Where a
 * selector appears twice (for example #cinema .transport near the top and again under the
 * comment that starts with A shared control size), the later declaration wins for any
 * property set in both. The only !important declarations are two display: none rules, each
 * explained where it occurs.
 *
 * Reads: --desktop-font (hyd-classic-desktop.css and hyd-platform.css), --menu-left and
 * --menu-width (set on the header bar by hyd-menu-reveal.js) and --player-width (set on
 * #cinema-view by hyd-world.js). Classes toggled by script: places-menu-reveal on #world and
 * menu-tucked on the bar (hyd-menu-reveal.js). The compact player's transport, including where
 * keep playing sits, is laid out in hyd-player-layout.css.
 *
 * Layout: menu reveal, player, Places toolbars, then small player and desktop fixes. Touch
 * sizing (44 px targets) is near the end under (max-width: 700px), (any-pointer: coarse),
 * followed by one more max-width: 700px block.
 */

/* Small application windows, shared aluminium chrome, no webpage-like footers. */

/* --- Places menu reveal ---
   While Places is open the site header bar (#world > .shell) is pinned to the top and slides
   away when the pointer leaves it; the 44 x 24 px peek tab brings it back. hyd-menu-reveal.js
   adds places-menu-reveal to #world, menu-tucked to the bar, and measures --menu-left /
   --menu-width so the pinned bar lines up with #world. */
html[data-theme] #world.places-menu-reveal > .shell {
  position: fixed;
  top: 0;
  left: var(--menu-left,0);
  width: var(--menu-width,100%);
  z-index: 1500;
  box-sizing: border-box;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 7px #0004;
}

html[data-theme] #world.places-menu-reveal > .shell.menu-tucked {
  transform: translateY(calc(-100% - 8px));
  pointer-events: none;
}

#world .desktop-menu-peek {
  position: fixed;
  top: 0;
  left: 50%;
  translate: -50% 0;
  z-index: 1501;
  width: 44px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 1px solid #7e92a6;
  border-top: 0;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(#ecf4fc, #bacada);
  box-shadow: 0 1px 3px #0003;
  cursor: pointer;
}

#world .desktop-menu-peek span {
  display: block;
  width: 17px;
  height: 3px;
  margin: auto;
  border-block: 1px solid #6d8397;
}

#world .desktop-menu-peek:focus-visible {
  outline: 2px solid #5b9bd6;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme] #world.places-menu-reveal > .shell {
    transition: none;
  }
}

/* --- Player (#cinema): transport, extras tray, memory margin ---
   Aluminium treatment for the playback bar, the tray of extra buttons under it and the memory
   margin panel. Sizes are settled again further down, under the comment that starts with
   A shared control size. */

/* !important group: hides the time readouts, scrub label, route time, chapter list and
   next-stop line in the player, and the minimised player's time and progress bar. Other player
   sheets (hyd-retro.css, hyd-player-layout.css) still style #time-readout, #duration-readout
   and #mini-progress, so !important is what keeps them hidden. */
html[data-theme]
  #world
  #cinema
  :is(#time-readout, #duration-readout, .scrub-label, #route-time, .chapters, .next-stop),
#minimised-player :is(#mini-time, #mini-progress) {
  display: none !important;
}

/* Transport bar: silver gradient with centred controls. */
html[data-theme] #world #cinema .transport {
  background: linear-gradient(#e6e6e6, #b9bdc1);
  border-top: 1px solid #f8f8f8;
  box-shadow: inset 0 -1px #70777e;
  padding: 7px 10px;
  justify-content: center;
}

html[data-theme] #world #cinema .transport #note-toggle {
  margin-left: auto;
  color: #20262b;
}

/* Extras tray under the transport bar (random, collection and deck buttons, volume). */
html[data-theme] #world #cinema .player-extras {
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  gap: 8px;
  background: #c5c7c9;
  border: 1px solid #666d75;
  border-top: 0;
  border-radius: 0 0 5px 5px;
  color: #242a31;
  box-shadow: 0 3px 5px #0004;
}

html[data-theme] #world #cinema .player-extras button {
  color: #20262b;
  background: linear-gradient(#fafafa, #d2d4d7);
  border: 1px solid #7d838a;
  border-radius: 3px;
  box-shadow: inset 0 1px #fff;
  min-height: 32px;
  padding: 4px 8px;
  font: calc(12 * var(--px)) var(--desktop-font);
}

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

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

/* Memory margin panel: location strip, title, description and the details list. */
html[data-theme] #world #cinema .memory-margin {
  padding: 0 12px 12px;
  background: #e2e3e4;
  color: #282c31;
  border: 1px solid #737a82;
  border-radius: 4px;
  overflow: hidden;
}

html[data-theme] #world #cinema .memory-margin .margin-location {
  margin: 0 -12px 11px;
  padding: 7px 12px;
  color: #31363c;
  background: linear-gradient(#fafafa, #bcc0c4);
  border-bottom: 1px solid #8b9299;
}

html[data-theme] #world #cinema .memory-margin h2 {
  font-size: calc(14 * var(--px));
  color: #1c2227;
}

html[data-theme] #world #cinema .memory-margin :is(#margin-description, dt, dd) {
  color: #454e56;
}

html[data-theme] #world #cinema .memory-margin dl {
  font-size: calc(11 * var(--px));
  border-top-color: #afb5ba;
}

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

/* Route window and the inline photo editor. */
html[data-theme] #world #cinema .route-window {
  border-radius: 4px;
  box-shadow: 0 3px 6px #0004;
}

html[data-theme] #world #cinema .route-window :is(.route-meta, .route-context) {
  font: calc(11 * var(--px))/1.5 var(--desktop-font);
}

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

html[data-theme] #world #cinema .photo-inline-editor {
  font: calc(11 * var(--px))/1.4 var(--desktop-font);
}

html[data-theme] #world #cinema .photo-inline-editor .photo-inline-export {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}

/* A shared control size prevents legacy icon rules stretching individual buttons. */
html[data-theme] #world #cinema .transport {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 10px;
  box-sizing: border-box;
}

html[data-theme] #world #cinema .transport :is(#previous-memory, #play-small, #skip-memory) {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  font: 22px/1 var(--desktop-font);
  display: grid;
  place-items: center;
}

html[data-theme] #world #cinema .transport #note-toggle {
  width: 72px;
  min-width: 72px;
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  font: calc(12 * var(--px))/1 var(--desktop-font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

html[data-theme] #world #cinema .player-extras :is([data-random], [data-player-return], .collection-link, .deck-launch) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* rem: the one-line button grows with its text (136px at the default size); the row wraps. */
  flex: 0 0 calc(136 * var(--px));
  width: calc(136 * var(--px));
  min-width: 0;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 8px;
  font: calc(12 * var(--px))/1 var(--desktop-font);
  white-space: nowrap;
}

html[data-theme]
  #world
  #cinema
  .player-extras
  :is([data-random], [data-player-return], .collection-link, .deck-launch)
  > :is([aria-hidden='true'], svg, img) {
  width: 16px;
  height: 16px;
  font-size: 16px;
  line-height: 1;
  flex: 0 0 16px;
  margin: 0;
  object-fit: contain;
  color: inherit;
}

html[data-theme] #world #cinema .player-extras .journey-volume {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  font-size: calc(11 * var(--px));
  white-space: nowrap;
}

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

html[data-theme] #world #cinema .transport #note-toggle:after {
  content: none;
  display: none;
}

/* Places: Aqua navigator chrome. All toolbar controls share one 32px baseline. */
html[data-theme] #world #places .places-browser {
  position: relative;
  overflow: visible;
  border: 1px solid #536c88;
  border-radius: 8px;
  box-shadow:
    0 2px 0 #dceaff inset,
    0 8px 22px #17263b55;
  background: #dae6f1;
}

html[data-theme] #world #places .places-heading {
  height: 60px;
  min-height: 60px;
  padding: 8px 72px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  background:
    repeating-linear-gradient(0deg, #ffffff24 0 1px, transparent 1px 3px),
    linear-gradient(#e8f3ff, #bfd3e7);
  border-bottom: 1px solid #8aa1ba;
  border-radius: 7px 7px 0 0;
  box-shadow: inset 0 1px #fff;
}

html[data-theme] #world #places .places-heading h1 {
  margin: 0;
  font: 600 15px/1 var(--desktop-font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transform: none;
  color: #254967;
  letter-spacing: 0;
  text-shadow: 0 1px #fff;
}

html[data-theme] #world #places .places-heading h1 svg {
  width: 24px;
  height: 24px;
  margin: 0;
}

html[data-theme] #world #places .places-heading .heading-souvenir {
  display: none;
}

html[data-theme] #world #places .places-heading > button {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
}

/* Cat slot on the right of the Places heading (class added by hyd-cat.js). */
#world #places .hyd-cat-slot-places {
  position: absolute;
  right: 16px;
  bottom: 2px;
  width: 58px;
  height: 60px;
  margin: 0;
  z-index: 4;
}

#world #places .hyd-cat-slot-places :is(.hyd-cat-pet, .hyd-cat-sprite) {
  width: 100%;
  height: 100%;
}

/* Search and route toolbar (.map-tools): destination field, route field and buttons. */
html[data-theme] #world #places .map-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  padding: 12px 14px;
  background: linear-gradient(#f2f7fc, #dae6f1);
  color: #222;
  flex-wrap: wrap;
  margin: 0;
  box-sizing: border-box;
}

html[data-theme] #world #places .destination-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 300px;
  min-width: 0;
}

html[data-theme] #world #places .map-tools label.destination-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  box-shadow: none;
  border-radius: 0;
  color: #30353a;
  font: 11px var(--desktop-font);
}

html[data-theme] #world #places .map-tools label.destination-picker:focus-within {
  outline: 0;
  box-shadow: none;
  background: none;
}

html[data-theme] #world #places .map-tools label.destination-picker > span {
  font: 600 12px var(--desktop-font);
  color: #305575;
  padding: 0;
  white-space: nowrap;
}

html[data-theme] #world #places :is(#area-search, #route-from) {
  width: 100%;
  height: 32px;
  min-width: 0;
  padding: 5px 9px;
  font: 12px var(--desktop-font);
  border: 1px solid #8099b0;
  border-radius: 5px;
  background: #fbfdff;
  color: #252a30;
  box-shadow: inset 0 1px 2px #0002;
  box-sizing: border-box;
  margin: 0;
}

/* Shared toolbar button: the same 116 x 32 px silver button for the search toolbar, memory
   tools, route options and notes toolbar. */
html[data-theme]
  #world
  #places
  :is(.map-tools, .map-memory-tools, .route-options, .map-notes-toolbar)
  button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 116px;
  min-width: 0;
  height: 32px;
  min-height: 32px;
  padding: 0 8px;
  margin: 0;
  font: 12px/1 var(--desktop-font);
  background: linear-gradient(#fff 0%, #edf4fa 48%, #d3e0ed 49%, #edf5fc 100%);
  color: #254662;
  border: 1px solid #829ab1;
  border-radius: 5px;
  box-shadow:
    inset 0 1px #fff,
    inset 0 -1px #ffffffb3,
    0 1px 1px #28476425;
  white-space: nowrap;
  box-sizing: border-box;
}

html[data-theme] #world #places :is(.map-tools, .map-memory-tools, .map-notes-toolbar) button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin: 0;
}

html[data-theme] #world #places .map-tools > button > span {
  font: 12px/1 var(--desktop-font);
}

html[data-theme] #world #places :is(#map-density, .map-status) {
  display: none;
}

/* Memory tools row: area and year selects, the video/photo mode switch and shuffle. */
html[data-theme] #world #places .map-memory-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  gap: 8px;
  margin: 0;
  background: #e6eef6;
  color: #294c6b;
  border-top: 1px solid #fff;
  border-bottom: 1px solid #b4c7d8;
  box-sizing: border-box;
}

html[data-theme] #world #places .map-memory-tools label:has(#map-memory-area) {
  display: none;
}

html[data-theme] #world #places .map-memory-tools label {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 11px var(--desktop-font);
  color: #343b43;
  margin: 0;
}

html[data-theme] #world #places .map-memory-tools select {
  font: 12px var(--desktop-font);
  height: 32px;
  min-height: 32px;
  width: 116px;
  padding: 0 8px;
  background: linear-gradient(#fff, #eaf1f8);
  color: #294c6b;
  border: 1px solid #829ab1;
  border-radius: 5px;
  margin: 0;
  box-sizing: border-box;
}

html[data-theme] #world #places .map-memory-tools .memory-mode-switch {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 0;
  margin: 0;
  overflow: visible;
  padding-right: 12px;
  border: 0;
  border-right: 1px solid #b4c7d8;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

html[data-theme] #world #places .memory-mode-switch button[aria-pressed='true'] {
  background: linear-gradient(#b8d9fa, #5b9bd6 49%, #3379b6 50%, #5f9ed3);
  color: #fff;
  border-color: #42709d;
  text-shadow: 0 1px #255784;
  box-shadow:
    inset 0 1px #def0ff,
    0 1px 1px #28476425;
}

html[data-theme] #world #places #map-memory-clear {
  margin-left: auto;
}

/* Route options: the collapsible add a start search under the toolbar. */
html[data-theme] #world #places .route-options {
  margin: 0;
  padding: 0 14px 10px;
  background: #dae6f1;
  color: #305575;
  border: 0;
  font: 12px var(--desktop-font);
}

html[data-theme] #world #places .route-options[hidden] {
  display: none;
}

html[data-theme] #world #places .route-options summary {
  cursor: pointer;
  padding: 4px 0;
  width: max-content;
  max-width: 100%;
  font: 12px var(--desktop-font);
  color: #303840;
}

html[data-theme] #world #places .route-from-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}

html[data-theme] #world #places .route-from-search label {
  font: 12px var(--desktop-font);
  color: inherit;
}

html[data-theme] #world #places .route-from-search input {
  flex: 1;
}

html[data-theme] #world #places .route-from-search button {
  flex: 0 0 116px;
}

/* Place search results dropdown (#place-search-results) and its row styles. */
html[data-theme] #world #places #place-search-results {
  position: absolute;
  max-width: calc(100% - 28px);
  max-height: 340px;
  overflow: auto;
  z-index: 1100;
  padding: 4px;
  background: #f3f3f3;
  color: #262b30;
  border: 1px solid #777d85;
  border-radius: 3px;
  box-shadow: 2px 4px 8px #0005;
  display: block;
  box-sizing: border-box;
}

html[data-theme] #world #places #place-search-results[hidden] {
  display: none;
}

html[data-theme] #world #places #place-search-results button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px;
  background: none;
  color: inherit;
  border: 0;
  box-shadow: none;
  text-align: left;
  font: 12px/1.35 var(--desktop-font);
  border-radius: 2px;
  white-space: normal;
}

html[data-theme] #world #places #place-search-results button:is(:hover, :focus-visible) {
  background: #427cb5;
  color: #fff;
  outline: none;
}

html[data-theme] #world #places #place-search-results button strong {
  font-weight: 400;
  display: block;
}

html[data-theme] #world #places #place-search-results button small {
  font: 10px/1.4 var(--desktop-font);
  display: block;
  opacity: 0.8;
  color: inherit;
}

html[data-theme] #world #places #place-search-results .place-result-icon {
  flex: 0 0 18px;
  font-size: 19px;
  color: inherit;
}

html[data-theme] #world #places .place-result-heading {
  padding: 7px 8px 4px;
  font: 600 10px var(--desktop-font);
  color: #636b74;
  border-top: 1px solid #d4d7da;
}

html[data-theme] #world #places .place-result-heading:first-child {
  border-top: 0;
}

/* The city's places follow the site's own under a rule of their own. */
html[data-theme] #world #places .place-result-group + .place-result-group > .place-result-heading {
  border-top: 1px solid #d4d7da;
}

html[data-theme] #world #places .place-result-message {
  padding: 7px 8px;
  margin: 0;
  font: 11px/1.4 var(--desktop-font);
  color: #55616e;
}

html[data-theme] #world #places .place-result-credit {
  display: block;
  padding: 4px 8px;
  font: 10px var(--desktop-font);
  color: #55616e;
}

html[data-theme] #world #places #place-search-results .place-result-wider {
  border-top: 1px solid #d4d7da;
  color: #275b8a;
}

html[data-theme] #world #places #place-search-results .place-result-wider:focus-visible {
  color: #fff;
}

/* Route status line and the map notes toolbar. */
html[data-theme] #world #places #route-selection-status {
  margin: 0;
  padding: 7px 14px;
  font: 11px/1.4 var(--desktop-font);
  background: #f5f9fd;
  color: #305575;
  border-top: 1px solid #bccddd;
}

/* Place result bar (#place-selection): what a picked destination selects, as a window status
   bar in the map's bottom-left corner, clear of the map credit; the play button is the aqua map
   button. Its left edge is the zoom control's (Leaflet's 10px control margin). Where the
   minimised player's card meets it, hyd-world.js (liftResultBar) sets --mini-player-lift to stand
   it above the card. */
html[data-theme] #world #places .place-selection {
  position: absolute;
  left: 10px;
  bottom: calc(28px + var(--mini-player-lift, 0px));
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: min(520px, calc(100% - 20px));
  margin: 0;
  padding: 7px 8px 7px 11px;
  box-sizing: border-box;
  background: #f5f9fd;
  color: #305575;
  border: 1px solid #8fa6bb;
  border-radius: 3px;
  box-shadow: 0 1px 3px #28476440;
  font: 12px/1.4 var(--desktop-font);
}

html[data-theme] #world #places .place-selection[hidden] {
  display: none;
}

/* The bar sits above the whole map pane, popups included: an open popup owns the map, so the bar
   steps aside until it closes, at every width. */
html[data-theme] #world #places .map-wrap:has(.leaflet-popup) .place-selection {
  visibility: hidden;
}

html[data-theme] #world #places .place-selection p {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

html[data-theme] #world #places .place-selection :is(b, span, small) {
  display: block;
}

html[data-theme] #world #places .place-selection b {
  font-weight: 600;
  color: #22374a;
}

html[data-theme] #world #places .place-selection small {
  font-size: 11px;
  color: #55616e;
}

html[data-theme] #world #places .place-selection small[hidden] {
  display: none;
}

html[data-theme] #world #places #place-selection-play {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 116px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0 12px;
  font: 12px/1 var(--desktop-font);
  background: linear-gradient(#e3f5ff, #aed8f7 49%, #78b5e2 50%, #a2d2f5);
  color: #143f62;
  border: 1px solid #6896ba;
  border-radius: 5px;
  box-shadow:
    inset 0 1px #fff,
    inset 0 -1px #ffffffb3,
    0 1px 1px #28476425;
  white-space: nowrap;
  box-sizing: border-box;
}

html[data-theme] #world #places #place-selection-play:hover {
  border-color: #3973a6;
  box-shadow:
    inset 0 1px #fff,
    0 0 0 1px #b8d9f6;
}

html[data-theme] #world #places #place-selection-play:active {
  background: linear-gradient(#b6cadf, #e5f0fa);
  box-shadow: inset 0 1px 3px #45648266;
}

html[data-theme] #world #places #place-selection-play[hidden] {
  display: none;
}

html[data-theme] #world #places .map-notes-toolbar {
  background: linear-gradient(#eef5fc, #d5e4f1);
  color: #305575;
  padding: 10px 14px;
  gap: 8px;
  box-sizing: border-box;
}

html[data-theme] #world #places .map-notes-toolbar :is(label, span, p) {
  color: #3c607e;
  font-size: 11px;
}

/* Map frame: the window bar is hidden here and the map fills the rest of the window. */
html[data-theme] #world #places .atlas-window-bar {
  display: none;
}

html[data-theme] #world #places .map-wrap {
  padding-top: 0;
  border: 0;
  border-top: 1px solid #7f9bb3;
  box-shadow: inset 0 1px #fff;
  margin: 0;
  background: #dce9f3;
}

html[data-theme] #world #places #area-map {
  top: 0;
  height: 100%;
}

/* Hover, pressed and keyboard-focus states shared by all toolbar buttons. */
html[data-theme]
  #world
  #places
  :is(.map-tools, .map-memory-tools, .route-options, .map-notes-toolbar)
  button:hover:not(:disabled) {
  border-color: #3973a6;
  box-shadow:
    inset 0 1px #fff,
    0 0 0 1px #b8d9f6;
}

html[data-theme]
  #world
  #places
  :is(.map-tools, .map-memory-tools, .route-options, .map-notes-toolbar)
  button:active:not(:disabled) {
  background: linear-gradient(#b6cadf, #e5f0fa);
  box-shadow: inset 0 1px 3px #45648266;
}

html[data-theme] #world #places :is(button, input, select):focus-visible {
  outline: 2px solid #559bd2;
  outline-offset: 2px;
}

/* A button that cannot act looks it: grey text, a flat face and no shadow (a shuffle with nothing
   to play, for one). The id rule matches the shuffle's own colours below. */
html[data-theme]
  #world
  #places
  :is(.map-tools, .map-memory-tools, .route-options, .map-notes-toolbar, .pocket-map-edge)
  button:disabled,
html[data-theme] #world #places #map-memory-shuffle:disabled {
  color: #8796a3;
  background: linear-gradient(#f8fafc, #e2e8ee);
  border-color: #b4c2ce;
  box-shadow: none;
  cursor: default;
}

html[data-theme]
  #world
  #places
  :is(.map-tools, .map-memory-tools, .route-options, .map-notes-toolbar, .pocket-map-edge)
  button:disabled
  :is(svg, img) {
  opacity: 0.4;
}

/* One-off button tweaks: shuffle colour, mode-switch ends, notes toolbar controls. */
html[data-theme] #world #places #map-memory-shuffle {
  background: linear-gradient(#e3f5ff, #aed8f7 49%, #78b5e2 50%, #a2d2f5);
  border-color: #6896ba;
  color: #143f62;
}

html[data-theme] #world #places .map-memory-tools .memory-mode-switch button:first-child {
  border-radius: 5px 0 0 5px;
}

html[data-theme] #world #places .map-memory-tools .memory-mode-switch > button {
  gap: 8px;
  padding-inline: 12px;
  flex: 0 0 116px;
}

html[data-theme] #world #places .map-memory-tools .memory-mode-switch > button:last-child {
  border-radius: 0 5px 5px 0;
  border-left: 0;
  border-right: 1px solid #829ab1;
}

html[data-theme] #world #places .map-notes-toolbar .map-note-leave img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex: none;
}

html[data-theme] #world #places .map-notes-toolbar .map-notes-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  margin: 0;
}

html[data-theme] #world #places .map-notes-toolbar input {
  accent-color: #397fb8;
  margin: 0;
}

html[data-theme] #world #places .map-notes-count {
  font-size: 11px;
  opacity: 0.8;
}

/* Leaflet zoom bar and compass skin. */
html[data-theme] #world #places .leaflet-bar {
  border: 1px solid #6c8ba7;
  border-radius: 5px;
  box-shadow: 0 2px 4px #1a395044;
  overflow: hidden;
}

html[data-theme] #world #places .leaflet-bar a {
  background: linear-gradient(#fff, #cbdfee);
  color: #27516e;
  width: 30px;
  height: 30px;
  line-height: 30px;
  border-color: #97b1c6;
  text-shadow: 0 1px #fff;
}

html[data-theme] #world #places .map-compass {
  color: #315c7d;
  background: #edf5f9e6;
  border: 1px solid #8ba8be;
  border-radius: 50%;
  box-shadow: 0 1px 3px #21435d33;
}

/* Keep the selected mode button blue while it is hovered or focused. */
html[data-theme]
  #world
  #places
  :is(.map-tools, .map-memory-tools, .route-options, .map-notes-toolbar)
  button:focus:not(:active) {
  color: #254662;
  background: linear-gradient(#fff 0%, #edf4fa 48%, #d3e0ed 49%, #edf5fc 100%);
}

html[data-theme] #world #places .memory-mode-switch button[aria-pressed='true']:is(:focus, :hover) {
  background: linear-gradient(#b8d9fa, #5b9bd6 49%, #3379b6 50%, #5f9ed3);
  color: white;
}

/* Destination pin on the map: a teardrop drawn with CSS (class set in hyd-world.js). */
.destination-map-pin span {
  display: block;
  width: 22px;
  height: 22px;
  background: #4d82b1;
  border: 2px solid white;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 4px #0006;
}

.destination-map-pin span:after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  margin: 6px;
  border-radius: 50%;
  background: white;
}

/* Narrow screens, first pass: extras tray becomes two columns; Places toolbars wrap. */
@media (max-width: 700px) {
  html[data-theme] #world #cinema .player-extras {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  html[data-theme]
    #world
    #cinema
    .player-extras
    :is([data-random], [data-player-return], .collection-link, .deck-launch) {
    width: 100%;
    flex: auto;
  }

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

  html[data-theme] #world #places .destination-search {
    flex-basis: 100%;
  }

  html[data-theme] #world #places .map-tools label.destination-picker {
    display: grid;
    gap: 5px;
  }

  html[data-theme] #world #places .destination-search {
    align-items: end;
  }

  html[data-theme] #world #places .map-tools > button:not([hidden]) {
    flex: 1;
  }

  html[data-theme] #world #places .map-memory-tools .memory-mode-switch {
    flex-basis: 100%;
    padding-right: 0;
    border-right: 0;
  }

  html[data-theme] #world #places .map-memory-tools .memory-mode-switch button {
    flex: 1;
  }

  html[data-theme] #world #places .map-memory-tools > label {
    flex: 1;
    display: grid;
    gap: 5px;
  }

  html[data-theme] #world #places #map-memory-clear {
    margin-left: 0;
    align-self: flex-end;
  }

  html[data-theme] #world #places .map-memory-tools select {
    width: 100%;
    font-size: 11px;
    padding-inline: 4px;
  }

  html[data-theme] #world #places .route-from-search {
    flex-wrap: wrap;
  }

  html[data-theme] #world #places .route-from-search input {
    flex-basis: calc(100% - 45px);
  }

  html[data-theme] #world #places .route-from-search button {
    flex: 1;
  }
}

/* Keep both media tabs intact when a fitted player or map toolbar narrows. */
html[data-theme] #world .memory-mode-switch {
  flex-shrink: 0;
}

html[data-theme] #world #cinema .player-modebar {
  height: auto;
  min-height: 34px;
  overflow: visible;
}

html[data-theme] #world #cinema .player-modebar .memory-mode-switch {
  max-width: none;
}

/* Playback continuation remains visible without restoring the old page footer. */
html[data-theme] #world #cinema .transport .auto-next {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 0 4px;
  font: calc(11 * var(--px)) var(--desktop-font);
  color: #29363e;
  white-space: nowrap;
}

html[data-theme] #world #cinema .transport .auto-next input {
  margin: 0;
  accent-color: #547e9a;
}

/* Narrow phones, in the moment before the player is fitted and made compact: keep playing wraps
   onto its own line, its checkbox under previous like the compact player's second line. */
@media (max-width: 420px) {
  html[data-theme] #world #cinema .transport {
    flex-wrap: wrap;
  }

  html[data-theme] #world #cinema .transport .auto-next {
    order: 2;
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }
}

/* Empty-queue notice under the player, as wide as the player. */
html[data-theme] #world #cinema #queue-empty {
  max-width: var(--player-width,840px);
  margin: 6px auto;
  padding: 6px 9px;
  background: #e2e4e7;
  color: #33424e;
  border: 1px solid #8797a4;
  font: calc(11 * var(--px))/1.4 var(--desktop-font);
}

/* !important: while the player is expanded the site header must leave the layout entirely.
   hyd-retro.css (.cinema-expanded .shell) only hides it with visibility, which keeps its space;
   !important stops any other display rule on .shell from bringing it back. */
body.cinema-expanded #world > .shell {
  display: none !important;
}

/* Paper effects need ink labels, while the infrared desktop keeps its existing type. */
html[data-theme][data-wallpaper-photo]:is(
    [data-wallpaper-effect='macpaint'],
    [data-wallpaper-effect='ascii']
  )
  #world
  #home
  .portal-brand
  :is(h1, span[lang='te'], .manad-byline) {
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  padding: 2px 8px;
  background: rgb(246 240 220 / 0.95);
  color: #182030;
  text-shadow: none;
  border-radius: 2px;
  box-sizing: border-box;
}

html[data-theme][data-wallpaper-photo]:is(
    [data-wallpaper-effect='macpaint'],
    [data-wallpaper-effect='ascii']
  )
  #world
  #home
  .portal-brand
  .manad-byline {
  color: #293742;
}

html[data-theme][data-wallpaper-photo] #world #home .desktop-icons b {
  background: #14131ab3;
  color: #fff;
  text-shadow: 0 1px 1px #000;
  border-radius: 2px;
}

/* Let blank desktop beside the title remain available to the small photo trail. */
html[data-theme] #world #home .portal-brand h1 {
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
}

/* Touch Places toolbars use one readable size and baseline. Native selects need
   room for both their value and disclosure arrow, including at 320px. */
@media (max-width: 700px), (any-pointer: coarse) {
  html[data-theme]
    #world
    #places
    :is(.map-tools, .map-memory-tools, .route-options, .map-notes-toolbar)
    button {
    width: auto;
    min-width: 128px;
    height: 44px;
    min-height: 44px;
    padding: 4px 10px;
    font-size: 16px;
    line-height: 1.25;
    white-space: normal;
  }

  html[data-theme] #world #places .map-tools > button > span {
    font: inherit;
  }

  html[data-theme] #world #places :is(#area-search, #route-from),
  html[data-theme] #world #places .map-memory-tools select {
    height: 44px;
    min-height: 44px;
    padding: 4px 10px;
    font-size: 16px;
    line-height: 1.25;
  }

  html[data-theme] #world #places .map-memory-tools select {
    width: 128px;
    max-width: 100%;
  }

  html[data-theme] #world #places .map-memory-tools label {
    font-size: 14px;
    line-height: 1.25;
  }

  html[data-theme] #world #places .map-memory-tools .memory-mode-switch {
    width: 245px;
    min-width: 245px;
    box-sizing: border-box;
  }

  html[data-theme] #world #places .map-memory-tools .memory-mode-switch > button {
    min-width: 0;
    flex: 1 0 116px;
  }

  html[data-theme] #world #places .map-notes-toolbar .map-notes-toggle {
    min-height: 44px;
    font-size: 16px;
    line-height: 1.25;
  }

  html[data-theme] #world #places .map-notes-toolbar .map-notes-toggle > span {
    font: inherit;
  }

  html[data-theme] #world #places .destination-search > button {
    min-width: 80px;
    flex: 0 0 auto;
  }

  /* The shuffle keeps one width while its label follows the selection (shuffle videos, area,
     nearby, route), so the search field beside it never moves; 150px fits the widest label. On
     phones the shuffle moves out of .map-tools onto the map edge. */
  html[data-theme] #world #places .map-tools #map-memory-shuffle {
    min-width: 150px;
  }

  /* Touch targets: the result bar's play button and the map popups' buttons. */
  html[data-theme] #world #places #place-selection-play {
    height: 44px;
    min-height: 44px;
  }

  html[data-theme] #world #places #area-map .map-media-popup .map-media-open {
    min-height: 44px;
  }
}

/* Narrow screens, second pass: memory tools become a two-column grid; the mode switch and the
   clear button take full rows. */
@media (max-width: 700px) {
  html[data-theme] #world #places .map-memory-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 10px 8px;
  }

  html[data-theme] #world #places .map-memory-tools .memory-mode-switch {
    grid-column: 1/-1;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  html[data-theme] #world #places .map-memory-tools .memory-mode-switch > button {
    min-width: 0;
    flex: 1 1 0;
  }

  html[data-theme] #world #places .map-memory-tools > label {
    min-width: 0;
    gap: 5px;
  }

  html[data-theme] #world #places .map-memory-tools select {
    width: 100%;
    max-width: none;
  }

  html[data-theme] #world #places #map-memory-clear {
    grid-column: 1/-1;
    width: 100%;
    margin: 0;
  }

  html[data-theme] #world #places .map-notes-toolbar button {
    flex: 1 1 128px;
  }
}
