:root {
  --bg: #f4f5f3;
  --panel: #fbfbf9;
  --panel-2: #f0f1ee;
  --ink: #202421;
  --muted: #686f69;
  --line: #cfd3ce;
  --line-strong: #9ea59f;
  --accent: #b95438;
  --accent-soft: #f1ddd6;
  --branch: #355f78;
  --branch-soft: #dfe9ef;
  --stage: #9b7737;
  --stage-soft: #efe6d2;
  --remote: #626089;
  --remote-soft: #e8e6f0;
  --danger: #9f423d;
  --danger-soft: #f0dedd;
  --success: #55715f;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}
button, input { font: inherit; }
button { color: inherit; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 40px;
  align-items: end;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line-strong);
}
.eyebrow {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .04em;
  text-decoration: none;
}
h1 {
  margin: 7px 0 8px;
  max-width: 760px;
  font-size: clamp(34px, 6vw, 66px);
  line-height: .98;
  letter-spacing: -.055em;
  font-weight: 650;
}
.lead {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 16px;
}
.header-tools { position: relative; }
.search-box { display: grid; gap: 7px; }
.search-box span {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}
.search-box input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  padding: 11px 12px;
  color: var(--ink);
  outline: none;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  overflow: hidden;
}
.search-result {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result:focus-visible { background: var(--panel-2); outline: 0; }
.search-result code { font-family: var(--mono); font-size: 12px; }
.search-result small { display: block; margin-top: 2px; color: var(--muted); }

.section-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-bottom: 1px solid var(--line-strong);
}
.nav-tab {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 13px 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.nav-tab:last-child { border-right: 0; }
.nav-tab:hover { color: var(--ink); background: rgba(255,255,255,.35); }
.nav-tab.is-active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }

.page { padding: 34px 0 20px; }
.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 380px);
  gap: 32px;
  margin-bottom: 24px;
}
.page-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
}
.page h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.08;
  letter-spacing: -.035em;
}
.page-intro { margin: 5px 0 0; color: var(--muted); }

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  align-content: start;
  padding-top: 5px;
}
.legend-item { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); }
.legend-swatch.branch { background: var(--branch); border-color: var(--branch); }
.legend-swatch.stage { background: var(--stage); border-color: var(--stage); }
.legend-swatch.remote { background: var(--remote); border-color: var(--remote); }
.legend-swatch.head { background: var(--accent); border-color: var(--accent); }

.world {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  padding: clamp(18px, 3vw, 30px);
  margin-bottom: 20px;
}
.world-grid {
  display: grid;
  grid-template-columns: 1fr 72px 1fr 72px 1fr 72px 1fr;
  align-items: center;
}
.world-zone {
  min-height: 160px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.world-zone h3 { margin: 0; font: 600 12px/1.2 var(--mono); color: var(--muted); }
.world-zone p { margin: 0; font-size: 13px; color: var(--muted); }
.world-zone .big-symbol { font-size: 28px; line-height: 1; }
.world-arrow { text-align: center; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.world-arrow strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 18px; font-weight: 500; }
.world.is-playing .zone-work { animation: zonePulse .65s ease 0s 1; }
.world.is-playing .zone-stage { animation: zonePulse .65s ease .22s 1; }
.world.is-playing .zone-local { animation: zonePulse .65s ease .44s 1; }
.world.is-playing .zone-remote { animation: zonePulse .65s ease .66s 1; }
@keyframes zonePulse { 50% { border-color: var(--accent); background: #fff; } }
.world-actions { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-top: 16px; }
.world-actions p { margin: 0; color: var(--muted); font-size: 13px; }

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.command-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  transition: border-color .18s ease, background .18s ease;
}
.command-card:hover { border-color: var(--line-strong); }
.command-card.is-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.command-card code {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
}
.card-type { color: var(--muted); font: 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.scene {
  position: relative;
  min-height: 208px;
  padding: 24px 18px;
  overflow: hidden;
}
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  padding: 12px 18px 15px;
  border-top: 1px solid var(--line);
}
.card-foot p { margin: 0; max-width: 80%; color: var(--muted); font-size: 13px; }
.play {
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  padding: 5px 10px;
  font: 11px var(--mono);
  cursor: pointer;
}
.play:hover, .play:focus-visible { border-color: var(--accent); color: var(--accent); outline: 0; }

.lane-label { color: var(--muted); font: 10px var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.file-stack { display: grid; gap: 6px; width: 130px; }
.file {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  padding: 7px 9px;
  font: 11px var(--mono);
}
.file::after { content: attr(data-state); float: right; color: var(--accent); }
.stage-box, .remote-box {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--stage-soft);
  padding: 11px;
  min-height: 68px;
}
.remote-box { background: var(--remote-soft); }
.arrow-text { color: var(--muted); font: 11px var(--mono); text-align: center; }

.flow-row { display: flex; align-items: center; justify-content: center; gap: clamp(12px, 4vw, 34px); min-height: 150px; }
.flow-arrow { position: relative; width: 58px; height: 1px; background: var(--line-strong); }
.flow-arrow::after { content: ""; position: absolute; right: -1px; top: -4px; width: 8px; height: 8px; border-top: 1px solid var(--line-strong); border-right: 1px solid var(--line-strong); transform: rotate(45deg); }

.graph { position: relative; width: 100%; min-height: 170px; }
.graph svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.graph-line { stroke: var(--line-strong); stroke-width: 2; fill: none; vector-effect: non-scaling-stroke; }
.graph-line.branch-line { stroke: var(--branch); }
.graph-line.remote-line { stroke: var(--remote); stroke-dasharray: 4 5; }
.commit-node { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 3px solid var(--panel); border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.commit-node.new { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ref {
  position: absolute;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--branch-soft);
  color: var(--branch);
  font: 10px var(--mono);
  white-space: nowrap;
}
.ref.remote { background: var(--remote-soft); color: var(--remote); border: 1px dashed #a9a6bd; }
.ref.head { background: var(--accent-soft); color: var(--accent); }
.ref.stage { background: var(--stage-soft); color: #775a29; }
.graph-note { position: absolute; color: var(--muted); font: 10px var(--mono); }

.diff {
  width: min(330px, 100%);
  margin: 10px auto 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  font: 11px/1.6 var(--mono);
}
.diff div { padding: 3px 9px; }
.diff .minus { color: var(--danger); background: #f8eeee; }
.diff .plus { color: var(--success); background: #edf3ef; }
.diff .context { color: var(--muted); }

.conflict {
  width: min(360px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 70px 1fr;
  align-items: center;
  gap: 10px;
}
.conflict-choice { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: #fff; font: 12px var(--mono); text-align: center; }
.conflict-bolt { color: var(--danger); text-align: center; font-size: 28px; }
.conflict-output { grid-column: 1 / -1; margin-top: 10px; border: 1px dashed var(--danger); border-radius: 6px; padding: 10px; color: var(--danger); background: var(--danger-soft); font: 11px/1.55 var(--mono); }

.pr-flow { display: grid; grid-template-columns: 1fr 42px 1.2fr 42px 1fr; gap: 8px; align-items: center; min-height: 150px; }
.pr-box { border: 1px solid var(--line); border-radius: 7px; padding: 12px; text-align: center; background: #fff; font: 11px var(--mono); }
.pr-box.review { background: var(--remote-soft); }

.command-card.is-playing .anim-file { animation: fileMove .82s cubic-bezier(.2,.7,.2,1) 1; }
@keyframes fileMove { 0% { transform: translateX(0); opacity: 1; } 45% { transform: translateX(42px); opacity: .2; } 50% { transform: translateX(-42px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
.command-card.is-playing .anim-node { animation: nodePop .65s ease 1; }
@keyframes nodePop { 0% { transform: scale(.35); opacity: 0; } 65% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.command-card.is-playing .anim-ref { animation: refMove .75s cubic-bezier(.2,.7,.2,1) 1; }
@keyframes refMove { 0% { transform: translateX(-62px); } 100% { transform: translateX(0); } }
.command-card.is-playing .anim-head { animation: headHop .72s ease 1; }
@keyframes headHop { 0%,100% { transform: translateY(0); } 45% { transform: translateY(-28px); } }
.command-card.is-playing .anim-fade { animation: fadeCycle .75s ease 1; }
@keyframes fadeCycle { 0%,100% { opacity: 1; } 48% { opacity: .12; } }
.command-card.is-playing .anim-slide-right { animation: slideRight .8s ease 1; }
@keyframes slideRight { 0% { transform: translateX(-56px); opacity: .25; } 100% { transform: translateX(0); opacity: 1; } }
.command-card.is-playing .anim-slide-left { animation: slideLeft .8s ease 1; }
@keyframes slideLeft { 0% { transform: translateX(56px); opacity: .25; } 100% { transform: translateX(0); opacity: 1; } }
.command-card.is-playing .anim-conflict { animation: conflictPulse .8s ease 1; }
@keyframes conflictPulse { 50% { transform: scale(1.16); color: #c13f37; } }
.command-card.is-playing .anim-highlight { animation: highlight .7s ease 1; }
@keyframes highlight { 50% { background: var(--accent-soft); border-color: var(--accent); } }

.callout {
  margin-top: 14px;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,.45);
  color: var(--muted);
  font-size: 13px;
}
.callout strong { color: var(--ink); }

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line-strong);
}
.pager button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: transparent;
  padding: 9px 12px;
  cursor: pointer;
}
.pager button:disabled { opacity: .35; cursor: default; }
.pager button:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
#pageNumber { font: 12px var(--mono); }
.pager-hint { margin-left: 10px; color: var(--muted); font-size: 11px; }

@media (max-width: 820px) {
  .site-header, .page-head { grid-template-columns: 1fr; gap: 20px; }
  .section-nav { grid-template-columns: repeat(3, 1fr); }
  .nav-tab:nth-child(3) { border-right: 0; }
  .nav-tab:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .cards { grid-template-columns: 1fr; }
  .world-grid { grid-template-columns: 1fr; gap: 8px; }
  .world-arrow { padding: 4px 0; }
  .world-arrow strong { transform: rotate(90deg); }
  .world-zone { min-height: 104px; }
}

@media (max-width: 520px) {
  .shell { width: min(100% - 20px, 1180px); padding-top: 20px; }
  .section-nav { grid-template-columns: repeat(2, 1fr); }
  .nav-tab { border-bottom: 1px solid var(--line); }
  .nav-tab:nth-child(odd) { border-right: 1px solid var(--line); }
  .nav-tab:nth-child(even) { border-right: 0; }
  .flow-row { gap: 9px; }
  .file-stack { width: 108px; }
  .conflict { grid-template-columns: 1fr; }
  .conflict-bolt { transform: rotate(90deg); }
  .conflict-output { grid-column: 1; }
  .pr-flow { grid-template-columns: 1fr; }
  .pr-flow .arrow-text { transform: rotate(90deg); }
  .pager-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
}
