:root {
  --fa-blue-dark: #294766;
  --fa-blue: #3e648f;
  --fa-blue-soft: #86a7cb;
  --fa-bg: #edf3f8;
  --fa-panel: #ffffff;
  --fa-line: #cfd9e3;
  --fa-line-strong: #b7c4d3;
  --fa-text: #243447;
  --fa-text-soft: #5d6d7e;
  --fa-link: #2d5b88;
  --fa-gold: #f4c84a;
  --fa-gold-dark: #9a6b00;
  --fa-error: #8a1f11;
  --fa-poster-empty-start: #d7e1eb;
  --fa-poster-empty-end: #edf2f7;
  --fa-shadow: 0 14px 32px rgba(34, 56, 78, 0.08);
  --fa-shadow-soft: 0 8px 22px rgba(34, 56, 78, 0.06);
  --fa-radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  background: #d7e4ef;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 14px;
  color: var(--fa-text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 28%),
    linear-gradient(180deg, #bfd1e3 0, #d7e4ef 110px, var(--fa-bg) 110px, var(--fa-bg) 100%);
}

a {
  color: var(--fa-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  background: linear-gradient(180deg, var(--fa-blue-dark), var(--fa-blue));
  color: #fff;
  border-bottom: 1px solid #314b67;
  box-shadow:
    inset 0 -1px 0 rgba(255, 255, 255, 0.1),
    0 10px 30px rgba(35, 57, 80, 0.16);
}

.topbar-inner,
.page-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
}

.topbar-inner {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  justify-content: space-between;
}

.brand-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.brand-mark {
  color: #f8fbfe;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.72rem;
  font-style: italic;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-mark:hover {
  text-decoration: none;
}

.brand-locale {
  font-size: 0.92rem;
  color: #d7e4f2;
}

.top-links {
  display: flex;
  gap: 4px;
  font-size: 0.95rem;
  align-items: center;
  justify-content: center;
  justify-self: center;
}

.topbar-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.topbar-user-field {
  min-width: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border: 1px solid rgba(203, 222, 239, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.topbar-user-field select {
  width: 180px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #6e8fb0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.98);
  color: #23415d;
  box-shadow: none;
}

.theme-toggle {
  min-height: 34px;
  padding: 4px 10px 4px 6px;
  border: 1px solid rgba(203, 222, 239, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #f1f6fc;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(233, 245, 255, 0.46);
}

.theme-toggle:active {
  transform: translateY(1px);
}

.theme-toggle-track {
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #9fb8d2, #6a89ad);
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 2px;
}

.theme-toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #d8e4f0);
  box-shadow: 0 2px 6px rgba(20, 33, 49, 0.35);
  transform: translateX(0);
  transition: transform 160ms ease;
}

.theme-toggle-text {
  font-size: 0.84rem;
  font-weight: 600;
  min-width: 48px;
  text-align: left;
}

.theme-toggle[aria-pressed='true'] .theme-toggle-track {
  background: linear-gradient(180deg, #6ea8ff, #3f69c3);
}

.theme-toggle[aria-pressed='true'] .theme-toggle-thumb {
  transform: translateX(20px);
  background: linear-gradient(180deg, #fef6c9, #f2cf68);
}

.top-links a {
  color: #eaf1f8;
  padding: 10px 12px;
  border-radius: 10px 10px 0 0;
  border-bottom: 2px solid transparent;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.top-links a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

.top-links a.is-active {
  background: rgba(255, 255, 255, 0.14);
  border-bottom-color: #ffd76b;
  color: #fff;
}

html[data-theme='dark'] {
  --fa-blue-dark: #0a0a0d;
  --fa-blue: #121217;
  --fa-blue-soft: #4f5561;
  --fa-bg: #060608;
  --fa-panel: #0f1014;
  --fa-line: #23262d;
  --fa-line-strong: #343844;
  --fa-text: #eceff4;
  --fa-text-soft: #a9afbb;
  --fa-link: #c5d4ee;
  --fa-gold: #e5bf64;
  --fa-gold-dark: #7c5f2a;
  --fa-error: #ff8a7d;
  --fa-poster-empty-start: #1b1d23;
  --fa-poster-empty-end: #111318;
  --fa-shadow: 0 18px 34px rgba(0, 0, 0, 0.44);
  --fa-shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.34);
}

html[data-theme='dark'] {
  background: #040405;
}

html[data-theme='dark'] body {
  background:
    radial-gradient(circle at 8% -6%, rgba(255, 255, 255, 0.06), transparent 28%),
    radial-gradient(circle at 92% -10%, rgba(255, 255, 255, 0.03), transparent 24%),
    linear-gradient(180deg, #0b0b0f 0, #08090d 110px, var(--fa-bg) 110px, var(--fa-bg) 100%);
}

html[data-theme='dark'] .topbar {
  background: linear-gradient(180deg, #0b0b0f, #121218);
  border-bottom-color: #262831;
}

html[data-theme='dark'] .topbar-user-field {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
}

html[data-theme='dark'] .topbar-user-field select,
html[data-theme='dark'] input,
html[data-theme='dark'] select {
  background: #13151b;
  border-color: #3a3f4a;
  color: #e3e8f0;
}

html[data-theme='dark'] .theme-toggle {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #eef2f8;
}

html[data-theme='dark'] .theme-toggle-track {
  background: linear-gradient(180deg, #545a66, #3a3f49);
}

html[data-theme='dark'] .theme-toggle-thumb {
  background: linear-gradient(180deg, #f3f6fb, #cfd6e0);
}

html[data-theme='dark'] .theme-toggle[aria-pressed='true'] .theme-toggle-track {
  background: linear-gradient(180deg, #2f333d, #1f232b);
}

html[data-theme='dark'] .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

html[data-theme='dark'] .panel,
html[data-theme='dark'] .hero,
html[data-theme='dark'] .stat-card,
html[data-theme='dark'] .chart-panel,
html[data-theme='dark'] .result-card,
html[data-theme='dark'] .watch-next-card,
html[data-theme='dark'] .overlap-card,
html[data-theme='dark'] .affinity-kpi-card,
html[data-theme='dark'] .insight-card {
  border-color: #2b2f38;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.05), transparent 44%),
    linear-gradient(180deg, #14161c, #0f1116);
  box-shadow: var(--fa-shadow-soft);
}

html[data-theme='dark'] .chart-surface {
  background: linear-gradient(180deg, #101217, #0c0e13);
  border-color: #313642;
}

html[data-theme='dark'] .status-text,
html[data-theme='dark'] .hint,
html[data-theme='dark'] .panel-kicker,
html[data-theme='dark'] .hero-copy,
html[data-theme='dark'] .results-meta {
  color: var(--fa-text-soft);
}

html[data-theme='dark'] .top-links a {
  color: #dde2ea;
}

html[data-theme='dark'] .top-links a:hover {
  background: rgba(255, 255, 255, 0.12);
}

html[data-theme='dark'] .top-links a.is-active {
  background: rgba(255, 255, 255, 0.16);
  border-bottom-color: #f1c96d;
  color: #ffffff;
}

html[data-theme='dark'] .site-footer-inner {
  border-color: #2d313a;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.04), transparent 42%),
    linear-gradient(180deg, #15181f, #101218);
  color: #aeb6c2;
}

html[data-theme='dark'] .site-footer-link {
  border-color: #3a404b;
  background: #171b22;
  color: #d3dcec;
}

html[data-theme='dark'] .site-footer-link:hover {
  background: #1d222b;
}

.page-shell {
  padding: 18px 0 36px;
}

.site-footer {
  width: min(1180px, calc(100% - 24px));
  margin: 2px auto 20px;
  padding: 0 0 12px;
}

.site-footer-inner {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--fa-line);
  border-radius: 12px;
  background:
    radial-gradient(circle at top right, rgba(126, 167, 210, 0.14), transparent 42%),
    linear-gradient(180deg, #fbfdff, #f3f8fc);
  color: var(--fa-text-soft);
  font-size: 0.86rem;
}

.site-footer-line {
  margin: 0;
  letter-spacing: 0.01em;
}

.site-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--fa-line-strong);
  border-radius: 999px;
  background: #f0f6fb;
  color: var(--fa-link);
  font-weight: 700;
  text-decoration: none;
}

.site-footer-link:hover {
  background: #e8f0f8;
  text-decoration: none;
}

.stats-page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.stats-user-field {
  margin-left: auto;
}

.stats-page .hero {
  margin-bottom: 20px;
  border-color: #bfd2e5;
  background:
    radial-gradient(circle at 8% -12%, rgba(133, 176, 223, 0.26), transparent 34%),
    radial-gradient(circle at 88% -18%, rgba(255, 219, 125, 0.24), transparent 32%),
    linear-gradient(180deg, #ffffff, #f4f9fd);
}

.stats-hero-head {
  max-width: 76ch;
  margin-bottom: 18px;
}

.stats-page #stats-title {
  letter-spacing: -0.02em;
  font-size: clamp(2rem, 3.2vw, 2.7rem);
}

.stats-page #stats-subtitle {
  margin-top: 10px;
  max-width: 62ch;
  font-size: 0.97rem;
  line-height: 1.5;
}

.stats-page .stats-kpi-grid {
  gap: 12px;
}

.stats-page .stat-card {
  position: relative;
  overflow: hidden;
  border-top-width: 0;
  border-color: #c9d9e8;
  background:
    radial-gradient(circle at top right, rgba(189, 220, 246, 0.3), transparent 48%),
    linear-gradient(180deg, #ffffff, #f6fafd);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.stats-page .stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #4f739a, #83a6c9);
}

.stats-page .stat-label {
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

.stats-page .stat-card strong {
  font-size: clamp(1.35rem, 2.3vw, 1.9rem);
  line-height: 1.1;
}

.stats-page .stat-card:hover {
  transform: translateY(-2px);
  border-color: #b4cade;
  box-shadow: 0 14px 28px rgba(39, 63, 89, 0.1);
}

.stats-page .stat-card:nth-child(2)::before {
  background: linear-gradient(90deg, #7f9e52, #a9c67a);
}

.stats-page .stat-card:nth-child(3)::before {
  background: linear-gradient(90deg, #c18d37, #e2b35a);
}

.stats-page .stat-card:nth-child(4)::before {
  background: linear-gradient(90deg, #4d8b88, #79b6ae);
}

.stats-page .stats-layout {
  gap: 18px;
}

.stats-page .chart-panel {
  border-color: #c8d9e8;
  background:
    radial-gradient(circle at top right, rgba(196, 222, 244, 0.2), transparent 42%),
    linear-gradient(180deg, #ffffff, #f7fbfe);
  box-shadow: 0 12px 24px rgba(39, 63, 89, 0.07);
}

.stats-page .chart-panel .panel-header {
  margin-bottom: 10px;
  padding-bottom: 8px;
}

.stats-page .chart-caption {
  margin-bottom: 12px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.stats-page .chart-surface {
  min-height: 300px;
  border-color: #c7d8e8;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 38%),
    linear-gradient(180deg, #fbfdff, #f1f7fc);
}

.stats-page .insight-card {
  border-color: #cadced;
  background:
    radial-gradient(circle at top right, rgba(214, 233, 196, 0.24), transparent 40%),
    linear-gradient(180deg, #ffffff, #f5f9fd);
}

.stats-page .insight-value {
  font-size: 1.05rem;
  line-height: 1.35;
}

.stats-page .ranking-item {
  border-color: #c9dcec;
  background:
    radial-gradient(circle at top right, rgba(190, 218, 242, 0.2), transparent 50%),
    linear-gradient(180deg, #ffffff, #f5f9fd);
  transition: transform 130ms ease, box-shadow 130ms ease, border-color 130ms ease;
}

.stats-page .ranking-item:hover {
  transform: translateY(-1px);
  border-color: #b7cfe2;
  box-shadow: 0 10px 20px rgba(41, 66, 92, 0.08);
}

.stats-page .ranking-list {
  gap: 6px;
}

.stats-page .ranking-item {
  padding: 7px 9px;
  gap: 8px;
}

.stats-page .ranking-main {
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
}

.stats-page .ranking-thumb,
.stats-page .ranking-thumb-fallback {
  width: 30px;
  height: 42px;
}

.stats-page .ranking-title {
  font-size: 0.89rem;
  line-height: 1.2;
}

.stats-page .ranking-score {
  min-width: 38px;
  min-height: 28px;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

.panel,
.stat-card,
.result-card {
  background: var(--fa-panel);
  border: 1px solid var(--fa-line);
  box-shadow: var(--fa-shadow);
  border-radius: var(--fa-radius);
}

.hero {
  padding: 24px;
  margin-bottom: 18px;
  background:
    radial-gradient(circle at top right, rgba(255, 224, 118, 0.22), transparent 24%),
    linear-gradient(180deg, #ffffff, #f8fbfd);
}

.hero-copy-wrap {
  margin-bottom: 20px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 6px;
  color: #65788d;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

h1,
h2,
h3,
strong {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 3vw, 2.8rem);
  line-height: 1.08;
  color: #294463;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  color: #294463;
}

.hero-copy,
.hint,
.status-text,
.results-meta,
.field span,
.result-date,
.result-year,
.page-info {
  color: var(--fa-text-soft);
  line-height: 1.45;
}

.stats-grid,
.layout,
.search-controls,
.actions,
.results-grid,
.result-topline {
  display: grid;
  gap: 12px;
}

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

.stat-card {
  padding: 16px;
  border-top: 4px solid var(--fa-blue-soft);
  box-shadow: var(--fa-shadow-soft);
}

.stat-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.84rem;
  color: var(--fa-text-soft);
}

.stat-card strong {
  color: #20364d;
  font-size: 1.5rem;
}

.layout {
  grid-template-columns: minmax(0, 1.8fr) 330px;
  align-items: start;
}

.layout-single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1120px;
  margin: 0 auto;
}

.library-layout {
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
}

/* Sidebar column: sticky wrapper for search + filters */
.sidebar-column {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.library-layout > section {
  grid-column: 1;
  grid-row: 1;
}

.sync-layout {
  width: min(820px, 100%);
}

.summary-panel {
  position: static;
}

.stats-grid-side {
  grid-template-columns: 1fr;
  gap: 10px;
}

.stats-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.stats-tabs {
  display: inline-flex;
  gap: 8px;
  margin: 0 0 14px;
  padding: 6px;
  border: 1px solid var(--fa-line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff, #f1f6fa);
}

.stats-tab {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #3f5d7b;
  font-weight: 700;
  box-shadow: none;
}

.stats-tab:hover {
  transform: none;
  filter: none;
  background: #eef4f9;
}

.stats-tab.is-active {
  border-color: #355878;
  background: linear-gradient(180deg, #6e8eaf, #45688f);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.stats-tabpanel {
  min-width: 0;
}

.panel {
  padding: 18px;
}

.stats-grid-large {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--fa-line);
}

.field {
  display: grid;
  gap: 6px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--fa-line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--fa-text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus {
  border-color: #648bb3;
  box-shadow: 0 0 0 3px rgba(122, 157, 193, 0.18);
  outline: 0;
}

.search-controls {
  grid-template-columns: minmax(0, 1fr) 180px 180px auto;
  align-items: stretch;
  margin-bottom: 10px;
}

.filter-sidebar {
  position: static;
  box-shadow: var(--fa-shadow-soft);
}

.sidebar-header {
  margin-bottom: 10px;
}

.sidebar-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 0;
}

.filters-inline {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.year-filter-field {
  width: min(240px, 100%);
}

.affinity-panel .panel-header {
  margin-bottom: 10px;
}

.affinity-lead {
  margin: 6px 0 0;
  max-width: 68ch;
  font-size: 0.9rem;
}

.affinity-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #cddceb;
  border-radius: 14px;
  background:
    radial-gradient(circle at top right, rgba(204, 233, 187, 0.45), transparent 42%),
    linear-gradient(180deg, #fcfeff, #f2f8fc);
}

.affinity-toolbar .year-filter-field {
  width: 100%;
  margin: 0;
}

.affinity-toolbar .field span {
  color: #38556f;
  font-weight: 700;
}

.affinity-toolbar-note {
  padding: 10px 12px;
  border: 1px solid #c9dced;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f3f8fc);
  color: #3f5c78;
}

.affinity-toolbar-note strong {
  display: block;
  margin-bottom: 3px;
  color: #2d4a66;
}

.affinity-toolbar-note p {
  margin: 0;
  font-size: 0.84rem;
  color: #506884;
}

.affinity-status {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px solid #d4e1ee;
  border-radius: 12px;
  background: linear-gradient(180deg, #f9fcff, #f1f7fb);
}

.affinity-content {
  display: grid;
  gap: 14px;
}

.affinity-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.affinity-kpi-card {
  padding: 12px;
  border: 1px solid #d1dfed;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f5f9fd);
  box-shadow: 0 8px 18px rgba(39, 63, 89, 0.06);
  display: grid;
  gap: 4px;
}

.affinity-kpi-label {
  color: #5c7289;
  font-size: 0.8rem;
}

.affinity-kpi-value {
  color: #203a52;
  font-size: 1.2rem;
  line-height: 1.15;
}

.affinity-kpi-hint {
  color: #678098;
  font-size: 0.78rem;
}

.affinity-summary-card {
  border-width: 1px;
  border-color: #bfd3e6;
  background:
    radial-gradient(circle at top right, rgba(186, 221, 160, 0.26), transparent 32%),
    linear-gradient(180deg, #ffffff, #f5f9fd);
  box-shadow: 0 12px 24px rgba(38, 62, 87, 0.08);
}

.affinity-summary-card.is-excellent {
  border-color: #8cb378;
  background:
    radial-gradient(circle at top right, rgba(173, 223, 138, 0.35), transparent 34%),
    linear-gradient(180deg, #ffffff, #eef9e7);
}

.affinity-summary-card.is-high {
  border-color: #9ec28a;
  background:
    radial-gradient(circle at top right, rgba(182, 229, 150, 0.28), transparent 34%),
    linear-gradient(180deg, #ffffff, #f1f9ea);
}

.affinity-summary-card.is-medium {
  border-color: #d7b66c;
  background:
    radial-gradient(circle at top right, rgba(244, 214, 129, 0.28), transparent 34%),
    linear-gradient(180deg, #ffffff, #fcf6e9);
}

.affinity-summary-card.is-low {
  border-color: #d7a7a7;
  background:
    radial-gradient(circle at top right, rgba(242, 178, 178, 0.23), transparent 34%),
    linear-gradient(180deg, #ffffff, #fbefef);
}

.affinity-summary-card.is-unknown {
  border-color: #bfd3e6;
}

.affinity-lists-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.affinity-list-block {
  padding: 12px;
  border: 1px solid #d4e1ee;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #f3f8fc);
}

.browse-user-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.browse-status {
  margin: 0;
}

.small-field {
  min-width: 0;
}

.search-pill {
  min-height: 40px;
  padding: 0;
  border: 1px dashed #bfd0df;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbfd, #f1f6fa);
  color: #59718a;
  overflow: hidden;
}

.search-pill input {
  border: 0;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 100%;
  padding: 0 14px;
  border: 1px solid var(--fa-line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #f4f8fb);
  color: #48617b;
  white-space: nowrap;
}

.toggle-field input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: #4f739a;
}

.toggle-field span {
  color: inherit;
  font-weight: 600;
}

.rating-filter {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0;
  border: 1px solid var(--fa-line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff, #f4f8fb);
  overflow: hidden;
}

.rating-filter select {
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.chart-panel {
  min-height: 100%;
}

.chart-panel-wide {
  grid-column: 1 / -1;
}

.chart-caption {
  margin: 0 0 14px;
  color: var(--fa-text-soft);
}

.chart-surface {
  min-height: 280px;
  padding: 10px;
  border: 1px solid var(--fa-line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fcfdff, #f4f8fb);
  overflow-x: auto;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--fa-text-soft);
  text-align: center;
}

.loading-block {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 180px;
  padding: 18px;
  color: var(--fa-text-soft);
  text-align: center;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #d6e0ea;
  border-top-color: #56779e;
  border-radius: 50%;
  animation: spin-loader 0.8s linear infinite;
}

.loading-text {
  margin: 0;
  color: inherit;
}

@keyframes spin-loader {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-axis {
  stroke: #bbcad9;
  stroke-width: 1.5;
}

.chart-bar {
  fill: #5f84ab;
}

.chart-bar-gold {
  fill: #e0b53d;
}

.chart-bar-soft {
  fill: #84a87e;
}

.chart-line {
  fill: none;
  stroke: #4d739b;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot {
  fill: #fff;
  stroke: #4d739b;
  stroke-width: 3;
}

.chart-tick,
.chart-value {
  fill: #5a7087;
  font-size: 11px;
  font-family: "Avenir Next", "Segoe UI", Arial, Helvetica, sans-serif;
}

.chart-value {
  font-size: 10px;
  fill: #334b65;
}

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

.insight-card {
  padding: 14px;
  border: 1px solid var(--fa-line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff, #f4f8fb);
}

.insight-label {
  display: block;
  margin-bottom: 8px;
  color: var(--fa-text-soft);
  font-size: 0.88rem;
}

.insight-value {
  display: block;
  color: #223a52;
  font-size: 1rem;
  line-height: 1.35;
}

.ranking-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.ranking-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--fa-line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfdff, #f4f8fb);
}

.ranking-item-empty {
  grid-template-columns: 1fr;
  color: var(--fa-text-soft);
}

.ranking-main {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.ranking-thumb,
.ranking-thumb-fallback {
  width: 34px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid #d6e0ea;
  background: #eef4f8;
}

.ranking-thumb {
  display: block;
  object-fit: cover;
}

.ranking-thumb-fallback {
  display: grid;
  place-items: center;
  color: #6f869d;
  font-size: 1rem;
}

.ranking-title {
  min-width: 0;
  color: #26415c;
  font-weight: 600;
  line-height: 1.25;
}

a.ranking-title:hover {
  color: #1d537f;
}

.ranking-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #d6b548;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe38f, var(--fa-gold));
  color: var(--fa-gold-dark);
  font-weight: 700;
}

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

.overlap-card {
  padding: 14px;
  border: 1px solid var(--fa-line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff, #f4f8fb);
}

.overlap-user {
  display: block;
  margin-bottom: 10px;
  color: #26415c;
  font-weight: 700;
}

.overlap-value {
  display: block;
  color: #20364d;
  font-size: 1.6rem;
  line-height: 1.1;
}

.overlap-label {
  display: block;
  margin-top: 6px;
  color: var(--fa-text-soft);
}

.agreement-card {
  display: grid;
  gap: 10px;
}

.agreement-metrics {
  display: grid;
  gap: 8px;
}

.affinity-hero-metric {
  display: grid;
  gap: 2px;
  margin-bottom: 2px;
}

.affinity-hero-value {
  color: #1f3e5a;
  font-size: clamp(1.7rem, 3.8vw, 2.3rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.affinity-hero-label {
  color: #4b6380;
  font-size: 0.9rem;
  font-weight: 600;
}

.agreement-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid #8cb378;
  border-radius: 999px;
  background: linear-gradient(180deg, #e8f7de, #cce9bb);
  color: #2f6221;
  font-weight: 700;
}

.agreement-summary {
  color: #415a73;
  font-size: 0.89rem;
  line-height: 1.35;
}

.agreement-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.agreement-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid #c8d7e6;
  border-radius: 999px;
  background: #f5f9fc;
  color: #3f5872;
  font-size: 0.82rem;
  font-weight: 600;
}

.agreement-list-title {
  margin: 4px 0 0;
  color: #304b65;
  font-size: 0.88rem;
  font-weight: 700;
}

.agreement-list-title-good {
  color: #2f5e2f;
}

.agreement-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}

.agreement-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--fa-line);
  border-radius: 10px;
  background: #f8fbfe;
}

.agreement-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.agreement-thumb,
.agreement-thumb-fallback {
  width: 34px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid #d6e0ea;
  background: #eef4f8;
}

.agreement-thumb {
  display: block;
  object-fit: cover;
}

.agreement-thumb-fallback {
  display: grid;
  place-items: center;
  color: #6f869d;
  font-size: 0.95rem;
}

.agreement-film {
  min-width: 0;
  color: #26415c;
  font-weight: 600;
  line-height: 1.25;
}

a.agreement-film:hover {
  color: #1d537f;
}

.agreement-gap {
  color: var(--fa-text-soft);
  font-size: 0.85rem;
}

.agreement-list-good .agreement-item {
  background: #f4fbf4;
  border-color: #cfe3cf;
}

.agreement-list .agreement-item.is-gap-strong {
  background: #fff4f4;
  border-color: #e9c5c5;
}

.agreement-list .agreement-item.is-gap-severe {
  background: #fdeaea;
  border-color: #e2a8a8;
}

.agreement-gap-good {
  color: #3e6940;
}

.has-tooltip {
  position: relative;
  cursor: help;
}

.has-tooltip:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(24, 41, 58, 0.96);
  color: #f5f9fd;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  box-shadow: 0 10px 22px rgba(16, 29, 44, 0.28);
  border: 1px solid rgba(176, 203, 227, 0.22);
  z-index: 30;
  white-space: normal;
}

.has-tooltip:hover::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(24, 41, 58, 0.96) transparent transparent transparent;
  z-index: 31;
}

button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #355878;
  border-radius: 999px;
  background: linear-gradient(180deg, #6e8eaf, #45688f);
  color: #fff;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

button:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
}

.ghost-button {
  background: linear-gradient(180deg, #fafbfd, #e7edf3);
  color: #2e4f72;
  border-color: var(--fa-line-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.results-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.watch-next-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.watch-next-card {
  background: var(--fa-panel);
  border: 1px solid var(--fa-line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--fa-shadow-soft);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.watch-next-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(34, 56, 78, 0.12);
  border-color: #b9cadb;
}

.watch-next-poster-link {
  display: block;
  position: relative;
  background: #eef2f5;
  border-bottom: 1px solid var(--fa-line);
  aspect-ratio: 0.8;
  overflow: hidden;
}

.watch-next-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
  display: block;
}

.watch-next-body {
  padding: 10px;
  display: grid;
  gap: 6px;
}

.watch-next-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.watch-next-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid #86b96f;
  border-radius: 999px;
  background: linear-gradient(180deg, #e7f7d9, #cde9b7);
  color: #355f22;
  font-weight: 700;
  font-size: 0.78rem;
}

.watch-next-year {
  color: var(--fa-text-soft);
  font-size: 0.8rem;
}

.watch-next-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  line-height: 1.2;
  color: #294463;
}

.watch-next-rationale {
  margin: 0;
  color: var(--fa-text-soft);
  font-size: 0.8rem;
  line-height: 1.3;
}

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

.watch-next-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid #d1ddea;
  border-radius: 999px;
  background: #f7fafd;
  color: #4b6580;
  font-size: 0.73rem;
  font-weight: 600;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--fa-line);
}

.page-info {
  min-width: 150px;
  text-align: center;
  font-size: 0.93rem;
}

.result-card {
  display: grid;
  grid-template-rows: auto auto;
  overflow: hidden;
  border-radius: 12px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(34, 56, 78, 0.12);
  border-color: #b9cadb;
}

.poster-link {
  display: block;
  position: relative;
  background: #eef2f5;
  border-bottom: 1px solid var(--fa-line);
  aspect-ratio: 0.8;
  overflow: hidden;
}

.poster-link.is-empty,
.watch-next-poster-link.is-empty {
  background: linear-gradient(180deg, var(--fa-poster-empty-start), var(--fa-poster-empty-end));
}

.trailer-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  background: rgba(19, 34, 48, 0.82);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  display: grid;
  place-items: center;
  z-index: 3;
}

.trailer-button:hover {
  background: rgba(16, 31, 44, 0.95);
}

.trailer-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 28, 40, 0.76);
}

.trailer-modal[hidden] {
  display: none !important;
}

.trailer-modal-dialog {
  width: min(920px, 100%);
  border: 1px solid #bfd2e5;
  border-radius: 16px;
  background: #f8fbfe;
  box-shadow: 0 20px 40px rgba(11, 24, 38, 0.4);
  overflow: hidden;
}

.trailer-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #d4e0eb;
  background: linear-gradient(180deg, #fbfdff, #edf4fa);
}

.trailer-close {
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  font-weight: 700;
}

.trailer-frame-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f1f2f;
}

.trailer-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

body.modal-open {
  overflow: hidden;
}

.result-poster {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
  background: linear-gradient(180deg, #edf2f7, #d6e0ea);
  transition: transform 140ms ease;
}

.result-card:hover .result-poster {
  transform: scale(1.01);
}

.result-body {
  padding: 10px;
  display: grid;
  gap: 6px;
}

.result-topline {
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}

.result-rating-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vote-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid #d6b548;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe38f, var(--fa-gold));
  color: var(--fa-gold-dark);
  font-weight: 700;
  font-size: 0.78rem;
}

.fa-average-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid #d5dee8;
  border-radius: 999px;
  background: #f5f8fb;
  color: #6c7f92;
  font-size: 0.72rem;
  font-weight: 600;
}

.result-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  line-height: 1.2;
  color: #294463;
}

.result-date {
  margin: 0;
  font-size: 0.8rem;
}

.result-year {
  font-size: 0.8rem;
}

.comparison-list {
  display: grid;
  gap: 5px;
  margin-top: 2px;
}

.comparison-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid #d1ddea;
  border-radius: 10px;
  background: #f7fafd;
  font-size: 0.76rem;
}

.comparison-user {
  min-width: 0;
  color: #4b6580;
  font-weight: 600;
}

.comparison-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid #d6b548;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe38f, var(--fa-gold));
  color: var(--fa-gold-dark);
  font-weight: 700;
  font-size: 0.73rem;
}

.comparison-value.is-higher {
  border-color: #86b96f;
  background: linear-gradient(180deg, #e8f7da, #cfeab9);
  color: #355f22;
}

.comparison-value.is-lower {
  border-color: #d7a7a7;
  background: linear-gradient(180deg, #fde6e6, #f2caca);
  color: #8a2f2f;
}

.actions {
  grid-template-columns: 1fr;
  margin: 18px 0;
}

.sync-card,
.sync-log,
.fallback-box {
  margin-top: 16px;
}

.sync-card {
  padding: 12px;
  border: 1px solid var(--fa-line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdff, #eef4f8);
}

.sync-card-row,
.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.sync-card-row {
  margin-bottom: 10px;
}

.sync-label {
  color: var(--fa-text-soft);
  font-size: 0.9rem;
}

.sync-state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--fa-line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--fa-link);
  font-size: 0.85rem;
  font-weight: 700;
}

.progress-block {
  display: grid;
  gap: 8px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--fa-line);
  border-radius: 999px;
  background: #e4edf4;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #5a7ba0, #7fa1c6);
  transition: width 240ms ease;
}

.progress-bar.is-active {
  background-image:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.18) 25%,
      transparent 25%,
      transparent 50%,
      rgba(255, 255, 255, 0.18) 50%,
      rgba(255, 255, 255, 0.18) 75%,
      transparent 75%,
      transparent
    ),
    linear-gradient(90deg, #5a7ba0, #7fa1c6);
  background-size: 18px 18px, 100% 100%;
  animation: progress-stripes 0.7s linear infinite;
}

@keyframes progress-stripes {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 18px 0, 0 0;
  }
}

.progress-meta {
  color: var(--fa-text-soft);
  font-size: 0.88rem;
}

.sync-log {
  display: grid;
  gap: 8px;
}

.log-line {
  padding: 8px 10px;
  border: 1px solid var(--fa-line);
  background: #f7fafd;
  color: #445566;
  font-size: 0.92rem;
}

.log-line-warning {
  border-color: #d8b15d;
  background: #fff8df;
  color: #7a5a10;
}

.fallback-box {
  padding-top: 12px;
  border-top: 1px solid var(--fa-line);
}

.fallback-box summary {
  cursor: pointer;
  color: var(--fa-link);
  font-weight: 700;
}

.access-status {
  margin-top: 10px;
}

.access-status-ok {
  color: #2f6a35;
}

.access-status-warning {
  color: #8a5a10;
}

.access-status-neutral {
  color: var(--fa-text-soft);
}

@media (max-width: 980px) {
  .topbar-inner {
    grid-template-columns: 1fr;
    padding: 10px 0;
    align-items: stretch;
    gap: 10px;
  }

  .brand-block {
    grid-column: 1 / -1;
  }

  .top-links {
    width: 100%;
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 8px;
  }

  .top-links a {
    flex: 1 1 160px;
    text-align: center;
    border-radius: 12px;
  }

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

  .library-layout {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
  }

  .filter-sidebar {
    position: static;
    top: auto;
  }

  .topbar-controls {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }

  .topbar-user-field {
    border: 0;
    background: transparent;
    padding: 0;
  }

  .theme-toggle,
  .topbar-user-field select {
    width: min(100%, 180px);
  }

  .stats-grid,
  .stats-grid-large,
  .stats-layout,
  .stats-page-header,
  .insights-grid,
  .overlap-grid {
    grid-template-columns: 1fr;
  }

  .stats-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .affinity-lists-grid {
    grid-template-columns: 1fr;
  }

  .affinity-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-shell,
  .topbar-inner {
    width: min(100% - 16px, 1180px);
  }

  .site-footer {
    width: min(100% - 16px, 1180px);
  }

  .topbar-inner {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .topbar-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-user-field {
    justify-content: flex-start;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .theme-toggle,
  .topbar-user-field select {
    width: 100%;
    min-height: 38px;
  }

  .hero,
  .panel {
    padding: 14px;
  }

  .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .brand-block {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  .brand-mark {
    font-size: 1.7rem;
  }

  h1 {
    font-size: 1.55rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .stats-grid {
    gap: 10px;
  }

  .stats-page-header {
    gap: 12px;
    margin-bottom: 14px;
  }

  .stats-user-field {
    width: 100%;
    margin-left: 0;
  }

  .stats-user-field select {
    width: 100%;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card strong {
    font-size: 1.32rem;
  }

  .results-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .result-card {
    grid-template-columns: 108px minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: stretch;
  }

  .poster-link {
    aspect-ratio: auto;
    height: 100%;
    border-right: 1px solid var(--fa-line);
    border-bottom: 0;
  }

  .result-poster {
    min-height: 172px;
  }

  .result-body {
    padding: 12px;
  }

  .panel-header {
    flex-direction: column;
    gap: 8px;
  }

  .stats-tab {
    width: 100%;
  }

  .search-controls {
    grid-template-columns: 1fr;
  }

  .sidebar-controls {
    grid-template-columns: 1fr;
  }

  .browse-user-bar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .toggle-field {
    width: 100%;
    justify-content: flex-start;
    white-space: normal;
    padding: 10px 14px;
  }

  .filters-inline {
    justify-content: flex-start;
  }

  .year-filter-field {
    width: 100%;
  }

  .affinity-toolbar {
    padding: 10px;
    grid-template-columns: 1fr;
  }

  .affinity-list-block {
    padding: 10px;
  }

  .affinity-kpi-grid {
    grid-template-columns: 1fr;
  }

  .pagination {
    flex-wrap: wrap;
    gap: 10px;
  }

  .page-info {
    min-width: 0;
    width: 100%;
    order: -1;
  }

  .result-topline {
    grid-template-columns: 1fr;
    justify-content: start;
    gap: 6px;
  }

  .result-rating-meta {
    flex-wrap: wrap;
  }

  .comparison-row {
    padding: 7px 8px;
  }

  .sync-card,
  .chart-surface,
  .insight-card,
  .overlap-card,
  .ranking-item {
    border-radius: 12px;
  }

  .chart-surface {
    min-height: 220px;
    padding: 8px;
  }

  .chart-svg {
    min-width: 440px;
  }

  .chart-caption {
    margin-bottom: 10px;
    font-size: 0.88rem;
  }

  .insight-card,
  .overlap-card {
    padding: 12px;
  }

  .insight-value,
  .overlap-value {
    font-size: 1.12rem;
  }

  .ranking-item {
    padding: 8px 10px;
  }

  .ranking-title {
    font-size: 0.92rem;
  }

  .actions button,
  .ghost-button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .top-links a {
    flex-basis: 100%;
  }

  .hero-copy,
  .chart-caption,
  .insight-label,
  .overlap-label {
    font-size: 0.84rem;
  }

  .result-card {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .result-poster {
    min-height: 156px;
  }

  .vote-pill {
    min-width: 28px;
    min-height: 28px;
  }

  .ranking-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .ranking-main {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .ranking-thumb,
  .ranking-thumb-fallback,
  .agreement-thumb,
  .agreement-thumb-fallback {
    width: 30px;
    height: 42px;
  }

  .agreement-item {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .ranking-score {
    justify-self: start;
  }

  .chart-svg {
    min-width: 360px;
  }

  .chart-surface {
    min-height: 200px;
  }

  .stat-card strong {
    font-size: 1.18rem;
  }
}

/* Final dark-pass overrides to avoid light-specific rules leaking into dark mode */
html[data-theme='dark'] h1,
html[data-theme='dark'] h2,
html[data-theme='dark'] .watch-next-title,
html[data-theme='dark'] .result-title,
html[data-theme='dark'] .ranking-title,
html[data-theme='dark'] .agreement-film {
  color: #e8eef7;
}

html[data-theme='dark'] .stats-page .hero,
html[data-theme='dark'] .stats-page .stat-card,
html[data-theme='dark'] .stats-page .chart-panel,
html[data-theme='dark'] .stats-page .insight-card,
html[data-theme='dark'] .stats-page .ranking-item {
  border-color: #2b2f38;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.04), transparent 48%),
    linear-gradient(180deg, #14161c, #0f1116);
}

html[data-theme='dark'] .stat-card strong,
html[data-theme='dark'] .insight-value,
html[data-theme='dark'] .overlap-value,
html[data-theme='dark'] .affinity-hero-value {
  color: #ecf2fb;
}

html[data-theme='dark'] .stats-tab {
  color: #c8d0dc;
}

html[data-theme='dark'] .stats-tab:hover {
  background: rgba(255, 255, 255, 0.12);
}

html[data-theme='dark'] .stats-tab.is-active {
  border-color: #696f7c;
  background: linear-gradient(180deg, #3a3f49, #2b2f38);
  color: #f8fbff;
}

html[data-theme='dark'] .chart-axis {
  stroke: #454b58;
}

html[data-theme='dark'] .chart-bar {
  fill: #7a879d;
}

html[data-theme='dark'] .chart-bar-gold {
  fill: #d9b968;
}

html[data-theme='dark'] .chart-bar-soft {
  fill: #82b39a;
}

html[data-theme='dark'] .chart-line {
  stroke: #8f9db4;
}

html[data-theme='dark'] .chart-dot {
  fill: #0e1118;
  stroke: #8f9db4;
}

html[data-theme='dark'] .chart-tick,
html[data-theme='dark'] .chart-value {
  fill: #adb6c4;
}

html[data-theme='dark'] .ranking-thumb,
html[data-theme='dark'] .ranking-thumb-fallback,
html[data-theme='dark'] .agreement-thumb,
html[data-theme='dark'] .agreement-thumb-fallback {
  border-color: #353944;
  background: #13161d;
  color: #9ea8b7;
}

html[data-theme='dark'] .ranking-score,
html[data-theme='dark'] .agreement-score,
html[data-theme='dark'] .watch-next-score {
  border-color: #c7a75f;
  background: linear-gradient(180deg, #f1d78f, #dfbd66);
  color: #4c3b14;
}

html[data-theme='dark'] .agreement-chip,
html[data-theme='dark'] .watch-next-chip {
  border-color: #353b47;
  background: #141820;
  color: #b7becb;
}

html[data-theme='dark'] .agreement-summary,
html[data-theme='dark'] .affinity-hero-label,
html[data-theme='dark'] .agreement-list-title {
  color: #b8bfcb;
}

html[data-theme='dark'] .agreement-list-good .agreement-item {
  background: #142d27;
  border-color: #2f6657;
}

html[data-theme='dark'] .agreement-gap-good {
  color: #9edab9;
}

html[data-theme='dark'] .agreement-list .agreement-item.is-gap-strong {
  background: #322325;
  border-color: #87565b;
}

html[data-theme='dark'] .agreement-list .agreement-item.is-gap-severe {
  background: #3a1f22;
  border-color: #a85760;
}

html[data-theme='dark'] .ghost-button {
  border-color: #4a505c;
  background: linear-gradient(180deg, #272b34, #1f232b);
  color: #dde3ec;
}

html[data-theme='dark'] .ghost-button:hover {
  background: linear-gradient(180deg, #303540, #252a33);
}

html[data-theme='dark'] .trailer-modal {
  background: rgba(5, 10, 18, 0.82);
}

html[data-theme='dark'] .trailer-modal-dialog {
  border-color: #3a404b;
  background: #0f1218;
}

html[data-theme='dark'] .trailer-modal-header {
  border-bottom-color: #343a46;
  background: linear-gradient(180deg, #191d26, #141820);
}

html[data-theme='dark'] .result-card:hover,
html[data-theme='dark'] .watch-next-card:hover {
  border-color: #5b6270;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.34);
}

/* Affinity page dark refinements */
html[data-theme='dark'] .affinity-panel .panel-header {
  border-bottom-color: #2c313b;
}

html[data-theme='dark'] .affinity-toolbar {
  border-color: #313641;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.04), transparent 42%),
    linear-gradient(180deg, #171a21, #11141a);
}

html[data-theme='dark'] .affinity-toolbar .field span {
  color: #c4ccd8;
}

html[data-theme='dark'] .affinity-toolbar-note {
  border-color: #373d49;
  background: linear-gradient(180deg, #1a1e26, #141820);
  color: #b3bcc9;
}

html[data-theme='dark'] .affinity-toolbar-note strong {
  color: #e3e9f2;
}

html[data-theme='dark'] .affinity-toolbar-note p {
  color: #aab4c2;
}

html[data-theme='dark'] .affinity-status {
  border-color: #343a46;
  background: linear-gradient(180deg, #1a1f28, #141921);
  color: #c2cbd8;
}

html[data-theme='dark'] .affinity-kpi-card {
  border-color: #2f3440;
  background: linear-gradient(180deg, #171a21, #11141a);
}

html[data-theme='dark'] .affinity-kpi-label,
html[data-theme='dark'] .affinity-kpi-hint {
  color: #aab2bf;
}

html[data-theme='dark'] .affinity-kpi-value {
  color: #edf2fa;
}

html[data-theme='dark'] .affinity-summary-card {
  border-color: #343a46;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.05), transparent 48%),
    linear-gradient(180deg, #171a21, #11141a);
}

html[data-theme='dark'] .affinity-summary-card.is-excellent {
  border-color: #3d6b55;
  background:
    radial-gradient(circle at top right, rgba(108, 210, 164, 0.16), transparent 44%),
    linear-gradient(180deg, #15231d, #101914);
}

html[data-theme='dark'] .affinity-summary-card.is-high {
  border-color: #4a667f;
  background:
    radial-gradient(circle at top right, rgba(133, 178, 224, 0.15), transparent 44%),
    linear-gradient(180deg, #15202b, #111821);
}

html[data-theme='dark'] .affinity-summary-card.is-medium {
  border-color: #7f6948;
  background:
    radial-gradient(circle at top right, rgba(225, 187, 109, 0.16), transparent 44%),
    linear-gradient(180deg, #221c13, #18140f);
}

html[data-theme='dark'] .affinity-summary-card.is-low {
  border-color: #865157;
  background:
    radial-gradient(circle at top right, rgba(225, 125, 125, 0.15), transparent 44%),
    linear-gradient(180deg, #231416, #1a1012);
}

html[data-theme='dark'] .affinity-summary-card.is-unknown {
  border-color: #454b56;
  background:
    radial-gradient(circle at top right, rgba(186, 196, 212, 0.08), transparent 44%),
    linear-gradient(180deg, #171a21, #11141a);
}

html[data-theme='dark'] .affinity-list-block {
  border-color: #2f3540;
  background: linear-gradient(180deg, #161921, #10131a);
}

html[data-theme='dark'] .agreement-list-title-good {
  color: #9fd8b9;
}

/* ─── Mobile filter toggle button ─── */
.mobile-filter-toggle {
  display: none;
}

/* ─── Hamburger button (hidden on desktop) ─── */
.hamburger-button {
  display: none;
}

/* ─── User selector label (hidden on desktop) ─── */
.user-selector-label {
  display: none;
}

@media (max-width: 640px) {
  /* ─── Topbar: hamburger layout ─── */
  .topbar-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 0;
    min-height: auto;
    padding: 10px 0;
    align-items: start;
  }

  .brand-block {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    padding: 2px 0;
  }

  .brand-mark {
    font-size: 1.42rem;
  }

  /* ─── Hamburger button ─── */
  .hamburger-button {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 9px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #f1f6fc;
    align-self: center;
    box-shadow: none;
  }

  .hamburger-button:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.34);
    transform: none;
    filter: none;
  }

  .hamburger-icon {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 200ms ease, opacity 200ms ease;
  }

  .hamburger-button[aria-expanded='true'] .hamburger-icon:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .hamburger-button[aria-expanded='true'] .hamburger-icon:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }

  .hamburger-button[aria-expanded='true'] .hamburger-icon:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* ─── Controls row: theme toggle + user selector ─── */
  .topbar-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 8px 0 4px;
    margin-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    justify-content: unset;
    flex-wrap: unset;
  }

  /* Theme toggle: compact, just the track + no text */
  .theme-toggle {
    flex-shrink: 0;
    width: auto;
    min-height: 36px;
    padding: 4px 8px;
    gap: 0;
  }

  .theme-toggle-text {
    display: none;
  }

  /* User selector: pill with label */
  .topbar-user-field {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0;
    padding: 2px 10px 2px 12px;
    border: 1px solid rgba(203, 222, 239, 0.28);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    min-width: 0;
    margin: 0;
  }

  .user-selector-label {
    display: block;
    color: #cddff0;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.01em;
    padding-right: 6px;
  }

  .topbar-user-field select {
    width: 100%;
    min-height: 34px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #e8f2fb;
    padding: 4px 4px;
    box-shadow: none;
  }

  html[data-theme='dark'] .topbar-user-field select {
    background: transparent;
    color: #d8e6f4;
    border: 0;
  }

  html[data-theme='dark'] .topbar-user-field {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
  }

  /* ─── Nav dropdown ─── */
  .top-links {
    grid-column: 1 / -1;
    grid-row: 3;
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 6px;
    width: auto;
    flex-wrap: nowrap;
    justify-content: unset;
  }

  .top-links.is-open {
    display: flex;
  }

  .top-links a {
    flex: none;
    padding: 11px 14px;
    border-radius: 10px;
    border-bottom: 2px solid transparent;
    font-size: 0.95rem;
    text-align: left;
  }

  .top-links a.is-active {
    border-bottom: 2px solid transparent;
    border-left: 3px solid #ffd76b;
    border-radius: 0 10px 10px 0;
    padding-left: 12px;
    background: rgba(255, 255, 255, 0.14);
  }

  /* ─── Library layout: flex column with filter at top ─── */
  .library-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  /* Unwrap the sidebar-column so children participate directly in the flex layout */
  .sidebar-column {
    display: contents;
  }

  .search-always-visible {
    order: 0;
    width: 100%;
  }

  .mobile-filter-toggle {
    order: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px dashed var(--fa-line-strong);
    border-radius: 12px;
    background: linear-gradient(180deg, #f5f9fd, #edf4f9);
    color: var(--fa-link);
    font-weight: 700;
    font-size: 0.93rem;
    box-shadow: none;
    margin: 0;
  }

  .mobile-filter-toggle:hover {
    background: linear-gradient(180deg, #edf4f9, #e3eef6);
    transform: none;
    filter: none;
  }

  html[data-theme='dark'] .mobile-filter-toggle {
    border-color: #3a404c;
    background: linear-gradient(180deg, #1a1e28, #14181f);
    color: #b8c8e0;
  }

  .filter-sidebar {
    order: 2;
    display: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .filter-sidebar.is-open {
    display: block;
  }

  .library-layout > section {
    order: 3;
  }

  /* ─── Watch-next cards: horizontal layout ─── */
  .watch-next-grid {
    grid-template-columns: 1fr;
  }

  .watch-next-card {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: stretch;
  }

  .watch-next-poster-link {
    aspect-ratio: auto;
    height: 100%;
    border-right: 1px solid var(--fa-line);
    border-bottom: 0;
    border-radius: 0;
    min-height: 150px;
  }

  .watch-next-poster {
    min-height: 150px;
  }

  .watch-next-body {
    padding: 10px 12px;
    gap: 5px;
  }

  .watch-next-title {
    font-size: 0.93rem;
  }

  .watch-next-rationale {
    font-size: 0.78rem;
  }

  /* ─── Panel padding tighter ─── */
  .panel {
    padding: 12px;
  }

  /* ─── Pagination ─── */
  .pagination {
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .watch-next-card {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .watch-next-poster-link,
  .watch-next-poster {
    min-height: 128px;
  }
}
