/* ===== Tokens: GitHub Primer colors ===== */
:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #21262d;
  --border: #30363d;
  --border-muted: #21262d;
  --text: #e6edf3;
  --muted: #7d8590;
  --link: #4493f8;
  --accent: #39d353;          /* contribution green */
  --btn-primary: #238636;
  --btn-primary-hover: #2ea043;
  --btn-primary-text: #ffffff;
  --selected: #1f6feb;
  --danger: #f85149;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --gutter: clamp(16px, 4vw, 32px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-elev-2: #f6f8fa;
  --border: #d0d7de;
  --border-muted: #d8dee4;
  --text: #1f2328;
  --muted: #656d76;
  --link: #0969da;
  --accent: #216e39;
  --btn-primary: #1f883d;
  --btn-primary-hover: #1a7f37;
  --selected: #0969da;
  --danger: #d1242f;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ffffff;
    --bg-elev: #ffffff;
    --bg-elev-2: #f6f8fa;
    --border: #d0d7de;
    --border-muted: #d8dee4;
    --text: #1f2328;
    --muted: #656d76;
    --link: #0969da;
    --accent: #216e39;
    --btn-primary: #1f883d;
    --btn-primary-hover: #1a7f37;
    --selected: #0969da;
    --danger: #d1242f;
    color-scheme: light;
  }
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code, pre, .mono { font-family: var(--mono); }
code { background: rgb(110 118 129 / .2); padding: .2em .4em; border-radius: var(--radius); font-size: 85%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 600; }
h3 { font-size: 16px; }
:focus-visible { outline: 2px solid var(--selected); outline-offset: -2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--bg-elev); color: var(--link); padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); z-index: 100; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ===== Header / footer (GitHub-style top bar) ===== */
.site-header-wrap { background: var(--bg-elev-2); border-bottom: 1px solid var(--border); }
:root:not([data-theme="light"]) .site-header-wrap { background: #010409; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .site-header-wrap { background: #f6f8fa; } }
:root[data-theme="light"] .site-header-wrap { background: #f6f8fa; }
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) 12px;
  max-width: 1280px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; font-size: 16px; }
.brand:hover { text-decoration: none; }
.header-nav { display: flex; align-items: center; gap: 4px; }
.header-nav a { color: var(--text); padding: 6px 8px; border-radius: var(--radius); font-weight: 600; }
.header-nav a:hover { background: rgb(177 186 196 / .12); text-decoration: none; }
@media (max-width: 480px) { .header-nav a { display: none; } }
.site-footer { max-width: 1280px; margin: 48px auto 0; padding: 24px var(--gutter) max(32px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 12px; border-top: 1px solid var(--border-muted); }
.site-footer p { margin: 4px 0; }
.noscript { text-align: center; padding: 24px; }

/* ===== Layout ===== */
main { max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter); }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* ===== Hero ===== */
.hero { text-align: center; padding: clamp(32px, 7vw, 72px) 0 clamp(24px, 4vw, 40px); }
.eyebrow { color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.hero h1 { font-size: clamp(28px, 6vw, 48px); letter-spacing: -.02em; margin-bottom: 12px; }
.accent { color: var(--accent); }
.lede { color: var(--muted); font-size: clamp(15px, 2.2vw, 18px); max-width: 620px; margin: 0 auto 24px; }

.search {
  display: flex; align-items: center; gap: 8px; max-width: 600px; margin: 0 auto;
}
.search-field {
  flex: 1; min-width: 0; display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px;
}
.search-field:focus-within { border-color: var(--selected); box-shadow: inset 0 0 0 1px var(--selected); }
.search-prefix { font-family: var(--mono); color: var(--muted); font-size: 14px; white-space: nowrap; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text);
  font: 14px var(--mono); padding: 9px 2px; height: 40px;
}
.search input::placeholder { color: var(--muted); }
@media (max-width: 560px) {
  .search { flex-direction: column; align-items: stretch; }
  .search-prefix { display: none; }
  .search input { font-size: 16px; }
}
.form-hint { min-height: 1.5em; margin: 10px 0 0; color: var(--muted); }
.form-hint.error { color: var(--danger); }
.examples { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); }

/* ===== Buttons (Primer) ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-elev-2); color: var(--text); font: 500 14px var(--font); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: rgb(177 186 196 / .2); border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--btn-primary); border-color: rgb(240 246 252 / .1); color: var(--btn-primary-text); }
.btn-primary:hover { background: var(--btn-primary-hover); border-color: rgb(240 246 252 / .1); }
.btn-ghost { background: transparent; }
.chip {
  font: 12px var(--font); color: var(--text); background: transparent; border: 0; border-radius: var(--radius);
  padding: 6px 12px; cursor: pointer; min-height: 32px;
}
.examples .chip { font-family: var(--mono); color: var(--link); }
.chip:hover { background: rgb(177 186 196 / .12); }
.chip[aria-selected="true"] { background: var(--selected); color: #fff; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600;
}
.icon-btn:hover { color: var(--text); }
.icon-btn:disabled { opacity: .5; cursor: default; }
.icon-btn[aria-pressed="true"] { color: var(--link); }

/* ===== Result ===== */
.result { display: grid; gap: 16px; animation: rise .3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.profile { display: flex; gap: 16px; align-items: center; border: 0; padding: 0 0 16px; border-bottom: 1px solid var(--border-muted); border-radius: 0; background: transparent; }
.avatar { width: 88px; height: 88px; border-radius: 50%; border: 1px solid var(--border); flex-shrink: 0; background: var(--bg-elev-2); }
.profile h2 { font-size: 24px; margin: 0; line-height: 1.25; }
.login { font-size: 20px; font-weight: 300; color: var(--muted); }
.login:hover { color: var(--link); text-decoration: none; }
.bio { margin: 6px 0 8px; font-size: 16px; }
.profile-meta { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); }
.profile-meta strong { color: var(--text); font-weight: 600; }
@media (max-width: 480px) { .profile { flex-direction: column; text-align: center; } .profile-meta { justify-content: center; } }

/* Contribution box styled like the GitHub profile graph */
.viewer-title { font-size: 16px; font-weight: 400; margin: 0 0 8px; }
.viewer-layout { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.viewer-layout > div { min-width: 0; }
@media (max-width: 760px) { .viewer-layout { grid-template-columns: 1fr; } }
.viewer { padding: 0; overflow: hidden; }
.viewer-toolbar { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.years { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
@media (max-width: 760px) {
  .years { flex-direction: row; overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; order: -1; }
  .years .chip { flex-shrink: 0; }
}
.years .chip { text-align: left; }
.viewer-actions { display: flex; gap: 6px; align-items: center; }

.stage { position: relative; height: clamp(320px, 55vh, 600px); background: var(--stage-bg, #0d1117); touch-action: none; }
.stage:fullscreen { height: 100vh; }
.stage-canvas, .stage-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-hint { position: absolute; left: 0; right: 0; bottom: 8px; margin: 0; text-align: center; font-size: 12px; color: var(--muted); pointer-events: none; }
.stage-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); background: color-mix(in srgb, var(--stage-bg, #0d1117) 70%, transparent); }
.spinner { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--muted); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tooltip {
  position: absolute; pointer-events: none; transform: translate(-50%, calc(-100% - 10px));
  background: #24292f; color: #fff; border-radius: var(--radius);
  padding: 4px 8px; font: 12px var(--font); white-space: nowrap; z-index: 5;
}
.grid2d { position: absolute; inset: 0; display: grid; place-items: center; overflow: auto; padding: 16px; touch-action: pan-x pan-y; }
.grid2d svg { max-width: 100%; height: auto; }
.grid2d rect { outline: 1px solid rgb(27 31 35 / .06); outline-offset: -1px; }

.legend { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.legend-right { display: flex; align-items: center; gap: 4px; }
.legend-swatches { display: inline-flex; gap: 3px; margin: 0 2px; }
.legend-swatches i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; outline: 1px solid rgb(27 31 35 / .06); outline-offset: -1px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 600; }
.stat-sub { font-size: 12px; color: var(--muted); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; font-size: 12px; color: var(--muted); }
.bar-fill { width: 100%; max-width: 32px; border-radius: 2px; background: var(--accent); min-height: 2px; transition: height .5s ease; }
.bar-value { color: var(--text); font-size: 12px; }

.langbar { display: flex; height: 8px; border-radius: var(--radius); overflow: hidden; background: var(--bg-elev-2); margin-bottom: 12px; gap: 2px; }
.langbar span { height: 100%; }
.lang-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.lang-list li { display: flex; align-items: center; gap: 8px; }
.lang-list i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.lang-list li span:first-of-type { font-weight: 600; }
.lang-list .pct { margin-left: auto; color: var(--muted); }

.repos { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.repos li a { display: block; height: 100%; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); color: var(--text); }
.repos li a:hover { text-decoration: none; border-color: var(--muted); }
.repo-name { font-weight: 600; color: var(--link); word-break: break-word; }
.repo-desc { color: var(--muted); font-size: 12px; margin: 8px 0 12px; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.repo-meta { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }

.share-link { display: flex; gap: 8px; margin-bottom: 12px; }
.share-link input {
  flex: 1; min-width: 0; height: 40px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-elev-2);
  color: var(--text); padding: 0 12px; font: 12px var(--mono);
}
.share-buttons, .share-socials { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
@media (max-width: 480px) { .share-buttons .btn { flex: 1 1 100%; } .share-socials .btn { flex: 1 1 calc(50% - 8px); } }
.readme-embed { margin-top: 8px; }
.readme-embed summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.readme-embed pre { background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; overflow-x: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all; }

/* ===== Info sections ===== */
.info { margin-top: 48px; }
.info h2 { font-size: 24px; padding-bottom: 8px; border-bottom: 1px solid var(--border-muted); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--muted); }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text); font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.steps strong { color: var(--text); display: block; }
#faq details { border-bottom: 1px solid var(--border-muted); }
#faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
#faq details p { margin: 0 0 12px; color: var(--muted); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #24292f; color: #fff; padding: 8px 16px; border-radius: var(--radius); font-size: 14px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .3); z-index: 50; animation: rise .2s ease both;
}
