/* ── Theming ─────────────────────────────────────── */

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #999;
  --search-bg: #f5f5f5;
  --search-border: #e2e2e2;
  --dropdown-bg: #fff;
  --dropdown-hover: #f5f5f5;
  --dropdown-border: #eee;
  --grid-header: #aaa;
  --poster-bg: #e8e8e8;
  --tooltip-bg: #2a2a2a;
  --tooltip-text: #fff;
  --tag-bg: #f0f0f0;
  --tag-text: #666;
}

[data-theme="dark"] {
  --bg: #111117;
  --text: #e8e8e8;
  --text-muted: #666;
  --search-bg: #1c1c28;
  --search-border: #2e2e3e;
  --dropdown-bg: #1c1c28;
  --dropdown-hover: #25254a;
  --dropdown-border: #2e2e3e;
  --grid-header: #666;
  --poster-bg: #222230;
  --tooltip-bg: #e8e8e8;
  --tooltip-text: #111;
  --tag-bg: #222238;
  --tag-text: #999;
}

/* ── Rating colors ────────────────────────────────── */

.cinema   { background-color: #5b8fd4; color: #fff; }
.awesome  { background-color: #1d7a34; color: #fff; }
.great    { background-color: #5dae4e; color: #1a1a1a; }
.good     { background-color: #d4c53a; color: #1a1a1a; }
.regular  { background-color: #e09530; color: #1a1a1a; }
.bad      { background-color: #d94a4a; color: #fff; }
.garbage  { background-color: #6b3a7d; color: #fff; }

/* ── Reset & Base ───────────────────────────────── */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ── Main ───────────────────────────────────────── */

.main {
  padding: 20px 32px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Controls row ───────────────────────────────── */

.controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Settings dropdown ─────────────────────────── */

.settings-wrap {
  position: relative;
}

.settings-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  z-index: 200;
  white-space: nowrap;
  transition: background 0.3s, border-color 0.3s;
}

[data-theme="dark"] .settings-dropdown {
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.settings-dropdown.hidden { display: none; }

/* ── Toggle switch ──────────────────────────────── */

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.toggle-label input { display: none; }

.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  background: #ccc;
  border-radius: 11px;
  transition: background 0.2s;
}

[data-theme="dark"] .toggle-track { background: #444; }

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

.toggle-label input:checked + .toggle-track {
  background: #5dae4e;
}

.toggle-label input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
}

/* ── Legend ──────────────────────────────────────── */

.legend {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

/* ── Search ─────────────────────────────────────── */

.search-container {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border: 1px solid var(--search-border);
  border-radius: 24px;
  background: var(--search-bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, background 0.3s;
}

#search-input:focus {
  border-color: #5dae4e;
}

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

/* ── Search tabs ───────────────────────────────── */

.search-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--dropdown-border);
  padding: 0 4px;
  position: sticky;
  top: 0;
  background: var(--dropdown-bg);
  z-index: 1;
  border-radius: 14px 14px 0 0;
}

.search-tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.search-tab:hover { color: var(--text); }

.search-tab.active {
  color: #5dae4e;
  border-bottom-color: #5dae4e;
}

/* ── Search dropdown ────────────────────────────── */

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 380px;
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  max-height: 440px;
  overflow-y: auto;
  z-index: 200;
  transition: background 0.3s, border-color 0.3s;
}

[data-theme="dark"] .search-results {
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.search-results.hidden { display: none; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--dropdown-border);
  transition: background 0.15s;
}

.search-result-item:last-child { border-bottom: none; }
.search-results-list .search-result-item:last-child { border-radius: 0 0 14px 14px; }
.search-results-list .search-result-item:only-child { border-radius: 0 0 14px 14px; }
.search-result-item:hover,
.search-result-item.active { background: var(--dropdown-hover); }

.search-result-poster {
  width: 46px;
  height: 69px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--poster-bg);
  flex-shrink: 0;
}

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

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

.search-result-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.search-result-rating {
  font-weight: 700;
  font-size: 15px;
  color: #5dae4e;
  flex-shrink: 0;
}

/* ── Search type badges ────────────────────────── */

.search-result-badges {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  margin-right: 4px;
}

.search-type-badge {
  display: block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: center;
  transition: opacity 0.15s;
}

.search-type-badge[style*="cursor: pointer"]:hover {
  opacity: 0.8;
}

.search-type-show {
  background: #5dae4e;
  color: #fff;
}

.search-type-anime {
  background: #6366f1;
  color: #fff;
}

.search-type-movie {
  background: #e09530;
  color: #fff;
}

/* ── Icon buttons ───────────────────────────────── */

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--search-border);
  border-radius: 50%;
  background: var(--search-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--text);
  border-color: #bbb;
}

/* ── Loading ────────────────────────────────────── */

.loading-state {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
}

.loading-state.hidden { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--search-border);
  border-top-color: #5dae4e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Show page ──────────────────────────────────── */

.show-page { animation: fadeIn 0.25s ease; margin-top: -14px; }

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

.show-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

/* ── Sidebar ────────────────────────────────────── */

.show-sidebar {
  flex-shrink: 0;
  width: 220px;
  padding-top: 6px;
}

.poster-wrap {
  width: 220px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--poster-bg);
  aspect-ratio: 2/3;
}

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

.poster-img.no-poster { display: none; }

.show-rating {
  margin-top: 18px;
  font-size: 22px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.star { color: #f5c518; font-size: 22px; }
.rating-value { font-weight: 700; font-size: 26px; }
.vote-count { font-size: 14px; color: var(--text-muted); font-weight: 400; }

.show-title {
  display: block;
  font-size: 22px;
  font-weight: 700;
  margin-top: 8px;
  line-height: 1.3;
  color: var(--text);
  text-decoration: none;
}

.show-title:hover {
  text-decoration: underline;
}

.show-years {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.show-genres {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

.show-tags {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-anime { background: #6366f1; color: #fff; }
.tag-kdrama { background: #ec4899; color: #fff; }
.tag-mini { background: var(--tag-bg); color: var(--tag-text); }

.show-genre-pills { display: none; }
.show-accent-line { display: none; }

.show-overview {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 14px;
  line-height: 1.6;
}

.show-overview:empty { display: none; }

/* ── Grid ───────────────────────────────────────── */

.grid-section {
  flex: 1;
  min-width: 0;
  padding-top: 6px;
}

.grid-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.rating-grid {
  border-collapse: separate;
  border-spacing: 4px;
}

.rating-grid th {
  font-size: 13px;
  font-weight: 600;
  color: var(--grid-header);
  padding: 4px 4px;
  text-align: center;
  white-space: nowrap;
  position: sticky;
  background: var(--bg);
  transition: background 0.3s;
}

.rating-grid thead th {
  top: 0;
  z-index: 2;
}

.rating-grid tbody th {
  left: 0;
  z-index: 1;
  min-width: 36px;
  padding-right: 6px;
}

.rating-grid thead th:first-child {
  z-index: 3;
  left: 0;
  position: sticky;
}

.rating-grid td {
  width: 56px;
  height: 42px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  border-radius: 8px;
  cursor: default;
  transition: transform 0.1s, box-shadow 0.1s;
  white-space: nowrap;
}

.rating-grid td:hover {
  transform: scale(1.12);
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  z-index: 5;
  position: relative;
}

.rating-grid td.empty {
  background: transparent;
  visibility: hidden;
}

/* ── Average row ───────────────────────────────── */

.rating-grid tfoot th {
  font-size: 12px;
  font-weight: 700;
  color: var(--grid-header);
  padding: 10px 4px 2px;
  text-align: center;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--bg);
}

.rating-grid tfoot td {
  padding-top: 10px;
  height: auto;
  background: transparent !important;
}

.avg-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.avg-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.avg-bar {
  width: 40px;
  height: 6px;
  border-radius: 3px;
}

.rating-grid tfoot td:hover {
  transform: none;
  box-shadow: none;
}

/* ── Tooltip ────────────────────────────────────── */

.tooltip {
  position: fixed;
  z-index: 300;
  padding: 10px 14px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 360px;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: opacity 0.15s;
}

.tooltip.hidden { opacity: 0; pointer-events: none; }
.tooltip-title { font-weight: 700; }
.tooltip-meta { color: #aaa; }
[data-theme="dark"] .tooltip-meta { color: #777; }
.tooltip-synopsis { margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--tooltip-text); opacity: 0.85; }

/* ── Responsive ─────────────────────────────────── */

@media (max-width: 900px) {
  .main { padding: 16px 16px; }

  .rating-grid td {
    width: 48px;
    height: 38px;
    font-size: 16px;
    border-radius: 6px;
  }

  .rating-grid { border-spacing: 3px; }
}

@media (max-width: 600px) {
  .show-layout {
    flex-direction: column;
    gap: 20px;
  }

  .show-sidebar { width: 180px; }
  .poster-wrap { width: 180px; }
}

@media (max-width: 700px) {
  .search-container { max-width: none; }
  .browse-grid { grid-template-columns: repeat(3, 1fr) !important; }
  .browse-columns-ctrl { display: none; }
  .browse-card-title { font-size: 14px; }
  .browse-card-rating { font-size: 13px; }
  .browse-card-year { font-size: 13px; }
}
@media (max-width: 420px) {
  .browse-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ── Settings extras ────────────────────────────── */

.settings-divider {
  height: 1px;
  background: var(--dropdown-border);
  margin: 10px 0;
}

.layout-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layout-picker-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.layout-options {
  display: flex;
  gap: 4px;
}

.layout-btn {
  width: 30px;
  height: 26px;
  border: 1px solid var(--search-border);
  border-radius: 6px;
  background: var(--search-bg);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.layout-btn.active {
  background: #5dae4e;
  color: #fff;
  border-color: #5dae4e;
}

/* ── Layout 2 ──────────────────────────────────── */

/* ── Layout 2 — shared base ────────────────────── */

[data-layout^="2"] .show-sidebar {
  width: 260px;
  padding-top: 26px;
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 0;
}

[data-layout^="2"] .poster-wrap {
  grid-column: 1 / -1;
  width: 100%;
}

[data-layout^="2"] .star { display: none; }
[data-layout^="2"] .show-years { display: none; }
[data-layout^="2"] .show-genres { display: none; }
[data-layout^="2"] .show-accent-line { display: none; }

.show-meta-row { display: none; }

[data-layout^="2"] .show-meta-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
  margin-top: 6px;
  max-width: 100%;
  overflow: hidden;
}

.show-years-inline {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-right: 8px;
  border-right: 1px solid var(--text-muted);
  margin-right: 8px;
}

[data-layout^="2"] .show-genre-pills {
  display: inline-flex;
  gap: 5px;
  flex-wrap: nowrap;
}

.genre-pill {
  padding: 2px 8px;
  border: 1px solid var(--text-muted);
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  white-space: nowrap;
}

[data-layout^="2"] .show-overview {
  grid-column: 1 / -1;
  font-size: 12px;
  line-height: 1.6;
  margin-top: 10px;
}

/* ── Layout 2 — shared base (pills + description unchanged) ── */

[data-layout^="2"] .poster-wrap { grid-column: 1 / -1; grid-row: 1; }

[data-layout^="2"] .show-meta-row .show-years-inline { display: none; }

[data-layout^="2"] .show-genre-pills {
  gap: 6px;
  flex-wrap: wrap;
}

/* ── 2a: Wider (290px), title left, rating box + votes right ── */

[data-layout="2a"] .show-sidebar { width: 290px; }
[data-layout="2a"] .poster-wrap { width: 290px; }

[data-layout="2a"] .show-title {
  grid-column: 1; grid-row: 2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px; font-weight: 700;
  line-height: 1.25; margin-top: 10px;
  min-width: 0;
}

[data-layout="2a"] .show-rating {
  grid-column: 2; grid-row: 2 / 4;
  margin-top: 10px; align-self: start;
  flex-shrink: 0; margin-left: 12px;
  flex-direction: column; align-items: center; gap: 0;
}

[data-layout="2a"] .rating-value {
  font-size: 24px; font-weight: 700;
  padding: 8px 16px; border-radius: 8px; line-height: 1;
  border: 1px solid var(--search-border); background: var(--search-bg);
}

[data-layout="2a"] .vote-count {
  font-size: 10px; font-weight: 400;
  color: var(--text-muted); text-align: center; margin-top: 4px;
}

[data-layout="2a"] .show-years {
  display: block; grid-column: 1; grid-row: 3;
  font-size: 13px; margin-top: 2px;
}

[data-layout="2a"] .show-meta-row { grid-row: 4; margin-top: 10px; }
[data-layout="2a"] .show-overview { grid-row: 5; }

/* ── 2b: Same as 2a but votes inside the box ──── */

[data-layout="2b"] .show-sidebar { width: 290px; }
[data-layout="2b"] .poster-wrap { width: 290px; }

[data-layout="2b"] .show-title {
  grid-column: 1; grid-row: 2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px; font-weight: 700;
  line-height: 1.25; margin-top: 10px;
  min-width: 0;
}

[data-layout="2b"] .show-rating {
  grid-column: 2; grid-row: 2 / 4;
  margin-top: 10px; align-self: start;
  flex-shrink: 0; margin-left: 12px;
  flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--search-border); background: var(--search-bg);
}

[data-layout="2b"] .rating-value {
  font-size: 24px; font-weight: 700; line-height: 1;
}

[data-layout="2b"] .vote-count {
  font-size: 9px; font-weight: 400;
  color: var(--text-muted); text-align: center;
}

[data-layout="2b"] .show-years {
  display: block; grid-column: 1; grid-row: 3;
  font-size: 13px; margin-top: 2px;
}

[data-layout="2b"] .show-meta-row { grid-row: 4; margin-top: 10px; }
[data-layout="2b"] .show-overview { grid-row: 5; }

/* ── 2c: Wider (290px), no vote count, compact box ── */

[data-layout="2c"] .show-sidebar { width: 290px; }
[data-layout="2c"] .poster-wrap { width: 290px; }

[data-layout="2c"] .show-title {
  grid-column: 1; grid-row: 2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px; font-weight: 700;
  line-height: 1.2; margin-top: 10px;
  min-width: 0;
}

[data-layout="2c"] .show-rating {
  grid-column: 2; grid-row: 2 / 4;
  margin-top: 10px; align-self: start;
  flex-shrink: 0; margin-left: 10px;
}

[data-layout="2c"] .rating-value {
  font-size: 22px; font-weight: 700;
  padding: 6px 12px; border-radius: 8px; line-height: 1;
  border: 1px solid var(--search-border); background: var(--search-bg);
}

[data-layout="2c"] .vote-count { display: none; }

[data-layout="2c"] .show-years {
  display: block; grid-column: 1; grid-row: 3;
  font-size: 13px; margin-top: 2px;
}

[data-layout="2c"] .show-meta-row { grid-row: 4; margin-top: 10px; }
[data-layout="2c"] .show-overview { grid-row: 5; }

/* ── 2e: Title full width, rating + year inline ── */

[data-layout="2e"] .show-title {
  grid-column: 1 / -1; grid-row: 2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px; font-weight: 700;
  line-height: 1.2; margin-top: 10px;
}

[data-layout="2e"] .show-years { display: none; }

[data-layout="2e"] .show-rating {
  grid-column: 1 / -1; grid-row: 3;
  margin-top: 6px; gap: 6px;
  align-items: baseline;
}

[data-layout="2e"] .star { display: inline; font-size: 16px; color: #f5c518; }
[data-layout="2e"] .rating-value { font-size: 20px; font-weight: 700; }
[data-layout="2e"] .vote-count { font-size: 13px; color: var(--text-muted); }

[data-layout="2e"] .show-meta-row { grid-row: 4; margin-top: 10px; }
[data-layout="2e"] .show-overview { grid-row: 5; }

/* ── Browse page ───────────────────────────────── */

.browse-page { animation: fadeIn 0.25s ease; }

/* Widen container when browse is active */
.main:has(.browse-page) { max-width: 1400px; }

.browse-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--search-border);
  border-radius: 20px;
  background: var(--search-bg);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn.active {
  background: #5dae4e;
  color: #fff;
  border-color: #5dae4e;
}

.filter-select {
  padding: 6px 10px;
  border: 1px solid var(--search-border);
  border-radius: 20px;
  background: var(--search-bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, background 0.3s;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.filter-select:focus { border-color: #5dae4e; }

.filter-range {
  gap: 6px;
}

.filter-range label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-input {
  width: 58px;
  padding: 6px 8px;
  border: 1px solid var(--search-border);
  border-radius: 8px;
  background: var(--search-bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, background 0.3s;
  -moz-appearance: textfield;
}

.filter-input::-webkit-outer-spin-button,
.filter-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.filter-input:focus { border-color: #5dae4e; }

.filter-dash {
  color: var(--text-muted);
  font-size: 13px;
}

.browse-count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── More Filters ────────────────────────────── */

.more-filters-btn {
  padding: 6px 12px;
  border: 1px solid var(--search-border);
  border-radius: 20px;
  background: var(--search-bg);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.more-filters-btn svg {
  transition: transform 0.2s;
}
.more-filters-btn.expanded svg {
  transform: rotate(180deg);
}

.more-filters-panel {
  display: none;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--search-border);
  width: 100%;
}
.more-filters-panel.open {
  display: flex;
}

.filter-group-labeled {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.filter-range-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Poster grid ────────────────────────────────── */

/* ── Column slider ────────────────────────────── */

.browse-columns-ctrl {
  margin-left: auto;
  gap: 6px !important;
}

.columns-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.columns-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--search-border);
  outline: none;
  cursor: pointer;
}

.columns-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5dae4e;
  border: 2px solid var(--bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 0.12s;
}

.columns-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.columns-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5dae4e;
  border: 2px solid var(--bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer;
}

.columns-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--search-border);
}

.browse-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px 14px;
}

.browse-card {
  cursor: pointer;
  min-width: 0;
}

.browse-card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--poster-bg);
}

.browse-card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.browse-card-poster .no-poster-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
}

.browse-card-meta {
  text-align: center;
  margin-top: 9px;
  padding-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  min-height: calc(2 * 1.4 * 18px);
}

.browse-card-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.browse-card-rating {
  font-size: 17px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  margin-right: 5px;
}

.browse-card-year {
  font-size: 17px;
  color: var(--text-muted);
  margin-left: 5px;
}

/* ── Infinite scroll sentinel ──────────────────── */

.browse-sentinel {
  height: 1px;
}

/* ── Movie page ────────────────────────────────── */

.movie-page { animation: fadeIn 0.25s ease; }

.main:has(.movie-page) { max-width: 1000px; }

.movie-backdrop-wrap {
  position: relative;
  width: calc(100% + 64px);
  margin: 0 -32px 0;
  height: 360px;
  overflow: hidden;
  border-radius: 16px 16px 0 0;
}

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

.movie-backdrop-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 180px;
  background: linear-gradient(transparent, var(--bg));
}

.movie-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  margin-top: -100px;
  position: relative;
  z-index: 1;
}

.movie-sidebar {
  flex-shrink: 0;
  width: 240px;
}

.movie-poster-wrap {
  width: 240px;
  aspect-ratio: 2/3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--poster-bg);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.movie-poster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.movie-main {
  flex: 1;
  min-width: 0;
  padding-top: 60px;
}

/* Title + meta */
.movie-header { margin-bottom: 20px; }

.movie-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.movie-meta-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.movie-mpaa {
  padding: 2px 8px;
  border: 1px solid var(--text-muted);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.movie-tagline {
  font-style: italic;
  color: var(--text-muted);
  font-size: 15px;
  margin-top: 10px;
}

/* Ratings */
.movie-ratings-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.movie-rating-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 18px;
  border: 1px solid var(--search-border);
  border-radius: 10px;
  background: var(--search-bg);
  min-width: 72px;
}

.movie-rating-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.movie-rating-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.movie-rating-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Synopsis */
.movie-synopsis { margin-bottom: 24px; }

.movie-overview {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

/* Section titles */
.movie-section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* Cast */
.movie-cast-section { margin-bottom: 28px; }

.movie-cast-list {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.movie-cast-card {
  flex-shrink: 0;
  width: 90px;
  text-align: center;
}

.movie-cast-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 6px;
  display: block;
  background: var(--poster-bg);
}

.movie-cast-no-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
}

.movie-cast-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.movie-cast-character {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 1px;
}

/* Crew */
.movie-crew-section { margin-bottom: 24px; }

.movie-crew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.movie-crew-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.movie-crew-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.movie-crew-value {
  font-size: 14px;
  font-weight: 500;
}

/* Details */
.movie-details-section { margin-bottom: 24px; }

.movie-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.movie-detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.movie-detail-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.movie-detail-value {
  font-size: 13px;
  line-height: 1.4;
}

/* Keywords */
.movie-keywords-section { margin-bottom: 24px; }

.movie-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.movie-keyword {
  padding: 4px 12px;
  border-radius: 16px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 12px;
  font-weight: 500;
}

/* Similar */
.movie-similar-section { margin-bottom: 28px; }

.movie-similar-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.movie-similar-chip {
  padding: 5px 12px;
  border-radius: 16px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 12px;
  font-weight: 500;
  cursor: default;
}

/* Movie responsive */
@media (max-width: 700px) {
  .movie-backdrop-wrap { height: 200px; }
  .movie-layout { flex-direction: column; gap: 20px; margin-top: -60px; }
  .movie-sidebar { width: 160px; }
  .movie-poster-wrap { width: 160px; }
  .movie-main { padding-top: 0; }
  .movie-title { font-size: 24px; }
}

/* Cast scrollbar */
.movie-cast-list::-webkit-scrollbar { height: 4px; }
.movie-cast-list::-webkit-scrollbar-track { background: transparent; }
.movie-cast-list::-webkit-scrollbar-thumb { background: var(--search-border); border-radius: 2px; }

/* ── Anime page ────────────────────────────────── */

.anime-page { animation: fadeIn 0.25s ease; }

.main:has(.anime-page) { max-width: 1000px; }

.anime-backdrop-wrap {
  position: relative;
  width: calc(100% + 64px);
  margin: 0 -32px 0;
  height: 360px;
  overflow: hidden;
  border-radius: 16px 16px 0 0;
}

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

.anime-backdrop-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 180px;
  background: linear-gradient(transparent, var(--bg));
}

.anime-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  margin-top: -100px;
  position: relative;
  z-index: 1;
}

.anime-sidebar {
  flex-shrink: 0;
  width: 220px;
}

.anime-poster-wrap {
  width: 220px;
  aspect-ratio: 225/350;
  border-radius: 12px;
  overflow: hidden;
  background: var(--poster-bg);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.anime-poster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.anime-main {
  flex: 1;
  min-width: 0;
  padding-top: 60px;
}

.anime-header { margin-bottom: 20px; }

.anime-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.anime-meta-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.anime-status-line { margin-top: 4px; }

/* Ratings */
.anime-ratings-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.anime-rating-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 18px;
  border: 1px solid var(--search-border);
  border-radius: 10px;
  background: var(--search-bg);
  min-width: 72px;
}

.anime-rating-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.anime-rating-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.anime-rating-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Synopsis (in sidebar beneath poster) */
.anime-synopsis { margin-top: 16px; }

.anime-overview {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

.anime-overview:empty { display: none; }

/* Seasons detail (multi-season breakdown) */
.anime-seasons-detail { margin-bottom: 24px; }
.anime-seasons-detail:empty { display: none; }

.anime-season-block {
  display: flex;
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--search-border);
  margin-left: -252px; /* extend into sidebar space (220px sidebar + 32px gap) */
}

.anime-season-block:last-child { border-bottom: none; }

.anime-season-poster {
  width: 220px;
  aspect-ratio: 225/350;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  align-self: flex-start;
}

.anime-season-block-content {
  flex: 1;
  min-width: 0;
}

.anime-season-block-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.anime-season-header-info {
  flex: 1;
  min-width: 0;
}

.anime-season-block-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
}

.anime-season-header-meta {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

.anime-season-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  padding-top: 6px;
}

.anime-season-chevron.expanded {
  transform: rotate(180deg);
}

/* Collapsible body */
.anime-season-block-body {
  padding-top: 8px;
}

.anime-season-block-body.collapsed {
  display: none;
}

.anime-season-block-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.anime-season-block-stats {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.anime-season-block-synopsis {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* Tags (genres, themes, demographics) */
.anime-tags-section {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.anime-tags-section:empty { display: none; }

.anime-genres,
.anime-themes,
.anime-demographics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.anime-genre-tag {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  background: #6366f1;
  color: #fff;
}

.anime-theme-tag {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  background: var(--tag-bg);
  color: var(--tag-text);
}

.anime-demo-tag {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  background: #ec4899;
  color: #fff;
}

/* Info grid */
.anime-info-section { margin-bottom: 24px; }

.anime-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.anime-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.anime-info-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.anime-info-value {
  font-size: 13px;
  line-height: 1.4;
}

/* Episode grid */
.anime-episodes-section { margin-bottom: 28px; }

.anime-grid-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.anime-rating-grid {
  border-collapse: separate;
  border-spacing: 4px;
}

.anime-rating-grid th {
  font-size: 13px;
  font-weight: 600;
  color: var(--grid-header);
  padding: 4px 6px;
  text-align: center;
  white-space: nowrap;
  background: var(--bg);
}

.anime-rating-grid td {
  width: 58px;
  height: 42px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  border-radius: 8px;
  cursor: default;
  transition: transform 0.1s, box-shadow 0.1s;
  white-space: nowrap;
}

.anime-rating-grid td:hover {
  transform: scale(1.12);
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  z-index: 5;
  position: relative;
}

.anime-rating-grid td.empty {
  background: transparent;
  visibility: hidden;
}

.anime-rating-grid td.filler {
  opacity: 0.5;
}

.anime-rating-grid td.recap {
  opacity: 0.4;
}

/* Grid source toggle (MAL / IMDb) */
.anime-grid-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.grid-toggle-btn {
  padding: 5px 16px;
  border: 1px solid var(--search-border);
  border-radius: 20px;
  background: var(--search-bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}

.grid-toggle-btn.active {
  background: #5dae4e;
  color: #fff;
  border-color: #5dae4e;
}

.grid-toggle-btn:hover:not(.active) {
  border-color: #999;
  color: var(--text);
}

/* Flowing card grid (single-season anime) */
.anime-ep-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.anime-ep-card {
  width: 72px;
  height: 58px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: transform 0.1s, box-shadow 0.1s;
}

.anime-ep-card:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  z-index: 5;
  position: relative;
}

.anime-ep-card.empty {
  background: var(--search-bg);
  opacity: 0.4;
}

.anime-ep-card.filler { opacity: 0.5; }
.anime-ep-card.recap { opacity: 0.4; }

.anime-ep-num {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.65;
  line-height: 1;
  margin-bottom: 2px;
}

.anime-ep-score {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.anime-grid-scroll::-webkit-scrollbar { height: 8px; }
.anime-grid-scroll::-webkit-scrollbar-track { background: transparent; }
.anime-grid-scroll::-webkit-scrollbar-thumb { background: var(--search-border); border-radius: 4px; }

/* Anime responsive */
@media (max-width: 700px) {
  .anime-backdrop-wrap { height: 200px; }
  .anime-layout { flex-direction: column; gap: 20px; margin-top: -60px; }
  .anime-sidebar { width: 160px; }
  .anime-poster-wrap { width: 160px; }
  .anime-main { padding-top: 0; }
  .anime-title { font-size: 24px; }
  .anime-rating-grid td {
    width: 48px;
    height: 38px;
    font-size: 16px;
    border-radius: 6px;
  }
  .anime-ep-card {
    width: 62px;
    height: 50px;
  }
  .anime-ep-score { font-size: 16px; }
  .anime-season-block { margin-left: 0; }
  .anime-season-poster { width: 120px; }
}

/* ── Scrollbars ─────────────────────────────────── */

.grid-scroll::-webkit-scrollbar { height: 8px; }
.grid-scroll::-webkit-scrollbar-track { background: transparent; }
.grid-scroll::-webkit-scrollbar-thumb { background: var(--search-border); border-radius: 4px; }
.search-results::-webkit-scrollbar { width: 6px; }
.search-results::-webkit-scrollbar-thumb { background: var(--search-border); border-radius: 3px; }
