:root {
  color-scheme: light;
  --link: #1a0dab;
  --link-visited: #609;
  --text: #202124;
  --muted: #5f6368;
  --border: #dadce0;
  --bg: #fff;
  --bg-soft: #f8f9fa;
  --accent: #4285f4;
  --accent-hover: #1a73e8;
  --accent-soft: #e8f0fe;
  --accent-softer: #d2e3fc;
  --highlight: #fef7e0;
  --danger: #c62828;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --link: #8ab4f8;
    --link-visited: #c58af9;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #3c4043;
    --bg: #1f1f1f;
    --bg-soft: #292a2d;
    --accent: #8ab4f8;
    --accent-hover: #aecbfa;
    --accent-soft: #28344a;
    --accent-softer: #34445e;
    --highlight: #3a3320;
    --danger: #f28b82;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --link: #8ab4f8;
  --link-visited: #c58af9;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #3c4043;
  --bg: #1f1f1f;
  --bg-soft: #292a2d;
  --accent: #8ab4f8;
  --accent-hover: #aecbfa;
  --accent-soft: #28344a;
  --accent-softer: #34445e;
  --highlight: #3a3320;
  --danger: #f28b82;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.4;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--link-visited); }

.page-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.page-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.header-actions { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 22px;
  color: var(--text);
  font-weight: 400;
}
.source-link { font-size: 13px; }

.theme-toggle {
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.theme-toggle:hover { background: var(--bg-soft); }
.theme-toggle-icon { font-size: 14px; line-height: 1; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* ---------- Profile block ---------- */

.profile-block {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) minmax(0, 560px);
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.profile-photo {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: var(--bg-soft) center/cover no-repeat;
  border: 1px solid var(--border);
}

.profile-details h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 400;
}
.profile-affiliation {
  color: var(--muted);
  margin-bottom: 4px;
  font-size: 15px;
}
.profile-meta {
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 13px;
}
.profile-meta > * + *::before { content: " · "; color: var(--muted); }
.profile-meta a { color: var(--link); }

.profile-labels {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.profile-labels li {
  font-size: 13px;
  color: var(--link);
  padding: 2px 0;
}
.profile-labels li::after { content: ", "; color: var(--muted); }
.profile-labels li:last-child::after { content: ""; }

/* ---------- Stats panel ---------- */

.stats-panel {
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px;
  align-self: start;
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.stats-table th, .stats-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
.stats-table th:first-child, .stats-table td:first-child {
  text-align: left;
  font-weight: 400;
  color: var(--text);
}
.stats-table thead th {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  background: var(--bg-soft);
}
.stats-table tbody tr:last-child td { border-bottom: none; }

.citations-chart,
.hindex-chart {
  width: 100%;
  overflow-x: auto;
}
.stats-charts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}
.stats-charts .chart-group {
  flex: 1 1 220px;
  min-width: 0;
}
.chart-heading {
  margin: 0 0 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Controls ---------- */

.controls {
  margin: 20px 0 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.date-range {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}
.date-range input[type="date"] {
  font: inherit;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  background: var(--bg);
}
.btn-reset {
  font: inherit;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg);
  color: var(--link);
  cursor: pointer;
}
.btn-reset:hover { background: var(--bg-soft); }
.date-hint { color: var(--muted); font-size: 12px; }

.self-cite-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  user-select: none;
  cursor: pointer;
}
.self-cite-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  margin: 0;
}

/* ---------- Publications table ---------- */

.publications-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.publications-table th {
  text-align: left;
  font-weight: 400;
  color: var(--text);
  border-top: 1px solid var(--border);
  border-bottom: 2px solid var(--text);
  padding: 8px 10px;
  font-size: 13px;
  background: var(--bg);
}
.publications-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.publications-table .col-citations,
.publications-table .col-new,
.publications-table .col-year { text-align: right; }
.publications-table .col-citations { width: 120px; }
.publications-table .col-new { width: 110px; }
.publications-table .col-year { width: 70px; }
.publications-table .col-title { width: auto; }

.sortable { cursor: pointer; user-select: none; }
.sortable:hover { background: var(--bg-soft); }
.sort-asc::after { content: " ▲"; color: var(--muted); font-size: 10px; }
.sort-desc::after { content: " ▼"; color: var(--muted); font-size: 10px; }

.paper-title {
  color: var(--link);
  font-size: 15px;
  display: inline;
}
.paper-title:visited { color: var(--link-visited); }
.paper-authors, .paper-venue {
  color: var(--muted);
  font-size: 13px;
  display: block;
}
.paper-venue { font-style: italic; }

.col-citations a {
  color: var(--link);
  font-size: 14px;
}
.cited-by-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.sparkline-wrap { height: 20px; }
.col-year { color: var(--muted); }

.new-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}
.new-badge:hover { background: var(--accent-softer); }
.new-badge.empty { background: transparent; color: var(--muted); cursor: default; }

.publications-table tr.expanded .new-badge { background: var(--accent-softer); }

.btn-more {
  display: block;
  margin: 12px auto 0;
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg);
  color: var(--link);
  cursor: pointer;
}
.btn-more:hover { background: var(--bg-soft); }

.citations-row td {
  background: var(--bg-soft);
  padding: 10px 16px 14px;
}
.citing-papers {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
}
.citing-papers li { margin: 6px 0; }
.citing-papers .citing-authors { color: var(--muted); }
.citing-papers .citing-venue { color: var(--muted); font-style: italic; }

/* ---------- Charts ---------- */

.chart-svg { display: block; width: 100%; height: auto; }
.chart-bar { fill: var(--accent); }
.chart-bar:hover { fill: var(--accent-hover); }
.chart-bar-proj {
  fill: var(--accent);
  fill-opacity: 0.28;
  stroke: var(--accent);
  stroke-width: 0.5;
  stroke-dasharray: 2 2;
}
.chart-axis-label { font-size: 10px; fill: var(--muted); }
.chart-tooltip { font-size: 11px; fill: var(--text); }
.chart-proj-label { fill: var(--accent); font-weight: 600; }

.sparkline-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sparkline-area { fill: var(--accent); fill-opacity: 0.12; }
.sparkline-dot { fill: var(--accent); }

.hindex-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
}
.hindex-line.recent {
  stroke: var(--accent);
  stroke-dasharray: 3 3;
  opacity: 0.7;
}
.hindex-dot { fill: var(--accent); }
.hindex-label { font-size: 10px; fill: var(--muted); }

/* ---------- Aggregates ---------- */

.aggregates {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.aggregate-panel {
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px 16px;
}
.aggregate-panel h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.aggregate-panel .panel-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.aggregate-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.aggregate-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--border);
  font-size: 13px;
}
.aggregate-list li:last-child { border-bottom: none; }
.aggregate-list .name { color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aggregate-list .count { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ---------- Footer ---------- */

.page-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.footer-sep { color: var(--border); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .profile-block {
    grid-template-columns: 96px minmax(0, 1fr);
  }
  .profile-photo { width: 96px; height: 96px; }
  .stats-panel { grid-column: 1 / -1; }
  .aggregates { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .stats-charts { flex-direction: column; }
}

@media (max-width: 600px) {
  .profile-block { grid-template-columns: 1fr; }
  .profile-photo { width: 96px; height: 96px; }
  .publications-table .col-citations,
  .publications-table .col-new,
  .publications-table .col-year { padding: 10px 6px; }
  .publications-table .col-citations { width: 90px; }
}
