body[data-page="explore"] main {
  max-width: none;
  margin: 0 0 140px;
  padding: 0;
}
.explore-toolbar {
  max-width: 1264px;
  margin: 8px auto 16px;
  padding: 0 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 24px;
}
.explore-lists,
.family-chips {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
  min-width: 0;
}
.explore-lists .chip,
.family-chips .chip {
  flex-shrink: 0;
  white-space: nowrap;
}
.family-chips {
  grid-column: 1/-1;
}
.family-chips .chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.family-chips i,
.space-song-list i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--family-color);
  flex: 0 0 8px;
}
.explore-options {
  display: flex;
  align-items: center;
  gap: 12px;
}
.explore-search {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 24px;
  background: var(--surface);
  padding-left: 14px;
}
.explore-search .icon {
  width: 18px;
  height: 18px;
  color: var(--text-2);
}
.explore-search input {
  width: 145px;
  min-width: 0;
  background: transparent;
  border-radius: 24px;
}
.space-dimensions {
  display: flex;
  background: var(--surface);
  border-radius: 24px;
  padding: 3px;
}
.space-dimensions .chip {
  min-width: 44px;
  padding: 8px;
}
.space-dimensions .selected {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 4px #0001;
}
.explore-layout {
  position: relative;
}
.explore-surface {
  position: relative;
  height: 100%;
}
#map-region {
  position: absolute;
  inset: 0 400px 0 24px;
  min-width: 0;
}
#song-map {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  border-radius: 16px;
}
#song-map:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}
.space-grid line {
  stroke: var(--line);
  stroke-width: 0.8;
}
.space-grid .space-edge {
  opacity: 0.6;
  stroke-dasharray: 3 6;
}
.point-hit {
  fill: transparent;
}
.point-mark {
  pointer-events: none;
  stroke: var(--bg);
  stroke-width: 1.5;
}
.point-ring,
.point-outline {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.3;
  pointer-events: none;
}
.point-outline {
  stroke: var(--accent);
  stroke-width: 2;
}
.map-point {
  outline: none;
}
.map-point:focus-visible .point-mark {
  stroke: var(--text);
  stroke-width: 3;
}
.space-labels {
  pointer-events: none;
}
.space-labels text {
  font: 12px var(--font-ui);
  fill: var(--text-2);
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 5px;
  stroke-linejoin: round;
}
.space-labels .selected-label {
  fill: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.space-labels .family-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.map-links line {
  stroke: var(--accent);
  stroke-width: 1;
  opacity: 0.35;
}
.space-drops line {
  stroke: var(--text-3);
  stroke-width: 1;
  stroke-dasharray: 3 5;
  opacity: 0.5;
}
.space-compass line {
  stroke: var(--text-3);
  stroke-width: 1;
}
.space-compass text {
  fill: var(--text-2);
  font: 10px var(--font-ui);
  text-anchor: middle;
}
.space-status {
  position: absolute;
  left: 30px;
  bottom: 16px;
  display: flex;
  gap: 18px;
  align-items: center;
  color: var(--text-2);
  font-size: 12px;
  pointer-events: none;
}
.space-controls {
  position: absolute;
  right: 420px;
  bottom: 12px;
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--bg);
}
.space-controls .icon-button {
  border-radius: 50%;
}
#space-axes {
  position: absolute;
  left: 40px;
  right: 420px;
  top: 8px;
  font-size: 12px;
  color: var(--text-2);
  pointer-events: none;
}
.explore-sidebar {
  position: absolute;
  z-index: 3;
  width: 320px;
  right: 40px;
  top: 24px;
  min-width: 0;
  display: grid;
  gap: 20px;
}
#explore-card {
  width: 320px;
  min-height: 240px;
}
.selection-card {
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  height: 240px;
  display: flex;
  flex-direction: column;
}
.selection-title {
  font: 500 22px var(--font-display);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.selection-card > svg {
  height: 44px;
  margin: 12px 0;
  color: var(--text-3);
  stroke: currentColor;
  fill: none;
  stroke-width: 1;
  flex-shrink: 0;
}
.selection-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}
.selection-card .actions {
  gap: 8px;
}
.selection-bottom .actions {
  gap: 0;
  flex-wrap: nowrap;
}
.selection-card .actions a {
  font-size: 13px;
  text-decoration: none;
  padding: 10px;
}
.space-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 15px;
}
#reference-tray:empty {
  display: none;
}
.reference-tray {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 2px;
}
.reference-tray .chip {
  flex-shrink: 0;
  max-width: 180px;
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  font-size: 13px;
}
.reference-tray .chip span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reference-tray .icon {
  width: 16px;
  height: 16px;
}
.space-nearby-label {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.space-song-list {
  display: grid;
}
.space-song-list button {
  display: flex;
  text-align: left;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  background: transparent;
  border-radius: 8px;
  padding: 8px 12px;
}
.space-song-list button:hover {
  background: var(--surface);
}
.space-song-list button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-size: 14px;
}
.space-song-list button .icon {
  transform: rotate(180deg);
  width: 16px;
  height: 16px;
  color: var(--text-3);
}
.explore-advanced {
  position: relative;
  z-index: 8;
}
.explore-advanced > summary {
  list-style: none;
  cursor: pointer;
  background: var(--surface);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.explore-advanced > summary::-webkit-details-marker {
  display: none;
}
.advanced-controls {
  position: absolute;
  right: 0;
  top: 52px;
  width: min(460px, calc(100vw - 40px));
  max-height: min(660px, 70dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 16px 60px #0002;
  display: grid;
  gap: 16px;
}
.advanced-controls label {
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.advanced-controls select,
.advanced-controls input {
  width: 100%;
  min-width: 0;
}
.advanced-controls input[type="range"] {
  padding: 0;
}
.advanced-controls input[type="checkbox"] {
  width: auto;
}
.group-summary {
  display: flex;
  gap: 16px;
  font-size: 13px;
  padding: 12px 0;
}
.group-summary span {
  color: var(--text-2);
}
#explore-results {
  max-width: 1200px;
  margin: 24px auto;
}
#explore-results .work-row {
  grid-template-columns: 44px minmax(150px, 1fr) 220px 52px 44px;
}
@media (min-width: 1700px) {
  #map-region {
    left: max(24px, calc((100vw - 1440px) / 2));
    right: max(400px, calc((100vw - 1440px) / 2 + 376px));
  }
  .explore-sidebar {
    right: max(40px, calc((100vw - 1440px) / 2));
  }
  .space-controls {
    right: max(420px, calc((100vw - 1440px) / 2 + 396px));
  }
}
@media (max-width: 999px) {
  .explore-toolbar {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 20px;
    gap: 8px;
  }
  .explore-options {
    grid-row: 2;
    justify-content: space-between;
  }
  .explore-search {
    flex: 1;
  }
  .explore-search input {
    width: 100%;
  }
  .explore-sidebar {
    position: static;
    width: auto;
    margin: 20px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 20px;
  }
  #explore-card {
    width: 100%;
  }
  #reference-tray {
    grid-column: 1/-1;
    grid-row: 2;
  }
  #map-region {
    inset: 0 20px 64px;
  }
  .space-controls {
    right: 20px;
    bottom: 10px;
  }
  .space-status {
    bottom: 24px;
    left: 20px;
  }
  .space-guide {
    display: none;
  }
  #space-axes {
    left: 20px;
    right: 20px;
    top: 0;
  }
  #explore-results {
    margin: 24px 20px;
  }
}
@media (max-width: 680px) {
  .explore-toolbar {
    margin-top: 0;
  }
  .explore-options {
    gap: 8px;
  }
  .family-chips .chip {
    padding: 8px 10px;
  }
  .explore-lists .chip {
    font-size: 13px;
  }
  .explore-sidebar {
    grid-template-columns: minmax(0, 1fr);
  }
  #reference-tray {
    grid-row: auto;
  }
  #explore-card:has(.space-empty) {
    display: none;
  }
  .selection-card {
    padding: 20px;
  }
  #explore-results .work-row {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }
  .advanced-controls {
    position: fixed;
    top: 100px;
    right: 20px;
  }
}

/* Keep the complete viewport and its controls above the persistent player.
   Edit/template mode retains the canonical artwork export dimensions. */
@media (min-width: 681px) {
  body:not(.editing):not(.template-mode) .slot[data-slot="explore.canvas"] {
    height: clamp(500px, calc(100svh - 250px), 900px);
  }
  body.has-audio:not(.editing):not(.template-mode)
    .slot[data-slot="explore.canvas"] {
    height: clamp(420px, calc(100svh - 338px), 900px);
  }
}
@media (max-width: 680px) {
}

#space-quick {
  display: none;
}
@media (max-width: 680px) {
  body:not(.editing):not(.template-mode) .slot[data-slot="explore.canvas"] {
    height: clamp(320px, calc(100svh - 380px), 640px);
  }
  body.has-audio:not(.editing):not(.template-mode)
    .slot[data-slot="explore.canvas"] {
    height: clamp(280px, calc(100svh - 454px), 640px);
  }
  body:not(.editing):not(.template-mode) #space-quick {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    left: 20px;
    right: 20px;
    bottom: 12px;
    height: 64px;
    padding: 8px;
    z-index: 60;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    box-shadow: 0 4px 24px #0001;
  }
  body.has-audio:not(.editing):not(.template-mode) #space-quick {
    bottom: 76px;
  }
  #space-quick > a {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
  }
  #space-quick > span {
    margin: auto;
    color: var(--text-2);
    font-size: 13px;
  }
  #space-quick > button:first-child {
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 50%;
  }
}

.editing #song-map {
  pointer-events: none;
}

.space-back {
  display: none;
}
@media (max-width: 680px) {
  body:not(.editing):not(.template-mode)
    .explore-layout:not(.inspecting)
    #explore-card {
    display: none;
  }
  .explore-layout.inspecting .space-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-self: start;
    background: transparent;
  }
  body:not(.editing):not(.template-mode)
    .explore-layout.inspecting
    ~ #space-quick {
    display: none;
  }
  .explore-sidebar {
    scroll-margin-top: 16px;
  }
}
