/* ============================================================
   OTAKU GRID — Design System & Full Stylesheet
   ============================================================ */

:root {
  --bg: #0d0f18;
  --surface: #161b2e;
  --surface-alt: #1e2540;
  --surface-hover: #252d4a;
  --accent: #02a9ff;
  --accent-dim: rgba(2, 169, 255, 0.15);
  --accent-glow: rgba(2, 169, 255, 0.4);
  --text: #f0f4ff;
  --text-muted: #7b8db0;
  --border: rgba(2, 169, 255, 0.18);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --tile-width: 180px;
  --tile-gap: 12px;
  --sidebar-w: 290px;
}

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

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100%;
  line-height: 1.5;
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-alt); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(2,169,255,0.45); }

/* ============================================================
   SPLASH SCREEN
   ============================================================ */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splash-fadeout 0.4s ease 0.7s forwards;
  pointer-events: none;
}

.splash-screen.hidden { display: none; }

.splash-logo {
  text-align: center;
  position: relative;
  animation: splash-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.splash-wordmark {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.splash-otaku { color: #fff; }
.splash-grid { color: var(--accent); }

.splash-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.splash-scanlines {
  position: absolute;
  inset: -10px;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.12) 2px,
    rgba(0,0,0,0.12) 4px
  );
  animation: scanline-scroll 3s linear infinite;
}

@keyframes splash-in {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes splash-fadeout {
  from { opacity: 1; }
  to   { opacity: 0; pointer-events: none; }
}

@keyframes scanline-scroll {
  from { background-position: 0 0; }
  to   { background-position: 0 100px; }
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  max-height: 100vh;
  padding: 1.25rem;
  gap: 1.25rem;
  background: var(--bg);
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  z-index: 10;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
  max-height: calc(100vh - 2.5rem);
}

/* ── Wordmark / Brand ── */
.sidebar-brand {
  position: sticky;
  top: -1.25rem;
  margin-top: -1.25rem;
  padding: 1.25rem 0 0.75rem;
  background: var(--surface);
  z-index: 100;
  text-align: center;
  margin-bottom: 1.25rem;
}

.wordmark {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.word-otaku { color: #fff; }
.word-grid  { color: var(--accent); }

.wordmark-rule {
  height: 2px;
  margin-top: 0.5rem;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 4px;
}

.tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-top: 0.3rem;
}

/* ── Sidebar Sections ── */
.sidebar-section { margin-bottom: 1.25rem; }

.sidebar-title {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}

.textarea-wrap { position: relative; }

.anime-textarea {
  width: 100%;
  height: 130px;
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  transition: var(--transition);
}

.anime-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.anime-textarea::placeholder { color: var(--text-muted); }

/* ── Autocomplete ── */
.autocomplete-dropdown {
  position: fixed;
  z-index: 5000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  overflow: hidden;
  display: none;
  width: 260px;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.autocomplete-item:hover, .autocomplete-item.focused { background: var(--surface-hover); }

.autocomplete-item img {
  width: 32px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.autocomplete-item-title { font-weight: 600; }
.autocomplete-item-year  { font-size: 0.75rem; color: var(--text-muted); }

/* ── Presets ── */
.preset-buttons {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.preset-btn {
  flex: 1;
  min-width: 36px;
  padding: 0.45rem;
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}

.preset-btn:hover {
  background: var(--border);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.preset-btn:active { transform: translateY(1px); }

.generate-btn {
  width: 100%;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  padding: 0.65rem;
}

/* ── Segmented Controls ── */
.toggle-group,
.segmented-buttons {
  display: flex;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  flex-wrap: wrap;
}

.toggle-btn, .seg-btn, .bg-btn, .style-btn, .theme-btn {
  flex: 1;
  min-width: fit-content;
  padding: 0.45rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.toggle-btn:hover, .seg-btn:hover, .bg-btn:hover,
.style-btn:hover, .theme-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.toggle-btn.active, .seg-btn.active, .bg-btn.active,
.style-btn.active, .theme-btn.active {
  background: var(--accent);
  color: #000;
  font-weight: 800;
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* ── Checkbox ── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.88rem;
  user-select: none;
}

.checkbox-label input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.footer-row {
  display: flex;
  gap: 0.4rem;
}

.footer-row .btn {
  flex: 1;
  font-size: 0.78rem;
  padding: 0.5rem 0.4rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}

.btn:hover    { transform: translateY(-1px); }
.btn:active   { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 16px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.15); box-shadow: 0 0 28px var(--accent-glow); }

.btn-outline-glow {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px var(--accent-dim);
}
.btn-outline-glow:hover {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }

.sidebar-btn { width: 100%; }

/* ============================================================
   CONTENT AREA & VIEW PANELS
   ============================================================ */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0 0.75rem;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── View Toggle ── */
.view-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.view-btn {
  padding: 0.45rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--accent); color: #000; font-weight: 800; }

/* ── Export Controls ── */
.export-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.export-format-select {
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

/* ── Views Container ── */
.views-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view-panel {
  display: none;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
}



/* ============================================================
   COLLAGE PANEL
   ============================================================ */
.collage-panel {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

.collage-canvas {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem;
  overflow: auto;
  min-height: 0;
}

/* ── Grid Container ── */
.grid-container {
  display: grid;
  gap: var(--tile-gap);
  padding: 20px;
  background: transparent;
  width: max-content;
  margin: 0 auto;
  position: relative;
  transition: gap 0.3s ease;
}

.grid-3x3 { grid-template-columns: repeat(3, var(--tile-width)); }
.grid-4x4 { grid-template-columns: repeat(4, var(--tile-width)); }
.grid-5x5 { grid-template-columns: repeat(5, var(--tile-width)); }

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-width), 1fr));
  align-items: start;
  width: 100%;
}

/* ── Collage Themes ── */
.theme-void   { --tile-gap: 10px; }
.theme-neon   { --tile-gap: 10px; }
.theme-neon   .tile { border-color: #02a9ff; box-shadow: 0 0 8px rgba(2,169,255,0.35), inset 0 0 8px rgba(2,169,255,0.08); }
.theme-sakura { --tile-gap: 12px; background: linear-gradient(135deg, rgba(255,183,197,0.08), rgba(255,183,197,0.04)); }
.theme-sakura .tile { border-color: rgba(255,183,197,0.4); }
.theme-gold   { --tile-gap: 10px; }
.theme-gold   .tile { border-color: #ffd700; box-shadow: 0 0 8px rgba(255,215,0,0.25); }

/* ── Safe Export Mode ── */
.export-mode,
.export-mode * {
  animation: none !important;
  transition: none !important;
}

/* ============================================================
   TILES
   ============================================================ */
.tile {
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 8px 0 8px;
  display: flex;
  flex-direction: column;
  height: max-content;
  transition: var(--transition);
  cursor: grab;
  position: relative;
  overflow: hidden;
  animation: tile-in var(--tile-anim-dur, 0.5s) cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: var(--i-delay, 0ms);
}

.tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(2,169,255,0.18);
  border-color: var(--accent);
  z-index: 2;
}

.tile:active { cursor: grabbing; }

@keyframes tile-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Skeleton shimmer */
.tile.loading {
  min-height: 240px;
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hover) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  cursor: default;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.tile img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.tile-info {
  display: flex;
  flex-direction: column;
  padding: 8px 2px 10px;
}

.t-title {
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 700;
  margin-bottom: 3px;
  word-break: break-word;
  line-height: 1.3;
}

.t-year { color: var(--text-muted); font-size: 0.75rem; }

/* Cache badge */
.cache-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0,0,0,0.7);
  border-radius: 4px;
  font-size: 10px;
  padding: 1px 4px;
  z-index: 3;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

/* Watchlist button */
.watchlist-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.6);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 3px 5px;
  font-size: 0.9rem;
  z-index: 4;
  backdrop-filter: blur(4px);
  transition: var(--transition);
  line-height: 1;
}

.watchlist-btn:hover { background: rgba(0,0,0,0.85); transform: scale(1.15); }

/* Watched overlay */
.watched-overlay {
  position: absolute;
  inset: 0;
  background: rgba(52,211,153,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border-radius: var(--radius-sm);
  z-index: 2;
}

.watched-overlay svg { opacity: 0.9; }

/* Tile rotateY flip for shuffle */
@keyframes tile-flip {
  0%   { transform: rotateY(0deg); }
  50%  { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}

.tile.flipping { animation: tile-flip 0.45s ease; }

/* Empty tile */
.tile.empty { visibility: hidden; }

/* Not found tile */
.tile.not-found {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(239,68,68,0.08);
  color: #ef4444;
  border-color: rgba(239,68,68,0.3);
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem;
  cursor: default;
}

.tile.not-found span { font-size: 1.5rem; margin-bottom: 0.4rem; }

/* Polaroid style */
.grid-container.style-polaroid .tile {
  background: #efeade;
  padding: 7px 7px 0 7px;
  border-radius: 3px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.6);
}

.grid-container.style-polaroid .tile img {
  border-radius: 2px;
}

.polaroid-info {
  display: flex;
  flex-direction: column;
  padding: 10px 0 14px;
  color: #111;
  font-family: 'DM Sans', sans-serif;
}

.p-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 5px;
}

.p-title {
  font-weight: 800;
  font-size: 0.82rem;
  text-transform: uppercase;
  flex: 1;
  line-height: 1.2;
  word-break: break-word;
}

.p-year { font-size: 0.62rem; font-weight: 700; color: #555; }

.p-meta {
  font-size: 0.56rem;
  text-transform: uppercase;
  color: #333;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.p-meta span.l { font-weight: 700; color: #000; margin-right: 3px; }

/* Auto grid tiles */
.grid-auto .tile {
  width: 100%;
  break-inside: avoid;
}

/* ============================================================
   DETAIL MODAL
   ============================================================ */
.detail-modal-content {
  max-width: 600px;
  padding: 0;
  overflow: hidden;
  position: relative;
}

.detail-modal-content .modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.detail-layout {
  display: flex;
  gap: 0;
}

.detail-cover-wrap {
  width: 200px;
  flex-shrink: 0;
}

.detail-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-info {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  max-height: 380px;
}

.detail-title {
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
}

.detail-english { font-size: 0.85rem; color: var(--text-muted); }

.detail-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

.detail-meta-item { display: flex; flex-direction: column; gap: 2px; }
.detail-meta-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.detail-meta-value { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.detail-score-val  { color: #facc15; }

.detail-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.detail-genre-tag {
  padding: 3px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.detail-links {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

.detail-link {
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition);
}

.detail-link-anilist { background: rgba(2,169,255,0.15); color: var(--accent); border: 1px solid var(--border); }
.detail-link-anilist:hover { background: var(--accent); color: #000; }
.detail-link-mal     { background: rgba(100,100,200,0.15); color: #8888ee; border: 1px solid rgba(100,100,200,0.3); }
.detail-link-mal:hover { background: rgba(100,100,200,0.3); color: #aaaaff; }

/* ============================================================
   GRAPH PANEL
   ============================================================ */
.graph-panel {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Graph Filters ── */
.graph-filters {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.genre-pill {
  padding: 3px 10px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.genre-pill:hover { border-color: var(--accent); color: var(--accent); }
.genre-pill.active { background: var(--accent); border-color: var(--accent); color: #000; }

/* ── Dual Range Slider ── */
.rating-range-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 18px;
  text-align: center;
}

.dual-range-container {
  position: relative;
  width: 120px;
  height: 20px;
}

.range-slider {
  position: absolute;
  width: 100%;
  height: 4px;
  top: 8px;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  pointer-events: all;
  border: 2px solid var(--bg);
  box-shadow: 0 0 6px var(--accent-glow);
  transition: box-shadow 0.2s;
}

.range-slider::-webkit-slider-thumb:hover { box-shadow: 0 0 12px var(--accent-glow); }

.range-track-fill {
  position: absolute;
  height: 4px;
  top: 8px;
  background: var(--accent);
  border-radius: 4px;
  pointer-events: none;
}

.dual-range-container::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 8px; height: 4px;
  background: var(--surface);
  border-radius: 4px;
}

/* ── Graph Canvas ── */
.graph-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: default;
  min-height: 0;
}

#bubble-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 400px;
}

.graph-empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  pointer-events: none;
}

.graph-empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.7;
}

/* ── Graph Tooltip ── */
.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  padding: 0.75rem;
  min-width: 180px;
  max-width: 240px;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 500;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.graph-tooltip.visible { opacity: 1; }

.tooltip-thumb {
  width: 40px;
  height: 55px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.tooltip-info { display: flex; flex-direction: column; gap: 3px; }
.tooltip-title { font-size: 0.82rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.tooltip-score { font-size: 0.75rem; color: #facc15; font-weight: 700; }
.tooltip-genres { font-size: 0.7rem; color: var(--text-muted); }
.tooltip-year   { font-size: 0.7rem; color: var(--text-muted); }

/* ============================================================
   MODALS (Shared)
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 1000;
  padding: 1rem;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 90%;
  max-width: 440px;
  transform: scale(0.93);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}

.modal.active .modal-content { transform: scale(1); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 { font-size: 1rem; font-weight: 700; }

.modal-close {
  background: var(--surface-alt);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: rgba(239,68,68,0.2); color: var(--danger); }

.modal-body { padding: 1.5rem; }

.setting-item { margin-bottom: 1.25rem; }
.setting-item h3 { font-size: 0.9rem; margin-bottom: 0.25rem; }
.setting-description { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.75rem; }

.actions-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.85rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateY(120px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease;
  z-index: 2000;
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 320px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { border-color: #34d399; }
.toast-error   { border-color: var(--danger); }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  margin-left: auto;
}

/* ============================================================
   RESPONSIVE / MOBILE
   ============================================================ */
@media (max-width: 768px) {
  /* Restore scroll suppressed by desktop overflow:hidden */
  html { height: auto !important; }
  body { overflow-x: hidden !important; overflow-y: auto !important; height: auto !important; }

  :root {
    --tile-width: 110px;
    --tile-gap: 8px;
    --sidebar-w: 100%;
  }

  .app-layout {
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.75rem;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .sidebar {
    width: 100%;
    order: 2;
    position: static;
    height: auto !important;
    max-height: none !important;
    margin-top: 1rem;
  }

  .sidebar-brand { position: static; margin-top: 0; }

  .content-area { order: 1; }

  .main-header {
    justify-content: center;
    padding: 0.5rem 0;
  }

  .export-controls { justify-content: center; width: 100%; }

  .collage-canvas { padding: 0.5rem; overflow-x: auto; }

  .grid-container { padding: 8px; }

  .views-container { height: 60vh; min-height: 400px; }

  .detail-layout { flex-direction: column; }
  .detail-cover-wrap { width: 100%; height: 200px; }
  .detail-info { max-height: none; }

  .graph-filters { gap: 0.5rem; }
  .dual-range-container { width: 80px; }
}

@media (max-width: 480px) {
  .views-container { height: 55vh; }
  .wordmark { font-size: 1.3rem; }
}