*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #25231f;
  --copy: #45423d;
  --muted: #6d6860;
  --line: #dedbd5;
  --soft: #f7f6f8;
  --soft-violet: #f0edfb;
  --violet: #6249d8;
  --green: #26745f;
  --gold: #815d00;
  --terracotta: #a14730;
  --sans: Arial, Helvetica, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

img,
svg {
  display: block;
  max-width: 100%;
}

code,
pre {
  font-family: var(--mono);
}

::selection {
  background: rgba(98, 73, 216, 0.22);
}

:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 4px;
}

.guide-shell {
  width: min(100%, 1292px);
  margin-inline: auto;
  padding-bottom: 56px;
}

.guide-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 74px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 16px clamp(20px, 4vw, 56px);
  border-bottom: 1px solid rgba(37, 35, 31, 0.14);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.guide-lockup {
  width: max-content;
  display: grid;
  grid-template-columns: 38px auto;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-decoration: none;
}

.guide-lockup img {
  width: 38px;
  height: auto;
  opacity: 0.9;
}

.guide-lockup strong {
  font-size: 22px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: -0.045em;
}

.guide-nav-main {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.1vw, 30px);
  color: #625c53;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.035em;
}

.guide-nav-main a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 0;
  line-height: 1;
  text-decoration: none;
}

.guide-nav-main a::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: currentColor;
  content: "";
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.guide-nav-main a:hover,
.guide-nav-main a:focus-visible {
  color: #4f4a42;
}

.guide-nav-main a:hover::after,
.guide-nav-main a:focus-visible::after {
  transform: scaleX(1);
}

.guide-nav-main a[aria-current="page"] {
  color: var(--violet);
}

.guide-nav-main a[aria-current="page"]::after {
  transform: scaleX(1);
}

.manual-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 760px);
  justify-content: center;
  align-items: start;
  gap: clamp(38px, 5vw, 72px);
  padding: 34px clamp(20px, 4vw, 56px) 0;
}

.manual-nav {
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 122px);
  overflow-y: auto;
  padding: 12px 0 18px;
  border-top: 3px solid var(--violet);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.manual-nav .here {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.manual-nav .here + p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.guide-route {
  position: relative;
  margin-top: 18px;
  display: grid;
  gap: 3px;
  list-style: none;
}

.guide-route::before {
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 13px;
  width: 1px;
  background: #e8e5ed;
  content: "";
}

.guide-route a {
  position: relative;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 7px 6px;
  border-radius: 8px;
  text-decoration: none;
}

.guide-route a:hover {
  background: #f5f2fb;
}

.guide-route i {
  z-index: 1;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--soft-violet);
  color: var(--violet);
  font-family: var(--mono);
  font-size: 8px;
  font-style: normal;
  font-weight: 800;
}

.guide-route span {
  color: #77737e;
  font-size: 9px;
  line-height: 1.3;
}

.guide-route b {
  display: block;
  margin-bottom: 1px;
  color: var(--ink);
  font-size: 10px;
}

.nav-note {
  margin: 18px 6px 0 42px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.nav-note b {
  display: block;
  margin-bottom: 4px;
  color: var(--violet);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.journey {
  min-width: 0;
  width: 100%;
  max-width: 760px;
  color: var(--copy);
  font-size: 16px;
  line-height: 1.68;
}

.guide-kicker {
  margin-bottom: 7px;
  color: var(--violet);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.journey h1 {
  max-width: 12ch;
  color: var(--ink);
  font-size: clamp(42px, 5vw, 54px);
  line-height: 1;
  letter-spacing: -0.055em;
}

.journey .lede {
  margin-top: 16px;
  color: #46424a;
  font-size: clamp(17px, 1.5vw, 19px);
  line-height: 1.58;
}

.level-map {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.level-map span {
  padding: 11px 9px 10px;
  border-radius: 7px;
  background: var(--soft);
  color: #55515b;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.level-map span:last-child {
  background: #eee8fa;
  color: var(--violet);
}

.guide-section {
  margin-top: clamp(66px, 8vw, 86px);
  scroll-margin-top: 98px;
}

.guide-section.first {
  margin-top: 58px;
}

.stack-flow {
  position: relative;
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 24px;
}

.stack-card {
  position: relative;
  min-width: 0;
  padding: 18px 16px 17px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--violet);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(35, 31, 42, 0.045);
}

.stack-card > span {
  display: block;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.11em;
  line-height: 1.3;
  text-transform: uppercase;
}

.stack-card > b {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 19px;
  letter-spacing: -0.035em;
}

.stack-card > p {
  margin-top: 8px;
  color: var(--copy);
  font-size: 11px;
  line-height: 1.55;
}

.karu-layer {
  border-top-color: #26745f;
}

.openzl-layer {
  border-top-color: #815d00;
}

.geozl-layer {
  border-top-color: #a14730;
}

.stack-connector {
  position: absolute;
  top: 74px;
  left: 25%;
  width: 24px;
  z-index: 2;
  padding: 2px;
  border-radius: 999px;
  background: #f5f2fb;
  color: var(--violet);
  font-family: var(--mono);
  font-size: 0;
  line-height: 1.25;
  text-align: center;
  transform: translateX(-50%);
}

.stack-connector::after {
  content: "\2192";
  font-family: var(--sans);
  font-size: 14px;
}

.stack-connector:nth-of-type(4) {
  left: 50%;
}

.stack-connector:nth-of-type(6) {
  left: 75%;
}

.stack-roles {
  margin-top: 14px;
}

.section-label {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-label span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--violet);
  color: #fff;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
}

.section-label small {
  color: var(--violet);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.journey h2 {
  max-width: 24ch;
  color: var(--ink);
  font-size: clamp(26px, 3vw, 32px);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.journey h3 {
  margin-top: 32px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.journey p {
  margin-top: 11px;
}

.journey .section-intro {
  margin-top: 11px;
  color: #4b4850;
  font-size: 17px;
  line-height: 1.62;
}

.journey .bridge {
  margin-top: 19px;
  color: var(--ink);
  font-weight: 700;
}

.journey a {
  color: var(--green);
  text-underline-offset: 3px;
}

.journey :not(pre) > code {
  padding: 0.1em 0.3em;
  background: #f3f2f4;
  color: var(--ink);
  font-size: 0.9em;
}

.journey pre {
  width: max-content;
  max-width: 100%;
  margin-top: 16px;
  overflow-x: auto;
  padding: 18px 20px;
  border-radius: 8px;
  background: var(--ink);
  color: #f8f8f7;
  font-size: 13px;
  line-height: 1.65;
}

.examples-page .journey pre {
  width: 100%;
  margin: 0;
  padding: 22px 24px 24px;
  border-radius: 0;
  background: #1e1e1e;
  color: #d4d4d4;
  font-size: 13px;
  line-height: 1.72;
  tab-size: 4;
}

.examples-page .journey pre code {
  color: inherit;
}

.syntax-comment { color: #6a9955; }
.syntax-string { color: #ce9178; }
.syntax-number { color: #b5cea8; }
.syntax-keyword { color: #c586c0; }
.syntax-constant { color: #569cd6; }
.syntax-function { color: #dcdcaa; }
.syntax-operator { color: #d4d4d4; }

.code-card,
.code-group {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid #343438;
  border-radius: 11px;
  background: #1e1e1e;
  box-shadow: 0 10px 28px rgba(37, 35, 31, 0.13);
}

.code-toolbar {
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 9px 6px 15px;
  border-bottom: 1px solid #343438;
  background: #252526;
}

.code-language {
  color: #9da0a6;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.code-copy {
  min-width: 58px;
  height: 29px;
  padding: 0 11px;
  border: 1px solid #46464b;
  border-radius: 6px;
  background: #2d2d30;
  color: #cccccc;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.code-copy:hover,
.code-copy:focus-visible {
  border-color: #77777e;
  background: #37373a;
  color: #ffffff;
}

.code-copy.is-copied {
  border-color: #4f907f;
  background: #173d34;
  color: #9cdcbe;
}

.code-toolbar--tabs {
  padding-left: 8px;
}

.code-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
}

.code-tab {
  min-width: 67px;
  height: 29px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #a7a7aa;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
}

.code-tab:hover {
  color: #ffffff;
}

.code-tab[aria-selected="true"] {
  background: #1e1e1e;
  color: #9cdcfe;
  box-shadow: 0 0 0 1px #46464b;
}

[data-language-panel][hidden] {
  display: none;
}

.code-coming-soon {
  min-height: 154px;
  padding: 28px 24px;
  display: grid;
  place-content: center;
  justify-items: center;
  background: #1e1e1e;
  color: #d4d4d4;
  text-align: center;
}

.code-coming-soon span {
  color: #9cdcfe;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.code-coming-soon strong {
  margin-top: 5px;
  color: #ffffff;
  font-size: 19px;
}

.code-coming-soon p {
  margin-top: 4px;
  color: #9da0a6;
  font-size: 12px;
}

.language-support {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.language-support > div {
  min-width: 0;
  padding: 12px 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #e0ddd7;
  border-radius: 8px;
  background: #faf9f7;
}

.language-support span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.language-support b {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
}

.language-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.story-figure {
  margin-top: 25px;
  padding: 22px 20px 16px;
  overflow-x: auto;
  border-radius: 11px;
  background: var(--soft);
  scrollbar-color: #c8c2d0 transparent;
  scrollbar-width: thin;
}

.story-figure > svg,
.story-figure > img {
  width: 100%;
  height: auto;
}

.story-figure > img {
  max-height: 470px;
  object-fit: contain;
}

.story-figure figcaption {
  margin-top: 12px;
  padding: 8px 2px 0;
  color: #67636d;
  font-size: 12px;
  line-height: 1.5;
}

.process-strip {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.process-strip > div {
  min-width: 0;
  padding: 12px 13px;
  border-radius: 8px;
  background: var(--soft);
}

.process-strip b,
.process-strip span {
  display: block;
}

.process-strip b {
  margin-bottom: 4px;
  color: var(--violet);
  font-size: 11px;
}

.process-strip span {
  color: #57525c;
  font-size: 11px;
  line-height: 1.48;
}

.definition-grid,
.choice-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.choice-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.header-formula {
  margin-top: 16px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  align-items: center;
  gap: 7px 18px;
  border: 1px solid #d8d1ee;
  border-radius: 9px;
  background: #f6f4fb;
}

.header-formula > span {
  color: var(--violet);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.header-formula > strong {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.header-formula > p {
  grid-column: 1 / -1;
  margin-top: 4px;
  color: #514d56;
  font-size: 14px;
  line-height: 1.58;
}

.definition-grid > div,
.choice-grid > div {
  min-width: 0;
  padding: 15px 16px;
  border-radius: 9px;
  background: var(--soft);
}

.definition-grid b,
.choice-grid b {
  color: var(--violet);
  font-size: 12px;
}

.definition-grid p,
.choice-grid p {
  margin-top: 5px;
  color: #56515c;
  font-size: 13px;
  line-height: 1.5;
}

.technical-note,
.callout {
  margin-top: 19px;
  padding: 17px 19px;
  border-radius: 9px;
  background: #f5f3f7;
  box-shadow: inset 2px 0 #8d829a;
}

.callout {
  background: #f4f8f6;
  box-shadow: inset 2px 0 var(--green);
}

.technical-note > span,
.callout > span {
  display: block;
  margin-bottom: 5px;
  color: #514959;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.callout > span {
  color: var(--green);
}

.technical-note p,
.callout p {
  margin-top: 0;
  color: #3f3b43;
  font-size: 14px;
  line-height: 1.58;
}

.technical-note p + p,
.callout p + p {
  margin-top: 8px;
}

.tablewrap {
  margin-top: 16px;
  overflow-x: auto;
}

.journey table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.journey th,
.journey td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.journey th {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.journey ul,
.journey ol.body {
  margin: 12px 0 0;
  padding-left: 22px;
}

.journey li + li {
  margin-top: 6px;
}

.figure-stage {
  fill: var(--violet);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
}

.figure-card rect {
  fill: #fff;
  stroke: #d4d0d9;
}

.figure-card.accent rect {
  stroke: var(--violet);
  stroke-width: 1.4;
}

.figure-card text {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
}

.figure-card .sub {
  fill: #706b76;
  font-size: 9px;
  font-weight: 400;
}

.figure-arrow {
  fill: none;
  stroke: #7d7884;
  stroke-width: 1.4;
}

.figure-note {
  fill: #716c77;
  font-size: 9px;
  text-anchor: middle;
}

.diagram-panel {
  fill: #fff;
  stroke: #d9d5dd;
}

.diagram-copy {
  fill: #625e67;
  font-size: 9px;
  text-anchor: middle;
}

.mini-frame rect,
.mini-frame path,
.decoded-tile rect,
.decoded-tile path {
  stroke-width: 1;
}

.mini-frame path,
.decoded-tile path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.76);
}

.mini-frame.green rect,
.decoded-tile.green rect {
  fill: #cfe2dc;
  stroke: #7aa99b;
}

.mini-frame.violet rect,
.decoded-tile.violet rect {
  fill: #ded8f5;
  stroke: #9c8be4;
}

.mini-frame.gold rect,
.decoded-tile.gold rect {
  fill: #e8dfc4;
  stroke: #b9a36a;
}

.mini-frame.terracotta rect,
.decoded-tile.terracotta rect {
  fill: #ead3cd;
  stroke: #bd7d6d;
}

.mini-frame text {
  fill: #5f5a64;
  font-family: var(--mono);
  font-size: 8px;
  text-anchor: middle;
}

.axis-pill rect {
  fill: var(--soft-violet);
  stroke: #d3cbee;
}

.axis-pill text {
  fill: var(--violet);
  font-size: 7px;
  font-weight: 700;
  text-anchor: middle;
}

.cell-stack rect {
  fill: #f1eff5;
  stroke: #bcb6c5;
}

.cell-stack rect.front {
  fill: #fff;
  stroke: var(--violet);
  stroke-width: 1.4;
}

.cell-stack path {
  fill: none;
  stroke: #ded9e5;
}

.cell-title {
  fill: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
}

.graph-frame > rect {
  fill: #fff;
  stroke: #d8d4dd;
}

.graph-frame .frame-index {
  fill: var(--ink);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
}

.graph-frame .frame-range {
  fill: #77717e;
  font-family: var(--mono);
  font-size: 8px;
}

.graph-node rect {
  fill: #f1eff8;
  stroke: #cfc7ed;
}

.graph-node.final rect {
  fill: #e8f2ef;
  stroke: #add0c5;
}

.graph-node text {
  fill: #514761;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  text-anchor: middle;
}

.graph-link {
  stroke: #918a98;
  stroke-width: 1.2;
}

.tile-grid rect {
  fill: #fff;
  stroke: #c9c6ce;
}

.tile-grid rect.selected {
  fill: #e9e4fa;
  stroke: var(--violet);
  stroke-width: 2;
}

.tile-grid text {
  fill: #77717e;
  font-family: var(--mono);
  font-size: 8px;
  text-anchor: middle;
}

.byte-strip .base {
  fill: #dedbe2;
}

.byte-strip .f0 { fill: rgba(38, 116, 95, 0.72); }
.byte-strip .f1 { fill: rgba(98, 73, 216, 0.72); }
.byte-strip .f2 { fill: rgba(129, 93, 0, 0.72); }
.byte-strip .f3 { fill: rgba(161, 71, 48, 0.72); }

.byte-strip text {
  fill: var(--ink);
  font-family: var(--mono);
  font-size: 9px;
  text-anchor: middle;
}

.page-end {
  margin-top: 78px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.page-end a {
  color: var(--violet);
}

@media (max-width: 860px) {
  .guide-shell {
    width: 100%;
  }

  .manual-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 34px;
  }

  .manual-nav {
    position: static;
    max-height: none;
  }

  .guide-route {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-route::before,
  .nav-note {
    display: none;
  }
}

@media (max-width: 760px) {
  .guide-shell {
    width: 100%;
  }

  .guide-header {
    grid-template-columns: 1fr auto;
    row-gap: 8px;
    padding: 12px 18px;
  }

  .guide-nav-main {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: space-between;
    gap: 18px;
  }

  .header-formula {
    grid-template-columns: minmax(0, 1fr);
  }

  .header-formula > p {
    grid-column: auto;
  }

  .level-map,
  .stack-flow,
  .process-strip,
  .definition-grid,
  .choice-grid,
  .language-support {
    grid-template-columns: minmax(0, 1fr);
  }

  .stack-flow {
    gap: 8px;
  }

  .stack-connector {
    position: static;
    width: max-content;
    max-width: 100%;
    margin: 0 0 0 18px !important;
    padding: 3px 6px;
    font-size: 7px;
    transform: none;
  }

  .stack-connector::after {
    content: none;
  }

  .code-toolbar {
    align-items: stretch;
  }

  .code-tabs {
    overflow-x: auto;
  }

  .code-tab {
    min-width: 62px;
  }

  .guide-section {
    scroll-margin-top: 126px;
  }

  .story-figure > svg {
    min-width: 660px;
  }
}

@media (max-width: 430px) {
  .guide-route {
    grid-template-columns: minmax(0, 1fr);
  }

  .guide-nav-main {
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
