:root {
  color-scheme: light;
  --page: #f6f5fb;
  --paper: #fff;
  --ink: #201937;
  --muted: #5f5873;
  --line: #ded9e9;
  --purple: #5135b2;
  --purple-dark: #402394;
  --tint: #eee8ff;
  --terminal: #201a33;
  --terminal-top: #2b2342;
  --terminal-text: #ece6f8;
  --green: #d5f5aa;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: "Space Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); font: 1rem/1.6 var(--sans); }
h1, h2, h3, p { margin: 0; }
a { color: var(--purple-dark); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
button, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; }
pre, code { font-family: var(--mono); }
code { font-size: .88em; }
:not(pre) > code { white-space: nowrap; }
pre { margin: 0; }
pre code { font-size: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid #7a53d4; outline-offset: 3px; }
.frame { width: min(1160px, calc(100% - 96px)); margin-inline: auto; }
.skip-link { position: fixed; top: 1rem; left: 1rem; z-index: 5; padding: .6rem 1rem; background: var(--paper); transform: translateY(-200%); }
.skip-link:focus { transform: none; }

.topbar { border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar-inner { min-height: 4.4rem; display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; }
.wordmark { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); text-decoration: none; font-size: 1.05rem; font-weight: 700; white-space: nowrap; }
.mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .42rem; background: var(--purple); color: white; font: 600 .88rem var(--mono); }
.topbar nav, .lab-footer nav { display: flex; flex-wrap: wrap; gap: .65rem 1.65rem; }
.topbar nav a, .home-link, .lab-footer nav a { color: var(--muted); font-size: .9rem; font-weight: 600; text-decoration: none; }
.topbar nav a:hover, .home-link:hover, .lab-footer nav a:hover { color: var(--purple-dark); text-decoration: underline; }

.hero { display: grid; grid-template-columns: 1.18fr .82fr; align-items: center; gap: clamp(1.5rem, 5.5vw, 5rem); padding: clamp(3.4rem, 7vw, 6rem) 0 clamp(3rem, 6vw, 5.3rem); border-bottom: 1px solid var(--line); }
.eyebrow { display: flex; align-items: center; gap: .75rem; color: var(--purple-dark); font: 600 .78rem/1.45 var(--mono); letter-spacing: .095em; }
.eyebrow-rule { display: inline-block; width: 1.75rem; height: 2px; background: #9d7ff0; }
.hero h1 { margin: .5rem 0 .85rem; font-size: clamp(3.35rem, 7.1vw, 7rem); line-height: .99; letter-spacing: -.072em; }
.hero h1 span { color: var(--purple); }
.hero-summary { max-width: 32rem; color: var(--muted); font-size: clamp(1.05rem, 1.7vw, 1.32rem); line-height: 1.5; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.65rem; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .52rem; min-height: 2.8rem; padding: .57rem 1.02rem; border: 1px solid transparent; border-radius: .45rem; font-size: .92rem; font-weight: 700; line-height: 1.35; text-decoration: none; }
.primary { background: var(--purple); color: #fff; }
.primary:hover { background: var(--purple-dark); }
.primary:disabled { opacity: .68; }
.outline { border-color: #c9bee4; background: var(--paper); color: var(--purple-dark); }
.outline:hover { border-color: var(--purple); background: var(--tint); }

.hero-diagram { min-width: 0; padding: 1.25rem; border: 1px solid #d9cfee; border-radius: .8rem; background-color: #eee9f8; background-image: radial-gradient(#d2c2eb 1px, transparent 1px); background-size: 12px 12px; box-shadow: 0 8px 0 #e7dff4; }
.diagram-title { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .85rem; color: var(--purple-dark); font: 600 .75rem/1.4 var(--mono); letter-spacing: .08em; }
.diagram-title a { padding: .15rem .45rem; background: var(--paper); border: 1px solid #d9cfee; border-radius: .25rem; text-decoration: none; letter-spacing: 0; }
.diagram-title a:hover { border-color: var(--purple); }
.diagram-flow { position: relative; display: grid; gap: .65rem; }
.diagram-flow::before { content: ""; position: absolute; top: 1rem; bottom: 1rem; left: 1.9rem; width: 1px; background: #8872bb; }
.diagram-node { position: relative; display: grid; grid-template-columns: 2.2rem auto minmax(0, 1fr); align-items: center; gap: .62rem; min-height: 3.35rem; padding: .5rem .75rem; border: 1px solid #d9cfee; border-radius: .4rem; background: var(--paper); }
.diagram-icon { display: grid; place-items: center; height: 2.05rem; border-radius: .25rem; background: var(--tint); color: var(--purple-dark); font: 600 .85rem var(--mono); }
.diagram-node code { justify-self: end; color: var(--muted); font-size: .72rem; text-align: right; }
.diagram-node strong { font-size: .95rem; line-height: 1.3; }
.diagram-node.verified { border-color: var(--terminal); background: var(--terminal); color: #fff; }
.verified .diagram-icon { background: var(--green); color: #273318; }
.verified code { color: var(--green); }

.lab-section { padding-top: 3.7rem; scroll-margin-top: 1rem; }
.section-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .45rem 1.5rem; margin-bottom: 1.1rem; }
.section-heading h2 { font-size: clamp(2rem, 4.6vw, 3.35rem); line-height: 1.06; letter-spacing: -.055em; }
.section-heading > p { max-width: 31rem; color: var(--muted); }
.notice { margin-top: 1rem; }
.workbench, .pipeline-box, .developer-box, .experiment { border: 1px solid var(--line); border-radius: .7rem; background: var(--paper); box-shadow: 0 4px 0 #eee9f5; }
.workbench-controls { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem 1rem; padding: 1rem 1.15rem; }
.control-group { display: grid; gap: .3rem; }
.control-group > label, .control-group legend, .rtl-control label { color: var(--muted); font-size: .85rem; font-weight: 700; }
select { appearance: none; min-height: 2.65rem; max-width: 100%; padding: .4rem 2.2rem .4rem .72rem; border: 1px solid #d4cce3; border-radius: .4rem; background: linear-gradient(45deg, transparent 50%, #685394 50%) right 1rem center / .28rem .28rem no-repeat, linear-gradient(135deg, #685394 50%, transparent 50%) right .73rem center / .28rem .28rem no-repeat, var(--paper); color: var(--ink); font-size: .91rem; font-weight: 600; }
select:hover { border-color: #917db7; }
.optimization { min-width: 0; padding: 0; margin: 0; border: 0; }
.optimization legend { padding: 0; margin-bottom: .3rem; }
.segmented { display: flex; align-items: center; min-height: 2.65rem; padding: .2rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--page); }
.segmented input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.segmented label { cursor: pointer; padding: .4rem .65rem; border-radius: .25rem; color: var(--muted); font: 500 .87rem/1.4 var(--mono); }
.segmented input:focus-visible + label { outline: 2px solid #7a53d4; outline-offset: 2px; }
.segmented input:checked + label { background: var(--tint); color: var(--purple-dark); box-shadow: 0 0 0 1px #e0d5ff; }
.run-button { margin-left: auto; min-height: 2.65rem; }
.run-button span { font-size: .7rem; }

.workbench-grid { display: grid; grid-template-columns: 1fr 1fr; border-block: 1px solid var(--line); }
.editor-pane, .assembly-pane { min-width: 0; }
.editor-pane { background: #fbfaff; }
.assembly-pane { background: var(--terminal); color: var(--terminal-text); }
.pane-heading, .snippet-bar { display: flex; justify-content: space-between; align-items: center; gap: .65rem; min-height: 2.75rem; padding: .3rem .95rem; }
.pane-heading { border-bottom: 1px solid var(--line); background: #f2eef9; }
.assembly-pane .pane-heading { border-color: #443859; background: var(--terminal-top); }
.pane-heading > label, .pane-heading > strong { display: flex; align-items: center; gap: .55rem; font: 600 .84rem/1.4 var(--mono); }
.language-icon { display: grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: .25rem; background: #e6dcfa; color: var(--purple-dark); }
.assembly-pane .language-icon { background: #44365d; color: #dac6ff; }
.text-button { padding: .27rem .5rem; border: 1px solid transparent; border-radius: .25rem; background: transparent; color: inherit; font-size: .86rem; line-height: 1.32; }
.text-button:hover { border-color: currentColor; }
.text-button:disabled { opacity: .5; cursor: default; }
.editor-body { display: flex; align-items: stretch; height: 17.75rem; }
.editor-body textarea, .line-numbers, .assembly-code, .snippet pre { font: 400 .84rem/1.64 var(--mono); tab-size: 4; }
.line-numbers { flex: 0 0 2.85rem; overflow: hidden; padding: .85rem .65rem; border-right: 1px solid #ece6f5; color: #6d6285; text-align: right; user-select: none; }
.editor-body textarea { width: 100%; min-width: 0; padding: .85rem .8rem; margin: 0; resize: none; border: 0; outline-offset: -3px; background: transparent; color: var(--ink); }
.assembly-code { height: 17.75rem; padding: .85rem .95rem; overflow: auto; white-space: pre; outline-offset: -3px; }
.code-heading { color: #d8c0ff; }
.code-op { color: #b6defb; }
.code-immediate { color: var(--green); }
.code-diagnostic { color: #ffd1c6; }
.workbench-footer { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .25rem 1rem; padding: .62rem 1rem; color: var(--muted); font-size: .85rem; }
.compile-status { font-weight: 700; }
.compile-status[data-state="success"] { color: #385422; }
.compile-status[data-state="error"] { color: #9d3123; }
.example-note, .scope-note { margin-top: .95rem; color: var(--muted); }
.local-details { margin-top: .9rem; padding: .62rem .85rem; border: 1px solid var(--line); border-radius: .42rem; background: var(--paper); }
.local-details summary { cursor: pointer; color: var(--purple-dark); font-weight: 700; }
.local-body { display: grid; gap: .75rem; margin-block: .8rem .2rem; }
.local-body .button { justify-self: start; }

.pipeline-tabs, .developer-tabs { display: grid; background: #f0ebf9; border-radius: .65rem .65rem 0 0; border-bottom: 1px solid var(--line); }
.pipeline-tabs { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.developer-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pipeline-tabs button, .developer-tabs button { min-height: 3.15rem; padding: .5rem .45rem; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-size: .95rem; font-weight: 700; }
.pipeline-tabs button + button, .developer-tabs button + button { border-left: 1px solid var(--line); }
.pipeline-tabs button:first-child, .developer-tabs button:first-child { border-top-left-radius: .65rem; }
.pipeline-tabs button:last-child, .developer-tabs button:last-child { border-top-right-radius: .65rem; }
.pipeline-tabs button:hover, .developer-tabs button:hover { background: var(--tint); color: var(--purple-dark); }
.pipeline-tabs button[aria-selected="true"], .developer-tabs button[aria-selected="true"] { border-bottom-color: var(--purple); background: var(--paper); color: var(--purple-dark); }
.pipeline-tabs button:focus-visible, .developer-tabs button:focus-visible { outline-offset: -4px; }
.stage-panel, .developer-panel { display: grid; grid-template-columns: minmax(0, .84fr) minmax(0, 1.16fr); gap: 1.25rem; padding: 1.2rem; }
.stage-description, .developer-description { display: flex; align-items: start; flex-direction: column; gap: .6rem; }
.stage-description h3, .developer-description h3, .experiment h3 { font-size: clamp(1.4rem, 2.5vw, 1.85rem); line-height: 1.14; letter-spacing: -.04em; }
.stage-description p, .developer-description p, .experiment-copy p { color: var(--muted); }
.stage-description .file-label { font: 500 .78rem/1.5 var(--mono); color: var(--purple-dark); overflow-wrap: anywhere; }
.source-link { font-weight: 700; font-size: .9rem; }
.rtl-control { display: grid; gap: .25rem; }
.snippet { min-width: 0; overflow: hidden; border: 1px solid #483a60; border-radius: .5rem; background: var(--terminal); color: var(--terminal-text); }
.snippet-bar { background: var(--terminal-top); border-bottom: 1px solid #483a60; }
.snippet-bar span { font: 500 .78rem/1.45 var(--mono); overflow-wrap: anywhere; }
.snippet pre { max-height: 19rem; padding: .8rem .95rem; overflow: auto; outline-offset: -3px; }
.stage-panel .snippet pre, .developer-panel .snippet pre { min-height: 10rem; }
.light-snippet { border-color: var(--line); background: #fbfaff; color: var(--ink); }
.light-snippet .snippet-bar { background: #f2eef9; border-color: var(--line); }
.pipeline-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; padding: .65rem 1.2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }

.experiment { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.4rem; margin-top: 1.1rem; padding: 1.2rem; }
.experiment-copy > p { margin-top: .5rem; }
.experiment-controls { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .75rem; }
.experiment-copy .experiment-result { margin-top: .75rem; color: var(--purple-dark); font-weight: 700; }
.cfg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: center; justify-items: center; gap: .65rem .55rem; padding: 0; margin: 0; list-style: none; }
.cfg li { position: relative; z-index: 0; display: flex; align-items: center; justify-content: space-between; gap: .45rem; width: 100%; min-height: 2.6rem; padding: .4rem .6rem; border: 1px solid #d9cfee; border-radius: .35rem; background: var(--page); color: var(--muted); font-size: .84rem; }
.cfg li code { color: var(--ink); }
.cfg li[data-visited] { border-color: #9475d9; background: var(--tint); color: var(--purple-dark); }
.cfg li[aria-current="step"] { border-color: var(--purple); background: var(--purple); color: #fff; }
.cfg li[aria-current="step"] code { color: #fff; }
.cfg .cfg-entry, .cfg .cfg-branch { grid-column: 1 / -1; width: 50%; min-width: 7rem; }
.cfg-branch::before, .cfg-true::before, .cfg-false::before { content: ""; position: absolute; width: 1px; height: .7rem; top: -.72rem; left: 50%; background: #a090ba; }
.lab-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .9rem; margin-top: 3.6rem; padding-block: 1.25rem 2.3rem; border-top: 1px solid var(--line); }

@media (max-width: 1020px) {
  .frame { width: calc(100% - 56px); }
  .section-heading { display: grid; }
}
@media (max-width: 800px) {
  .hero { gap: 1rem; }
  .diagram-node { grid-template-columns: 1.9rem 1fr; gap: .2rem .55rem; }
  .diagram-icon { grid-row: 1 / span 2; }
  .diagram-node code { justify-self: start; text-align: left; }
}
@media (max-width: 660px) {
  .frame { width: calc(100% - 32px); }
  .topbar-inner { flex-wrap: wrap; gap: .5rem; padding-block: .65rem; }
  .topbar nav { order: 3; justify-content: space-between; width: 100%; gap: .5rem; padding-top: .45rem; border-top: 1px solid var(--line); }
  .hero { grid-template-columns: 1fr; gap: 1.7rem; padding-block: 2.55rem 2.5rem; }
  .hero h1 { font-size: clamp(3rem, 12vw, 5rem); }
  .hero-diagram { padding: .8rem; }
  .diagram-node { grid-template-columns: 1.9rem auto minmax(0, 1fr); gap: .55rem; }
  .diagram-icon { grid-row: auto; }
  .diagram-node code { justify-self: end; text-align: right; }
  .lab-section { padding-top: 2.75rem; }
  .workbench-controls { padding: .72rem; gap: .6rem; }
  .run-button { flex: 1; }
  .workbench-grid, .stage-panel, .developer-panel, .experiment { grid-template-columns: minmax(0, 1fr); }
  .stage-panel, .developer-panel, .experiment { gap: .8rem; padding: .85rem; }
  .editor-body, .assembly-code { height: 14rem; }
  .pipeline-tabs button, .developer-tabs button { font-size: .85rem; padding-inline: .2rem; }
}
@media (max-width: 360px) {
  .pipeline-tabs { grid-template-columns: repeat(3, 1fr); }
  .diagram-node code { font-size: .66rem; }
  .diagram-node strong { font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
