/*
 * TuneFriend
 * Copyright (C) 2026 James
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 */

:root {
  --bg: #0a0a0f;
  --bg-elevated: #14141f;
  --bg-card: #1a1a28;
  --text: #f0f0f5;
  --text-muted: #8888a0;
  --accent: #7c5cff;
  --accent-2: #ff6b9d;
  --gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 60px;
  --np-h: 64px;
  --dock-h: 60px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: fadeIn 0.25s ease;
}

.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Login */
#screen-login {
  padding: 2rem 1.5rem;
  justify-content: center;
  overflow-y: auto;
}

.login-hero {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  color: var(--accent);
}

.login-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.4rem;
  font-size: 0.95rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-form label span {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-form input[type="text"],
.login-form input[type="password"],
.login-form input[type="url"] {
  background: var(--bg-elevated);
  border: 1px solid #2a2a3a;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.login-form input:focus {
  border-color: var(--accent);
}

.checkbox-row {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 0.6rem !important;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.checkbox-row input { margin-top: 2px; accent-color: var(--accent); }

.error {
  color: #ff6b6b;
  font-size: 0.85rem;
  text-align: center;
}

.hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 1.5rem;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.9rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--gradient);
  color: white;
}

.btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid #2a2a3a;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.icon-btn:active { background: var(--bg-card); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.lg svg { width: 32px; height: 32px; }
.icon-btn.xl svg { width: 40px; height: 40px; }

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  background: var(--bg);
  border-bottom: 1px solid #1a1a28;
  flex-shrink: 0;
}

.top-bar h2 {
  font-size: 1.25rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.top-bar-back[hidden] {
  display: none;
}

.top-bar-spacer {
  width: 40px;
  flex-shrink: 0;
}

.settings-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid #2a2a3a;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.settings-btn svg {
  width: 18px;
  height: 18px;
}

.settings-btn:active {
  opacity: 0.8;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.top-bar-actions .settings-btn span {
  display: none;
}

@media (min-width: 380px) {
  .top-bar-actions .settings-btn span {
    display: inline;
  }
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: calc(var(--dock-h) + var(--safe-bottom) + 1rem);
  -webkit-overflow-scrolling: touch;
}

/* Bottom dock — pinned to screen bottom */
.bottom-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border-top: 1px solid #1a1a28;
  padding-bottom: var(--safe-bottom);
  display: flex;
  flex-direction: column;
}

.bottom-dock.hidden {
  display: none;
}

/* Bottom nav */
.bottom-nav {
  display: flex;
  flex-shrink: 0;
  height: var(--nav-h);
  background: var(--bg-elevated);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.5rem 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  cursor: pointer;
  transition: color 0.15s;
}

.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--accent); }

/* Section headers */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  margin-top: 1rem;
}

.section-title:first-child { margin-top: 0; }

/* Quick play actions */
.quick-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.quick-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.quick-btn:active { transform: scale(0.97); }
.quick-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.quick-btn.primary {
  background: var(--gradient);
  color: white;
}

.quick-btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid #2a2a3a;
}

.album-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.album-actions .quick-btn { flex: none; padding: 0.65rem 1.1rem; }

/* Album grid */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
}

.album-card-wrap {
  position: relative;
}

.album-cover-wrap {
  position: relative;
}

.album-card-wrap > .album-fav {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}

.album-card {
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: inherit;
  padding: 0;
}

.album-card:active { opacity: 0.7; }

.album-cover {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-card);
  display: block;
}

.album-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--text-muted);
}

.album-cover.placeholder svg { width: 40%; height: 40%; opacity: 0.4; }

.album-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.album-artist {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Song list */
.song-list { list-style: none; }

.song-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid #1a1a28;
  cursor: pointer;
  transition: background 0.15s;
}

.song-item:active { background: var(--bg-card); }

.song-item.playing .song-title { color: var(--accent); }

.song-num {
  width: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.song-info { flex: 1; min-width: 0; }

.song-title {
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-dur {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.fav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}

.fav-btn svg {
  width: 18px;
  height: 18px;
}

.fav-btn:active {
  transform: scale(0.9);
}

.fav-btn.active {
  color: var(--accent-2);
}

.album-fav {
  background: rgba(10, 10, 15, 0.65);
  backdrop-filter: blur(4px);
  padding: 6px;
}

.album-fav svg {
  width: 16px;
  height: 16px;
}

.favorites-panel {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: calc(var(--dock-h) + var(--safe-bottom) + 1rem);
  -webkit-overflow-scrolling: touch;
}

.favorites-section + .favorites-section {
  margin-top: 1.5rem;
}

.detail-fav {
  flex-shrink: 0;
  align-self: flex-start;
}

.detail-fav svg {
  width: 24px;
  height: 24px;
}

/* Artist list */
.artist-list { list-style: none; }

.artist-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #1a1a28;
  cursor: pointer;
}

.artist-item:active { opacity: 0.7; }

.artist-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.artist-avatar img { width: 100%; height: 100%; object-fit: cover; }

.artist-name {
  font-size: 1rem;
  font-weight: 500;
}

/* Search */
.search-box {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding-bottom: 0.75rem;
  z-index: 10;
}

.search-box input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid #2a2a3a;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.search-box input:focus { border-color: var(--accent); }

/* Genres / decades */
.genre-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.genre-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.9rem 1rem;
  background: var(--bg-card);
  border: 1px solid #2a2a3a;
  border-radius: var(--radius);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.genre-item:active {
  opacity: 0.85;
  transform: scale(0.99);
}

.genre-item-name {
  font-weight: 600;
  font-size: 1rem;
}

.genre-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.genre-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.genre-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 1rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid #2a2a3a;
  border-radius: var(--radius);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 72px;
}

.genre-chip:active {
  border-color: var(--accent);
}

.genre-chip-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.genre-chip-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Now playing bar */
.now-playing {
  flex-shrink: 0;
  height: var(--np-h);
  background: var(--bg);
  border-bottom: 1px solid #2a2a3a;
  display: flex;
  align-items: center;
  padding: 0 0.5rem 0 0.75rem;
  gap: 0.5rem;
}

.now-playing.hidden {
  display: none;
}

.np-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  min-width: 0;
  padding: 0;
}

.np-art {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-card);
  flex-shrink: 0;
}

.np-info {
  min-width: 0;
  text-align: left;
}

.np-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-artist {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing .np-fav svg {
  width: 20px;
  height: 20px;
}

.now-playing .np-fav:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.player-fav svg {
  width: 22px;
  height: 22px;
}

.player-fav:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Full player — keep clear of status bar + 3-button / gesture nav */
.player-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  /* WebView often reports 0 for 3-button nav; 48px is a safe system-nav fallback */
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 48px);
  box-sizing: border-box;
}

.player-screen .top-bar {
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
}

.player-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.player-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1rem 1.5rem 1rem;
  gap: 0.5rem;
  min-height: 0;
  overflow: hidden;
}

.player-art {
  width: min(70vw, 280px);
  max-height: min(40vh, 280px);
  aspect-ratio: 1;
  border-radius: 20px;
  object-fit: cover;
  background: var(--bg-card);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  margin-bottom: 0.5rem;
  flex-shrink: 1;
}

#player-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  flex-shrink: 0;
}

#player-artist {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 100%;
  width: 100%;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.player-album {
  color: var(--text-muted);
  font-size: 0.85rem;
  max-width: 100%;
  width: 100%;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 400px;
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.progress-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 28px;
  min-height: 44px;
  touch-action: none;
  cursor: pointer;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
  width: 100%;
}

.play-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gradient);
  color: white;
}

.play-btn:active { transform: scale(0.95); }

/* Settings */
.settings-panel {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-group h3 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.settings-value {
  font-size: 0.95rem;
  word-break: break-all;
  text-align: right;
}

.settings-link {
  color: var(--accent);
  text-decoration: none;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #1a1a28;
}

.settings-row:last-of-type {
  border-bottom: none;
}

.settings-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.settings-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: 0.5rem;
}

.library-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid #2a2a3a;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  line-height: 1.45;
}

/* Playlists */
.playlist-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  border: 1px solid #2a2a3a;
  border-radius: var(--radius);
  overflow: hidden;
}

.playlist-item-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.playlist-item-main:active {
  opacity: 0.85;
}

.playlist-item-name {
  font-weight: 600;
  font-size: 1rem;
}

.playlist-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.playlist-item-delete {
  flex-shrink: 0;
  margin-right: 0.35rem;
  opacity: 0.7;
}

.playlist-add-panel {
  margin: 0.75rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.playlist-add-panel input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid #2a2a3a;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.playlist-add-panel input:focus {
  border-color: var(--accent);
}

.playlist-artist-results {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid #2a2a3a;
  border-radius: var(--radius);
  background: var(--bg-card);
}

.playlist-artist-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-bottom: 1px solid #1a1a28;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.playlist-artist-row:last-child {
  border-bottom: none;
}

.playlist-artist-row:active {
  background: #222233;
}

.song-remove {
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.65;
  flex-shrink: 0;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.settings-field span {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-field input,
.settings-field select {
  background: var(--bg-elevated);
  border: 1px solid #2a2a3a;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.settings-field input:focus,
.settings-field select:focus {
  border-color: var(--accent);
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid #1a1a28;
  cursor: pointer;
  font-size: 0.95rem;
}

.settings-toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.settings-btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.btn.danger {
  background: transparent;
  color: #ff6b6b;
  border: 1px solid #ff6b6b;
}

#screen-settings {
  overflow-y: auto;
}

#screen-settings .settings-panel {
  padding-bottom: calc(var(--dock-h) + var(--safe-bottom) + 2rem);
}

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  padding: 3rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-card);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 0.95rem;
}

.toast {
  position: fixed;
  bottom: calc(var(--dock-h) + var(--safe-bottom) + 1rem);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #ff6b6b;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
  cursor: pointer;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.loading-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.loading-overlay span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Back header for detail views */
.detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-header img {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-card);
}

.detail-header .meta h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.detail-header .meta {
  flex: 1;
  min-width: 0;
}

.detail-header .meta p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}