.pattern,.runner { scroll-margin-top: 16px; }
.pattern-layout {
  display: grid; grid-template-columns: minmax(0,.89fr) minmax(0,1.11fr);
  grid-template-areas: "head art" "intro art" "controls art";
  grid-template-rows: auto auto 1fr; align-items: start; column-gap: clamp(38px,6.5vw,112px);
}
.pattern .chapter-head { grid-area: head; display: block; margin: 0; }
.pattern .chapter-head h2 { font-size: clamp(58px,6.5vw,112px); }
.pattern .chapter-head p { max-width: 32em; margin-top: .95em; }
.pattern-intro { grid-area: intro; }
.pattern-intro p,.runner-intro p { max-width: 31em; font: 400 clamp(17px,1.32vw,23px)/1.44 var(--sans); color: #cdd2c7; }
.pattern-controls { grid-area: controls; min-width: 0; display: flex; align-items: end; gap: clamp(18px,2.2vw,40px); margin-top: clamp(21px,2.5vw,42px); }
.pattern-count { min-width: 0; padding: 0; margin: 0; border: 0; }
.pattern-count legend { padding: 0; font: 400 clamp(15px,1.12vw,20px)/1.3 var(--sans); color: #d6c7b6; }
.count-track { --choice-index: 1; display: inline-grid; grid-template-columns: repeat(3,minmax(45px,1fr)); position: relative; isolation: isolate; margin-top: 8px; border-block: 1px solid #8b7966; }
.count-track::before { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(100%/3); background: var(--paper); transform: translateX(calc(100% * var(--choice-index))); transition: transform .39s var(--ease); }
.count-track label { position: relative; display: grid; place-items: center; }
.count-track input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.count-track label span { display: grid; place-items: center; min-width: 46px; min-height: 44px; font: 400 23px/1 var(--serif); }
.count-track input:checked + span { color: var(--ink); }
.count-track input:focus-visible + span { outline: 2px solid var(--copper); outline-offset: 2px; }
.rotation-control { flex: 1; min-width: 0; max-width: 255px; }
.rotation-control label { display: flex; justify-content: space-between; gap: 4px; align-items: baseline; font: 400 clamp(15px,1.14vw,19px)/1.35 var(--sans); }
.rotation-control strong { font: 400 1.35em/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; color: #ecc1a0; }
.rotation-control input { appearance: none; background: transparent; width: 100%; height: 44px; margin: 0; cursor: pointer; }
.rotation-control input::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(to right,#e9a780 var(--fill,0%),#8c7c6b var(--fill,0%)); }
.rotation-control input::-webkit-slider-thumb { appearance: none; width: 19px; height: 19px; margin-top: -8px; background: #e8c9a0; border-radius: 50%; border: 3px solid #be8662; box-shadow: 1px 2px 3px #17120f70; }
.rotation-control input::-moz-range-track { height: 3px; background: #8c7c6b; }
.rotation-control input::-moz-range-progress { height: 3px; background: #e9a780; }
.rotation-control input::-moz-range-thumb { width: 17px; height: 17px; border: 2px solid #be8662; border-radius: 50%; background: #e8c9a0; }
.rotation-control input:focus-visible { outline: none; }
.rotation-control input:focus-visible::-webkit-slider-thumb { outline: 2px solid #f7d6a8; outline-offset: 3px; }
.rotation-control input:focus-visible::-moz-range-thumb { outline: 2px solid #f7d6a8; outline-offset: 3px; }
.pattern-figure {
  grid-area: art; align-self: center; display: grid; justify-items: center; min-width: 0; margin: 0;
}
.pattern-dial { display: block; width: min(100%,590px); height: auto; overflow: visible; }
.mount-edge { fill: #202319; }
.mount-face { fill: var(--reviews-background); stroke: #a68a66; stroke-opacity: .26; stroke-width: .65; }
.mount-rim { fill: none; stroke: #ccb38a; stroke-width: .55; opacity: .36; }
.scale-ticks { fill: none; stroke: #ceb996; stroke-width: 3; stroke-dasharray: .30 9.70; opacity: .49; }
.scale-ticks.major { stroke-width: 5; stroke-dasharray: .4 29.6; opacity: .73; }
.zero-tick { fill: none; stroke: #e0c9a6; stroke-width: .8; }
.petal-bloom {
  transform-box: view-box; transform-origin: 0 0;
}
.drawing-ray .petal-bloom {
  transform: rotate(calc((var(--spread,1) - 1) * 4deg))
             scale(calc(.24 + .76 * var(--extension,1)), calc(.065 + .935 * var(--spread,1)));
  opacity: clamp(0, calc(var(--extension,1) * 4), 1);
}
.drawing-ray.is-folding > .petal-bloom { visibility: hidden; }
:where(html[data-motion="on"]) .pattern-dial.changing-count .petal-bloom {
  transition: transform .46s var(--ease), opacity .28s ease;
}
.drawing-ray.unused .petal-bloom { opacity: 0; transform: rotate(-4deg) scale(.24,.065); }
.angle-arc,.angle-arrow { fill: none; stroke: #ecc19a; stroke-width: 1.18; stroke-linecap: round; stroke-linejoin: round; opacity: var(--sector,1); }
.arc-start { fill: #ecc19a; opacity: var(--sector,1); }
.dial-rotor .flower-heart { opacity: var(--core-ink,1); }
.runner.is-live .trace-dial:not(:has(.printed)) .flower-heart { visibility: hidden; }
.trace-spoke.latest .petal-bloom { filter: brightness(1.1); }
.scale-label { fill: #d7c5aa; font: 11px var(--sans); }
.sector-label { fill: #f6c7a3; font: italic 20px var(--serif); font-variant-numeric: lining-nums tabular-nums; paint-order: stroke; stroke: #37322d; stroke-width: 3px; stroke-linejoin: round; opacity: var(--angle-ink,1); }
.angle-caption { display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: 3px 16px; padding-block: clamp(8px,1.2vw,19px); }
.angle-caption > :first-child { font: 400 clamp(15px,1.2vw,21px)/1.25 var(--sans); color: #c9bba8; }
.angle-formula { font: 400 clamp(23px,2.3vw,39px)/1.1 var(--serif); color: #ede1cb; font-variant-numeric: lining-nums tabular-nums; letter-spacing: -.04em; white-space: nowrap; }
.angle-formula strong { color: #f4b48f; font-weight: 400; }
.pattern-status { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.runner { --printed-angle-color: #f4b48f; }
.runner-layout { display: grid; grid-template-columns: minmax(0,1.06fr) minmax(220px,.94fr); grid-template-areas: "intro result" "work result"; align-items: center; gap: clamp(18px,2.1vw,40px) clamp(30px,6.2vw,100px); }
.runner-intro { grid-area: intro; }
.runner-intro p { margin-block-start: .65em; }
.notation { --fold-progress: 1; display: flex; align-items: baseline; gap: .55em; margin: 0 0 .35em; font: 400 clamp(23px,2.4vw,43px)/1.2 var(--serif); perspective: 620px; }
.notation i,.notation code { display: inline-block; white-space: nowrap; }
.notation > span { font: 350 .84em var(--sans); color: #ceb797; }
.notation code { font: 400 .76em/1.2 Consolas,monospace; color: #e8bda1; }
:where(html[data-motion="on"]) .notation i { transform-origin: bottom; transform: rotateX(calc(-23deg * var(--fold-progress))); }
:where(html[data-motion="on"]) .notation code { transform-origin: top; transform: translateY(calc((1 - var(--fold-progress)) * .24em)) rotateX(calc((1 - var(--fold-progress)) * 48deg)); opacity: calc(.68 + .32 * var(--fold-progress)); }
.runner-intro p code { font-size: .92em; color: #f2bd98; }
.runner-work { grid-area: work; min-width: 0; }
.source-panel {
  --pad: clamp(14px,1.65vw,27px); --row: clamp(28px,2.9vw,49px); --line: 0;
  position: relative; isolation: isolate; overflow: hidden; border-block: 1px solid #b6a68b64;
  background: #0c0c0c;
}
.source-code { position: relative; z-index: 1; overflow-x: auto; margin: 0; padding: var(--pad) clamp(8px,1.7vw,30px); }
.source-code code { display: grid; grid-auto-rows: var(--row); white-space: normal; font: 400 clamp(13px,1.32vw,22px)/var(--row) Consolas,"Courier New",monospace; }
.source-line { white-space: pre; color: #deddd0; }
.source-line em { color: #ffb694; font-style: normal; }
.source-line b { color: #e5d9b2; font-weight: 500; }
.exec-marker { display: none; position: absolute; z-index: 0; left: 0; right: 0; top: var(--pad); height: var(--row); border-left: 3px solid #f4b08b; background: linear-gradient(90deg,#d3be8d35,#d3be8d0c); transform: translateY(calc(100% * var(--line))); transition: transform .26s var(--ease); }
.runner.is-live .exec-marker { display: block; }
.source-line.line-active { color: white; }
.line-active .print-command { color: #f4b08b; }
.run-controls { display: flex; align-items: center; gap: 12px; margin-top: 15px; }
.run-controls button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px; padding: 8px 17px; border: 1px solid #b8aa9580; border-radius: 2px; font-size: clamp(15px,1.12vw,19px); }
.play-loop { min-width: 112px; background: #dfc7a8; color: #2c2723; }
.step-loop { color: #f3edde; }
.step-loop i { font: normal 20px/1 var(--sans); }
.runner-result { grid-area: result; min-width: 0; display: grid; justify-items: center; gap: 18px; }
.trace-dial { display: block; width: min(100%,26vw,405px); height: auto; overflow: visible; }
.trace-ring { fill: var(--reviews-background); stroke: #bdb79e; stroke-width: .8; stroke-opacity: .49; stroke-dasharray: 2 2.6; }
.trace-axis { stroke: #cbbd9f; stroke-width: .85; }
.trace-angle-mark { stroke: var(--printed-angle-color); stroke-width: 2; stroke-linecap: round; }
.trace-zero { font: 12px var(--sans); fill: #d7cdb7; }
.trace-spoke.unused { display: none; }
.trace-spoke .petal-bloom { transition: transform .38s var(--ease), opacity .25s ease; }
.runner.is-live .trace-spoke:not(.printed) .petal-bloom { opacity: 0; transform: rotate(-8deg) scale(.13,.03); }
.run-controls button:disabled { opacity: .48; cursor: default; }
.result-readout { width: min(100%,390px); }
.result-title { font-size: clamp(14px,1.2vw,20px); color: #d9cbb7; }
.run-register { margin-block: 5px 8px; font: 500 clamp(18px,2.05vw,35px)/1.1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.run-register strong { color: var(--printed-angle-color); font-weight: 500; }
.output-strip { display: grid; grid-template-columns: repeat(var(--columns,4),minmax(0,1fr)); gap: 4px; min-height: 32px; }
.output-strip span { padding: 7px 0; text-align: center; border-bottom: 1px solid #9ba8a06b; font: 400 clamp(13px,1.15vw,19px)/1.1 Consolas,monospace; }
.output-strip span.just-printed { color: var(--printed-angle-color); border-color: currentColor; animation: print-value .22s ease-out; }
@keyframes print-value { from { opacity: .55; } }

@media (max-width: 960px) {
  .pattern-layout { grid-template-columns: minmax(0,1fr) minmax(0,1.08fr); column-gap: 26px; }
  .pattern .chapter-head h2 { font-size: clamp(52px,6.8vw,68px); }
  .pattern-controls { gap: 13px; }
}
@media (max-width: 760px) {
  .pattern-layout { grid-template-columns: minmax(0,1fr); grid-template-areas: "head" "intro" "controls" "art"; grid-template-rows: auto; }
  .pattern .chapter-head h2 { font-size: clamp(45px,11.4vw,79px); }
  .pattern .chapter-head p { margin-top: 11px; }
  .runner-intro p { margin-block-start: 7px; }
  .pattern-controls { width: min(100%,495px); gap: clamp(13px,4vw,24px); margin-top: 15px; }
  .count-track { grid-template-columns: repeat(3,44px); margin-top: 5px; }
  .count-track label span { min-width: 44px; min-height: 44px; font-size: 21px; }
  .rotation-control { max-width: none; }
  .rotation-control label,.pattern-count legend { font-size: 15px; }
  .pattern-figure { width: min(100%,555px); justify-self: center; margin-top: 12px; }
  .angle-caption { padding-block: 11px 13px; }
  .runner-layout { grid-template-columns: minmax(0,1fr); grid-template-areas: "intro" "work" "result"; gap: 18px; }
  .source-panel { --pad: 12px; --row: clamp(25px,4.5vw,35px); }
  .source-code { padding-inline: 11px 3px; }
  .source-code code { font-size: clamp(12px,3.05vw,18px); }
  .run-controls { margin-top: 11px; }
  .runner-result { grid-template-columns: minmax(104px,.92fr) minmax(134px,1fr); align-items: center; justify-items: start; gap: 12px; }
  .trace-dial { width: min(100%,225px); justify-self: center; }
  .trace-zero { font-size: 21px; }
  .output-strip { gap: 2px; }
  .output-strip span { font-size: 12px; }
}
@media (max-width: 760px) and (max-height: 360px) and (orientation: landscape) {
  .source-panel { --row: clamp(25px,4.5vw,28px); }
}
@media (max-width: 380px) {
  .pattern-controls { gap: 13px; }
  .rotation-control label { flex-wrap: wrap; gap: 0 4px; }
  .run-controls { gap: 8px; }
  .run-controls button { padding-inline: 13px; }
}
@media (forced-colors: active) {
  .count-track input:checked + span { outline: 2px solid Highlight; outline-offset: -4px; }
  .rotation-control input { appearance: auto; }
  .rotation-control input:focus-visible { outline: 2px solid Highlight; outline-offset: 0; }
  .pattern-dial,.trace-dial { forced-color-adjust: none; }
}
