:root {
  --radius: 10px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e8eef7;
  --muted: #8b9bb4;
  --accent: #5b9fd4;
  --accent-dim: #3d7aad;
  --chip: #2a3f5c;
  --chip-active: #4a7ab8;
  --bar: #3d6ea5;
  --dash-chart-blue: #42a5f5;
  --dash-chart-orange: #ff9800;
  --dash-icon-bg: rgba(66, 165, 245, 0.15);
  --header-grad-a: #152238;
  --header-grad-b: #0f1419;
  --code-bg: rgba(255, 255, 255, 0.08);
  --error: #f09090;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-hover: #e5ecf4;
  --border: #c5d0df;
  --text: #15202b;
  --muted: #5a6b7d;
  --accent: #1d6bb8;
  --accent-dim: #155a9e;
  --chip: #e2eaf3;
  --chip-active: #c5daf0;
  --bar: #4a8fd4;
  --dash-chart-blue: #1976d2;
  --dash-chart-orange: #f57c00;
  --dash-icon-bg: rgba(25, 118, 210, 0.12);
  --header-grad-a: #e8f0fb;
  --header-grad-b: #f8f9fb;
  --code-bg: rgba(0, 0, 0, 0.06);
  --error: #b83232;
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

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

a:hover {
  text-decoration: underline;
}

.site-header {
  background: linear-gradient(145deg, var(--header-grad-a) 0%, var(--header-grad-b) 55%);
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 1.5rem 2rem;
}

.site-header__inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}

.site-header__text {
  flex: 1;
  min-width: min(100%, 16rem);
}

.theme-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--surface-hover);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle__icon {
  width: 22px;
  height: 22px;
  grid-area: 1 / 1;
}

[data-theme="dark"] .theme-toggle__icon--moon {
  display: none;
}

[data-theme="light"] .theme-toggle__icon--sun {
  display: none;
}

.site-footer code {
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.site-title {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.site-title__link {
  color: inherit;
  text-decoration: none;
}

.site-title__link:hover {
  text-decoration: underline;
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: 0.25rem 0.75rem;
  flex-shrink: 0;
}

.site-header__nav-link {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius);
  white-space: nowrap;
}

.site-header__nav-link:hover {
  text-decoration: none;
  background: var(--surface-hover);
}

.site-header__nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-header__nav-link[aria-current="page"] {
  background: var(--surface-hover);
}

.dashboard {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 0;
}

.dashboard__grid {
  display: grid;
  grid-template-columns: minmax(200px, 0.95fr) minmax(220px, 1.1fr) minmax(220px, 1.1fr);
  gap: 1rem;
  align-items: stretch;
}

@media (max-width: 960px) {
  .dashboard__grid {
    grid-template-columns: 1fr;
  }
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .dash-card {
  box-shadow: none;
}

.dash-card--stats {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.1rem;
}

.dash-stat {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.dash-stat__icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--dash-icon-bg);
  color: var(--dash-chart-blue);
  display: grid;
  place-items: center;
}

.dash-stat__body {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.dash-stat__value {
  font-size: 1.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.dash-stat__label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.dash-card--chart {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.vchart {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 220px;
}

.vchart__title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.vchart__scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.vchart__cols {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-height: 168px;
  padding-top: 0.25rem;
}

.vchart__col {
  flex: 1 0 26px;
  min-width: 22px;
  max-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.vchart__count {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-height: 1rem;
  line-height: 1;
}

.vchart__track {
  width: 100%;
  height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
}

.vchart__bar {
  width: 100%;
  border-radius: 6px 6px 0 0;
  min-height: 3px;
  transition: height 0.25s ease;
}

.vchart__bar--blue {
  background: var(--dash-chart-blue);
}

.vchart__bar--orange {
  background: var(--dash-chart-orange);
}

.vchart__tick {
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.15;
  word-break: break-word;
  max-width: 100%;
}

/* Top Venues: wider columns so labels like SIGCOMM stay on one line */
.vchart__cols--venues .vchart__col {
  flex: 1 0 52px;
  min-width: 48px;
  max-width: 88px;
}

.vchart__cols--venues .vchart__tick {
  white-space: nowrap;
  word-break: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vchart__empty {
  margin: 0;
  padding: 2rem 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1.5rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem;
  align-items: start;
}

@media (max-width: 880px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  position: sticky;
  top: 1rem;
}

.sidebar h2 {
  margin: 0 0 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sidebar section + section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.search-wrap {
  margin-bottom: 0.5rem;
}

.search-wrap input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.search-wrap input:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

select:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-height: 160px;
  overflow-y: auto;
  padding-right: 2px;
}

.filter-group--tags {
  max-height: 200px;
}

.chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: var(--chip);
  color: var(--text);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
}

.chip:hover {
  background: var(--surface-hover);
}

.chip[aria-pressed="true"] {
  background: var(--chip-active);
  border-color: var(--accent);
}

.chip--clear {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.main-panel h2 {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.paper-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.paper-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  transition: border-color 0.15s;
}

.paper-card:hover {
  border-color: var(--accent-dim);
}

.paper-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
}

.paper-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.paper-card__tag {
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--chip);
  color: var(--muted);
}

.paper-card__meta {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.paper-card__venue {
  font-size: 0.82rem;
  color: var(--accent);
}

.paper-card__links {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.82rem;
}

.loading,
.error {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

.error {
  color: var(--error);
}

.bib-parse-warning {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.site-footer {
  margin-top: 3rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Static help / doc pages (e.g. add-paper.html) */
.static-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.page-heading {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.static-page h2 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.static-page p,
.static-page li {
  max-width: 65ch;
}

.static-page ul,
.static-page ol {
  margin: 0.75rem 0 0;
  padding-left: 1.35rem;
}

.static-page li {
  margin-bottom: 0.35rem;
}

.static-page pre {
  margin: 1rem 0 0;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
  overflow-x: auto;
  line-height: 1.45;
}

.static-page code {
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.static-page pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

/* venues.html */
.venues-page__lead {
  margin-top: 0;
}

.venues-page__list {
  margin-top: 0.5rem;
}

.venues-page__list li {
  margin-bottom: 0.45rem;
}

.venues-page__meta {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.92em;
}

.venues-page__note {
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 65ch;
}
