/* Iris — an instrument on hairline rules.
   One column, no cards. Structure comes from 1px rules, type and spacing;
   the only filled control is the primary button. */

:root {
    /* Ground and rules (GitHub dark) */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --rule: #21262d;
    --rule-strong: #30363d;

    /* Text */
    --text-primary: #f0f6fc;
    --text-secondary: #9198a1;
    --text-tertiary: #7d8590;

    /* Signal: blue is the path, green is where it starts, red where it ends */
    --accent-blue: #58a6ff;
    --accent-blue-hover: #79c0ff;
    --success-green: #3fb950;
    --danger-red: #f85149;
    --danger-ink: #ff7b72;

    /* Spacing: 4px base; the step number is the multiple */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-14: 56px;
    --sp-18: 72px;
    --sp-24: 96px;

    /* Type */
    --fs-label: 12px;
    --fs-small: 13px;
    --fs-body: 15px;
    /* 16px minimum on inputs is load-bearing: smaller and iOS Safari zooms */
    --fs-control: 18px;
    --fs-reading: 22px;
    --fs-display: clamp(28px, 4.4vw, 46px);

    --shell: 1040px;
    --measure: 62ch;
    --gutter: clamp(16px, 4vw, 40px);
    --radius: 6px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --focus-ring: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--accent-blue);

    color-scheme: dark;
}

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

body {
    font-family: "JetBrains Mono", ui-monospace, monospace;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--fs-body);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}

a {
    color: inherit;
    text-underline-offset: 3px;
}

.hidden {
    display: none !important;
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: var(--sp-4);
    top: -100px;
    background: var(--accent-blue);
    color: var(--bg-primary);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius);
    font-weight: 600;
    z-index: 10;
}

.skip-link:focus {
    top: var(--sp-4);
}

.shell {
    max-width: calc(var(--shell) + 2 * var(--gutter));
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* --- Masthead ----------------------------------------------------------- */

.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    border-bottom: 1px solid var(--rule);
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 44px;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.wordmark img {
    display: block;
}

.masthead-links {
    display: flex;
    gap: var(--sp-6);
}

.masthead-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: var(--fs-small);
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.masthead-links a:hover {
    color: var(--text-primary);
}

/* --- Lead ---------------------------------------------------------------- */

.lead {
    padding-top: var(--sp-18);
}

.lead h1 {
    font-size: var(--fs-display);
    font-weight: 600;
    line-height: 1.12;
    letter-spacing: -0.035em;
    max-width: 21ch;
    text-wrap: balance;
}

/* 404: the code is a reading, so it takes the reading face */
.lost-code {
    margin-bottom: var(--sp-3);
    font-size: var(--fs-reading);
    font-weight: 500;
    color: var(--danger-ink);
}

.lead-copy {
    margin-top: var(--sp-5);
    max-width: var(--measure);
    color: var(--text-secondary);
    text-wrap: pretty;
}

.howto {
    margin-top: var(--sp-5);
}

.howto summary {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 44px;
    font-size: var(--fs-small);
    color: var(--accent-blue);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.howto summary::-webkit-details-marker {
    display: none;
}

/* Drawn chevron: two borders of a rotated square */
.howto summary::after {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.2s var(--ease-out);
}

.howto[open] summary::after {
    transform: translateY(1px) rotate(-135deg);
}

.howto summary:hover {
    color: var(--accent-blue-hover);
}

.howto-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-6);
    margin-top: var(--sp-4);
}

.howto-list > div {
    border-top: 1px solid var(--rule-strong);
    padding-top: var(--sp-3);
}

.howto-list dt {
    font-size: var(--fs-small);
    font-weight: 600;
}

.howto-list dd {
    margin-top: var(--sp-1);
    font-size: var(--fs-small);
    line-height: 1.6;
    color: var(--text-secondary);
}

/* --- Route form ---------------------------------------------------------- */

.route {
    margin-top: var(--sp-12);
}

.route-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
    column-gap: var(--sp-6);
}

.field {
    position: relative;
}

.field label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-label);
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* The start/end colour language begins here, on the labels */
.field label::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dot);
}

.field-from {
    --dot: var(--success-green);
}

.field-to {
    --dot: var(--danger-red);
}

.field input {
    display: block;
    width: 100%;
    margin-top: var(--sp-1);
    padding: var(--sp-3) 0;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--rule-strong);
    border-radius: 0;
    color: var(--text-primary);
    font: inherit;
    font-size: var(--fs-control);
    font-weight: 500;
    letter-spacing: -0.01em;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.field input::placeholder {
    color: var(--text-tertiary);
    opacity: 1;
}

.field input:hover {
    border-bottom-color: var(--text-tertiary);
}

.field input:focus,
.field input:focus-visible {
    outline: none;
    border-radius: 0;
    border-bottom-color: var(--accent-blue);
    box-shadow: 0 1px 0 var(--accent-blue);
}

.field input[aria-invalid="true"] {
    border-bottom-color: var(--danger-red);
    box-shadow: 0 1px 0 var(--danger-red);
}

/* Title suggestions float over the page like the graph tooltip: the one
   raised, shadowed surface, because it sits above whatever is below it. */
.suggestions {
    position: absolute;
    z-index: 20;
    top: 100%;
    left: 0;
    right: 0;
    max-height: min(360px, 60vh);
    overflow-y: auto;
    list-style: none;
    border: 1px solid var(--rule-strong);
    border-top: 0;
    background: var(--bg-secondary);
    box-shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
}

.suggestion {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 44px;
    padding: var(--sp-2) var(--sp-3);
    border-top: 1px solid var(--rule);
    cursor: pointer;
}

.suggestion:first-child {
    border-top: 0;
}

.suggestion-title {
    font-size: var(--fs-body);
    font-weight: 500;
    overflow-wrap: anywhere;
}

.suggestion-note {
    font-size: var(--fs-label);
    color: var(--text-tertiary);
    overflow-wrap: anywhere;
}

.suggestion[aria-selected="true"],
.suggestion:hover {
    background: var(--bg-tertiary);
}

.suggestion[aria-selected="true"] .suggestion-title {
    color: var(--accent-blue);
}

.suggestion.is-ambiguous .suggestion-title {
    color: var(--text-secondary);
}

.route-arrow {
    width: 22px;
    height: 22px;
    margin-bottom: var(--sp-4);
    fill: none;
    stroke: var(--text-tertiary);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.route-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-top: var(--sp-6);
}

/* Example routes: in-text actions, so Path Blue like "How it works" */
.examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 var(--sp-4);
    margin-top: var(--sp-3);
    font-size: var(--fs-small);
    color: var(--text-tertiary);
}

.examples-list {
    display: contents;
}

.example,
.examples-surprise {
    min-height: 44px;
    border: 0;
    background: none;
    font: inherit;
    color: var(--accent-blue);
    text-align: left;
    cursor: pointer;
    transition: color 0.15s ease;
}

.example:hover,
.examples-surprise:hover {
    color: var(--accent-blue-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.examples-surprise {
    color: var(--text-secondary);
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 var(--sp-5);
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: none;
    color: inherit;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s var(--ease-out);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--accent-blue);
    color: var(--bg-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-blue-hover);
}

.btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.btn-quiet {
    border-color: var(--rule-strong);
    color: var(--text-primary);
}

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

.btn-text {
    padding: 0 var(--sp-3);
    color: var(--text-secondary);
}

.btn-text:hover {
    color: var(--text-primary);
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.15s ease;
}

.icon-btn:hover {
    color: var(--text-primary);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
}

/* --- Notice (errors and the quieter "stopped" message) ------------------ */

.notice {
    --tone: var(--danger-red);
    --tone-ink: var(--danger-ink);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--sp-3);
    margin-top: var(--sp-6);
    padding: var(--sp-4) 0;
    /* Ruled, not boxed: the same hairline vocabulary as the readings */
    border-top: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
    border-bottom: 1px solid var(--rule);
    animation: notice-in 0.35s var(--ease-out);
}

.notice.is-neutral {
    --tone: var(--text-tertiary);
    --tone-ink: var(--text-primary);
}

@keyframes notice-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
}

.notice-icon {
    width: 20px;
    height: 20px;
    margin-top: 1px;
    fill: none;
    stroke: var(--tone);
    stroke-width: 1.6;
    stroke-linecap: round;
}

.notice-title {
    font-weight: 600;
    color: var(--tone-ink);
}

.notice-message,
.notice-hint {
    font-size: var(--fs-small);
    line-height: 1.6;
    max-width: var(--measure);
    overflow-wrap: anywhere;
}

.notice-message {
    margin-top: var(--sp-1);
    color: var(--text-primary);
}

.notice-hint {
    margin-top: var(--sp-1);
    color: var(--text-secondary);
}

.notice-message:empty,
.notice-hint:empty {
    display: none;
}

.notice-actions {
    display: flex;
    align-items: center;
    margin-top: calc(-1 * var(--sp-3));
}

.notice-actions .btn-text {
    color: var(--accent-blue);
}

.notice-actions .btn-text:hover {
    color: var(--accent-blue-hover);
}

/* --- Run ----------------------------------------------------------------- */

.run {
    display: none;
    margin-top: var(--sp-14);
    padding-top: var(--sp-6);
    border-top: 1px solid var(--rule);
}

.run.show {
    display: block;
    animation: run-in 0.5s var(--ease-out);
}

@keyframes run-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.run-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
}

.run-route {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0 var(--sp-2);
    min-width: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.end-mark {
    align-self: center;
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-green);
}

.end-mark.to {
    background: var(--danger-red);
}

.run-route-arrow {
    align-self: center;
    flex: none;
    width: 16px;
    height: 16px;
    margin: 0 var(--sp-1);
    fill: none;
    stroke: var(--text-tertiary);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.run-state {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-small);
    color: var(--text-secondary);
}

.run-state::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.run-state[data-state="searching"]::before {
    background: var(--accent-blue);
    animation: beat 1.4s ease-in-out infinite;
}

.run-state[data-state="found"]::before {
    background: var(--success-green);
}

@keyframes beat {
    50% {
        opacity: 0.3;
    }
}

/* One pixel of motion along the rule: the search is working */
.activity {
    position: relative;
    height: 1px;
    margin-top: var(--sp-4);
    background: var(--rule-strong);
    overflow: clip;
}

.activity-fill {
    position: absolute;
    inset: 0;
    width: 40%;
    background: linear-gradient(
        90deg,
        transparent,
        var(--accent-blue) 30%,
        var(--accent-blue) 70%,
        transparent
    );
    animation: sweep 1.6s var(--ease-out) infinite;
}

@keyframes sweep {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(260%);
    }
}

@keyframes activity-pulse {
    0%,
    100% {
        opacity: 0.35;
    }
    50% {
        opacity: 1;
    }
}

.readings {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 2fr);
    margin-top: var(--sp-5);
}

.reading {
    min-width: 0;
    padding: 0 var(--sp-5);
    border-left: 1px solid var(--rule);
}

.reading:first-child {
    padding-left: 0;
    border-left: 0;
}

.reading dt {
    font-size: var(--fs-label);
    color: var(--text-tertiary);
}

.reading dd {
    display: flex;
    align-items: center;
    min-height: 36px;
    font-size: var(--fs-reading);
    font-weight: 500;
    letter-spacing: -0.02em;
}

.reading-wide dd {
    font-size: var(--fs-body);
    letter-spacing: 0;
}

#lastNode {
    display: block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--accent-blue);
    text-decoration: none;
}

#lastNode:hover {
    text-decoration: underline;
}

#lastNode.disabled {
    color: var(--text-tertiary);
    pointer-events: none;
}

.depth-dots {
    display: flex;
    gap: 6px;
}

.depth-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--rule-strong);
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease;
}

.depth-dot.completed {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.depth-dot.active {
    border-color: var(--accent-blue);
    animation: beat 1.4s ease-in-out infinite;
}

/* --- The field: dot grid framed by registration marks ------------------- */

.field-frame {
    position: relative;
    margin-top: var(--sp-8);
    min-height: 360px;
    background-image: radial-gradient(
        circle,
        rgba(139, 148, 158, 0.16) 1px,
        transparent 1.25px
    );
    background-size: 20px 20px;
    background-position: center;
}

.reg {
    position: absolute;
    width: 14px;
    height: 14px;
    border-color: var(--text-tertiary);
    border-style: solid;
    border-width: 0;
    pointer-events: none;
}

.reg-tl {
    top: 0;
    left: 0;
    border-top-width: 1px;
    border-left-width: 1px;
}

.reg-tr {
    top: 0;
    right: 0;
    border-top-width: 1px;
    border-right-width: 1px;
}

.reg-bl {
    bottom: 0;
    left: 0;
    border-bottom-width: 1px;
    border-left-width: 1px;
}

.reg-br {
    bottom: 0;
    right: 0;
    border-bottom-width: 1px;
    border-right-width: 1px;
}

/* While searching, the field shows the two frontiers: each end with the
   pages that side read last, joined by a line each side fills as it goes
   deeper. The fills are scaled to the whole depth budget, so they meet. */
.wait {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(64px, 320px) minmax(0, 1fr);
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-10);
}

.wait-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--sp-2);
    min-width: 0;
}

.wait-side.to {
    align-items: flex-start;
}

.wait-end {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    max-width: 100%;
    padding: var(--sp-1) var(--sp-3);
    border: 1px solid var(--rule-strong);
    border-radius: 4px;
    background: var(--bg-secondary);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wait-end::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-green);
}

.wait-end.to::before {
    background: var(--danger-red);
}

/* Newest first, fading with age */
.wait-trail {
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: inherit;
    max-width: 100%;
    min-height: calc(6 * 20px);
    font-size: var(--fs-label);
    line-height: 20px;
    color: var(--text-secondary);
}

.wait-trail li {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wait-trail li:nth-child(2) { opacity: 0.8; }
.wait-trail li:nth-child(3) { opacity: 0.65; }
.wait-trail li:nth-child(4) { opacity: 0.5; }
.wait-trail li:nth-child(5) { opacity: 0.38; }
.wait-trail li:nth-child(6) { opacity: 0.26; }

.wait-trail li.is-new:first-child {
    color: var(--text-primary);
    animation: trail-in 0.3s var(--ease-out);
}

@keyframes trail-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
}

.wait-count {
    min-height: 20px;
    font-size: var(--fs-label);
    color: var(--text-tertiary);
}

.wait-line {
    position: relative;
    height: 1px;
    background-image: linear-gradient(
        90deg,
        var(--rule-strong) 50%,
        transparent 50%
    );
    background-size: 8px 1px;
    overflow: clip;
}

.wait-reach {
    position: absolute;
    top: 0;
    bottom: 0;
    width: calc(var(--reach, 0) * 100%);
    background: var(--accent-blue);
    transition: width 0.5s var(--ease-out);
}

.wait-reach.from {
    left: 0;
}

.wait-reach.to {
    right: 0;
}

.wait-sweep {
    position: absolute;
    inset: 0;
    width: 30%;
    background: linear-gradient(
        90deg,
        transparent,
        var(--accent-blue),
        transparent
    );
    animation: sweep 2.2s var(--ease-out) infinite;
}

#graph {
    display: block;
    width: 100%;
    height: 500px;
    background: transparent;
    overflow: visible;
}

/* --- Route list ---------------------------------------------------------- */

.route-list {
    margin-top: var(--sp-10);
}

.route-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
}

.share-btn {
    gap: var(--sp-2);
    margin-right: calc(-1 * var(--sp-3));
}

.share-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.route-list-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.route-summary {
    margin-top: var(--sp-1);
    font-size: var(--fs-small);
    color: var(--text-secondary);
}

.route-explain {
    margin-top: var(--sp-2);
    max-width: var(--measure);
    font-size: var(--fs-small);
    color: var(--text-secondary);
    text-wrap: pretty;
}

.route-summary span + span::before {
    content: "·";
    margin: 0 var(--sp-2);
    color: var(--text-tertiary);
}

.steps {
    list-style: none;
    margin-top: var(--sp-4);
    border-bottom: 1px solid var(--rule);
}

.steps li {
    position: relative;
    --mark: var(--accent-blue);
}

.steps li:first-child {
    --mark: var(--success-green);
}

.steps li:last-child {
    --mark: var(--danger-red);
}

/* The rail: one blue line threading every step's mark */
.steps li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--accent-blue);
    opacity: 0.45;
}

/* From the first mark, which sits mid-row: a step can be taller than its
   row once its link context is below it, so 50% of the item would miss. */
.steps li:first-child::before {
    top: 26px;
}

.steps li:last-child::before {
    bottom: 50%;
}

.steps li:only-child::before {
    display: none;
}

.step {
    position: relative;
    display: grid;
    grid-template-columns: 9px 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-3);
    min-height: 52px;
    padding: var(--sp-3) 0;
    border-top: 1px solid var(--rule);
    text-decoration: none;
    transition: color 0.15s ease;
}

.step-mark {
    position: relative;
    z-index: 1;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--mark);
    box-shadow: 0 0 0 3px var(--bg-primary);
}

.step-index {
    font-size: var(--fs-small);
    color: var(--text-tertiary);
}

.step-title {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.step-open {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: var(--text-tertiary);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition:
        stroke 0.15s ease,
        transform 0.2s var(--ease-out);
}

.step:hover .step-title {
    color: var(--accent-blue);
}

.step:hover .step-open {
    stroke: var(--accent-blue);
    transform: translate(2px, -2px);
}

.step:focus-visible {
    border-radius: 0;
}

.step-tag {
    font-size: var(--fs-label);
    font-weight: 400;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.step-tag::before {
    content: "·";
    margin-right: var(--sp-2);
}

/* The sentence linking a step to the next, hung under its title */
.step-context {
    max-width: var(--measure);
    margin: calc(-1 * var(--sp-1)) 0 0 calc(9px + 36px + 2 * var(--sp-3));
    padding-bottom: var(--sp-3);
    font-size: var(--fs-small);
    line-height: 1.6;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
    animation: context-in 0.3s var(--ease-out);
}

.step-context.is-loading,
.step-context.is-structural {
    color: var(--text-tertiary);
}

.step-context q {
    quotes: "“" "”";
}

.step-context-link {
    color: var(--accent-blue);
}

.step-context-section {
    color: var(--text-tertiary);
    white-space: nowrap;
}

.step-context-section::before {
    content: "— ";
}

@keyframes context-in {
    from {
        opacity: 0;
    }
}

/* --- Colophon ------------------------------------------------------------ */

.colophon {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin-top: var(--sp-24);
    padding: var(--sp-6) 0 var(--sp-10);
    border-top: 1px solid var(--rule);
    font-size: var(--fs-label);
    color: var(--text-tertiary);
}

.colophon p:first-child {
    max-width: var(--measure);
}

.colophon a {
    color: var(--text-secondary);
}

.colophon a:hover {
    color: var(--text-primary);
}

/* --- Graph (D3) — look and physics carried over unchanged --------------- */

.node {
    fill: var(--accent-blue);
    stroke: var(--bg-primary);
    stroke-width: 2px;
    cursor: grab;
    transition: 0.15s ease;
    touch-action: none;
}

.node:hover {
    fill: var(--accent-blue-hover);
    stroke-width: 3px;
}

.node:active {
    cursor: grabbing;
}

.node.start {
    fill: var(--success-green);
    stroke: rgba(63, 185, 80, 0.3);
    stroke-width: 5px;
}

.node.start:hover {
    stroke: rgba(63, 185, 80, 0.45);
    stroke-width: 6px;
}

.node.end {
    fill: var(--danger-red);
    stroke: rgba(248, 81, 73, 0.3);
    stroke-width: 5px;
}

.node.end:hover {
    stroke: rgba(248, 81, 73, 0.45);
    stroke-width: 6px;
}

.link {
    stroke: var(--rule-strong);
    stroke-width: 2px;
    stroke-linecap: round;
    fill: none;
    opacity: 0.6;
}

.link.path {
    stroke: var(--accent-blue);
    stroke-width: 2.5px;
    opacity: 1;
}

.node-label-bg {
    fill: var(--bg-secondary);
    stroke: var(--rule-strong);
    stroke-width: 1px;
    pointer-events: none;
}

.node-label {
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    font-weight: 500;
    fill: var(--text-primary);
    text-anchor: middle;
    pointer-events: none;
}

.tooltip {
    position: absolute;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    box-shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
    font-family: "JetBrains Mono", monospace;
    font-size: var(--fs-label);
    color: var(--text-primary);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 100;
}

/* --- Narrow screens ------------------------------------------------------ */

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

    .readings {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        row-gap: var(--sp-4);
    }

    .reading-wide {
        grid-column: 1 / -1;
        padding-left: 0;
        padding-top: var(--sp-3);
        border-left: 0;
        border-top: 1px solid var(--rule);
    }
}

@media (max-width: 640px) {
    .lead {
        padding-top: var(--sp-10);
    }

    .route {
        margin-top: var(--sp-8);
    }

    .route-fields {
        grid-template-columns: minmax(0, 1fr);
        row-gap: var(--sp-5);
    }

    .route-arrow {
        display: none;
    }

    .route-actions .btn-primary,
    .route-actions .btn-quiet {
        flex: 1;
    }

    .howto-list {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--sp-4);
    }

    .run {
        margin-top: var(--sp-10);
    }

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

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

    .reading dd {
        font-size: 18px;
    }

    .field-frame {
        min-height: 300px;
    }

    .wait {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 56px auto;
        justify-items: center;
        align-content: center;
        gap: var(--sp-3);
        padding: var(--sp-6);
    }

    .wait-side,
    .wait-side.to {
        align-items: center;
        max-width: 100%;
    }

    /* The end reads bottom-up, so its newest page sits nearest the line */
    .wait-side.to {
        flex-direction: column-reverse;
    }

    .wait-trail {
        min-height: calc(3 * 20px);
    }

    .wait-side.to .wait-trail {
        flex-direction: column-reverse;
    }

    .wait-trail li:nth-child(n + 4) {
        display: none;
    }

    .wait-line {
        width: 1px;
        height: 100%;
        background-image: linear-gradient(
            180deg,
            var(--rule-strong) 50%,
            transparent 50%
        );
        background-size: 1px 8px;
    }

    .wait-reach {
        left: 0;
        right: 0;
        width: auto;
        height: calc(var(--reach, 0) * 100%);
        transition-property: height;
    }

    .wait-reach.from {
        top: 0;
        bottom: auto;
    }

    .wait-reach.to {
        top: auto;
        bottom: 0;
    }

    .wait-sweep {
        width: 100%;
        height: 30%;
        background: linear-gradient(
            180deg,
            transparent,
            var(--accent-blue),
            transparent
        );
        animation-name: sweep-down;
    }

    .colophon {
        margin-top: var(--sp-18);
    }
}

@keyframes sweep-down {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(340%);
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .lead {
        padding-top: var(--sp-8);
    }

    .field-frame {
        min-height: 240px;
    }
}

/* --- Reduced motion ------------------------------------------------------ */

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

    /* Searching must stay perceivable: swap travel for a slow fade instead
       of freezing it, which reads as broken. */
    .activity-fill,
    .wait-sweep {
        width: 100% !important;
        height: 100% !important;
        transform: none !important;
        animation: activity-pulse 2s ease-in-out infinite !important;
    }
}
