:root {
  --bg: #0a0a0b;
  --bg-card: #151517;
  --bg-card-hover: #1c1c1f;
  --bg-modal: #111113;
  --text: #e0e0e0;
  --text-dim: #888;
  --text-faint: #555;
  --accent: #e8a230;
  --accent-dim: #b87a18;
  --border: #222;
  --border-bright: #333;
  --radius: 10px;
  --serif: 'Cormorant Garamond', 'Georgia', serif;
  --sans: 'Inter', -apple-system, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  padding: 60px 40px 40px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.logo {
  font-family: var(--serif);
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -1px;
  color: var(--text);
}
.tagline {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.stats {
  font-size: 13px;
  color: var(--accent);
  margin-top: 12px;
  font-weight: 400;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 40px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
  flex-wrap: wrap;
}
.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.filter-tab {
  padding: 6px 14px;
  font-size: 12px;
  font-family: var(--sans);
  font-weight: 400;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border-bright);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.filter-tab:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}
.filter-tab.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}
.search-box {
  width: 240px;
  padding: 7px 14px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 20px;
  outline: none;
  transition: border-color 0.2s ease;
}
.search-box:focus { border-color: var(--accent-dim); }
.search-box::placeholder { color: var(--text-faint); }

/* ===== Mode Toggle ===== */
.mode-toggle {
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 12px 40px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.mode-btn {
  padding: 7px 24px;
  font-size: 13px;
  font-family: var(--sans);
  font-weight: 400;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border-bright);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}
.mode-btn:first-child {
  border-radius: 20px 0 0 20px;
}
.mode-btn:last-child {
  border-radius: 0 20px 20px 0;
}
.mode-btn:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}
.mode-btn.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

/* ===== Gallery Layout ===== */
.gallery {
  padding: 40px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Source section header */
.source-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 32px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.source-header:first-child {
  padding-top: 0;
}
.source-name {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
}
.source-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
  line-height: 1.5;
}
.source-meta {
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}
.source-meta-sep {
  color: var(--text-faint);
  opacity: 0.5;
}
.source-type-badge {
  color: var(--accent);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
}
.source-link {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid var(--border-bright);
  padding: 6px 14px;
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}
.source-link:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* Card grid within a source section */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 16px;
}
.loading-msg {
  color: var(--text-faint);
  font-size: 14px;
  text-align: center;
  grid-column: 1 / -1;
  padding: 60px;
}

/* ===== Card ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--accent-dim);
  background: var(--bg-card-hover);
}

/* Card Preview (screenshot or palette fallback) */
.card-preview {
  height: 200px;
  display: flex;
  position: relative;
  overflow: hidden;
  background: #0d0d0e;
}
.preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.4s ease;
}
.card:hover .preview-img {
  transform: scale(1.05);
}
.preview-band {
  flex: 1;
  height: 100%;
  position: relative;
}
.preview-band::after {
  content: attr(data-year);
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  font-family: var(--sans);
}

/* Card Body */
.card-body {
  padding: 16px 18px;
  flex: 1;
}
.card-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.2;
}
.card-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.card-category {
  color: var(--accent);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
}
.card-author {
  color: var(--text-faint);
  font-size: 11px;
}
.card-tags {
  margin-top: 10px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.card-tag {
  font-size: 10px;
  color: var(--text-faint);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 10px;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  width: 100%;
  max-width: 1200px;
  height: 80vh;
  display: flex;
  position: relative;
  overflow: hidden;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 10;
  background: rgba(0,0,0,0.6);
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.modal-close:hover { background: rgba(232,162,48,0.3); }
.modal-body {
  display: flex;
  width: 100%;
  height: 100%;
}
.modal-left {
  flex: 1;
  border-right: 1px solid var(--border);
}
.modal-left iframe { width: 100%; height: 100%; border: none; }
.modal-right {
  width: 340px;
  padding: 32px 28px;
  overflow-y: auto;
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.modal-subtitle {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 12px;
}
.modal-tagline {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  font-style: italic;
  margin-bottom: 20px;
  padding-left: 12px;
  border-left: 2px solid var(--accent-dim);
}
.modal-best-for {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}
.modal-section {
  margin-bottom: 24px;
}
.modal-section-title {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-weight: 500;
}
.token-table {
  width: 100%;
  font-size: 12px;
  font-family: 'SF Mono', 'Monaco', monospace;
}
.token-table td {
  padding: 3px 0;
  color: var(--text-dim);
}
.token-color-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid rgba(255,255,255,0.1);
}
.modal-link {
  display: inline-block;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
  padding-bottom: 1px;
  transition: opacity 0.2s ease;
  word-break: break-all;
}
.modal-link:hover { opacity: 0.7; }
.modal-source {
  font-size: 12px;
  color: var(--text-dim);
}
.modal-source strong { color: var(--text); font-weight: 500; }

/* ===== Agent Integration Guide ===== */
.agent-guide {
  margin-top: 28px;
  padding: 20px;
  background: rgba(232, 162, 48, 0.06);
  border: 1px solid rgba(232, 162, 48, 0.2);
  border-radius: var(--radius);
}
.agent-guide-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}
.agent-guide-intro {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.4;
}
.agent-step { margin-bottom: 12px; }
.agent-step:last-child { margin-bottom: 0; }
.agent-step-num {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.agent-step-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  line-height: 1.4;
}
.agent-download-btn {
  display: inline-block;
  width: 100%;
  padding: 9px 14px;
  font-size: 12px;
  font-family: var(--sans);
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.agent-download-btn:hover {
  background: var(--accent);
  color: var(--bg);
}
.agent-divider {
  height: 1px;
  background: rgba(232, 162, 48, 0.15);
  margin: 14px 0;
}
.agent-code-wrap {
  position: relative;
}
.agent-code {
  font-size: 11px;
  font-family: 'SF Mono', 'Monaco', monospace;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  padding: 12px 44px 12px 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.agent-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--sans);
  font-weight: 500;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.agent-copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}
.agent-copy-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 40px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12px;
}
.footer p {
  margin: 4px 0;
}
.footer-link a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.footer-link a::before {
  content: "↗";
  font-size: 11px;
}
.footer-link a:hover {
  color: var(--accent);
}

/* ===== Cinema Palette Card ===== */
.cinema-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
  display: flex;
  flex-direction: column;
}
.cinema-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--accent-dim);
  background: var(--bg-card-hover);
}
.cinema-preview {
  height: 240px;
  position: relative;
  overflow: hidden;
  background: #0d0d0e;
}
.cinema-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.4s ease;
}
.cinema-card:hover .cinema-preview-img {
  transform: scale(1.05);
}
.cinema-palette-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  height: 8px;
}
.cinema-palette-swatch {
  height: 100%;
}
.cinema-card-body {
  padding: 16px 18px;
  flex: 1;
}
.cinema-card-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.2;
}
.cinema-card-scene {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.cinema-card-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cinema-card-meta {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.cinema-card-mood {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.cinema-mood-chip {
  font-size: 10px;
  color: var(--accent);
  background: rgba(232, 162, 48, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(232, 162, 48, 0.2);
}

/* ===== Cinema Palette Modal ===== */
.cinema-modal-body {
  display: flex;
  width: 100%;
  height: 100%;
}
.cinema-modal-left {
  flex: 1;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.cinema-modal-left-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.cinema-modal-right {
  width: 380px;
  padding: 32px 28px;
  overflow-y: auto;
  flex-shrink: 0;
}
.cinema-modal-title {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.cinema-modal-scene {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.cinema-modal-credits {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 16px;
  line-height: 1.5;
}
.cinema-modal-desc {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 20px;
  padding-left: 12px;
  border-left: 2px solid var(--accent-dim);
}
.cinema-palette-vis {
  margin-bottom: 20px;
}
.cinema-palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  height: 28px;
}
.cinema-palette-swatch-block {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}
.cinema-palette-label {
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'SF Mono', 'Monaco', monospace;
  min-width: 100px;
  flex-shrink: 0;
  white-space: nowrap;
}
.cinema-palette-ratio-bar {
  flex: 1;
  height: 16px;
  border-radius: 3px;
  display: flex;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
}
.cinema-palette-ratio-fill {
  height: 100%;
  border-radius: 3px;
}
.cinema-analysis {
  margin-bottom: 20px;
}
.cinema-analysis-line {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  line-height: 1.5;
}
.cinema-analysis-line strong {
  color: var(--text);
  font-weight: 500;
}
.cinema-best-for-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.cinema-best-tag {
  font-size: 10px;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-bright);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header { padding: 40px 20px 30px; }
  .logo { font-size: 32px; }
  .toolbar { padding: 12px 20px; }
  .search-box { width: 100%; }
  .gallery { padding: 20px; }
  .card-grid { gap: 16px; }
  .modal { flex-direction: column; height: 90vh; }
  .modal-right { width: 100%; height: 40%; border-top: 1px solid var(--border); }
  .modal-left { height: 60%; }
}