:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #8a887f;
  --grid: #e5e4e0;
  --border: #dedad2;
  --link: #2a78d6;

  --series-commit: #2a78d6;
  --series-pr: #eb6834;
  --series-issue: #1baf7a;
  --series-review: #eda100;
  --series-repo-created: #e87ba4;
  --series-repo-active: #008300;
  --series-star: #4a3aa7;
  --series-fork: #e34948;

  --hover-wash: rgba(11, 11, 11, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #928f83;
    --grid: #2a2a28;
    --border: #34332f;
    --link: #6fa8ec;

    --series-commit: #3987e5;
    --series-pr: #d95926;
    --series-issue: #199e70;
    --series-review: #c98500;
    --series-repo-created: #d55181;
    --series-repo-active: #008300;
    --series-star: #9085e9;
    --series-fork: #e66767;

    --hover-wash: rgba(255, 255, 255, 0.06);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI",
    "Noto Sans JP", sans-serif;
  line-height: 1.55;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

header.page-header h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.version-badge {
  font-size: 0.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  text-decoration: none;
}

.version-badge:hover {
  background: var(--hover-wash);
  color: var(--text-primary);
}

header.page-header p.lede {
  color: var(--text-secondary);
  margin: 0 0 4px;
}

.meta-line {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0 0 28px;
}

.meta-line a {
  color: var(--link);
}

/* --- Filter row --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 10px;
}

.filters .presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

button.preset {
  font: inherit;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}

button.preset:hover {
  background: var(--hover-wash);
}

button.preset[aria-pressed="true"] {
  background: var(--series-commit);
  border-color: var(--series-commit);
  color: #ffffff;
}

.filters .custom-range {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.filters input[type="date"] {
  font: inherit;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 5px 8px;
}

.range-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0 0 28px;
}

/* --- Stat tiles --- */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 32px;
}

.stat-tile {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 14px 16px;
  border-left: 3px solid transparent;
}

.stat-tile .label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-tile .value {
  font-size: 1.6rem;
  font-weight: 600;
  font-variant-numeric: proportional-nums;
  color: var(--text-primary);
}

.stat-tile.commit { border-left-color: var(--series-commit); }
.stat-tile.pr { border-left-color: var(--series-pr); }
.stat-tile.issue { border-left-color: var(--series-issue); }
.stat-tile.review { border-left-color: var(--series-review); }
.stat-tile.repo-created { border-left-color: var(--series-repo-created); }
.stat-tile.repo-active { border-left-color: var(--series-repo-active); }
.stat-tile.star { border-left-color: var(--series-star); }
.stat-tile.fork { border-left-color: var(--series-fork); }
.stat-tile.score { border-left-color: var(--text-primary); }

/* --- Chart cards --- */
.chart-card {
  margin-bottom: 40px;
}

.chart-card h2 {
  font-size: 1.05rem;
  margin: 0 0 2px;
}

.chart-card .chart-caption {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0 0 12px;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.legend .item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

svg.chart {
  width: 100%;
  display: block;
  overflow: visible;
}

.axis text,
.bar-label,
.member-label {
  fill: var(--text-secondary);
  font-size: 11px;
}

.gridline {
  stroke: var(--grid);
  stroke-width: 1;
}

.hit-rect {
  fill: transparent;
  cursor: pointer;
}

.hit-rect:hover,
.hit-rect:focus {
  fill: var(--hover-wash);
}

.bar-total-label {
  fill: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
}

.trend-area {
  fill: var(--series-commit);
  opacity: 0.1;
}

.trend-line {
  fill: none;
  stroke: var(--series-commit);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.crosshair-line {
  stroke: var(--text-muted);
  stroke-width: 1;
  pointer-events: none;
  display: none;
}

.crosshair-dot {
  fill: var(--series-commit);
  stroke: var(--surface-1);
  stroke-width: 2;
  pointer-events: none;
  display: none;
}

/* --- Tooltip --- */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--surface-1);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.5;
  max-width: 240px;
  opacity: 0;
  transform: translate(-50%, -120%);
  transition: opacity 0.08s ease;
  z-index: 10;
}

.tooltip.visible {
  opacity: 1;
}

.tooltip .t-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.tooltip .t-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.tooltip .t-row .t-key {
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.85;
}

.tooltip .t-key .t-swatch {
  width: 8px;
  height: 2px;
  display: inline-block;
}

/* --- Table --- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

table.data-table caption {
  caption-side: top;
  text-align: left;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

table.data-table th,
table.data-table td {
  text-align: right;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

table.data-table th:first-child,
table.data-table td:first-child {
  text-align: left;
}

table.data-table td:first-child {
  color: var(--text-primary);
}

table.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

table.data-table td {
  font-variant-numeric: tabular-nums;
}

table.data-table a {
  color: inherit;
  text-decoration: none;
}

table.data-table a:hover {
  text-decoration: underline;
}

/* --- Footer --- */
footer.page-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

footer.page-footer p {
  margin: 0 0 8px;
}

footer.page-footer a {
  color: var(--link);
}

.error-banner {
  background: #fdecea;
  color: #7a2a20;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 20px;
}

@media (prefers-color-scheme: dark) {
  .error-banner {
    background: #3a2320;
    color: #f2b8ac;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
