/* ============================================================
   Hone3 — Visual System
   ============================================================ */

:root {
  --bg-app: #f5f5f7;
  --bg-screen: #ffffff;
  --bg-elevated: #ffffff;
  --bg-subtle: #f7f7f9;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #a1a1a6;
  --border: #e8e8eb;
  --border-strong: #d2d2d7;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --apple-music: #fa233b;
  --apple-music-light: #fb5c74;
  --success: #34c759;
  --danger: #ff3b30;
  --warning: #ff9500;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  /* Prevent horizontal bounce / pull to refresh interfering with swipes */
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

#appRoot {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-screen);
  overflow: hidden;
}

@media (min-width: 768px) {
  body {
    padding: 20px;
  }
  #appRoot {
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
    box-shadow: var(--shadow-lg);
    border-radius: 28px;
  }
}

/* ============================================================
   Screens (stacked, only one visible at a time)
   ============================================================ */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  background: var(--bg-screen);
  overflow: hidden;
  padding-top: var(--safe-top);
}

.screen.active {
  display: flex;
}

.screen-tiles {
  background: linear-gradient(180deg, #fafafc 0%, #f1f1f4 100%);
}

/* Screen header */
.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-screen);
  z-index: 10;
}

.screen-header-floating {
  position: absolute;
  top: var(--safe-top);
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.screen-title {
  font-weight: 700;
  font-size: 17px;
  flex: 1;
  text-align: center;
}

.back-btn, .header-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 16px;
  font-weight: 500;
  padding: 6px 4px;
  cursor: pointer;
  font-family: inherit;
  min-width: 60px;
  text-align: left;
}

.header-link {
  text-align: right;
}

.step-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 4px 10px;
  background: var(--bg-subtle);
  border-radius: 20px;
  min-width: 60px;
  text-align: center;
}

.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 100px;
  -webkit-overflow-scrolling: touch;
}

.screen-h2 {
  font-size: 26px;
  font-weight: 700;
  margin: 8px 0 6px;
  line-height: 1.25;
}

.screen-sub {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 24px;
}

/* ============================================================
   HOME SCREEN
   ============================================================ */
.home-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 16px 8px;
}

.home-title {
  font-family: -apple-system, "SF Pro Display", sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 120px;
  text-align: center;
}

.home-hero {
  margin-bottom: 48px;
}

.home-tagline {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.home-sub {
  font-size: 15px;
  color: var(--text-secondary);
}

.home-plus {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 36px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.home-plus:active {
  transform: scale(0.95);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.5);
}

.home-plus svg {
  width: 40px;
  height: 40px;
}

.home-recent {
  margin-top: 36px;
  width: 100%;
}

/* ============================================================
   Bottom nav
   ============================================================ */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  padding: 10px 8px calc(10px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}

.nav-tab {
  flex: 1;
  padding: 10px 4px;
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: inherit;
  border-radius: 8px;
}

.nav-tab.active {
  color: var(--accent);
}

/* ============================================================
   Buttons
   ============================================================ */
.primary-btn {
  width: 100%;
  padding: 14px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.primary-btn:active {
  transform: scale(0.98);
}

.primary-btn:disabled {
  background: var(--border-strong);
  cursor: not-allowed;
}

.primary-btn-large {
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 700;
}

.primary-btn-apple {
  background: var(--apple-music);
}

.secondary-btn {
  padding: 14px 20px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.danger-btn {
  padding: 14px 20px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* ============================================================
   Choice cards (Step 1 — playlist vs library)
   ============================================================ */
.choice-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.choice-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s, transform 0.1s;
}

.choice-card.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.04);
}

.choice-card:active {
  transform: scale(0.98);
}

.choice-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.choice-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
}

.choice-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.connect-area {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  text-align: center;
}

.connect-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 8px 0 0;
}

/* Picker row with optional artwork thumbnail */
.picker-row {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  gap: 12px;
}

.picker-row-art {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--border);
  flex-shrink: 0;
  object-fit: cover;
}

.picker-row-art-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: linear-gradient(135deg, #c7d2fe, #ddd6fe);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.85);
  font-size: 18px;
}

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

.picker-row-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.picker-row-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.picker-row-btn {
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 12px;
  white-space: nowrap;
}

/* Library-scan opt-in row (before project flow) */
.library-scan-card {
  margin-top: 18px;
  padding: 16px;
  background: linear-gradient(135deg, #fdf2f8, #fef3c7);
  border: 1px solid #fde68a;
  border-radius: var(--radius-lg);
}

.library-scan-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: #92400e;
}

.library-scan-card p {
  margin: 0 0 12px;
  font-size: 12px;
  color: #78350f;
  line-height: 1.45;
}

.library-scan-card .scan-actions {
  display: flex;
  gap: 8px;
}

.library-scan-card button {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid #d97706;
  background: #fff;
  color: #92400e;
  cursor: pointer;
  font-family: inherit;
}

.library-scan-card button.primary {
  background: #d97706;
  color: #fff;
  border-color: #d97706;
}

/* Preview length toggle in Profile */
.preview-length-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
}

.preview-length-row:last-child { border-bottom: none; }

.preview-length-options {
  display: flex;
  background: var(--bg-subtle);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.preview-length-options button {
  padding: 6px 14px;
  background: transparent;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-secondary);
}

.preview-length-options button.active {
  background: #fff;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.library-loading-area {
  margin-top: 16px;
  padding: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
}

.library-loading-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  font-size: 14px;
}

.library-loading-status {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.library-progress-track {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 3px;
  overflow: hidden;
}

.library-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}

/* ============================================================
   Settings step
   ============================================================ */
.settings-block {
  background: var(--bg-elevated);
  padding: 18px;
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.settings-h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.settings-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0 0 14px;
}

/* Genre chips */
.genre-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genre-chip {
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.genre-chip.excluded {
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  text-decoration: line-through;
}

.genre-chip-pct {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.8;
}

/* Slider */
.slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 3px;
  outline: none;
}

.slider-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider-val {
  font-weight: 700;
  color: var(--accent);
  min-width: 32px;
  text-align: right;
}

/* Discovery mode row */
.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-btn {
  padding: 14px 6px;
  background: var(--bg-subtle);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.mode-btn.active {
  background: var(--bg-elevated);
  border-color: var(--accent);
}

.mode-emoji {
  font-size: 22px;
  margin-bottom: 4px;
}

.mode-label {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

.mode-desc {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ============================================================
   Loading screen
   ============================================================ */
.loading-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 32px;
  text-align: center;
}

.loading-orb {
  width: 120px;
  height: 120px;
  position: relative;
  margin-bottom: 32px;
}

.loading-orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  animation: spin 1.4s linear infinite;
}

.loading-orb-ring-2 {
  inset: 12px;
  border-top-color: transparent;
  border-right-color: #8b5cf6;
  animation-duration: 2s;
  animation-direction: reverse;
}

.loading-orb-ring-3 {
  inset: 24px;
  border-top-color: transparent;
  border-bottom-color: #ec4899;
  animation-duration: 2.6s;
}

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

.loading-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.loading-status {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.loading-progress {
  width: 100%;
  max-width: 280px;
  height: 4px;
  background: var(--bg-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.4s ease;
}

/* Loading-error state — shown if generation fails or returns no results.
   Replaces the spinning orb when active (the orb is hidden by JS). */
.loading-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 32px;
  text-align: center;
}

.loading-error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.loading-error-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.loading-error-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 320px;
  line-height: 1.5;
}

.loading-error-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.loading-error-actions .secondary-btn,
.loading-error-actions .primary-btn {
  flex: 1;
}

/* ============================================================
   Tile stage (the dating-app-style swiper)
   ============================================================ */
.tile-stage {
  flex: 1;
  position: relative;
  padding: calc(72px + var(--safe-top)) 20px 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;  /* let JS handle all gestures */
}

/* Peeking neighbor tiles — colored bars at the screen edges that show
   the dominant color of the next/previous tile. Hints that more tiles
   are coming without rendering them in full. */
.tile-peek {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 65%;
  width: 14px;
  z-index: 0;
  background: #2a2a2e;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transition: background 0.4s ease, opacity 0.3s ease;
  opacity: 0.85;
}

.tile-peek-left {
  left: 0;
  border-radius: 0 14px 14px 0;
}

.tile-peek-right {
  right: 0;
  border-radius: 14px 0 0 14px;
}

.tile-peek.hidden {
  opacity: 0;
}

/* Bookmark button — top-right corner of the tile, above the album art */
.tile-bookmark-btn {
  position: absolute;
  top: 26px;
  right: 26px;
  z-index: 6;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, background 0.2s ease;
}

.tile-bookmark-btn:active { transform: scale(0.88); }

.tile-bookmark-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.tile-bookmark-btn.bookmarked {
  background: rgba(255, 255, 255, 0.92);
  color: #1a1a1a;
}

/* Bookmarks list (Library screen) */
.bookmarks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.bookmark-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.bookmark-row-art {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}

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

.bookmark-row-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-row-artist {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.bookmark-similar-btn {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.bookmark-remove-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.bookmarks-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.bookmarks-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

/* ============================================================
   Tile onboarding (first-run gesture overlay)
   ============================================================ */
.tile-onboarding {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: onboardFadeIn 0.25s ease-out;
}

@keyframes onboardFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tile-onboarding-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  padding: 22px 22px 18px;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: onboardSlideIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes onboardSlideIn {
  from { transform: scale(0.92) translateY(12px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.tile-onboarding-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
  text-align: center;
  color: var(--text-primary);
}

.tile-onboarding-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.tile-onboarding-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}

.tile-onboarding-row strong {
  font-weight: 700;
}

.tile-onb-arrow {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.02em;
}

/* ============================================================
   Undo toast (3-second window after a decision)
   ============================================================ */
.undo-toast {
  position: absolute;
  left: 50%;
  bottom: calc(90px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 70;
  background: rgba(28, 28, 32, 0.92);
  color: #fff;
  border-radius: 999px;
  padding: 10px 6px 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: undoSlideUp 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  max-width: 88%;
}

.undo-toast.fading {
  animation: undoFadeOut 0.3s ease-out forwards;
}

@keyframes undoSlideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes undoFadeOut {
  to { opacity: 0; transform: translate(-50%, 8px); }
}

.undo-toast-text {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.undo-toast-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

.undo-toast-btn:active {
  background: rgba(255, 255, 255, 0.28);
}

.tile {
  position: absolute;
  width: calc(100% - 40px);
  max-width: 400px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-xl);
  background: #333;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1),
              opacity 0.28s ease;
  will-change: transform, opacity;
}

.tile-tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
              rgba(0,0,0,0) 50%,
              rgba(0,0,0,0.55) 100%);
  pointer-events: none;
  z-index: 1;
}

/* BIG album art — dominates the tile (about 60% height), with breathing
   room so the art doesn't touch the tile's outer walls. */
.tile-art-hero {
  position: relative;
  width: 100%;
  height: 62%;
  flex-shrink: 0;
  padding: 16px 16px 0;
  overflow: visible;
}

/* Inner frame holds the art image + its overlays, with its own rounded
   corners. Gives the art breathing room from the tile edges. */
.tile-art-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
}

.tile-art-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Prevent native browser image drag from intercepting our pointer
     events. Without this, pressing on the img starts a drag-and-drop
     operation instead of bubbling pointerdown up to the tile, which
     made swipes on the image area not register as swipes. */
  pointer-events: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.tile-art-hero .tile-genre {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Circular preview progress — sits at the BOTTOM-right of the album art
   so it never collides with the bookmark button at the top-right. */
.tile-preview-progress {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 4;
  width: 44px;
  height: 44px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.tile-preview-progress.active {
  opacity: 1;
}

.tile-preview-progress svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.tile-preview-progress circle.bg {
  fill: rgba(0, 0, 0, 0.4);
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 2;
}

.tile-preview-progress circle.fg {
  fill: none;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.1s linear;
}

.tile-preview-progress .countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Bottom info area (track / artist / album) */
.tile-info {
  flex: 1;
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  z-index: 2;
}

.tile-track-name {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  /* Allow up to 2 lines, ellipsize after */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-artist {
  font-size: 15px;
  font-weight: 600;
  opacity: 0.95;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-album {
  font-size: 12px;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}

.tile-play-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  opacity: 0.85;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tile-play-indicator svg {
  width: 14px;
  height: 14px;
}

.tile-play-indicator.no-preview {
  opacity: 0.55;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
}

/* Tile state visuals */
.tile-action-overlay {
  position: absolute;
  top: 20px;
  z-index: 5;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 8px;
  border: 4px solid;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.tile-action-overlay.added {
  left: 20px;
  color: var(--success);
  border-color: var(--success);
  transform: rotate(-14deg);
}

.tile-action-overlay.passed {
  right: 20px;
  color: var(--warning);
  border-color: var(--warning);
  transform: rotate(14deg);
}

.tile-action-overlay.disliked {
  left: 50%;
  transform: translateX(-50%);
  color: var(--danger);
  border-color: var(--danger);
}

/* "Done" tile - shown after last recommendation */
.tile.tile-done {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  padding: 32px;
}

.tile-done-emoji {
  font-size: 56px;
  margin-bottom: 18px;
}

.tile-done-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 10px;
}

.tile-done-sub {
  font-size: 14px;
  opacity: 0.9;
  line-height: 1.5;
  margin-bottom: 24px;
}

.tile-done-btn {
  padding: 14px 32px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Floating action overlay (Added / Passed feedback after swipe) */
.tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  z-index: 50;
  font-size: 80px;
  font-weight: 800;
  color: #fff;
  transition: opacity 0.18s;
}

.tile-overlay.show {
  opacity: 1;
}

.tile-overlay-badge {
  padding: 20px 36px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 28px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.tile-overlay-badge.added {
  background: var(--success);
  color: #fff;
}

.tile-overlay-badge.passed {
  background: var(--warning);
  color: #fff;
}

.tile-overlay-badge.disliked {
  background: var(--danger);
  color: #fff;
}

.tile-bottom {
  position: absolute;
  bottom: calc(20px + var(--safe-bottom));
  left: 20px;
  right: 20px;
  z-index: 20;
}

/* Long-press context menu */
.tile-context-menu {
  position: fixed;
  z-index: 100;
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  min-width: 180px;
  animation: menuPop 0.18s ease-out;
}

@keyframes menuPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.tile-context-menu button {
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
}

.tile-context-menu button:hover {
  background: var(--bg-subtle);
}

.tile-context-menu button[data-action="dislike"] {
  color: var(--danger);
}

/* ============================================================
   Summary screen
   ============================================================ */
.summary-section {
  margin-bottom: 22px;
}

.summary-h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.summary-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}

.summary-icon.added { background: var(--success); }
.summary-icon.passed { background: var(--warning); }
.summary-icon.disliked { background: var(--danger); }

.summary-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 4px;
}

.summary-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: 10px;
}

.summary-row-art {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--border);
  flex-shrink: 0;
  object-fit: cover;
}

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

.summary-row-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-row-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-row-action {
  display: flex;
  gap: 4px;
}

.summary-action-btn {
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-tertiary);
  font-family: inherit;
}

.summary-action-btn:hover {
  background: var(--bg-subtle);
}

.summary-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
  font-style: italic;
}

.summary-footer {
  position: sticky;
  bottom: 0;
  margin: 24px -16px -100px;
  padding: 14px 16px calc(14px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.summary-footer .secondary-btn {
  flex: 0 0 auto;
}

.summary-footer .primary-btn {
  flex: 1;
}

/* ============================================================
   Success screen
   ============================================================ */
.success-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

.success-check {
  width: 120px;
  height: 120px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  margin-bottom: 28px;
  animation: checkPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkPop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.success-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.success-sub {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.success-stage .primary-btn {
  max-width: 280px;
}

/* ============================================================
   Placeholder screens
   ============================================================ */
.placeholder-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 32px 100px;
}

.placeholder-emoji {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.placeholder-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 12px;
}

.placeholder-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 320px;
}

.placeholder-soft {
  opacity: 0.7;
}

/* ============================================================
   Profile (settings) toggles
   ============================================================ */
.profile-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

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

.profile-row-status {
  color: var(--text-tertiary);
  font-size: 13px;
}

.profile-row-status.active {
  color: var(--success);
  font-weight: 600;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  position: relative;
  cursor: pointer;
}

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

.toggle-row span:first-child {
  grid-column: 1;
  grid-row: 1;
}

.toggle-row .toggle-sub {
  grid-column: 1;
  grid-row: 2;
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-top: 2px;
}

.toggle-row input[type=checkbox] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-slider {
  grid-column: 2;
  grid-row: 1 / 3;
  width: 48px;
  height: 28px;
  background: var(--border-strong);
  border-radius: 14px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-row input:checked ~ .toggle-slider {
  background: var(--success);
}

.toggle-row input:checked ~ .toggle-slider::after {
  transform: translateX(20px);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-actions .secondary-btn,
.modal-actions .danger-btn {
  width: 100%;
  padding: 12px 16px;
}
