/* Marina palette: #FFF1E7, #B5D2E6, #326080, #805232 */

:root {
  --bg-main: #0a1a28;
  --bg-mid: #112233;
  --bg-glow: #1a3050;
  --bg-panel: #1f3a55;
  --text-main: #FFF1E7;
  --text-subtle: #a3bdd1;
  --text-dim: #7a9ab8;
  --card-bg: rgba(15, 30, 48, 0.82);
  --card-border: rgba(181, 210, 230, 0.18);
  --accent-primary: #326080;
  --accent-secondary: #805232;
  --accent-light: #B5D2E6;
  --accent-warm: #FFF1E7;
  --section-bg: rgba(12, 26, 42, 0.75);
  --section-border: rgba(181, 210, 230, 0.14);
  --input-bg: rgba(18, 35, 55, 0.9);
  --input-border: rgba(181, 210, 230, 0.22);
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --divider: rgba(181, 210, 230, 0.18);
  --bar-empty: rgba(181, 210, 230, 0.1);
  --tooltip-bg: rgba(10, 22, 38, 0.95);
  --cover-bg: rgba(20, 38, 58, 0.95);
  --cover-border: rgba(181, 210, 230, 0.18);
  --tab-color: #7a9ab8;
  --tab-active: #5a9cc0;
  --error-color: #e8917a;
  --btn-primary-bg: #326080;
  --btn-primary-text: #FFF1E7;
  --btn-secondary-bg: #1e3a52;
  --btn-secondary-text: #c8dce8;
  --dropzone-bg: #d9ccc3;
  --dropzone-border: #9a8e84;
  --dropzone-text: #2c2420;
  --dropzone-hover-border: #6b5f55;
  --dropzone-active-bg: #ece3da;
  --dropzone-active-border: #326080;
  --loading-gradient: linear-gradient(90deg, #326080, #5a9cc0);
  --genre-gradient: linear-gradient(90deg, #4a9cc8, #6ccef0);
  --country-gradient: linear-gradient(90deg, #c88848, #f0b858);
  --hero-bg: radial-gradient(ellipse at 50% 40%, #14283e 0%, #0d1e30 50%, #080f1a 100%);
}

[data-theme="light"] {
  --bg-main: #f0e4d8;
  --bg-mid: #e8dace;
  --bg-glow: #e2d4c8;
  --bg-panel: #ddd0c4;
  --text-main: #2a2018;
  --text-subtle: #5e4e3e;
  --text-dim: #8a7a6a;
  --card-bg: rgba(248, 240, 232, 0.92);
  --card-border: rgba(50, 96, 128, 0.1);
  --section-bg: rgba(248, 240, 232, 0.88);
  --section-border: rgba(50, 96, 128, 0.08);
  --input-bg: rgba(248, 240, 232, 0.95);
  --input-border: rgba(128, 82, 50, 0.18);
  --overlay-bg: rgba(40, 30, 20, 0.3);
  --shadow-color: rgba(80, 50, 30, 0.08);
  --divider: rgba(128, 82, 50, 0.12);
  --bar-empty: rgba(50, 96, 128, 0.06);
  --tooltip-bg: rgba(248, 240, 232, 0.97);
  --cover-bg: rgba(240, 230, 220, 0.95);
  --cover-border: rgba(128, 82, 50, 0.12);
  --tab-color: #8a7a6a;
  --tab-active: #326080;
  --error-color: #b03828;
  --btn-primary-bg: #326080;
  --btn-primary-text: #f8f0e8;
  --btn-secondary-bg: #e0d4c8;
  --btn-secondary-text: #3a2a1a;
  --dropzone-bg: #f0e4d8;
  --dropzone-border: #c8b8a8;
  --dropzone-text: #3a2a1a;
  --dropzone-hover-border: #805232;
  --dropzone-active-bg: #e8dcd0;
  --dropzone-active-border: #326080;
  --loading-gradient: linear-gradient(90deg, #326080, #6aa0b8);
  --genre-gradient: linear-gradient(90deg, #1e4868, #2a5570);
  --country-gradient: linear-gradient(90deg, #5a3820, #704828);
  --hero-bg: linear-gradient(180deg, #e2d4c8 0%, #ecdecf 100%);
  --accent-light: #326080;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-main: #f0e4d8;
    --bg-mid: #e8dace;
    --bg-glow: #e2d4c8;
    --bg-panel: #ddd0c4;
    --text-main: #2a2018;
    --text-subtle: #5e4e3e;
    --text-dim: #8a7a6a;
    --card-bg: rgba(248, 240, 232, 0.92);
    --card-border: rgba(50, 96, 128, 0.1);
    --section-bg: rgba(248, 240, 232, 0.88);
    --section-border: rgba(50, 96, 128, 0.08);
    --input-bg: rgba(248, 240, 232, 0.95);
    --input-border: rgba(128, 82, 50, 0.18);
    --overlay-bg: rgba(40, 30, 20, 0.3);
    --shadow-color: rgba(80, 50, 30, 0.08);
    --divider: rgba(128, 82, 50, 0.12);
    --bar-empty: rgba(50, 96, 128, 0.06);
    --tooltip-bg: rgba(248, 240, 232, 0.97);
    --cover-bg: rgba(240, 230, 220, 0.95);
    --cover-border: rgba(128, 82, 50, 0.12);
    --tab-color: #8a7a6a;
    --tab-active: #326080;
    --error-color: #b03828;
    --btn-primary-bg: #326080;
    --btn-primary-text: #f8f0e8;
    --btn-secondary-bg: #e0d4c8;
    --btn-secondary-text: #3a2a1a;
    --dropzone-bg: #f0e4d8;
    --dropzone-border: #c8b8a8;
    --dropzone-text: #3a2a1a;
    --dropzone-hover-border: #805232;
    --dropzone-active-bg: #e8dcd0;
    --dropzone-active-border: #326080;
    --loading-gradient: linear-gradient(90deg, #326080, #6aa0b8);
    --genre-gradient: linear-gradient(90deg, #1e4868, #2a5570);
    --country-gradient: linear-gradient(90deg, #5a3820, #704828);
    --hero-bg: linear-gradient(180deg, #e2d4c8 0%, #ecdecf 100%);
    --accent-light: #326080;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at 20% 20%, var(--bg-glow) 0%, var(--bg-mid) 40%, var(--bg-main) 85%);
  transition: background 0.3s ease, color 0.3s ease;
}

.view {
  display: none;
}

.is-visible {
  display: grid;
}

.landing,
.confirm {
  min-height: 100vh;
  padding: 24px 24px 38px;
  width: min(96vw, 860px);
  gap: 24px;
  justify-items: center;
  text-align: center;
  align-content: center;
  margin: 0 auto;
}

.brand {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 0;
}

.brand-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.brand-logo {
  width: 130px;
  height: 130px;
  object-fit: contain;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 4px;
}

.brand-copy h1,
.dashboard-copy h1 {
  margin: 0;
  font-size: 3.2rem;
  line-height: 1;
  letter-spacing: 0.2px;
}

.brand-copy p,
.hero-subtitle {
  margin: 0;
  font-size: 0.88rem;
  letter-spacing: 1.1px;
  font-weight: 600;
  color: var(--text-subtle);
}

.intro {
  margin: 0;
  max-width: 760px;
  font-size: 1.05rem;
  line-height: 1.5;
}

.uploader-section {
  width: 100%;
  display: grid;
  place-items: center;
}

#csvInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropzone {
  width: min(100%, 720px);
  min-height: 190px;
  border: 2px dashed var(--dropzone-border);
  background: var(--dropzone-bg);
  color: var(--dropzone-text);
  border-radius: 4px;
  display: grid;
  place-items: center;
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease, background-color 0.2s ease;
}

.dropzone:hover,
.dropzone:focus {
  border-color: var(--dropzone-hover-border);
  transform: translateY(-1px);
}

.dropzone.dragover {
  background: var(--dropzone-active-bg);
  border-color: var(--dropzone-active-border);
}

#dropzoneText {
  font-size: 1rem;
  line-height: 1.4;
}

.confirm-label {
  margin: 0;
  font-size: 2rem;
  color: var(--text-main);
}

.selected-file-name {
  margin: 0;
  max-width: 760px;
  font-size: clamp(0.92rem, 1.9vw, 1.3rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.confirm-button,
.secondary-button {
  border: 0;
  border-radius: 16px;
  padding: 14px 28px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.confirm-button {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

.secondary-button {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
}

.confirm-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
  opacity: 0.94;
}

.confirm-error {
  min-height: 1.3rem;
  margin: 0;
  color: var(--error-color);
}

.dashboard {
  min-height: 100vh;
  display: none;
}

.dashboard.is-visible {
  display: block;
}

.dashboard-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 24px 48px;
  text-align: center;
  overflow: hidden;
  border-bottom: 1px solid var(--section-border);
  background: var(--hero-bg);
}

.dashboard-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 300px at 20% 60%, var(--accent-primary) 0%, transparent 70%),
    radial-gradient(ellipse 500px 250px at 80% 40%, var(--accent-secondary) 0%, transparent 70%);
  opacity: 0.06;
  animation: heroGlow 8s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes heroGlow {
  0%   { opacity: 0.04; transform: scale(1) translateX(0); }
  50%  { opacity: 0.08; transform: scale(1.05) translateX(-10px); }
  100% { opacity: 0.04; transform: scale(1) translateX(10px); }
}

.hero-bars {
  display: flex;
  align-items: flex-end;
  gap: 0;
  height: 180px;
  flex-shrink: 0;
  opacity: 0.85;
}

.hero-bars-left {
  justify-content: flex-end;
  padding-right: 32px;
}

.hero-bars-right {
  justify-content: flex-start;
  padding-left: 32px;
}

.hero-bar {
  width: 5px;
  border-radius: 2px;
}

.hero-line-canvas {
  height: 180px;
  flex-shrink: 0;
}

.hero-line-canvas-left {
  padding-right: 24px;
}

.hero-line-canvas-right {
  padding-left: 24px;
}

.hero-center {
  flex-shrink: 0;
  z-index: 1;
}

.hero-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.hero-badge-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.hero-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  opacity: 0.8;
}

.source-badge {
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.92rem;
  letter-spacing: 1.8px;
}

.global-theme-toggle {
  position: fixed;
  top: 16px;
  right: 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  color: var(--text-subtle);
  transition: color 0.4s ease, border-color 0.4s ease, background 0.4s ease, transform 0.3s ease, opacity 0.3s ease;
  z-index: 1000;
  backdrop-filter: blur(6px);
}

.global-theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
}

.global-theme-toggle:hover {
  color: var(--text-main);
  border-color: var(--accent-primary);
}

.global-theme-toggle.is-switching {
  transform: scale(0.82);
  opacity: 0.5;
}

.loading-wrap {
  margin-top: 16px;
  width: 100%;
}

.loading-bar-track {
  height: 4px;
  border-radius: 2px;
  background: var(--bar-empty);
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--loading-gradient);
  transition: width 0.3s ease;
}

.loading-text {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.stats-strip {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px 14px;
  text-align: center;
}

.stat-value {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.7rem);
  font-weight: 700;
}

.stat-label {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--text-dim);
  letter-spacing: 1.1px;
}

.next-section {
  width: min(1180px, calc(100% - 32px));
  margin: 26px auto 48px;
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: 12px;
  padding: 30px 24px;
}

.next-section h2 {
  margin: 0;
  font-size: 1.3rem;
}

.next-section p {
  margin: 12px 0 0;
  color: var(--text-subtle);
}

.insights-section,
.decades-section {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 0;
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: 12px;
  padding: 20px 20px 16px;
}

.decades-section {
  margin-top: 20px;
  margin-bottom: 48px;
}

.insights-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.line-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  font-size: 1.1rem;
  letter-spacing: 0.9px;
}

.line-divider {
  flex: 1;
  height: 1px;
  background: var(--divider);
}

.insights-tabs {
  display: flex;
  gap: 14px;
}

.tab-button {
  border: 0;
  background: transparent;
  color: var(--tab-color);
  font-size: 0.98rem;
  letter-spacing: 0.8px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease;
}

.tab-button.is-active {
  color: var(--tab-active);
}

.year-chart-wrap {
  margin-top: 16px;
  transition: transform 0.35s ease;
}

.year-chart-wrap:hover {
  transform: translateY(-2px);
}

.year-chart {
  min-height: 170px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  padding: 8px 0 2px;
  overflow: visible;
  position: relative;
  border-bottom: 1px dashed var(--divider);
}

.year-bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px 2px 0 0;
  transition: filter 0.15s ease, transform 0.15s ease;
  transform-origin: bottom;
}

.year-bar-empty {
  height: 2px !important;
  background: var(--bar-empty) !important;
  border-radius: 0;
}

.year-bar:not(.year-bar-empty):hover {
  filter: brightness(1.25);
  transform: scaleY(1.06);
}

.year-tooltip {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--tooltip-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 6px 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, left 0.15s ease, bottom 0.15s ease;
  white-space: nowrap;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 140px;
  text-align: center;
}

.year-tooltip strong {
  font-size: 0.82rem;
  color: var(--text-main);
}

.year-tooltip span {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 1px;
}

.year-axis {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  color: var(--text-main);
  font-size: 1.75rem;
}

.section-loading,
.section-empty {
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.95rem;
}

.decades-list {
  margin-top: 14px;
  display: grid;
  gap: 20px;
}

.decade-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  align-items: start;
}

.decade-meta h3 {
  margin: 0;
  font-size: 2.6rem;
  line-height: 1;
}

.decade-meta p {
  margin: 6px 0 0;
  color: var(--text-subtle);
  font-size: 1.1rem;
}

.decade-books {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  max-width: 620px;
}

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

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

.cover-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 0.62rem;
  padding: 4px;
  text-align: center;
}

.taxonomy-section,
.themes-section,
.collections-section {
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto 48px;
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: 12px;
  padding: 20px;
}

.taxonomy-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.taxonomy-column-title {
  margin: 0 0 10px;
  font-size: 0.84rem;
  color: var(--text-subtle);
  letter-spacing: 1px;
}

.taxonomy-list {
  display: grid;
  gap: 8px;
}

.taxonomy-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: center;
  gap: 10px;
}

.taxonomy-label {
  color: var(--text-main);
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.taxonomy-bar-track {
  background: var(--card-bg);
  border-radius: 4px;
  height: 24px;
  position: relative;
  overflow: hidden;
}

.taxonomy-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.taxonomy-bar-fill.genres {
  background: var(--genre-gradient);
}

.taxonomy-bar-fill.countries {
  background: var(--country-gradient);
}

.themes-pies {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.theme-pie-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.35s ease;
}

.theme-pie-wrap:hover {
  transform: translateY(-4px);
}

.theme-pie-title {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-subtle);
  letter-spacing: 1px;
}

.theme-pie-wrap canvas {
  max-width: 100%;
  height: auto;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-pie-wrap canvas:hover {
  transform: translateY(-6px) rotate(180deg);
}

.theme-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  max-width: 320px;
}

.theme-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  color: var(--text-subtle);
}

.theme-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .themes-pies {
    grid-template-columns: 1fr;
  }
}

.taxonomy-value {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-warm);
  font-size: 0.98rem;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.taxonomy-item:hover .taxonomy-value,
.taxonomy-item:focus-within .taxonomy-value {
  opacity: 1;
}

.taxonomy-note {
  margin: 16px 0 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.86rem;
}

.reading-pace-section,
.scatter-section,
.radar-section {
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto 48px;
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: 12px;
  padding: 20px;
}

.reading-pace-chart-wrap,
.scatter-chart-wrap,
.radar-chart-wrap {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.reading-pace-chart-wrap canvas,
.scatter-chart-wrap canvas,
.radar-chart-wrap canvas {
  max-width: 100%;
  height: auto;
  cursor: default;
}

.authors-section {
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto 48px;
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: 12px;
  padding: 20px;
}

.authors-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 22px 16px;
}

.author-card {
  text-align: center;
  animation: fadeSlideUp 0.4s ease both;
  position: relative;
}

.author-override-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
  letter-spacing: 1px;
}

.author-card:hover .author-override-btn {
  opacity: 1;
}

.author-override-btn:hover {
  color: var(--text-main);
  background: var(--card-bg);
}

.author-photo {
  width: 100%;
  max-width: 150px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--card-border);
  background: var(--cover-bg);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.author-card:hover .author-photo {
  transform: scale(1.06);
  box-shadow: 0 4px 18px var(--shadow-color);
}

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

.author-photo-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: var(--text-dim);
}

.author-name {
  margin: 8px 0 2px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.author-stat {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.author-photo-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: var(--overlay-bg);
  display: grid;
  place-items: center;
}

.author-photo-popup {
  background: var(--section-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 22px 26px;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 8px 32px var(--shadow-color);
}

.author-photo-popup h4 {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.author-popup-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.author-popup-label input {
  width: 100%;
  margin-top: 5px;
  padding: 7px 10px;
  font-size: 0.82rem;
  border-radius: 5px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
}

.author-popup-actions {
  display: flex;
  gap: 8px;
}

.author-popup-actions .confirm-button,
.author-popup-actions .secondary-button {
  font-size: 0.78rem;
  padding: 6px 14px;
}

.authors-more-wrap {
  margin-top: 16px;
  text-align: center;
}

.show-more-btn {
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-subtle);
  padding: 10px 32px;
  border-radius: 8px;
  font-size: 0.82rem;
  letter-spacing: 1.2px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.show-more-btn:hover {
  background: var(--section-bg);
  transform: translateY(-1px);
}

@media (max-width: 700px) {
  .authors-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 450px) {
  .authors-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.most-read-section {
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto 48px;
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: 12px;
  padding: 20px;
}

.most-read-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 24px 28px;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}

.most-read-card {
  text-align: center;
}

.most-read-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 3px;
  border: 1px solid var(--cover-border);
  background: var(--cover-bg);
  overflow: hidden;
}

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

.most-read-count {
  margin: 6px 0 0;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}

/* ── World Map ──────────────────────────────────────── */
.worldmap-section {
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto 48px;
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: 12px;
  padding: 20px;
}

.worldmap-wrap {
  margin-top: 16px;
  border-radius: 8px;
  overflow: hidden;
}

#worldMap {
  width: 100%;
  height: 480px;
  background: var(--bg-main);
  border-radius: 8px;
}

#worldMap svg {
  border-radius: 8px;
}

#worldMap .google-visualization-tooltip {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  pointer-events: none;
}

@media (max-width: 600px) {
  #worldMap {
    height: 300px;
  }
}

/* World Map country popup */
.wm-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: wmFadeIn 0.2s ease;
}

@keyframes wmFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.wm-popup {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  width: min(520px, calc(100% - 32px));
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px var(--shadow-color);
  position: relative;
  animation: wmSlideUp 0.25s ease;
}

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

.wm-popup-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.2s ease;
}

.wm-popup-close:hover {
  color: var(--text-main);
}

.wm-popup-heading {
  margin: 0;
  padding: 18px 20px 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--divider);
}

.wm-popup-list {
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 12px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(5 * 78px);
}

.wm-popup-list::-webkit-scrollbar {
  width: 5px;
}

.wm-popup-list::-webkit-scrollbar-track {
  background: transparent;
}

.wm-popup-list::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: 4px;
}

.wm-popup-book {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.wm-popup-cover {
  width: 42px;
  height: 62px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--cover-bg);
  border: 1px solid var(--cover-border);
}

.wm-popup-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.wm-popup-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wm-popup-book-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wm-popup-book-author {
  font-size: 0.78rem;
  color: var(--text-subtle);
}

.wm-popup-book-rating {
  font-size: 0.75rem;
  color: var(--accent-light);
  letter-spacing: 1px;
}

.metadata-section {
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto 48px;
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: 12px;
  padding: 20px;
}

.metadata-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

.meta-alpha-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--section-bg);
  padding: 6px 0 8px;
}

.meta-alpha-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--divider);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.meta-alpha-btn:hover:not(.disabled) {
  background: var(--accent);
  color: var(--bg-main);
  transform: translateY(-1px);
}

.meta-alpha-btn.disabled {
  opacity: 0.3;
  cursor: default;
}

.metadata-table-scroll {
  overflow-x: auto;
}

.metadata-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.submit-all-btn {
  font-size: 0.82rem;
  padding: 8px 16px;
  white-space: nowrap;
}

.metadata-help-text {
  margin: 0;
  font-size: 0.83rem;
  color: var(--text-subtle);
}

.metadata-actions-end {
  justify-content: flex-end;
}

.small-action-btn {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
}

.metadata-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.metadata-table th,
.metadata-table td {
  border-bottom: 1px solid var(--divider);
  padding: 8px 10px;
  text-align: left;
  font-size: 0.86rem;
}

.metadata-table th {
  color: var(--text-subtle);
  letter-spacing: 0.7px;
}

.metadata-table td:first-child {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: rgba(50, 96, 128, 0.2);
  color: var(--text-main);
}

.source-tag.openlibrary {
  background: rgba(50, 96, 128, 0.3);
}

.source-tag.google {
  background: rgba(90, 156, 192, 0.25);
}

.source-tag.wikidata {
  background: rgba(128, 82, 50, 0.25);
}

.source-tag.goodreads {
  background: rgba(128, 82, 50, 0.3);
}

.source-tag.manual {
  background: rgba(181, 210, 230, 0.25);
}

.override-open-btn {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
}

.override-editor {
  margin-top: 16px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 14px;
  display: none;
  background: var(--card-bg);
}

.override-editor.is-visible {
  display: block;
}

.override-editor h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

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

.override-grid label {
  display: grid;
  gap: 5px;
  font-size: 0.84rem;
  color: var(--text-subtle);
}

.override-grid input {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  padding: 8px 9px;
  background: var(--input-bg);
  color: var(--text-main);
}

.override-full-width {
  grid-column: 1 / -1;
}

.override-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.override-actions .confirm-button,
.override-actions .secondary-button {
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
}

.collections-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 800px) {
  .collections-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-bars,
  .hero-line-canvas {
    display: none;
  }

  .dashboard-hero {
    padding: 44px 16px 36px;
  }
}

.collection-card {
  text-align: center;
}

.collection-covers {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
  min-height: 90px;
  align-items: flex-end;
  cursor: pointer;
}

.collection-stack {
  position: relative;
  width: 68px;
  height: 90px;
  transition: width 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  margin: 0 auto;
}

.collection-stack .collection-cover {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 54px;
  height: 80px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--bar-empty);
  box-shadow: 1px 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.collection-stack .collection-cover-placeholder {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 54px;
  height: 80px;
  border-radius: 3px;
  background: var(--bar-empty);
  border: 1px dashed var(--card-border);
  box-shadow: 1px 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.3s ease;
}

.collection-stack:hover .collection-cover,
.collection-stack:hover .collection-cover-placeholder {
  box-shadow: 2px 2px 8px rgba(0,0,0,0.4);
}

.collection-cover-slot {
  transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1), left 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.collection-stack:hover .collection-cover-slot {
  transform: translateY(-4px);
}

.collection-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 4px 0 2px;
}

.collection-count {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ── Animations ──────────────────────────────────────── */

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

.stat-card,
.decade-row,
.collection-card,
.most-read-card,
.taxonomy-item,
.theme-pie-wrap {
  animation: fadeSlideUp 0.45s ease both;
}

.stat-card:nth-child(1) { animation-delay: 0.04s; }
.stat-card:nth-child(2) { animation-delay: 0.08s; }
.stat-card:nth-child(3) { animation-delay: 0.12s; }
.stat-card:nth-child(4) { animation-delay: 0.16s; }
.stat-card:nth-child(5) { animation-delay: 0.20s; }

.stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px var(--shadow-color);
}


.most-read-cover {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.most-read-card:hover .most-read-cover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px var(--shadow-color);
}

.cover-card {
  transition: transform 0.2s ease;
}

.cover-card:hover {
  transform: scale(1.08);
  z-index: 1;
}

.taxonomy-bar-fill {
  transition: width 0.6s ease, filter 0.25s ease;
}

.taxonomy-item:hover .taxonomy-bar-fill {
  filter: brightness(1.15);
}

.tab-button {
  transition: color 0.2s ease, transform 0.15s ease;
}

.tab-button:hover {
  transform: translateY(-1px);
}

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

@media (max-width: 600px) {
  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .decade-row {
    grid-template-columns: 1fr;
  }

  .decade-books {
    grid-template-columns: repeat(5, 1fr);
  }

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

  .taxonomy-item {
    grid-template-columns: 100px 1fr;
  }

  .most-read-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 100%;
  }

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

  .brand-logo {
    width: 80px;
    height: 80px;
  }

  .brand-copy h1,
  .dashboard-copy h1 {
    font-size: 2.2rem;
  }
}

