:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --good: #006300;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --good: #0ca30c;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --good: #0ca30c;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.hero {
  text-align: center;
  padding-block: 8px 20px;
}

.hero h1 {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(2rem, 6vw, 3rem);
  margin: 0;
  letter-spacing: 0.5px;
}

.hero h1 .paw {
  /* Emoji glyphs don't have an 800 weight — letting them inherit it makes
     some renderers (notably iOS Safari) synthetically re-bold the glyph,
     which comes out visually garbled. Reset to normal weight, system font. */
  font-family: system-ui, sans-serif;
  font-weight: 400;
  display: inline-block;
}

.tagline {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin: 4px 0 0;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-tile {
  flex: 1 1 200px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  position: relative;
}

.crown-tile {
  position: absolute;
  top: -14px;
  right: 12px;
  font-size: 1.5rem;
}

.stat-tile-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-tile.has-photo .stat-tile-head {
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.avatar-wrap {
  position: relative;
  width: 100%;
  max-width: 160px;
}

.avatar {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
}

.avatar-wrap .crown {
  position: absolute;
  top: -12px;
  right: -10px;
  font-size: 1.75rem;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.stat-tile .label {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 1rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-tile.has-photo .label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-tile .value {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 2px;
}

.stat-tile .delta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 2px;
}

.stat-tile .delta.good {
  color: var(--good);
}

.stat-tile .caption {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 22px;
  margin-bottom: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.card-head h2 {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 1.2rem;
  margin: 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

.viz-root {
  width: 100%;
  overflow-x: auto;
}

.viz-root svg {
  width: 100%;
  height: auto;
  display: block;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.bar-value-label,
.bar-name-label {
  fill: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}

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

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

.hover-lift {
  filter: brightness(1.08);
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  min-width: 120px;
  z-index: 5;
}

.tooltip .tt-date {
  font-family: "Baloo 2", system-ui, sans-serif;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
}

.tooltip .tt-key {
  width: 10px;
  height: 2px;
  border-radius: 1px;
  flex: 0 0 auto;
}

.tooltip .tt-name {
  color: var(--text-secondary);
  margin-right: auto;
}

.tooltip .tt-val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart-wrap {
  position: relative;
}

.ghost-btn {
  font-family: "Baloo 2", system-ui, sans-serif;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}

.ghost-btn:hover {
  background: var(--grid);
}

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

table caption {
  text-align: left;
  color: var(--muted);
  margin-bottom: 6px;
}

th,
td {
  text-align: right;
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}

th:first-child,
td:first-child {
  text-align: left;
  font-variant-numeric: normal;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 12px;
}
