/* Image layers stay beneath readable surfaces; opacity is independent of text. */
:root {
  --ui-scale: 1;
  --wallpaper-opacity: 0.35;
}
html {
  zoom: var(--ui-scale);
}
#wallpaper {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-position: center;
  background-size: cover;
  opacity: var(--wallpaper-opacity);
  filter: blur(2px);
  transform: scale(1.02);
  transition: opacity 0.35s ease;
}
body {
  isolation: isolate;
}
body.has-wallpaper {
  background: var(--bg);
}
body.has-wallpaper .main {
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}
body.has-wallpaper .content {
  background: transparent;
}
body.has-wallpaper .sidebar,
body.has-wallpaper .topbar,
body.has-wallpaper .player,
body.has-wallpaper .mobile-nav {
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(22px);
}
body.has-wallpaper .panel,
body.has-wallpaper .hero {
  background: color-mix(in srgb, var(--panel) 90%, transparent);
}
body.has-wallpaper .auth {
  background: transparent;
}
body.has-wallpaper .auth-art {
  background: transparent;
}
body.has-wallpaper .auth-form {
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(20px);
}
body.has-wallpaper .vinyl {
  opacity: 0.6;
}
.history-controls {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.history-controls .icon-btn {
  width: 40px;
  height: 44px;
  font-size: 30px;
}
.history-controls button:disabled {
  opacity: 0.25;
  cursor: default;
}
.background-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.wallpaper-preview {
  aspect-ratio: 16/7;
  display: grid;
  place-content: center;
  text-align: center;
  border-radius: 14px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  margin: 16px 0;
  color: var(--text);
  border: 1px solid var(--line);
}
.wallpaper-preview img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.4;
}
.wallpaper-preview span {
  position: relative;
  background: var(--panel);
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 13px;
}
.background-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
  font-size: 13px;
}
.background-form label.check {
  flex-direction: row;
  align-items: center;
}
.background-form input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}
.background-form input[type="file"] {
  max-width: 100%;
}
.background-form input[type="range"],
.display-form input[type="range"] {
  height: 44px;
  padding: 0;
  accent-color: var(--accent);
}
.display-form {
  display: grid;
  grid-template-columns: 200px minmax(120px, 1fr) 70px;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}
.display-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.context-menu {
  position: fixed;
  z-index: 100;
  min-width: 220px;
  max-width: calc(100vw - 20px);
  padding: 7px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 60px #0006;
}
.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 7px;
  font-size: 13px;
}
.context-menu button:hover,
.context-menu button:focus-visible {
  background: var(--raised);
  color: var(--accent-ink);
}
.client-token-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.client-token-row div {
  flex: 1;
  min-width: 0;
}
.client-token-row small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}
.token-reveal {
  width: 100%;
  font-family: monospace;
  overflow-wrap: anywhere;
  user-select: all;
}
.spotify-heading {
  display: flex;
  align-items: center;
  gap: 14px;
}
.spotify-label {
  color: #1ed760;
  font-weight: 700;
  font-size: 14px;
}
.spotify-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 24px;
}
.spotify-card {
  text-align: left;
  min-width: 0;
}
.spotify-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
  background: #121212;
}
.spotify-card h3 {
  font-size: 14px;
  margin-top: 12px;
  overflow-wrap: anywhere;
}
.spotify-card a {
  display: inline-block;
  font-size: 12px;
  margin: 8px 0;
  color: var(--muted);
}
.spotify-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.spotify-track {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.spotify-track img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.spotify-track .spotify-track-title {
  min-width: 0;
  flex: 1;
  text-align: left;
}
.spotify-track small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}
.spotify-track a {
  font-size: 12px;
  color: var(--muted);
}
#spotify-dock {
  position: fixed;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 31;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 15px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 100px;
}
#spotify-dock img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}
#spotify-dock .spotify-playing {
  flex: 1;
  min-width: 0;
}
#spotify-dock strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#spotify-dock small {
  color: var(--muted);
}
#spotify-dock .icon-btn {
  width: 44px;
  height: 44px;
}
body.spotify-active #player {
  visibility: hidden;
}
#spotify-progress {
  width: 100%;
  height: 28px;
  accent-color: var(--accent);
}
.spotify-device {
  max-width: 260px;
}
.spotify-error {
  color: var(--text);
  border-left: 3px solid var(--accent);
  padding: 12px;
  line-height: 1.5;
}
@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    height: auto;
    min-height: calc(114px + var(--safe-top));
    padding-bottom: 12px;
  }
  .history-controls {
    order: 0;
  }
  .topbar .search {
    order: 2;
    width: 100%;
    flex-basis: 100%;
  }
  .topbar .top-right {
    margin-left: auto;
  }
  .topbar .mobile-brand {
    display: none;
  }
  .background-grid {
    grid-template-columns: 1fr;
  }
  .display-form {
    grid-template-columns: 1fr 65px;
    gap: 12px;
  }
  .display-form > label:first-child {
    grid-column: 1/-1;
  }
  #spotify-dock {
    left: 8px;
    right: 8px;
    bottom: calc(var(--mobile-nav-height) + 7px);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px 12px;
    min-height: 76px;
    gap: 8px;
  }
  #spotify-dock img {
    width: 44px;
    height: 44px;
  }
  #spotify-dock strong {
    font-size: 12px;
  }
  #spotify-dock .spotify-label {
    font-size: 10px;
  }
  #spotify-dock small,
  #spotify-progress,
  #spotify-dock [data-spotify-command="previous"] {
    display: none;
  }
  .spotify-track a {
    font-size: 10px;
  }
  .spotify-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
  .spotify-device {
    max-width: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  #wallpaper {
    transition: none;
  }
}

:is(#full-player, #spotify-full-player) {
  height: calc(100dvh / var(--ui-scale));
}

.album-grouping {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 24px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.album-grouping label {
  font-size: 13px;
  font-weight: 600;
}
.album-grouping select {
  width: auto;
  min-width: 180px;
  min-height: 44px;
}
.album-grouping p {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.folder-caption {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-caption .ico {
  display: inline;
  font-size: 13px;
}
.folder-location {
  overflow-wrap: anywhere;
}
.panel .album-grouping {
  padding: 0;
  border: 0;
  margin: 18px 0 0;
}
@media (max-width: 760px) {
  .album-grouping select {
    width: 100%;
    font-size: 16px;
  }
  .album-grouping {
    padding: 14px;
  }
  .folder-caption {
    font-size: 10px;
  }
}

/* Glossy is optional. Solid surfaces remain the fallback without backdrop-filter. */
:root {
  --glass-opacity: 70%;
  --glass-blur: 20px;
  --glass-shine: rgb(255 255 255 / 8%);
}
body.light {
  --glass-shine: rgb(255 255 255 / 38%);
}
.wallpaper-preview img {
  opacity: var(--wallpaper-opacity);
}
body.glossy .main {
  /* Keep page headings readable even over a bright photograph. */
  background: color-mix(in srgb, var(--bg) 35%, transparent);
}
body.glossy .content {
  background: transparent;
}
body.glossy
  :is(.sidebar, .topbar, .player, .mobile-nav, .panel, .hero, .auth-form),
.wallpaper-preview.glossy span {
  background: var(--panel);
  box-shadow:
    inset 0 1px 0 var(--glass-shine),
    0 10px 30px rgb(0 0 0 / 8%);
  border-color: color-mix(in srgb, var(--line) 70%, var(--glass-shine));
}
@supports (
  (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))
) {
  body.glossy
    :is(.sidebar, .topbar, .player, .mobile-nav, .panel, .hero, .auth-form),
  .wallpaper-preview.glossy span {
    background:
      linear-gradient(135deg, var(--glass-shine), transparent 55%),
      color-mix(in srgb, var(--panel) var(--glass-opacity), transparent);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(125%);
    backdrop-filter: blur(var(--glass-blur)) saturate(125%);
  }
}
@media (prefers-reduced-transparency: reduce) {
  body.glossy
    :is(.sidebar, .topbar, .player, .mobile-nav, .panel, .hero, .auth-form),
  .wallpaper-preview.glossy span {
    background: var(--panel);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.server-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 10px 18px;
  font-size: 14px;
}
.server-details dt {
  color: var(--muted);
}
.server-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  .server-details {
    grid-template-columns: minmax(0, 1fr);
  }
  .server-details dd {
    margin-bottom: 8px;
  }
}
