:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #737373;
  --secondary: #525252;
  --surface: #f5f5f5;
  --border: #e5e5e5;
  --code-bg: #fafafa;
  --dot: #e5e5e5;
  --accent: #2563eb;
  --radius: 10px;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a; --fg: #fafafa; --muted: #a1a1a1; --secondary: #d4d4d4;
    --surface: #171717; --border: #ffffff1a; --code-bg: #111111; --dot: #ffffff14; --accent: #60a5fa;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0a; --fg: #fafafa; --muted: #a1a1a1; --secondary: #d4d4d4;
  --surface: #171717; --border: #ffffff1a; --code-bg: #111111; --dot: #ffffff14; --accent: #60a5fa;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
code, pre { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Top bar */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: -0.01em; }
.toplinks { display: flex; align-items: center; gap: 4px; }
.toplinks > a:not(.icon-link) { padding: 6px 10px; color: var(--muted); border-radius: 8px; transition: color .15s; }
.toplinks > a:not(.icon-link):hover { color: var(--fg); }
.icon-link { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; transition: color .15s, background .15s; }
.icon-link:hover { color: var(--fg); background: var(--surface); }
#theme-toggle .moon { display: none; }
:root[data-theme="dark"] #theme-toggle .sun { display: none; }
:root[data-theme="dark"] #theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) #theme-toggle .sun { display: none; }
  :root:not([data-theme]) #theme-toggle .moon { display: block; }
}

/* Layout */
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); max-width: 1180px; margin: 0 auto; }
.sidebar { position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow: auto; padding: 28px 16px 28px 24px; border-right: 1px solid var(--border); }
.nav-group { display: flex; flex-direction: column; margin-bottom: 24px; }
.nav-group > span { font-size: 12px; font-weight: 600; padding: 0 10px 6px; }
.nav-group a { padding: 5px 10px; border-radius: 8px; color: var(--muted); font-size: 13.5px; display: flex; align-items: center; justify-content: space-between; transition: color .15s, background .15s; }
.nav-group a:hover { color: var(--fg); }
.nav-group a[aria-current="page"] { color: var(--fg); background: var(--surface); font-weight: 500; }
.nav-group em { font-style: normal; font-size: 10.5px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
main { padding: 40px 48px 96px; min-width: 0; outline: none; }
.page { max-width: 880px; }

/* Page head */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
h1 { font-size: 30px; line-height: 1.2; font-weight: 600; letter-spacing: -0.025em; margin: 0 0 8px; }
.lead { font-size: 16px; color: var(--muted); margin: 0 0 28px; max-width: 640px; }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; margin: 48px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
h3 { font-size: 15px; font-weight: 600; margin: 28px 0 8px; }
p { margin: 0 0 12px; }
.prose { color: var(--secondary); }
.prose code, td code { font-size: 12.5px; padding: 1px 5px; border-radius: 5px; background: var(--surface); color: var(--fg); }

/* Hero */
.hero { padding: 24px 0 8px; margin-bottom: 28px; }
.hero h1 { font-size: 40px; letter-spacing: -0.035em; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); margin-bottom: 18px; }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: #39d353; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 36px; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--border); font-weight: 500; font-size: 13.5px; transition: opacity .15s, background .15s; }
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.primary:hover { opacity: .88; background: var(--fg); }

/* Preview block */
.block { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 20px; }
.block-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--border); min-height: 44px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; align-self: stretch; }
.tab { position: relative; border: 0; background: none; padding: 0 10px; color: var(--muted); cursor: pointer; font-size: 13.5px; font-weight: 500; transition: color .15s; }
.tab:hover { color: var(--fg); }
.seg button:disabled { cursor: not-allowed; opacity: .55; }
.tab[aria-selected="true"] { color: var(--fg); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--fg); border-radius: 2px; }
.controls { display: flex; align-items: center; gap: 6px; padding: 6px 0; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface); }
.seg button { border: 0; background: none; padding: 3px 9px; border-radius: 6px; font-size: 12px; color: var(--muted); cursor: pointer; transition: color .15s, background .15s; }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 0 0 1px var(--border); }
.icon-btn { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface); color: var(--fg); }
.stage {
  display: grid; place-items: center; gap: 12px; padding: 40px 24px; min-height: 300px;
  background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 16px 16px;
  overflow-x: auto;
}
.stage.dark-stage { background-color: #0d1117; --dot: #ffffff10; }
.stage.light-stage { background-color: #ffffff; --dot: #e5e5e5; }
.stage svg { max-width: 100%; height: auto; display: block; }
.stage .grid { display: grid; grid-template-columns: repeat(3, minmax(0, 272px)); gap: 12px; justify-content: center; width: 100%; }
.stage .grid a { display: block; border-radius: 10px; transition: transform .2s; }
.stage .grid a:hover { transform: translateY(-2px); }
.stage .clickable { cursor: pointer; }

/* Code */
.code { position: relative; background: var(--code-bg); }
.code pre { margin: 0; padding: 18px 20px; overflow: auto; font-size: 12.5px; line-height: 1.7; color: var(--secondary); white-space: pre; max-height: 420px; }
.code .copy { position: absolute; top: 8px; right: 8px; }
.code-block { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin: 12px 0 20px; }
.code-block .label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 8px 14px; border-bottom: 1px solid var(--border); font-family: var(--mono); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 20px; }
th { text-align: left; font-weight: 500; color: var(--muted); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--secondary); }
td:first-child { white-space: nowrap; color: var(--fg); }

/* Steps */
.steps { counter-reset: step; padding-left: 0; list-style: none; margin: 0; }
.steps > li { position: relative; padding: 0 0 8px 44px; border-left: 1px solid var(--border); margin-left: 14px; }
.steps > li::before {
  counter-increment: step; content: counter(step); position: absolute; left: -15px; top: -2px; width: 28px; height: 28px;
  display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; font-weight: 600;
}
.steps > li:last-child { border-left-color: transparent; }
.steps h3 { margin: 0 0 6px; }

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

/* Mobile */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 16px; display: flex; gap: 2px; overflow-x: auto; }
  .nav-group { flex-direction: row; margin: 0; }
  .nav-group > span { display: none; }
  .nav-group a { white-space: nowrap; }
  main { padding-block: 28px 72px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .toplinks > a:not(.icon-link) { display: none; }
  .hero h1 { font-size: 32px; }
  .stage { padding: 24px 12px; min-height: 0; }
  .stage .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) { .stage .grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .stage { place-items: center start; }
  .stage .wide, .stage .activity-view { min-width: 640px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Try your own profile */
.try-wrap { margin: 28px 0 0; padding-top: 24px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.try-title { margin: 0; font-size: 13px; font-weight: 500; color: var(--secondary); }
.try { display: flex; gap: 8px; flex-wrap: wrap; }
.try-field { display: inline-flex; align-items: center; height: 36px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 4px 0 12px; background: var(--bg); min-width: 0; flex: 0 1 320px; transition: border-color .15s; }
.try-field:focus-within { border-color: var(--fg); }
.try-field span { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.try-field input { border: 0; outline: none; background: none; color: var(--fg); font: 500 13px var(--mono); min-width: 0; flex: 1; padding: 0 4px 0 0; }
.try .btn { cursor: pointer; }
.try .btn[disabled] { opacity: .6; cursor: progress; }
.try-status { margin: 0; font-size: 12.5px; color: var(--muted); min-height: 1.2em; }
.try-status a { color: var(--fg); text-decoration: underline; }
.try-status.error { color: #dc2626; }

/* Activity: chart + overview strip */
.activity-view { width: 100%; max-width: 840px; display: grid; gap: 10px; }
.activity-chart { cursor: grab; touch-action: pan-y; }
.activity-chart.dragging, .overview.dragging { cursor: grabbing; }
.activity-chart svg { user-select: none; -webkit-user-select: none; }
.overview-wrap { display: grid; gap: 4px; }
.overview { position: relative; height: 34px; border: 1px solid var(--ov-border); border-radius: 8px; background: var(--ov-bg); cursor: pointer; touch-action: none; overflow: hidden; }
.overview svg { position: absolute; inset: 5px 0 4px; width: 100%; height: calc(100% - 9px); display: block; }
.overview-window { position: absolute; top: -1px; bottom: -1px; border: 1.5px solid var(--ov-fg); border-radius: 8px; background: color-mix(in srgb, var(--ov-fg) 7%, transparent); cursor: grab; transition: left .18s cubic-bezier(.2,.7,.2,1), width .18s; }
.overview.dragging .overview-window { transition: none; }
.overview-window::before, .overview-window::after { content: ""; position: absolute; top: 50%; width: 2px; height: 12px; margin-top: -6px; border-radius: 1px; background: var(--ov-fg); opacity: .55; }
.overview-window::before { left: 4px; } .overview-window::after { right: 4px; }
.overview:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.overview-labels { position: relative; height: 14px; font: 10.5px var(--mono); }
.overview-labels span { position: absolute; top: 0; transform: translateX(2px); }
.overview-labels .now { transform: none; }

/* Gallery + lightbox */
.gallery-wrap .tile { cursor: zoom-in; outline: none; }
.gallery-wrap .tile:focus-visible rect:last-of-type { stroke: var(--accent); stroke-width: 2; }
.lightbox { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--bg); color: var(--fg); width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.lightbox::backdrop { background: rgb(0 0 0 / .55); backdrop-filter: blur(4px); }
.lightbox-media { background: #000; display: grid; place-items: center; }
.lightbox-media video, .lightbox-media img { display: block; max-width: 100%; max-height: 70vh; }
.lightbox-text { display: grid; gap: 4px; padding: 14px 18px 18px; font-size: 13.5px; }
.lightbox-text span { color: var(--muted); }
.lightbox-text a { font-size: 12.5px; color: var(--fg); text-decoration: underline; justify-self: start; }
.lightbox-close { position: absolute; top: 8px; right: 8px; z-index: 1; background: rgb(0 0 0 / .5); color: #fff; }
.lightbox-close:hover { background: rgb(0 0 0 / .7); color: #fff; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Intro popup: the old hero, parked bottom-left */
.hero-pop {
  position: fixed; z-index: 20; left: max(20px, env(safe-area-inset-left, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px));
  width: min(340px, calc(100vw - 40px)); padding: 16px 18px 16px; display: grid; gap: 6px; justify-items: start;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / .28), 0 2px 6px rgb(0 0 0 / .06);
  animation: pp-pop-in .55s .5s cubic-bezier(.2,.9,.25,1.15) both, pp-pop-ring 1.4s 1.2s ease-out 2;
}
.hero-pop .badge { margin: 0 0 4px; }
.hero-pop-title { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.hero-pop-lead { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.hero-pop-link { margin-top: 6px; font-size: 13px; font-weight: 500; color: var(--fg); border-bottom: 1px solid var(--border); }
.hero-pop-link:hover { border-bottom-color: var(--fg); }
.hero-pop-close { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; }
.hero-pop.leaving { animation: pp-pop-out .2s ease-in forwards; }
.hero-pop .badge i { animation: pp-dot 1.6s ease-in-out infinite; }
@keyframes pp-pop-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes pp-pop-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes pp-pop-ring { 0% { box-shadow: 0 12px 32px -12px rgb(0 0 0 / .28), 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 12px 32px -12px rgb(0 0 0 / .28), 0 0 0 14px transparent; } }
@keyframes pp-dot { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .hero-pop, .hero-pop .badge i { animation: none; } }
.controls { flex-wrap: wrap; }
.seg button { white-space: nowrap; }
@media (max-width: 520px) {
  .hero-pop { padding: 12px 14px; gap: 4px; }
  .hero-pop-lead { display: none; }
  .hero-pop-title { font-size: 15px; }
}
