/* ==========================================================================
   Music Discovery Graph — Stylesheet
   Premium dark theme, interactive knowledge graph UI
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111627;
  --bg-surface: #161b2e;
  --bg-surface-hover: #1c2340;
  --bg-overlay: rgba(10, 14, 26, 0.85);
  --bg-glass: rgba(22, 27, 46, 0.80);

  --text-primary: #e8ecf4;
  --text-secondary: #8899aa;
  --text-muted: #556677;

  --color-macro: #D4A84B;
  --color-sub: #4A90D9;
  --color-micro: #8899AA;
  --color-regional: #4CAF50;
  --color-accent: #D4A84B;
  --color-focus: rgba(74, 144, 217, 0.5);

  --border-subtle: rgba(136, 153, 170, 0.12);
  --border-medium: rgba(136, 153, 170, 0.25);

  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);

  --topbar-height: 56px;
  --sidebar-width: 340px;
  --audio-bar-height: 52px;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition-fast: 150ms ease;
  --transition-base: 300ms ease;
  --transition-slow: 500ms ease;

  --z-graph: 1;
  --z-topbar: 100;
  --z-sidebar: 200;
  --z-audio: 250;
  --z-tooltip: 300;
  --z-modal: 500;
  --z-loading: 600;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-family);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.5;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

button {
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select {
  font-family: var(--font-family);
  color: inherit;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 3px; }

/* --------------------------------------------------------------------------
   Top Bar
   -------------------------------------------------------------------------- */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.top-bar-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
}

.top-bar-center {
  flex: 0 1 360px;
  margin: 0 16px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Search
   -------------------------------------------------------------------------- */
.search-wrap {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
  font-size: 0.8125rem;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:hover {
  border-color: var(--border-medium);
}

.search-input:focus {
  border-color: var(--color-sub);
  box-shadow: 0 0 0 3px var(--color-focus);
  background: var(--bg-secondary);
}

.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-tooltip);
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.search-result-item:hover {
  background: var(--bg-surface-hover);
}

.sr-name {
  font-weight: 500;
  color: var(--text-primary);
}

.sr-cat {
  font-size: 0.6875rem;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 500;
}

.sr-cat.cat-macro-genre { background: rgba(212,168,75,0.15); color: var(--color-macro); }
.sr-cat.cat-sub-genre { background: rgba(74,144,217,0.15); color: var(--color-sub); }
.sr-cat.cat-micro-genre { background: rgba(136,153,170,0.1); color: var(--color-micro); }
.sr-cat.cat-regio { background: rgba(76,175,80,0.15); color: var(--color-regional); }

/* --------------------------------------------------------------------------
   Filter Selects
   -------------------------------------------------------------------------- */
.filter-select {
  height: 32px;
  padding: 0 24px 0 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238899aa' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all var(--transition-fast);
}

.filter-select:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.filter-select:focus {
  border-color: var(--color-sub);
  box-shadow: 0 0 0 3px var(--color-focus);
}

.filter-select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Graph Container
   -------------------------------------------------------------------------- */
.graph-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-graph);
}

.graph-container svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

.graph-container svg:active {
  cursor: grabbing;
}

/* SVG Elements */
.link {
  pointer-events: none;
}

.node {
  cursor: pointer;
}

.node-circle {
  transition: r var(--transition-base), stroke-width var(--transition-fast);
  fill-opacity: 0.85;
}

.node:hover .node-circle {
  fill-opacity: 1;
  stroke-width: 3;
}

.pulse-ring {
  pointer-events: none;
}

.pulse-ring.pulsing {
  animation: pulse 1.5s ease-in-out infinite;
}

.label {
  font-family: var(--font-family);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.label-visible {
  opacity: 1 !important;
}

.node:hover + text.label,
.node:hover ~ text.label {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Graph Tooltip
   -------------------------------------------------------------------------- */
.graph-tooltip {
  display: none;
  position: fixed;
  z-index: var(--z-tooltip);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  max-width: 220px;
  font-size: 0.8125rem;
}

.graph-tooltip strong {
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.tooltip-artist {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.tooltip-category {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.6875rem;
  padding: 1px 6px;
  border-radius: 100px;
  font-weight: 500;
}

.tooltip-category.cat-macro-genre { background: rgba(212,168,75,0.15); color: var(--color-macro); }
.tooltip-category.cat-sub-genre { background: rgba(74,144,217,0.15); color: var(--color-sub); }
.tooltip-category.cat-micro-genre { background: rgba(136,153,170,0.1); color: var(--color-micro); }
.tooltip-category.cat-regio { background: rgba(76,175,80,0.15); color: var(--color-regional); }

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  z-index: var(--z-sidebar);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  padding: 24px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--transition-base);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 1.25rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.sidebar-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.sidebar-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  padding-right: 40px;
  line-height: 1.2;
}

.category-badge, .mood-badge, .country-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  margin-right: 6px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mood-badge {
  background: rgba(74,144,217,0.15);
  color: var(--color-sub);
  border: 1px solid rgba(74,144,217,0.3);
}

.country-badge {
  background: rgba(76,175,80,0.15);
  color: var(--color-regional);
  border: 1px solid rgba(76,175,80,0.3);
}

.sidebar-section {
  margin-top: 24px;
}

.sidebar-section h3 {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sidebar-artist {
  font-weight: 600;
  font-size: 1rem;
}

.sidebar-track {
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 2px;
}

.sidebar-play-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: var(--color-accent);
  color: var(--bg-primary);
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 10px;
  transition: all var(--transition-fast);
}

.sidebar-play-btn:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212,168,75,0.3);
}

.sidebar-play-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

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

.sidebar-youtube-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  background: #ff0000;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 10px;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.sidebar-youtube-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255, 0, 0, 0.25);
  color: white;
}

.sidebar-expand-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-weight: 500;
  font-size: 0.8125rem;
  border-radius: 10px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.sidebar-expand-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.sidebar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   Chips
   -------------------------------------------------------------------------- */
.chip {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.chip-link {
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip-link:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--color-sub);
}

/* --------------------------------------------------------------------------
   Entry Modal
   -------------------------------------------------------------------------- */
.entry-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

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

.entry-content {
  max-width: 640px;
  width: 90%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  text-align: center;
}

.entry-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--color-accent), #f0d78c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.entry-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 40px;
  line-height: 1.6;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.entry-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 24px 12px;
  cursor: pointer;
  transition: all var(--transition-base);
}

.entry-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--color-accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.entry-icon {
  margin-bottom: 14px;
  line-height: 1;
  color: var(--color-accent);
  opacity: 0.85;
  transition: all var(--transition-base);
}

.entry-card:hover .entry-icon {
  opacity: 1;
  transform: scale(1.15);
}

.entry-card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.entry-card p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Back button in modal sub-selections */
.entry-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  margin-bottom: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.entry-back-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* Story Selection */
.story-selection h2,
.country-selection h2,
.mood-selection h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.story-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.story-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-base);
}

.story-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.story-card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-accent);
}

.story-card p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Country chips in modal */
.country-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
}

.country-chip {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

/* Mood cards */
.mood-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.mood-card {
  border-radius: 14px;
  padding: 24px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-base);
  border: 1px solid transparent;
}

.mood-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.mood-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: white;
}

.mood-card p {
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.8);
}

/* --------------------------------------------------------------------------
   Audio Player Bar
   -------------------------------------------------------------------------- */
.audio-player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--audio-bar-height);
  z-index: var(--z-audio);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  transform: translateY(100%);
  transition: transform var(--transition-base);
}

.audio-player-bar.active {
  transform: translateY(0);
}

.audio-play-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--bg-primary);
  font-size: 0.875rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.audio-play-btn:hover {
  transform: scale(1.08);
}

.audio-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-shrink: 0;
  max-width: 200px;
}

.audio-genre {
  font-weight: 600;
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-artist {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-progress {
  flex: 1;
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  cursor: pointer;
  overflow: hidden;
}

.audio-progress-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  width: 0;
  transition: width 100ms linear;
}

.audio-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
}

.audio-youtube-link {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  color: #ff0000;
  border-radius: 6px;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.audio-youtube-link:hover {
  background: rgba(255, 0, 0, 0.15);
  transform: scale(1.1);
  color: #ff0000;
}

/* --------------------------------------------------------------------------
   Loading
   -------------------------------------------------------------------------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-loading);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  gap: 16px;
}

.loading-overlay p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

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

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes pulse {
  0%, 100% {
    opacity: 0.7;
    stroke-width: 2;
  }
  50% {
    opacity: 0.15;
    stroke-width: 6;
  }
}

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

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

/* --------------------------------------------------------------------------
   Sidebar Backdrop (mobile)
   -------------------------------------------------------------------------- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-sidebar) - 1);
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.sidebar-backdrop.visible {
  display: block;
  opacity: 1;
}

/* Drag handle for mobile bottom sheet */
.sidebar-drag-handle {
  display: none;
}

/* --------------------------------------------------------------------------
   Responsive — Tablet
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .sidebar {
    width: 280px;
  }

  .top-bar-title {
    display: none;
  }

  .btn-label {
    display: none;
  }

  .entry-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --------------------------------------------------------------------------
   Responsive — Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root {
    --topbar-height: 48px;
    --audio-bar-height: 56px;
  }

  .top-bar {
    padding: 0 12px;
  }

  .top-bar-center {
    flex: 1;
    margin: 0 8px;
  }

  .top-bar-right {
    gap: 4px;
  }

  .filter-select {
    display: none;
  }

  /* --- Sidebar as bottom sheet --- */
  .sidebar {
    width: 100%;
    max-height: 75vh;
    height: auto;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    padding: 12px 20px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .sidebar.open {
    transform: translateY(0);
  }

  /* Show drag handle on mobile */
  .sidebar-drag-handle {
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border-medium);
    border-radius: 2px;
    margin: 0 auto 12px;
    flex-shrink: 0;
  }

  .sidebar-close {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
  }

  .sidebar-title {
    font-size: 1.25rem;
  }

  .sidebar-play-btn {
    padding: 14px;
    font-size: 1rem;
  }

  .sidebar-expand-btn {
    padding: 12px;
  }

  /* When audio bar is active, sidebar needs extra bottom padding */
  .sidebar.has-audio {
    padding-bottom: calc(var(--audio-bar-height) + 20px + env(safe-area-inset-bottom, 0px));
  }

  /* Show backdrop on mobile */
  .sidebar-backdrop.visible {
    display: block;
  }

  /* --- Entry modal mobile --- */
  .entry-modal {
    align-items: flex-end;
    padding: 0;
  }

  .entry-content {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 32px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-primary);
    border-radius: 0;
  }

  .entry-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .entry-card {
    padding: 16px 10px;
  }

  .entry-card:nth-child(5) {
    grid-column: span 2;
  }

  .entry-icon svg {
    width: 28px;
    height: 28px;
  }

  .entry-title {
    font-size: 1.5rem;
    margin-bottom: 4px;
  }

  .entry-subtitle {
    font-size: 0.8125rem;
    margin-bottom: 20px;
  }

  .story-cards,
  .mood-cards {
    grid-template-columns: 1fr;
  }

  .story-card {
    padding: 16px;
  }

  .mood-card {
    padding: 18px;
  }

  .country-chips {
    max-height: 40vh;
  }

  /* --- Audio bar mobile --- */
  .audio-player-bar {
    padding: 0 12px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(var(--audio-bar-height) + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  .audio-info {
    max-width: 110px;
  }

  .audio-play-btn {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }

  .audio-time {
    display: none;
  }

  /* --- Graph tooltip: disable on touch --- */
  .graph-tooltip {
    display: none !important;
  }

  /* --- Search results mobile --- */
  .search-results {
    max-height: 50vh;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    border-radius: 0 0 12px 12px;
  }

  .search-result-item {
    padding: 12px 16px;
    min-height: 44px;
  }
}

/* --------------------------------------------------------------------------
   Responsive — Small Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 380px) {
  .top-bar-left .icon-btn {
    display: none;
  }

  .entry-grid {
    grid-template-columns: 1fr;
  }

  .entry-card:nth-child(5) {
    grid-column: span 1;
  }

  .entry-card {
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
  }

  .entry-icon {
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .entry-icon svg {
    width: 24px;
    height: 24px;
  }
}
