:root { --progress-track-height:22px; }
:root {
  color-scheme: dark;
  --bg: #111316;
  --surface: #191c21;
  --surface-hover: #22262d;
  --ink: #eceef2;
  --muted: #9da5b1;
  --line: #2d323b;
  --accent: #c4c9d1;
  --code-color: #3edc81;
  --data-color: #4396f5;
  --empty: #30363f;
  --track: #242930;
  --secondary: #87919e;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --text-small: 12px;
  --text-label: 13px;
  --text-body: 15px;
  --text-section: 16px;
  --text-title: 23px;
  --control-height: 42px;
  --control-radius: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--text-body)/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
::selection { background: #c4c9d130; color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:disabled { opacity: .4; cursor: default; }
.icon { display: block; width: 17px; height: 17px; flex: 0 0 auto; }
.external-icon { width: 13px; height: 13px; color: var(--muted); }
.shell { width: min(1120px, calc(100% - 80px)); margin: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
/* Hidden until a keyboard user reaches it, then shown over the header. */
.skip-link { position: absolute; left: 16px; top: 12px; z-index: 20; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font-size: var(--text-label); transform: translateY(-200%); }
.skip-link:focus-visible { transform: none; }
/* Shown until the app mounts, or if it cannot. */
.startup { padding: 48px 0; color: var(--muted); }
/* An in-place Retry after a section fails to load. */
.inline-retry { margin-left: 6px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }

header { height: 96px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; flex-shrink: 0; border-radius: 4px; }
.brand img { display: block; width: 136px; height: auto; }
nav { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 500; }
nav a { display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; color: var(--muted); transition: color .16s, background .16s, border-color .16s; }
nav a:hover { color: var(--ink); background: var(--surface); }
nav .contribute-link { color: var(--ink); border-color: var(--line); }
nav .contribute-link:hover { background: var(--surface-hover); border-color: #434b58; }

.progress { display: flex; flex-direction: column; gap: 26px; padding: 40px 0 36px; margin-bottom: 6px; }
.progress-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.progress-heading h2 { display: flex; align-items: center; margin: 0; font-size: var(--text-section); font-weight: 550; letter-spacing: -.2px; }
.progress-value { color: var(--ink); font-size: 14px; line-height: 1.5; letter-spacing: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.track { position: relative; height: var(--progress-track-height); border-radius: 4px; background: var(--track); overflow: visible; }
.track i { display: block; position: absolute; left: 0; top: 0; height: 100%; width: 0; border-radius: 4px; }
.progress-element[data-progress="code"] {
  --bar-color: var(--code-color);
  --matched-light: #36c573;
  --matched-dark: #247f4c;
  --fuzzy-light: #376f4c;
  --fuzzy-dark: #294d37;
}
.progress-element[data-progress="data"] {
  --bar-color: var(--data-color);
  --matched-light: #3c85da;
  --matched-dark: #295b96;
  --fuzzy-light: #375c86;
  --fuzzy-dark: #293f5b;
}
.progress-linked, .linked-key { background: var(--bar-color); }
.progress-linked { z-index: 3; }
.progress-matched, .matched-key { background: repeating-linear-gradient(135deg, var(--matched-light) 0 4px, var(--matched-dark) 4px 8px); }
.progress-matched { z-index: 2; }
.progress-fuzzy, .fuzzy-key { background: repeating-linear-gradient(135deg, var(--fuzzy-light) 0 4px, var(--fuzzy-dark) 4px 8px); }
.progress-fuzzy { z-index: 1; }
.progress-key { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.progress-key span { display: flex; align-items: center; gap: 7px; }
.progress-key i { display: inline-block; width: 16px; height: 7px; border-radius: 2px; }
.progress-hover { position: absolute; top: 50%; z-index: 4; height: 100%; border-radius: 4px; pointer-events: none; opacity: 1; transform: translateY(-50%) scale(1.008,1.3); transform-origin: center; box-shadow: 0 4px 14px #0003; }
.track i, .function-track i { transition: width .9s var(--ease); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; }
.function-stats { min-width: 0; }
.stats-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 22px; }
.stats-heading h2 { font-size: var(--text-section); font-weight: 550; letter-spacing: -.15px; margin: 0; }
.stats-total { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.function-stat + .function-stat { margin-top: 22px; }
.stat-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.function-stat h3 { font-size: 13px; font-weight: 450; color: var(--muted); margin: 0; }
.function-count { display: flex; align-items: baseline; gap: 18px; font-variant-numeric: tabular-nums; }
.function-count strong { font-size: 20px; line-height: 1.2; font-weight: 500; letter-spacing: -.3px; }
.function-track { height: 4px; background: var(--track); margin-top: 10px; overflow: hidden; border-radius: 2px; }
.function-track i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; }
[data-function="named"] .function-track i, [data-file="named"] .function-track i { background: var(--secondary); }

#project-map { --map-color: var(--code-color); position: relative; margin: 42px 0 48px; scroll-margin-top: 24px; }
#project-map[data-kind="data"] { --map-color: var(--data-color); }
.map-controls { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 18px; }
.ui-search { display: flex; align-items: center; gap: 10px; width: min(320px,100%); min-width: 0; height: var(--control-height); padding: 0 13px; border: 1px solid var(--line); border-radius: var(--control-radius); background: var(--surface); color: var(--muted); transition: border-color .18s, background .18s; }
.ui-search:focus-within { border-color: #657083; background: #1d2127; }
.ui-search input { color: var(--ink); background: transparent; outline: none; box-shadow: none; border: 0; padding: 0; font: inherit; font-size: var(--text-small); width: 100%; min-width: 0; height: 100%; }
.ui-search input:focus-visible { outline: none; }
.ui-search input::placeholder { color: var(--muted); opacity: 1; }
.map-toggle { position: relative; display: grid; grid-template-columns: 1fr 1fr; flex-shrink: 0; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.map-toggle::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 12px)/2); border-radius: 5px; background: color-mix(in srgb, var(--map-color) 18%, var(--surface)); box-shadow: 0 1px 3px #0004, inset 0 1px 0 #ffffff0b; transform: translateX(0); transition: transform .25s var(--ease), background .2s; pointer-events: none; }
.map-toggle[data-selected="data"]::before { transform: translateX(calc(100% + 4px)); }
.map-toggle button { position: relative; z-index: 1; display: flex; justify-content: center; align-items: center; gap: 7px; min-width: 86px; height: 32px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; transition: color .18s; }
.map-toggle .icon { width: 14px; height: 14px; }
.map-toggle button:hover { color: var(--ink); }
.map-toggle button[aria-pressed="true"] { color: var(--map-color); }
.map-toggle button:focus-visible { outline: 1px solid var(--map-color); outline-offset: -2px; }
.map-view { position: relative; overflow: visible; }
.canvas { position: relative; height: clamp(340px,37vw,420px); background: var(--bg); border-radius: 5px; overflow: hidden; isolation: isolate; }
.tile { position: absolute; z-index: 2; text-align: left; border: 0; border-radius: 0; box-shadow: none; background: transparent; padding: 0; min-width: 0; min-height: 0; color: var(--ink); }
.tile:focus-visible { outline: 0; box-shadow: inset 0 0 0 1px var(--map-color); }
.map-pixels, .map-ripple { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-ripple { z-index: 0; }
.map-pixels { z-index: 1; }
.map-lift { position: absolute; z-index: 3; pointer-events: none; border-radius: 1px; opacity: 0; transform-origin: center; box-shadow: 0 3px 12px #0006, inset 0 0 0 1px color-mix(in srgb, var(--map-color) 80%, transparent); filter: brightness(1.08); }
.map-lift.is-complete { background-image: linear-gradient(180deg, #ffffff0b, transparent 45%, #0000000b); box-shadow: 0 3px 12px #0006, 0 0 8px color-mix(in srgb, var(--map-color) 10%, transparent), inset 1px 1px 0 #ffffff47, inset -1px -1px 0 #00000024, inset 3px 3px 0 #ffffff09; }
#map-back { position: absolute; left: 12px; top: 12px; z-index: 4; display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #596372; border-radius: 8px; background: #171b22ed; color: var(--ink); box-shadow: 0 2px 8px #0003; transition: background .16s, border-color .16s; }
#map-back:hover { background: #2b333e; border-color: var(--map-color); }
#map-back .icon { width: 17px; height: 17px; }
.empty-search { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.map-tooltip { position: fixed; z-index: 10; pointer-events: none; display: flex; align-items: baseline; gap: 14px; width: max-content; max-width: min(460px,calc(100vw - 20px)); padding: 9px 12px; border: 1px solid #454e5b; border-radius: 7px; background: #20252cf7; color: var(--ink); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; box-shadow: 0 5px 24px #0005; }
.tooltip-name { min-width: 0; }
.tooltip-value { color: var(--map-color); font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums; white-space: nowrap; }
.map-details { margin-top: 14px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.map-details-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.map-details h3 { margin: 0; font-size: 14px; font-weight: 550; overflow-wrap: anywhere; }
.map-details button { display: grid; place-items: center; flex-shrink: 0; width: 28px; height: 28px; margin: -4px -6px 0 0; padding: 5px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); }
.map-details button:hover { background: var(--surface-hover); color: var(--ink); }
.map-details button:focus-visible { outline: 1px solid var(--map-color); outline-offset: 2px; }
.map-details dl { display: grid; grid-template-columns: minmax(90px,auto) minmax(0,1fr); gap: 6px 18px; margin: 12px 0 0; font-size: 12px; }
.map-details dt { color: var(--muted); }
.map-details dd { margin: 0; overflow-wrap: anywhere; }

.history-section, .people-section { padding: 22px 0 38px; }
.history-section h2, .people-section h2 { margin: 0 0 24px; font-size: 18px; font-weight: 550; letter-spacing: -.3px; }
.history-summary { display: flex; gap: 24px; align-items: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 26px; }
.history-summary > span { display: flex; align-items: center; gap: 8px; }
.history-summary i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.code-line-key { background: var(--code-color); }
.data-line-key { background: var(--data-color); }
.history-summary strong { color: var(--ink); font-size: 12px; font-weight: 500; }
.history-summary time { margin-left: auto; font-size: 11px; }
.history-chart { height: 200px; position: relative; }
.history-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-guides path { stroke: var(--line); stroke-width: 1; fill: none; vector-effect: non-scaling-stroke; stroke-dasharray: 2 6; opacity: .65; }
.history-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.code-line { stroke: var(--code-color); }
.data-line { stroke: var(--data-color); }
#history-cursor { stroke: #a6b5c450; stroke-width: 1; stroke-dasharray: 3 5; vector-effect: non-scaling-stroke; }
.history-chart circle { stroke: var(--bg); stroke-width: 2; vector-effect: non-scaling-stroke; }
.history-chart [data-dot="code"] { fill: var(--code-color); }
.history-chart [data-dot="data"] { fill: var(--data-color); }
.history-ceiling { position: absolute; top: 0; right: 0; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
#history-scrub { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: crosshair; pointer-events: none; }
.history-chart:focus-within { outline: 1px solid #657083; outline-offset: 8px; border-radius: 4px; }
.history-axis { display: flex; justify-content: space-between; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); margin-top: 10px; }
.history-axis span:nth-child(2) { text-align: center; }
.history-axis span:last-child { text-align: right; }

.contributor-rankings { padding: 0; margin: 0; list-style: none; }
.contributor-rankings li { display: flex; align-items: center; gap: 18px; padding: 15px 12px; margin: 0 -12px; border-radius: 8px; transition: background .18s; }
.contributor-rankings li:hover, .contributor-rankings li:focus-within { background: var(--surface); }
.contributor-place { display: flex; align-items: center; gap: 9px; width: 54px; flex-shrink: 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.rank-medal { --medal-light: #ffe9a6; --medal-mid: #e8b751; --medal-dark: #9a651f; display: block; width: 26px; height: 30px; flex-shrink: 0; filter: drop-shadow(0 2px 2px #0004); }
.contributor-rankings li:nth-child(2) .rank-medal { --medal-light: #f3f7fc; --medal-mid: #b8c5d4; --medal-dark: #697c94; }
.contributor-rankings li:nth-child(3) .rank-medal { --medal-light: #f3c3a1; --medal-mid: #cc8959; --medal-dark: #7c472d; }
.person-avatar { position: relative; overflow: hidden; display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; font-size: 11px; color: var(--ink); border: 1px solid #ffffff12; background: #2a303a; }
.person-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.contributor-name { min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 500; }
.contributor-name:hover { text-decoration: underline; text-underline-offset: 4px; }
.contributor-functions { margin-left: auto; display: flex; align-items: baseline; gap: 7px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.contributor-functions b { color: var(--ink); font-size: 20px; font-weight: 500; letter-spacing: -.5px; }
.lower { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 28px 0 44px; }
.lower h3 { font-size: 15px; font-weight: 500; color: var(--muted); margin: 0; }
.lower a { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); transition: color .16s; }
.lower a:hover { color: var(--accent); }
footer { border-top: 1px solid var(--line); padding: 22px 0 32px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 11px; }
footer a { transition: color .16s; }
footer a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 700px) {
  .shell { width: calc(100% - 40px); }
  header { height: 80px; }
  .brand img { width: 112px; }
  nav { gap: 4px; font-size: 12px; }
  nav a { padding: 0 9px; gap: 7px; }
  nav .external-icon { display: none; }
  .progress { padding-top: 32px; gap: 24px; }
  :root { --progress-track-height:20px; }
  .stats-grid { grid-template-columns: 1fr; gap: 28px; }
  .stats-heading { margin-bottom: 18px; }
  .stats-heading h2 { font-size: 15px; }
  .function-stat + .function-stat { margin-top: 18px; }
  #project-map { margin-top: 34px; margin-bottom: 36px; }
  .map-controls { gap: 10px; margin-bottom: 14px; }
  .ui-search { flex: 1; padding: 0 11px; gap: 7px; }
  .map-toggle button { min-width: 61px; padding: 0 10px; }
  .map-toggle .icon { display: none; }
  .ui-search input { font-size: 12px; }
  .canvas { height: 340px; }
  .map-tooltip { gap: 10px; font-size: 11px; }
  .tooltip-value { font-size: 12px; }
  .history-section, .people-section { padding: 16px 0 32px; }
  .history-chart { height: 180px; }
  .history-summary { flex-wrap: wrap; gap: 12px 20px; }
  .history-summary time { font-size: 10px; }
  .contributor-rankings li { gap: 12px; padding: 13px 6px; margin: 0 -6px; }
  .contributor-place { width: 44px; gap: 6px; font-size: 10px; }
  .rank-medal { width: 24px; height: 28px; }
  .person-avatar { width: 30px; height: 30px; }
  .contributor-name { font-size: 12px; }
  .contributor-functions { flex-direction: column; align-items: flex-end; gap: 0; font-size: 10px; }
  .contributor-functions b { font-size: 17px; }
  .lower { align-items: flex-start; flex-direction: column; gap: 16px; padding-bottom: 32px; }
  footer { flex-direction: column; gap: 8px; padding: 20px 0 26px; font-size: 10px; }
}
@media (max-width: 400px) {
  .brand img { width: 100px; }
  nav { gap: 2px; font-size: 11px; }
  nav a { padding: 0 6px; gap: 6px; }
  nav .icon { width: 15px; height: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.stats-grid > .function-stats:only-child { grid-column: 1 / -1; }

/* Navigation feedback belongs to the persistent shell; it never blocks input. */
.route-progress { position:fixed;inset:0 0 auto;height:2px;z-index:100;pointer-events:none;overflow:hidden;background:var(--track); }
.route-progress::after { content:'';display:block;width:35%;height:100%;background:var(--code-color);animation:route-loading 1s ease-in-out infinite; }
.route-progress[hidden] { display:none; }
.map-loading { display:grid;place-items:center;height:100%;color:var(--muted);font-size:12px; }
@keyframes route-loading { from { transform:translateX(-100%); } to { transform:translateX(390%); } }
@media(prefers-reduced-motion:reduce) { .route-progress::after { animation:none;width:100%;opacity:.6; } }
