:root {
  color-scheme: light dark;
  --background: light-dark(#f4f7fb, #0b1018);
  --surface: light-dark(rgba(255, 255, 255, 0.9), rgba(21, 29, 41, 0.9));
  --surface-solid: light-dark(#ffffff, #383838);
  --surface-muted: light-dark(#f0f4f9, #1c2635);
  --text: light-dark(#142033, #f4f7fb);
  --text-muted: light-dark(#66758b, #9caabd);
  --border: light-dark(#dce4ee, #29364a);
  --accent: light-dark(#e84d1c, #ff6b3d);
  --accent-soft: light-dark(#fff0e9, #382117);
  --shadow: light-dark(
    0 18px 45px rgba(29, 48, 74, 0.09),
    0 20px 50px rgba(0, 0, 0, 0.28)
  );
  --shadow-small: light-dark(
    0 6px 20px rgba(29, 48, 74, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.22)
  );
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  padding: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body {
  background:
    radial-gradient(
      circle at 10% 0%,
      color-mix(in srgb, var(--accent) 8%, transparent),
      transparent 28rem
    ),
    var(--background);
  color: var(--text);
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

a {
  color: inherit;
  text-decoration: none;
}
.app {
  min-height: 100vh;
}

.header {
  align-items: center;
  backdrop-filter: blur(18px);
  background: color-mix(in srgb, var(--background) 82%, transparent);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 14px clamp(20px, 5vw, 72px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand,
.header-actions,
.navigation {
  align-items: center;
  display: flex;
}
.brand {
  gap: 11px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--accent), #ff916f);
  border-radius: 10px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 25%, transparent);
  color: #fff;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}
.header-actions {
  gap: 16px;
}
.nav-link {
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 650;
  padding: 8px 11px;
  transition: 150ms ease;
}
.nav-link:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.theme-toggle {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  height: 38px;
  justify-content: center;
  transition: 150ms ease;
  width: 38px;
}
.theme-toggle:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.theme-toggle-fixed {
  position: fixed;
  right: clamp(20px, 5vw, 72px);
  top: 14px;
  z-index: 30;
}
.header-actions {
  padding-right: 54px;
}
.theme-icon {
  font-size: 18px;
  line-height: 1;
}
.theme-icon-dark {
  display: none;
}
[data-theme="dark"] .theme-icon-light {
  display: none;
}
[data-theme="dark"] .theme-icon-dark {
  display: inline;
}
.sr-only {
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.page {
  padding: clamp(36px, 7vw, 88px) clamp(18px, 5vw, 72px);
}
.overview,
.chart-page,
.not-found {
  margin: 0 auto;
  max-width: 1120px;
  width: 100%;
}
.section-heading {
  margin-bottom: 34px;
  max-width: 680px;
}
.section-heading h2,
.chart-page h2 {
  font-size: clamp(30px, 5vw, 48px);
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 8px 0 12px;
}
.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin: 0;
}
.section-intro {
  color: var(--text-muted);
  font-size: 17px;
  line-height: 1.6;
  margin: 0;
}
.load-warning { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: 14px; color: var(--text); margin-bottom: 24px; padding: 16px 18px; }
.load-warning ul { margin: 8px 0 0; padding-left: 20px; }
.chart-heading { margin-bottom: 20px; }
.chart-heading h2 { margin-bottom: 8px; }
.resize-hint { color: var(--text-muted); font-size: 14px; margin: -10px 0 12px; }
.chart-resizer {
  height: min(72vh, 720px);
  max-width: 100%;
  min-height: 300px;
  min-width: 300px;
  overflow: hidden;
  position: relative;
  width: 100%;
}
.chart-resize-handle {
  border-bottom: 3px solid var(--accent);
  border-right: 3px solid var(--accent);
  bottom: 5px;
  cursor: nwse-resize;
  height: 10px;
  position: absolute;
  right: 5px;
  touch-action: none;
  width: 10px;
  z-index: 5;
}
.chart-resizer #chart,
.chart-resizer .chart {
  height: 100%;
  width: 100%;
}

.publication-search {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-small);
  display: flex;
  margin-bottom: 20px;
  padding: 0 16px;
  transition: 150ms ease;
}
.publication-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.search-icon {
  color: var(--text-muted);
  font-size: 30px;
  line-height: 1;
  margin-bottom: 5px;
}
.publication-search-input {
  background: transparent;
  border: 0;
  color: var(--text);
  flex: 1;
  font: inherit;
  min-width: 0;
  outline: 0;
  padding: 15px 12px;
}
.publication-search-input::placeholder {
  color: var(--text-muted);
}
.search-empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
  color: var(--text-muted);
  display: none;
  margin: 0;
  padding: 36px 24px;
  text-align: center;
}
.search-empty p {
  color: var(--text);
  font-weight: 700;
  margin: 0 0 6px;
}
.search-empty span {
  font-size: 14px;
}
.search-hidden {
  display: none !important;
}
.search-empty-visible {
  display: block;
}

.publication-list {
  display: grid;
  gap: 14px;
}
.publication-list details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-small);
  overflow: hidden;
  transition: 160ms ease;
}
.publication-list details:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  transform: translateY(-2px);
}
.publication-list summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-weight: 700;
  justify-content: space-between;
  list-style: none;
  padding: 22px 24px;
  user-select: none;
}
.publication-list summary::-webkit-details-marker {
  display: none;
}
.publication-count {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  padding: 6px 10px;
}
.publication-list ul {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 12px;
}
.publication-list li a {
  border-radius: 10px;
  color: var(--text-muted);
  display: block;
  padding: 12px;
  transition: 150ms ease;
}
.publication-list li a:hover {
  background: var(--surface-muted);
  color: var(--accent);
}

.graph-with-embed-link {
  display: grid;
  gap: 24px;
}
.embed-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-small);
  display: grid;
  gap: 12px;
  padding: 22px;
}
.embed-panel h3,
.embed-panel p {
  margin: 0;
}
.embed-panel p {
  color: var(--text-muted);
}
.embed-url-row,
.embed-code-row {
  align-items: stretch;
  display: flex;
  gap: 8px;
  min-width: 0;
}
.embed-url-input {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  flex: 1;
  font: inherit;
  min-width: 0;
  padding: 10px 12px;
}
.embed-copy {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  display: inline-flex;
  justify-content: center;
  min-width: 42px;
}
.embed-panel code {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  display: block;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding: 10px;
  white-space: nowrap;
}

.embed-page {
  min-height: 100vh;
}
#chart,
.chart {
  height: min(72vh, 720px);
}
.chart {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.embed-chart,
.embed-page #chart {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  height: 100vh;
}
.main-svg {
  background-color: transparent !important;
}

@media (max-width: 640px) {
  .brand-name {
    display: none;
  }
  .header {
    padding: 12px 16px;
  }
  .header-actions {
    gap: 8px;
  }
  .theme-toggle-fixed {
    right: 16px;
    top: 12px;
  }
  .page {
    padding-top: 40px;
  }
  .publication-list summary {
    padding: 18px;
  }
  .embed-url-row,
  .embed-code-row {
    flex-direction: column;
  }
  .embed-copy {
    min-height: 40px;
  }
  #chart,
  .chart {
    height: 62vh;
  }
}
