:root {
  --bg: #f4f0e8;
  --bg-grad: #ebe4d6;
  --surface: #fffdf8;
  --surface-2: #f6f1e7;
  --border: #ddd3c0;
  --text: #241f18;
  --muted: #6e6555;
  --accent: #8a6a1f;
  --good: #2e7d32;
  --warn: #a15c00;
  --grid: #e6dece;
  --axis: #8b816f;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06), 0 4px 14px rgba(60, 45, 20, .06);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218;
    --bg-grad: #171b24;
    --surface: #1a1f2a;
    --surface-2: #222836;
    --border: #2f3646;
    --text: #ece6d8;
    --muted: #9a9384;
    --accent: #d9b45a;
    --good: #6fd27a;
    --warn: #f0b450;
    --grid: #262c39;
    --axis: #7d7768;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218;
  --bg-grad: #171b24;
  --surface: #1a1f2a;
  --surface-2: #222836;
  --border: #2f3646;
  --text: #ece6d8;
  --muted: #9a9384;
  --accent: #d9b45a;
  --good: #6fd27a;
  --warn: #f0b450;
  --grid: #262c39;
  --axis: #7d7768;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg) linear-gradient(180deg, var(--bg-grad), var(--bg) 420px) no-repeat;
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 16px 40px; }

/* Header */
.site-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 12px 24px; padding-bottom: 18px; margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.eyebrow {
  margin: 0 0 4px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
}
h1 {
  margin: 0; font-family: var(--serif); font-weight: 700;
  font-size: clamp(26px, 5vw, 36px); line-height: 1.15; letter-spacing: .01em;
}
.meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.updated { margin: 0; color: var(--muted); font-size: 13px; }
.updated strong { color: var(--text); font-weight: 600; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: #6b4a00; background: #ffe7a8; border: 1px solid #e8c46a;
}
:root[data-theme="dark"] .badge { color: #ffd77a; background: rgba(217, 180, 90, .14); border-color: rgba(217, 180, 90, .45); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge { color: #ffd77a; background: rgba(217, 180, 90, .14); border-color: rgba(217, 180, 90, .45); }
}

.section-h {
  margin: 0 0 12px; font-family: var(--serif); font-size: 18px; font-weight: 700;
  letter-spacing: .02em;
}
.error {
  padding: 12px 14px; border-radius: 10px; border: 1px solid #d9534f;
  background: rgba(217, 83, 79, .1); color: var(--text); margin: 0 0 20px;
}

/* Cards */
.cards {
  display: grid; gap: 12px; margin-bottom: 28px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
.card {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 14px; padding: 14px 16px 18px; text-align: left; width: 100%;
  font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
  transition: border-color .15s, transform .15s, opacity .15s;
}
.card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--cls);
}
.card:hover { transform: translateY(-1px); border-color: var(--cls); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card[aria-pressed="true"] { border-color: var(--cls); box-shadow: 0 0 0 1px var(--cls), var(--shadow); }
.cards.filtered .card[aria-pressed="false"] { opacity: .55; }

.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center;
  border: 2px solid var(--cls); background: var(--surface-2);
}
.avatar { position: relative; }
.avatar img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .2s;
}
.avatar.loaded img { opacity: 1; }
.avatar.loaded .initials { visibility: hidden; }
.avatar.fallback {
  background: color-mix(in srgb, var(--cls) 28%, var(--surface));
  color: var(--text); font-family: var(--serif); font-weight: 700; font-size: 18px; letter-spacing: .02em;
}

.who { min-width: 0; }
.name {
  margin: 0; font-weight: 700; font-size: 16px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sub { margin: 1px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub .cls { color: var(--cls-text); font-weight: 600; }
.delta { margin: 6px 0 0; font-size: 13px; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.none { color: var(--muted); font-weight: 500; }
.delta.new { color: var(--accent); }
.delta .est { display: block; margin-top: 2px; color: var(--muted); font-weight: 500; font-size: 12px; }
.warn {
  margin: 4px 0 0; font-size: 12px; color: var(--warn); display: flex; align-items: center; gap: 5px;
}
.warn::before {
  content: "!"; display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid currentColor; font-size: 10px; font-weight: 700; line-height: 1; flex: none;
}
.delta .pill {
  display: inline-block; padding: 0 7px; margin-right: 6px; border-radius: 999px;
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid currentColor;
}

.level { text-align: right; }
.level-num {
  display: block; font-family: var(--serif); font-weight: 700; font-size: 40px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.level-label { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

.xp {
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--surface-2);
}
.xp > span { display: block; height: 100%; background: var(--cls); opacity: .85; }

/* Chart panel */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 16px 16px 10px;
}
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 8px; }
.panel-head .section-h { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font: 500 13px/1.2 var(--sans); cursor: pointer;
}
.chip:hover { border-color: var(--axis); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cls); flex: none; }

.chart { position: relative; width: 100%; min-height: 260px; }
.chart > svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font: 11px var(--sans); }
.chart .axis line.base { stroke: var(--axis); }
.chart .series path { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .series circle { stroke: var(--surface); stroke-width: 1.5; }
.chart .series circle.est { fill: var(--surface); stroke-width: 1.75; }
.chart .series path.est { opacity: .55; stroke-width: 1.75; }
.chart .hover-line { stroke: var(--axis); stroke-dasharray: 3 3; }
.chart .empty { fill: var(--muted); font: 13px var(--sans); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 4px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { flex: none; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 240px;
  padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4;
  background: var(--text); color: var(--surface); box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.tooltip .tt-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.tooltip .tt-name i { width: 8px; height: 8px; border-radius: 50%; background: var(--cls); display: inline-block; }
.tooltip .tt-time { opacity: .75; }

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

@media (max-width: 560px) {
  .wrap { padding-top: 20px; }
  .site-header { align-items: flex-start; flex-direction: column; }
  .meta { align-items: flex-start; text-align: left; }
  .panel { padding: 14px 12px 8px; }
  .level-num { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; }
}
