/* =========================================================
   Bézier Sphere — "Cercles & Lignes" design system
   Paper, ink hairlines and a single red line.
   ========================================================= */

:root {
    --paper: #F6F4EE;
    --sand: #EFECE4;
    --card: #FBFAF6;
    --ink: #141414;
    --red: #E0464E;
    --graphite: #55524B;
    --stone: #8A877F;
    --rule: #D9D5CB;
    --rule-strong: #CFCBC1;
    --body: #3A3832;

    --serif: 'EB Garamond', 'Iowan Old Style', Georgia, serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    --gutter: 48px;
    --nav-h: 64px;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 19px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

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

button, input, select {
    font: inherit;
    color: inherit;
}

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

[hidden] {
    display: none !important;
}

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

/* ----- Type helpers ----- */
.mono {
    font-family: var(--mono);
}

.eyebrow {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--stone);
}

.caption {
    font-style: italic;
    font-size: 17px;
    line-height: 1.35;
    color: var(--body);
}

.caption b {
    font-style: normal;
    font-weight: 500;
}

.coords {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--stone);
    letter-spacing: 0.02em;
}

.accent {
    color: var(--red);
}

em.accent, .display em {
    font-style: italic;
}

.display {
    font-weight: 400;
    font-size: clamp(52px, 6.4vw, 92px);
    line-height: 0.98;
    letter-spacing: -0.025em;
}

.h1 {
    font-weight: 400;
    font-size: clamp(48px, 5.6vw, 80px);
    line-height: 1;
    letter-spacing: -0.02em;
}

.h2 {
    font-weight: 400;
    font-size: clamp(34px, 3.6vw, 52px);
    line-height: 1.05;
    letter-spacing: -0.015em;
}

.h3 {
    font-weight: 400;
    font-size: clamp(28px, 2.8vw, 40px);
    line-height: 1.1;
}

.lede {
    font-size: 22px;
    line-height: 1.42;
    color: var(--body);
    max-width: 34em;
}

/* ----- Buttons, chips, keys, tags ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 48px;
    padding: 0 22px;
    border: 1px solid var(--ink);
    border-radius: 24px;
    background: transparent;
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.04em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:hover {
    background: var(--ink);
    color: var(--paper);
}

.btn--primary {
    background: var(--ink);
    color: var(--paper);
}

.btn--primary:hover {
    background: var(--red);
    border-color: var(--red);
}

.btn--sm {
    height: 36px;
    padding: 0 16px;
    font-size: 12px;
}

.btn[aria-pressed="true"] {
    background: var(--ink);
    color: var(--paper);
}

.btn--danger:hover {
    background: var(--red);
    border-color: var(--red);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--rule-strong);
    border-radius: 15px;
    background: transparent;
    font-family: var(--mono);
    font-size: 12px;
    cursor: pointer;
}

.chip:hover {
    border-color: var(--ink);
}

.chip[aria-pressed="true"] {
    border-color: var(--red);
    color: var(--red);
}

.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 11px;
    font-style: normal;
}

.tag {
    display: inline-block;
    padding: 3px 8px;
    border: 1px solid var(--ink);
    border-radius: 10px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.tag--red {
    border-color: var(--red);
    color: var(--red);
}

.tag--stone {
    border-color: var(--stone);
    color: var(--stone);
}

/* ----- Header & navigation ----- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--gutter);
    background: var(--paper);
    border-bottom: 1px solid var(--ink);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    text-decoration: none;
}

.brand-mark {
    width: 22px;
    height: 22px;
}

.brand-badge {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--stone);
    border: 1px solid var(--rule-strong);
    border-radius: 20px;
    padding: 2px 7px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 20px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--graphite);
}

.nav-link:hover {
    color: var(--ink);
}

.nav-link[aria-current="page"] {
    color: var(--ink);
    border-color: var(--ink);
}

.nav-link--gh {
    margin-left: 12px;
    background: var(--ink);
    color: var(--paper);
}

.nav-link--gh:hover {
    color: var(--paper);
    background: var(--red);
}

.nav-toggle {
    display: none;
    background: none;
    border: 0;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 8px 0;
}

/* ----- Footer ----- */
.site-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 32px;
    justify-content: space-between;
    align-items: center;
    padding: 28px var(--gutter);
    border-top: 1px solid var(--ink);
    font-size: 16px;
}

.site-footer b {
    font-weight: 500;
}

.footer-links {
    display: flex;
    gap: 24px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.footer-links a {
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--red);
}

/* ----- Shared layout ----- */
.section {
    padding: 88px var(--gutter);
}

.section--sand {
    background: var(--sand);
}

.section--ruled {
    border-top: 1px solid var(--ink);
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 40px;
}

.section-head .eyebrow {
    margin-bottom: 10px;
}

.rule {
    border: 0;
    border-top: 1px solid var(--ink);
}

.hair {
    border: 0;
    border-top: 1px solid var(--rule);
}

/* Sphere plates rendered by shared.js */
.plate svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.figure {
    border: 1px solid var(--ink);
    background: var(--card);
}

/* ----- Home ----- */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    align-items: center;
    padding: 64px var(--gutter) 48px;
}

.hero .display {
    margin: 22px 0 28px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 36px;
}

.hero-plate {
    max-width: 640px;
    justify-self: center;
    width: 100%;
}

.hero-plate figcaption, .plate-caption {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 6% 0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
}

.stat {
    padding: 22px var(--gutter);
}

.stat + .stat {
    border-left: 1px solid var(--ink);
}

.stat-value {
    font-size: 44px;
    line-height: 1;
    margin-bottom: 8px;
}

.plates {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 32px;
}

.plates .figure {
    aspect-ratio: 4 / 4.5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6%;
}

.plates .figure .plate {
    width: 88%;
}

.plate-title {
    display: flex;
    gap: 12px;
    font-size: 22px;
    margin: 14px 0 6px;
}

.thumbs {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 24px;
}

.thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-family: var(--mono);
    font-size: 11px;
    text-align: center;
}

.thumb .plate {
    width: 100%;
    max-width: 160px;
    transition: transform 0.2s;
}

.thumb:hover .plate {
    transform: scale(1.04);
}

.thumb span + span {
    color: var(--stone);
}

.colophon {
    display: grid;
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 80px;
}

.colophon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px 56px;
}

.colophon-grid .eyebrow {
    margin-bottom: 6px;
}

/* ----- Visualizer ----- */
.page-visualizer {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace {
    flex: 1;
    min-height: 0;
    display: flex;
}

.stage {
    position: relative;
    flex: 1;
    min-width: 0;
    background: var(--sand);
    overflow: hidden;
}

#canvas {
    position: absolute;
    inset: 0;
}

#canvas canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

#canvas canvas:active {
    cursor: grabbing;
}

.stage-caption {
    position: absolute;
    top: 28px;
    left: 32px;
    pointer-events: none;
}

.stage-caption h1 {
    font-weight: 400;
    font-size: 30px;
    line-height: 1.15;
    margin: 6px 0;
}

.stage-caption .coords {
    color: var(--graphite);
    font-size: 12px;
}

.stage-toolbar {
    position: absolute;
    top: 28px;
    right: 32px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 60%;
}

.stage-toolbar .btn {
    background: var(--paper);
}

.stage-toolbar .btn:hover, .stage-toolbar .btn[aria-pressed="true"] {
    background: var(--ink);
}

.stage-shortcuts {
    position: absolute;
    left: 32px;
    bottom: 28px;
    display: flex;
    gap: 24px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--graphite);
    pointer-events: none;
}

.stage-shortcuts span {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.readout {
    position: absolute;
    right: 32px;
    bottom: 28px;
    display: flex;
    gap: 32px;
    padding: 14px 20px;
    border: 1px solid var(--ink);
    border-radius: 8px;
    background: var(--paper);
}

.readout dt {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--stone);
}

.readout dd {
    font-family: var(--mono);
    font-size: 20px;
}

.toast {
    position: absolute;
    left: 50%;
    bottom: 96px;
    transform: translate(-50%, 8px);
    padding: 10px 16px;
    border-radius: 20px;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--mono);
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Theme-aware overlay colours for dark plates */
.stage[data-theme="blueprint"], .stage[data-theme="night"] {
    color: #F6F4EE;
}

.stage[data-theme="blueprint"] .stage-caption .coords,
.stage[data-theme="night"] .stage-caption .coords,
.stage[data-theme="blueprint"] .stage-shortcuts,
.stage[data-theme="night"] .stage-shortcuts,
.stage[data-theme="blueprint"] .eyebrow,
.stage[data-theme="night"] .eyebrow {
    color: rgba(246, 244, 238, 0.72);
}

.stage[data-theme="blueprint"] .readout,
.stage[data-theme="night"] .readout,
.stage[data-theme="blueprint"] .stage-toolbar .btn,
.stage[data-theme="night"] .stage-toolbar .btn {
    color: var(--ink);
}

.panel {
    width: 400px;
    flex: none;
    overflow-y: auto;
    padding: 28px;
    border-left: 1px solid var(--ink);
    background: var(--paper);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.panel[hidden] {
    display: none;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.link-btn {
    background: none;
    border: 0;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--graphite);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.point legend {
    font-size: 22px;
    margin-bottom: 10px;
}

.point legend span {
    color: var(--red);
}

.point {
    border: 0;
}

.field-row {
    display: flex;
    gap: 10px;
}

.field {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label, .field-label {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--stone);
}

.input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--ink);
    border-radius: 6px;
    background: var(--card);
    font-family: var(--mono);
    font-size: 15px;
}

.input::placeholder {
    color: var(--stone);
}

.input:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 1px var(--red);
}

.input[aria-invalid="true"] {
    border-color: var(--red);
}

.actions {
    display: flex;
    gap: 10px;
}

.actions .btn--primary {
    flex: 1;
}

.message {
    min-height: 1.2em;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--graphite);
}

.message:empty {
    display: none;
}

.message.error {
    color: var(--red);
}

.list {
    list-style: none;
}

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 0;
    border: 0;
    border-bottom: 1px solid var(--rule);
    background: none;
    font-size: 17px;
    text-align: left;
    cursor: pointer;
}

.list-row .coords {
    flex: none;
}

.list-row:hover, .list-row[aria-current="true"] {
    color: var(--red);
}

.list-row[aria-current="true"] .coords {
    color: var(--red);
}

.list-row[aria-current="true"] span:first-child::before {
    content: '● ';
    font-size: 0.7em;
    vertical-align: 0.15em;
}

.saved-row {
    display: flex;
    gap: 8px;
}

.saved-row .input {
    flex: 1;
}

.saved-item {
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--rule);
}

.saved-item .list-row {
    flex: 1;
    border-bottom: 0;
}

.saved-delete {
    background: none;
    border: 0;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--stone);
    cursor: pointer;
    padding: 6px;
}

.saved-delete:hover {
    color: var(--red);
}

.empty {
    padding: 10px 0;
    font-style: italic;
    font-size: 16px;
    color: var(--stone);
}

/* ----- Method ----- */
.article-head, .step {
    display: grid;
    grid-template-columns: 300px minmax(0, 820px);
    gap: 80px;
    padding: 56px var(--gutter);
}

.article-head {
    padding-top: 80px;
    padding-bottom: 40px;
}

.article-head .lede {
    margin-top: 28px;
    font-size: 24px;
    max-width: none;
}

.step-num {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 10px;
}

.step-aside .caption {
    margin-top: 20px;
}

.step-body {
    display: flex;
    flex-direction: column;
    gap: 22px;
    font-size: 20px;
    line-height: 1.5;
}

.equation {
    padding: 22px 26px;
    border: 1px solid var(--ink);
    border-radius: 6px;
    background: var(--card);
    font-family: var(--mono);
    font-size: 17px;
    line-height: 1.75;
    overflow-x: auto;
    white-space: pre;
}

.figure-row {
    display: grid;
    grid-template-columns: minmax(0, 260px) minmax(0, 560px);
    gap: 28px;
    align-items: end;
}

.figure-row figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.figure-row .plate, .figure-row .plot {
    width: 100%;
}

.stack {
    border-top: 1px solid var(--ink);
}

.stack div {
    display: grid;
    grid-template-columns: 260px 1fr;
    padding: 14px 0;
    border-bottom: 1px solid var(--rule);
    font-size: 19px;
}

.stack dd {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--graphite);
    align-self: center;
}

.rule-wrap {
    padding: 0 var(--gutter);
}

/* ----- Routes ----- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: space-between;
    align-items: flex-end;
    padding: 64px var(--gutter) 32px;
}

.page-head .eyebrow {
    margin-bottom: 14px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filters .spacer {
    width: 16px;
}

.route-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 32px;
    padding: 16px var(--gutter) 88px;
}

.route-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 20px 18px;
    border: 1px solid var(--ink);
    background: var(--card);
}

.route-card-head, .route-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
}

.route-card .plate {
    width: 76%;
    margin: 0 auto;
}

.route-card h2 {
    font-weight: 400;
    font-size: 22px;
}

.route-card-meta .coords {
    color: var(--graphite);
    line-height: 1.5;
}

.route-card-meta .km {
    font-family: var(--mono);
    font-size: 13px;
    white-space: nowrap;
}

.route-card-actions {
    display: flex;
    gap: 8px;
}

.route-card-actions .btn:first-child {
    flex: 1;
}

.route-empty {
    grid-column: 1 / -1;
    padding: 48px 0;
    text-align: center;
}

/* ----- Settings ----- */
.settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 760px) minmax(0, 1fr);
    gap: 72px;
    padding: 64px var(--gutter) 88px;
}

.settings-layout .h1 {
    margin: 14px 0 30px;
}

.settings-list {
    border-top: 1px solid var(--ink);
}

.setting {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 64px;
    gap: 28px;
    align-items: center;
    padding: 22px 0;
    border: 0;
    border-bottom: 1px solid var(--rule);
}

.setting-label {
    font-size: 21px;
    line-height: 1.2;
}

.setting-label .caption {
    display: block;
    font-size: 15px;
    margin-top: 2px;
}

.setting-value {
    font-family: var(--mono);
    font-size: 15px;
    text-align: right;
}

.setting-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

.setting--wide .setting-control {
    grid-column: 2 / 4;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 20px;
    background: linear-gradient(to right, var(--red) 0 var(--fill, 50%), transparent var(--fill, 50%)) 0 50% / 100% 3px no-repeat,
                linear-gradient(var(--ink), var(--ink)) 0 50% / 100% 1px no-repeat;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--paper);
    border: 1.5px solid var(--ink);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--paper);
    border: 1.5px solid var(--ink);
}

.swatch {
    position: relative;
}

.swatch input {
    position: absolute;
    opacity: 0;
    inset: 0;
    cursor: pointer;
}

.swatch span {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--swatch);
    border: 1px solid var(--ink);
}

.swatch input:checked + span {
    box-shadow: 0 0 0 3px var(--paper), 0 0 0 4.5px var(--ink);
}

.swatch input:focus-visible + span {
    outline: 2px solid var(--red);
    outline-offset: 5px;
}

.swatch--custom span {
    background: conic-gradient(#E0464E, #C8902E, #2E8B6A, #2F5BEA, #8A4FD0, #E0464E);
}

.segmented {
    display: inline-flex;
    border: 1px solid var(--ink);
    border-radius: 22px;
    overflow: hidden;
}

.segmented label {
    position: relative;
}

.segmented input {
    position: absolute;
    opacity: 0;
}

.segmented span {
    display: block;
    padding: 12px 18px;
    font-family: var(--mono);
    font-size: 12px;
    cursor: pointer;
}

.segmented input:checked + span {
    background: var(--ink);
    color: var(--paper);
}

.segmented input:focus-visible + span {
    outline: 2px solid var(--red);
    outline-offset: -4px;
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    font-family: var(--mono);
    font-size: 13px;
    cursor: pointer;
}

.switch input {
    position: absolute;
    opacity: 0;
}

.switch-track {
    position: relative;
    width: 52px;
    height: 30px;
    border-radius: 15px;
    border: 1px solid var(--ink);
    background: var(--card);
    transition: background 0.15s;
}

.switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ink);
    transition: transform 0.15s, background 0.15s;
}

.switch input:checked + .switch-track {
    background: var(--ink);
}

.switch input:checked + .switch-track::after {
    transform: translateX(22px);
    background: var(--paper);
}

.switch input:focus-visible + .switch-track {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-top: 32px;
}

.settings-preview {
    position: sticky;
    top: calc(var(--nav-h) + 24px);
    align-self: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 40px;
}

.settings-preview .figure {
    width: 100%;
    max-width: 520px;
    padding: 20px;
    background: var(--sand);
    transition: background 0.2s;
}

/* ----- 404 ----- */
.not-found {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    gap: 48px;
    align-items: center;
    padding: 88px var(--gutter);
    min-height: calc(100vh - var(--nav-h) - 90px);
}

.not-found .lede {
    margin: 24px 0 32px;
}

/* ----- Responsive ----- */
@media (max-width: 1100px) {
    .article-head, .step {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .colophon {
        grid-template-columns: 1fr;
        gap: 32px;
    }

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

    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-preview {
        position: static;
        order: -1;
        padding-top: 0;
    }

    .settings-preview .figure {
        max-width: 360px;
    }
}

@media (max-width: 860px) {
    :root {
        --gutter: 20px;
        --nav-h: 56px;
    }

    .brand {
        font-size: 18px;
    }

    .brand-badge {
        display: none;
    }

    .nav-toggle {
        display: block;
    }

    .main-nav {
        display: none;
        position: absolute;
        top: var(--nav-h);
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        padding: 12px var(--gutter) 20px;
        background: var(--paper);
        border-bottom: 1px solid var(--ink);
    }

    .main-nav.is-open {
        display: flex;
    }

    .nav-link {
        padding: 12px 14px;
    }

    .nav-link--gh {
        margin: 8px 0 0;
        text-align: center;
    }

    .section {
        padding: 56px var(--gutter);
    }

    .hero {
        grid-template-columns: 1fr;
        padding-top: 32px;
    }

    .stats {
        grid-template-columns: 1fr 1fr;
    }

    .stat {
        padding: 18px var(--gutter);
    }

    .stat:nth-child(3) {
        border-left: 0;
    }

    .stat:nth-child(n + 3) {
        border-top: 1px solid var(--ink);
    }

    .stat-value {
        font-size: 36px;
    }

    .plates {
        grid-template-columns: 1fr;
    }

    .colophon-grid {
        grid-template-columns: 1fr;
    }

    .figure-row {
        grid-template-columns: 1fr;
    }

    .stack div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .setting {
        grid-template-columns: minmax(0, 1fr) 64px;
        gap: 12px 16px;
    }

    .setting-label {
        grid-column: 1 / -1;
    }

    .setting--wide .setting-control {
        grid-column: 1 / -1;
    }

    .not-found {
        grid-template-columns: 1fr;
    }

    /* Visualizer becomes a scrolling page: stage on top, panel as a sheet */
    .page-visualizer {
        height: auto;
        overflow: visible;
    }

    .workspace {
        flex-direction: column;
    }

    .stage {
        height: 62vh;
        min-height: 380px;
        flex: none;
    }

    .stage-caption {
        top: 16px;
        left: 16px;
    }

    .stage-caption h1 {
        font-size: 22px;
    }

    .stage-toolbar {
        top: auto;
        bottom: 16px;
        right: 16px;
        left: 16px;
        max-width: none;
        justify-content: flex-start;
    }

    .stage-shortcuts, .readout, #toggle-controls {
        display: none;
    }

    .panel {
        width: auto;
        overflow: visible;
        margin-top: -18px;
        position: relative;
        border-left: 0;
        border-top: 1px solid var(--ink);
        border-radius: 18px 18px 0 0;
        padding: 24px var(--gutter) 40px;
    }

    .panel::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;
        border-radius: 2px;
        background: var(--rule-strong);
    }
}

@media (max-width: 560px) {
    .thumbs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-actions .btn, .settings-actions .btn {
        flex: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
