/* Full-history discovery and local library additions. */
#sidebar {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 18px;
}
#sidebar .brand {
  flex-shrink: 0;
}
#sidebar nav {
  margin-top: 14px;
  flex: 1;
  min-height: 70px;
  overflow-y: auto;
  display: block;
  flex-shrink: 1;
}
#sidebar nav > a {
  margin-bottom: 5px;
}
#sidebar .sidebar-foot {
  position: static;
  flex-shrink: 0;
  margin-top: auto;
  font-size: 11px;
}
#sidebar .sidebar-foot p {
  display: none;
}
#sidebar .sidebar-foot small {
  margin-top: 8px;
}
.more-nav summary {
  cursor: pointer;
  padding: 12px 14px;
  min-height: 44px;
  color: var(--muted);
  font-weight: 550;
}
.more-nav a {
  font-size: 12px;
  padding-left: 24px;
}
#close-menu {
  flex-shrink: 0;
}
.coverage-bar {
  border: 1px solid var(--line);
  background: #f0eee8;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 0 0 16px;
  font-size: 11px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.coverage-bar > a {
  font-weight: 600;
}
.coverage-bar strong {
  color: var(--brand);
  font-weight: 600;
}
.coverage-bar button {
  min-height: 30px;
  padding: 3px 9px;
  font-size: 11px;
}
.mode-tabs {
  margin-bottom: 10px;
  overflow-x: auto;
  gap: 24px;
}
.mode-tabs a {
  white-space: nowrap;
  font-size: 12px;
  min-height: 44px;
}
.v1-filters {
  gap: 7px 14px;
  padding-bottom: 3px;
}
.v1-filters label {
  font-size: 10px;
}
.v1-filters select {
  max-width: 175px;
  font-size: 11px;
  min-height: 36px;
}
.scope-note,
.method-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.8;
}
.scope-note a {
  color: var(--brand);
}
.method-note {
  background: var(--tint);
  padding: 8px 12px;
  border-radius: 6px;
}
.entity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.entity-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
  min-height: 90px;
}
.entity-rank {
  min-width: 25px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding-top: 10px;
  font-variant-numeric: tabular-nums;
}
.entity-art,
.type-art {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 8px;
}
.type-art {
  background: #ece7df;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  color: #716655;
  font-size: 21px;
}
.entity-copy {
  min-width: 0;
  flex: 1;
}
.entity-title {
  font-weight: 650;
  font-size: 15px;
  line-height: 1.45;
  display: block;
  overflow-wrap: anywhere;
  margin-bottom: 6px;
}
.entity-counts {
  color: var(--muted);
  font-size: 11px;
  margin: 7px 0;
}
.entity-counts strong {
  font-weight: 650;
  color: var(--ink);
}
.entity-counts > span {
  margin-left: 10px;
  display: inline-block;
}
.entity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}
.entity-actions button,
.entity-actions select {
  font-size: 10px;
  min-height: 32px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.entity-actions button[aria-pressed="true"] {
  color: var(--brand);
  background: var(--tint);
}
.entity-actions select {
  max-width: 160px;
}
.seed-strip {
  margin: 24px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--brand);
}
.collection-actions {
  display: flex;
  gap: 8px;
  padding: 0 0 15px;
  list-style: none;
}
.collection-actions button {
  font-size: 11px;
  min-height: 32px;
}
.history-entry {
  border-bottom: 1px solid var(--line);
  padding: 15px 0;
}
.history-entry > p {
  font-size: 12px;
  color: var(--muted);
}
.history-entry .collection-actions {
  display: none;
}
.settings-panel {
  display: grid;
  gap: 18px;
  max-width: 650px;
  margin: 25px 0 35px;
}
.settings-panel > label {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}
.settings-panel select {
  padding: 10px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.settings-panel input {
  accent-color: var(--brand);
  width: 20px;
  height: 20px;
}
.transfer-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 15px 0 25px;
  padding: 16px;
  background: #f0eee8;
  border-radius: 8px;
}
.transfer-panel label {
  display: grid;
  gap: 8px;
  max-width: 100%;
  font-size: 12px;
}
.transfer-panel input {
  max-width: 100%;
}
#new-playlist,
#rename-playlist {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin: 24px 0;
}
#new-playlist label,
#rename-playlist label {
  display: grid;
  gap: 6px;
  font-size: 12px;
}
#new-playlist input,
#rename-playlist input {
  padding: 11px;
  border: 1px solid #8c857c;
  border-radius: 6px;
  background: var(--surface);
  max-width: 100%;
  min-width: 0;
}
.playlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.playlist-grid article {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.playlist-grid h2 {
  overflow-wrap: anywhere;
}
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin: 20px 0;
}
.table-scroll table {
  border-collapse: collapse;
  width: 100%;
  min-width: 450px;
  font-size: 12px;
}
.table-scroll th,
.table-scroll td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  position: relative;
  min-width: 80px;
}
.table-scroll caption {
  padding: 14px;
  text-align: left;
  color: var(--muted);
}
.count-bar {
  height: 5px;
  background: var(--brand);
  display: block;
  min-width: 0;
  margin-bottom: 4px;
  opacity: 0.65;
}
.data-facts {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 2fr;
  gap: 10px 20px;
  font-size: 12px;
}
.data-facts dt {
  color: var(--muted);
}
.data-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.shortcut-list {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 18px;
}
.shortcut-list dt {
  font-family: monospace;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 8px;
  border-radius: 5px;
  text-align: center;
}
.shortcut-list dd {
  margin: 0;
  padding: 8px;
}
.recommendation-reason {
  font-size: 11px;
  color: var(--brand);
}
:root[data-theme="dark"] {
  --canvas: #191919;
  --surface: #242322;
  --ink: #f8f7f3;
  --muted: #c4bdb3;
  --line: #4c4842;
  --brand: #ff8968;
  --tint: #42281f;
  color-scheme: dark;
}
.dark-placeholder {
  color: var(--muted);
}
[data-theme="dark"] button,
[data-theme="dark"] a.button,
[data-theme="dark"] #search-form,
[data-theme="dark"] #player,
[data-theme="dark"] .show-card,
[data-theme="dark"] .source-comment,
[data-theme="dark"] .player-extra select {
  background: var(--surface);
  color: var(--ink);
}
[data-theme="dark"] .coverage-bar,
[data-theme="dark"] .description,
[data-theme="dark"] .transfer-panel,
[data-theme="dark"] .type-art {
  background: #2e2b27;
  color: var(--muted);
}
[data-theme="dark"] .feature {
  background: #30271f;
  border-color: var(--line);
}
[data-theme="dark"] .prose p {
  color: var(--muted);
}
[data-theme="dark"] .badge,
[data-theme="dark"] .queue-count {
  background: #38332d;
  color: var(--muted);
}
[data-theme="dark"] button.primary,
[data-theme="dark"] a.primary {
  background: #bd472b;
  color: #fff;
}
[data-theme="dark"] .transport .main-play {
  background: #f8f7f3;
  color: #191919;
}
[data-theme="dark"] .chip.active {
  background: #f8f7f3;
  color: #191919;
}
@media (max-height: 600px) and (min-width: 768px) {
  #sidebar {
    display: block;
  }
  #sidebar nav {
    overflow: visible;
    min-height: 0;
  }
  #sidebar .sidebar-foot {
    margin-top: 16px;
  }
}
@media (max-width: 767px) {
  .entity-row {
    gap: 9px;
    padding: 15px 0;
  }
  .entity-rank {
    min-width: 17px;
    font-size: 10px;
  }
  .entity-art,
  .type-art {
    width: 34px;
    height: 34px;
  }
  .entity-title {
    font-size: 13px;
  }
  .entity-counts > span {
    display: block;
    margin: 5px 0 0;
  }
  .entity-actions button,
  .entity-actions select {
    min-height: 44px;
    font-size: 10px;
    padding: 6px 8px;
  }
  .coverage-bar {
    padding: 10px;
    font-size: 10px;
  }
  .entity-copy .metadata {
    font-size: 9px;
    gap: 5px;
  }
  .mode-tabs {
    gap: 18px;
  }
  .mode-tabs a {
    font-size: 11px;
  }
  .v1-filters label {
    max-width: 100%;
  }
  .v1-filters select {
    min-height: 44px;
    max-width: 155px;
  }
  .data-facts {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .data-facts dd {
    margin-bottom: 12px;
  }
  .entity-actions select {
    max-width: 145px;
  }
  .shortcut-list {
    grid-template-columns: 80px 1fr;
    gap: 10px;
  }
  #sidebar nav {
    min-height: 80px;
    overflow-y: auto;
  }
  #sidebar .sidebar-foot {
    margin-top: 8px;
  }
  #sidebar #close-menu {
    margin-top: 0;
  }
  .tabs {
    overflow-x: auto;
    gap: 18px;
  }
  .tabs a {
    white-space: nowrap;
  }
  .history-entry > button {
    margin: 8px 6px 0 0;
  }
}

/* Compact discovery: browse first, reveal the less common controls on demand. */
body.player-idle {
  --player: 72px;
}
body.player-idle #player {
  min-height: 72px;
  height: 72px;
  grid-template-columns: minmax(0, 1fr) auto;
}
body.player-idle .player-controls {
  display: none;
}
.coverage-bar {
  padding: 7px 11px;
  margin-bottom: 10px;
  line-height: 1.5;
}
.coverage-index {
  display: inline-block;
  margin-left: 12px;
}
.discover-filters {
  min-width: 0;
}
.discovery-filters {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.basic-filters {
  margin: 0;
  padding: 0;
  gap: 12px;
  flex: 1;
}
.basic-filters label {
  min-width: 0;
}
.basic-filters button {
  font-size: 10px;
  min-height: 36px;
  padding: 4px 8px;
}
.advanced-filters {
  font-size: 11px;
  min-width: 0;
}
.advanced-filters summary,
.ranking-details summary {
  cursor: pointer;
  min-height: 32px;
  padding: 7px 0;
  color: var(--muted);
}
.advanced-filters[open] {
  flex-basis: 100%;
}
.advanced-filters .filter-line {
  padding: 6px 0;
}
.ranking-details {
  font-size: 11px;
  margin: 2px 0 6px;
}
.ranking-details .method-note {
  margin: 0 0 6px;
}
.ranking-details a {
  color: var(--brand);
}
.mode-tabs {
  margin-bottom: 5px;
}
.entity-list + button {
  margin-top: 14px;
}
@media (min-width: 768px) {
  main:has(.discovery-filters) {
    padding-top: 24px;
  }
  main:has(.discovery-filters) .page-heading p {
    margin-bottom: 12px;
  }
  .entity-row {
    padding: 11px 0;
    min-height: 84px;
    gap: 12px;
    align-items: center;
  }
  .entity-copy {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 18px;
    align-items: start;
  }
  .entity-copy > .entity-title,
  .entity-copy > .metadata,
  .entity-copy > .entity-counts {
    grid-column: 1;
  }
  .entity-copy > .entity-title {
    margin-bottom: 4px;
    font-size: 14px;
  }
  .entity-copy > .entity-counts {
    margin: 5px 0 0;
  }
  .entity-copy > .entity-actions {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
    max-width: 260px;
    justify-content: flex-end;
    margin: 0;
  }
  .entity-copy > p:not(.entity-counts),
  .entity-copy > button {
    grid-column: 1 / -1;
  }
}
@media (max-width: 767px) {
  main:has(.discovery-filters) {
    padding-top: 16px;
  }
  main:has(.discovery-filters) h1 {
    font-size: 23px;
  }
  main:has(.discovery-filters) .page-heading p {
    margin-bottom: 12px;
    font-size: 11px;
  }
  .coverage-bar {
    font-size: 9px;
    padding: 7px 9px;
    margin-bottom: 7px;
  }
  .coverage-index {
    display: block;
    margin-left: 0;
  }
  .mode-tabs {
    margin-bottom: 4px;
    gap: 15px;
  }
  .mode-tabs a {
    padding: 9px 0;
    min-height: 38px;
  }
  .discovery-filters {
    display: block;
  }
  .basic-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 12px;
  }
  .basic-filters label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    font-size: 10px;
  }
  .basic-filters select {
    max-width: 100%;
    width: 100%;
    padding: 4px 0;
    min-height: 36px;
  }
  .basic-filters button {
    justify-self: end;
    align-self: end;
    min-height: 36px;
    margin-bottom: 1px;
  }
  .advanced-filters .filter-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 7px 12px;
  }
  .advanced-filters .filter-line label {
    display: grid;
    gap: 0;
  }
  .advanced-filters select {
    width: 100%;
    max-width: 100%;
  }
  .entity-row {
    padding: 12px 0;
  }
  .entity-actions {
    margin-top: 6px;
  }
  .entity-counts {
    margin: 5px 0;
  }
  body.player-idle #player {
    height: calc(72px + env(safe-area-inset-bottom));
    min-height: 72px;
    grid-template-rows: auto;
  }
  body.player-idle .player-extra {
    grid-row: 1;
  }
  body.player-idle #shell {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
  body.player-idle #notice {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
}

.results-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.results-toolbar > p {
  margin: 0;
  font-size: 12px;
}
.view-switch {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.view-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--muted);
}
.view-switch a[aria-current] {
  color: var(--brand);
  background: var(--tint);
}
.cover-fallback,
.grid-context {
  display: none;
}
.entity-list.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  border: 0;
}
.grid-view .entity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "cover" "copy";
  align-content: start;
  position: relative;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  gap: 12px;
  min-width: 0;
}
.grid-view .entity-art,
.grid-view .type-art,
.grid-view .cover-fallback {
  grid-area: cover;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 7px;
}
.grid-view .cover-fallback {
  display: grid;
  place-items: center;
  font:
    44px Georgia,
    serif;
  background: var(--tint);
  color: var(--brand);
}
.grid-view .type-art {
  font-size: 44px;
}
.grid-view .entity-art {
  position: relative;
  z-index: 1;
}
.grid-view .entity-rank {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 18px;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}
.grid-view .entity-copy {
  grid-area: copy;
  display: block;
}
.grid-view .entity-title {
  font-size: 14px;
}
.grid-view .metadata {
  overflow-wrap: anywhere;
}
.grid-view .metadata > span {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.grid-view .entity-counts {
  line-height: 1.7;
}
.grid-view .entity-counts > span {
  display: block;
  margin-left: 0;
}
.grid-view .entity-actions {
  margin-top: 10px;
  justify-content: flex-start;
  max-width: none;
}
.grid-view .grid-context {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0;
}
@media (max-width: 767px) {
  .entity-list.grid-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .grid-view .entity-row {
    padding: 9px;
    gap: 9px;
  }
  .grid-view .entity-title {
    font-size: 12px;
  }
  .grid-view .entity-counts,
  .grid-view .grid-context {
    font-size: 10px;
  }
  .grid-view .entity-actions button,
  .grid-view .entity-actions select {
    max-width: 100%;
  }
  .results-toolbar > p {
    font-size: 11px;
  }
  .view-switch a {
    padding: 5px 8px;
    min-height: 40px;
  }
}
