/*
 * nn-lab: the essay layout and the dark "stages" of the neural network article
 * (see assets/js/nn-lab.js). Everything is scoped to pages that contain a stage.
 */

/* ---------- essay layout: a narrow reading column, stages break out of it ---------- */

.bg-white:has(#post [data-nn]) { container-type: inline-size; }
.bg-white:has(#post [data-nn]) > .mx-auto { max-width: 46rem; padding-left: 0.5rem; padding-right: 0.5rem; }
.bg-white:has(#post [data-nn]) h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.08; letter-spacing: -0.02em; }

#post:has([data-nn]) { text-align: left; }
#post:has([data-nn]) p {
    font-size: 1.13rem;
    line-height: 1.75;
    color: #2b3340;
    margin: 1.15em 0;
}
#post:has([data-nn]) h2 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    letter-spacing: -0.02em;
    line-height: 1.12;
    margin: 4.5rem 0 1.4rem;
}
#post:has([data-nn]) li { font-size: 1.13rem; line-height: 1.7; color: #2b3340; margin-bottom: 0.5em; }
#post:has([data-nn]) pre code { background: #0b0d12; border-radius: 18px; padding: 1.3rem 1.5rem; font-size: 0.86rem; line-height: 1.6; }
#post p.nn-lead { font-size: 1.4rem; line-height: 1.5; color: #0f172a; font-weight: 500; }

/* ---------- stage ---------- */

#post .nn-stage,
#post .nn-figure {
    width: min(60rem, 100cqw - 2rem);
    margin: 3rem calc((100% - min(60rem, 100cqw - 2rem)) / 2);
    box-sizing: border-box;
    padding: clamp(1.25rem, 4cqw, 2.75rem);
    border-radius: 28px;
    background: radial-gradient(120% 90% at 20% 0%, #161a26 0%, #0b0d12 60%);
    color: #f2f4f8;
    text-align: left;
}
#post .nn-grid2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
    gap: clamp(1.25rem, 4cqw, 2.75rem);
    align-items: center;
}

/* ---------- plot ---------- */

.nn-plot { width: 100%; height: auto; display: block; touch-action: manipulation; overflow: visible; }
.nn-plot-bg { fill: rgba(77, 163, 255, 0.07); }
.nn-zone { fill: rgba(255, 176, 32, 0.16); }
.nn-grid { stroke: rgba(255, 255, 255, 0.06); stroke-width: 1; }
.nn-tick { font-size: 10px; fill: #5d667a; }
.nn-axis { font-size: 11px; fill: #8a93a6; letter-spacing: 0.02em; }
.nn-line { stroke: #fff; stroke-width: 2.5; stroke-linecap: round; filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.55)); }
.nn-fold { stroke: #fff; stroke-width: 1; stroke-dasharray: 3 5; opacity: 0.28; }
.nn-pt-hit { fill: transparent; cursor: pointer; }
.nn-pt-ring { fill: none; stroke: transparent; stroke-width: 2; }
.nn-pt.is-bug .nn-pt-shape { fill: #ffb020; filter: drop-shadow(0 0 5px rgba(255, 176, 32, 0.7)); }
.nn-pt.is-ok .nn-pt-shape { fill: #4da3ff; filter: drop-shadow(0 0 5px rgba(77, 163, 255, 0.6)); }
.nn-pt.is-wrong .nn-pt-ring { stroke: #fff; stroke-dasharray: 2 4; opacity: 0.9; }
.nn-pt.is-selected .nn-pt-ring { stroke: #fff; stroke-dasharray: none; opacity: 1; }

#post .nn-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1.1rem;
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: #8a93a6;
}
.nn-legend span { display: inline-flex; align-items: center; gap: 0.45rem; }
.nn-key { display: inline-block; width: 0.62rem; height: 0.62rem; }
.nn-key-bug { background: #ffb020; transform: rotate(45deg) scale(0.9); }
.nn-key-ok { background: #4da3ff; border-radius: 50%; }
.nn-key-zone { background: rgba(255, 176, 32, 0.3); border-radius: 3px; }

/* ---------- the one number that matters ---------- */

#post .nn-score { line-height: 1; margin-bottom: 1.6rem; font-variant-numeric: tabular-nums; }
.nn-score b { font-size: clamp(3.2rem, 9cqw, 5rem); font-weight: 700; letter-spacing: -0.04em; color: #fff; transition: color 0.3s; }
.nn-score span { font-size: 1.5rem; color: #5d667a; font-weight: 500; }
.nn-score small { display: block; margin-top: 0.55rem; font-size: 0.85rem; color: #8a93a6; }
.nn-score.is-perfect b { color: #ffb020; text-shadow: 0 0 28px rgba(255, 176, 32, 0.45); }

/* ---------- sliders ---------- */

.nn-slider { display: block; margin-bottom: 1.1rem; }
.nn-slider-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.88rem; color: #8a93a6; }
.nn-slider-head b { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95rem; color: #fff; font-weight: 500; }
.nn-slider input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 28px;
    margin: 0.1rem 0 0;
    background: transparent;
    cursor: pointer;
}
.nn-slider input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.18); }
.nn-slider input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.18); }
.nn-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px; margin-top: -9.5px;
    border-radius: 50%; border: 0; background: #fff;
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.1);
}
.nn-slider input[type="range"]::-moz-range-thumb {
    width: 22px; height: 22px;
    border-radius: 50%; border: 0; background: #fff;
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.1);
}

/* ---------- small text inside a stage ---------- */

#post .nn-calc {
    margin-top: 0.4rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    font-size: 0.88rem;
    line-height: 1.55;
    color: #8a93a6;
    min-height: 5.2rem;
}
.nn-calc span { display: block; }
.nn-calc b { color: #fff; font-weight: 500; }
.nn-calc-line { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.84rem; margin: 0.2rem 0; }
.nn-verdict { color: #fff; }
.nn-verdict.is-wrong { color: #ffb020; }
#post .nn-stage p.nn-hint { margin: 0.6rem 0 0; font-size: 0.8rem; line-height: 1.45; color: #5d667a; }
#post .nn-stage p.nn-cheer {
    display: none;
    margin: 1.75rem 0 0;
    font-size: 1.05rem;
    line-height: 1.5;
    color: #ffb020;
}
#post .nn-stage p.nn-cheer.is-on { display: block; animation: nn-pop 0.5s ease-out; }
#post .nn-readout {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86rem;
    color: #8a93a6;
    font-variant-numeric: tabular-nums;
}
.nn-readout b { color: #fff; font-weight: 500; }
#post .nn-log { min-height: 4rem; margin-top: 1rem; }

/* errors per pass */
.nn-bars-title { margin-top: 1rem; font-size: 0.78rem; color: #5d667a; }
.nn-bars { display: flex; align-items: flex-end; gap: 4px; height: 4.2rem; margin-top: 0.4rem; }
.nn-bar {
    flex: 1 1 0; min-width: 0; max-width: 1.3rem; height: 100%;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    animation: nn-pop 0.3s ease-out;
}
.nn-bar i { display: block; width: 100%; border-radius: 2px; background: rgba(255, 255, 255, 0.4); }
.nn-bar.is-zero i { background: #ffb020; }
.nn-bar span { font-size: 0.62rem; color: #5d667a; line-height: 1.5; font-variant-numeric: tabular-nums; }
.nn-bars.is-dense { gap: 2px; }
.nn-bars.is-dense .nn-bar span { font-size: 0.5rem; letter-spacing: -0.04em; }

/* ---------- controls ---------- */

.nn-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 1.75rem; }
.nn-btn {
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: transparent;
    color: #fff;
    border-radius: 9999px;
    padding: 0.55rem 1.25rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
}
.nn-btn:hover { border-color: #fff; }
.nn-btn:active { transform: scale(0.97); }
.nn-btn:disabled { opacity: 0.35; cursor: default; }
.nn-btn-primary { background: #fff; border-color: #fff; color: #0b0d12; font-weight: 600; }
.nn-btn-primary:hover { background: #ffb020; border-color: #ffb020; }
.nn-btn-primary:disabled:hover { background: #fff; border-color: #fff; }
.nn-btn-ghost { border-color: transparent; color: #8a93a6; }
.nn-btn-ghost:hover { border-color: transparent; color: #fff; }

#post .nn-seg { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 1rem; }
.nn-seg-label { font-size: 0.82rem; color: #8a93a6; margin-right: 0.5rem; }
.nn-btn.nn-seg-btn { padding: 0.28rem 0.8rem; font-size: 0.82rem; border-color: rgba(255, 255, 255, 0.16); color: #8a93a6; }
.nn-btn.nn-seg-btn.is-on { background: #fff; border-color: #fff; color: #0b0d12; }

/* ---------- error curve ---------- */

.nn-descent-bg { fill: transparent; }
.nn-curve { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linejoin: round; filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.35)); }
.nn-trail { fill: none; stroke: rgba(255, 176, 32, 0.55); stroke-width: 1.5; stroke-dasharray: 2 5; }
.nn-ball { fill: #ffb020; filter: drop-shadow(0 0 10px rgba(255, 176, 32, 0.9)); transition: cx 0.12s linear, cy 0.12s linear; }
#post .nn-stage > .nn-readout { margin-top: 0.75rem; }

/* ---------- network diagram ---------- */

.nn-diagram { width: 100%; max-width: 340px; height: auto; display: block; margin: 0 0 0.5rem; }
.nn-edge-pos { stroke: #ffb020; stroke-linecap: round; }
.nn-edge-neg { stroke: #4da3ff; stroke-linecap: round; }
.nn-node { fill: #0b0d12; stroke: #fff; stroke-width: 1.5; }
.nn-node-io { fill: #fff; }

/* ---------- digits ---------- */

#post .nn-samples { display: grid; grid-template-columns: repeat(10, 1fr); gap: clamp(0.3rem, 1.2cqw, 0.9rem); }
#post .nn-sample { margin: 0; text-align: center; }
.nn-sample canvas, .nn-eight { width: 100%; height: auto; display: block; image-rendering: pixelated; border-radius: 6px; }
.nn-sample figcaption { font-size: 0.75rem; color: #5d667a; margin-top: 0.3rem; font-variant-numeric: tabular-nums; }

.nn-pad-wrap { position: relative; }
.nn-pad {
    width: 100%; height: auto; display: block;
    border-radius: 20px;
    background: #05060a;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    touch-action: none;
    cursor: crosshair;
}
.nn-pad-hint {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #5d667a; font-size: 1.05rem;
    pointer-events: none;
}
.nn-pad-hint[hidden] { display: none; }
.nn-pad-wrap .nn-btn-ghost { position: absolute; right: 0.6rem; bottom: 0.6rem; padding: 0.3rem 0.8rem; font-size: 0.8rem; }

.nn-answer { display: flex; align-items: baseline; gap: 1.1rem; line-height: 1; }
.nn-answer b {
    font-size: clamp(6rem, 22cqw, 11rem);
    font-weight: 700;
    letter-spacing: -0.05em;
    color: #ffb020;
    text-shadow: 0 0 60px rgba(255, 176, 32, 0.35);
    min-width: 0.62em;
}
.nn-answer.is-empty b { color: rgba(255, 255, 255, 0.12); text-shadow: none; }
.nn-answer span { font-size: 0.95rem; color: #8a93a6; line-height: 1.4; }
.nn-digit-bars { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; align-items: end; height: 3.2rem; margin-top: 1.5rem; }
.nn-digit-col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: 0.72rem; color: #5d667a; font-variant-numeric: tabular-nums; }
.nn-digit-col i { display: block; width: 100%; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); transition: height 0.15s ease-out; margin-bottom: 0.3rem; }
.nn-digit-col.is-top { color: #fff; }
.nn-digit-col.is-top i { background: #ffb020; }
.nn-seen { display: flex; align-items: center; gap: 0.9rem; margin-top: 1.5rem; font-size: 0.8rem; line-height: 1.45; color: #5d667a; }
.nn-seen .nn-eight { width: 64px; flex: none; }
#post .nn-gate { margin-top: 1.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem; font-size: 0.95rem; color: #ffb020; }
#post .nn-gate[hidden] { display: none; }

/* ---------- runnable Python ---------- */

#post .nn-py {
    width: min(50rem, 100cqw - 2rem);
    margin: 2.25rem calc((100% - min(50rem, 100cqw - 2rem)) / 2);
    border-radius: 18px;
    background: #0b0d12;
    overflow: hidden;
    text-align: left;
}
#post .nn-py > textarea { display: block; width: 100%; min-height: 8rem; background: transparent; color: #e2e8f0; padding: 1.2rem; font-family: monospace; }
.nn-editor { overflow-x: auto; }
.nn-editor-inner { display: grid; min-width: max-content; }
#post .nn-code {
    grid-area: 1 / 1;
    margin: 0;
    padding: 1.4rem 1.6rem 1.1rem;
    border: 0;
    background: transparent;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.88rem;
    line-height: 1.6;
    letter-spacing: 0;
    tab-size: 4;
    white-space: pre;
    overflow: hidden;
    color: #e2e8f0;
    text-align: left;
}
#post textarea.nn-input { width: 100%; height: 100%; resize: none; outline: none; color: transparent; caret-color: #ffb020; }
#post textarea.nn-input::selection { background: rgba(148, 163, 184, 0.35); color: transparent; }
.nn-code .hljs-comment { color: #6b7488; font-style: italic; }
.nn-code .hljs-keyword, .nn-code .hljs-literal { color: #ffb020; }
.nn-code .hljs-string { color: #c3e88d; }
.nn-code .hljs-number { color: #8cc4ff; }
.nn-code .hljs-built_in { color: #8cc4ff; }
.nn-code .hljs-title, .nn-code .hljs-title.function_ { color: #fff; font-weight: 600; }
.nn-code .hljs-params { color: #e2e8f0; }

.nn-pybar { display: flex; align-items: center; gap: 0.8rem; padding: 0.4rem 1.6rem 1.3rem; }
.nn-pybar .nn-btn { padding: 0.45rem 1.1rem; font-size: 0.85rem; }
.nn-pybar .nn-btn-ghost { margin-left: auto; }
.nn-shortcut { font-size: 0.74rem; color: #5d667a; }
@media (hover: none) { .nn-shortcut { display: none; } }
#post pre.nn-out {
    margin: 0;
    padding: 1.1rem 1.6rem 1.3rem;
    max-height: 17rem;
    overflow: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: #05060a;
    color: #c8ced9;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.84rem;
    line-height: 1.55;
    white-space: pre-wrap;
    border-radius: 0;
}
#post pre.nn-out.is-error { color: #ff8a8a; }
#post pre.nn-out.is-info { color: #ffb020; animation: nn-wait 1.2s ease-in-out infinite; }
.nn-py.is-busy .nn-pybar .nn-btn-primary:disabled { opacity: 1; background: #ffb020; border-color: #ffb020; animation: nn-wait 1.2s ease-in-out infinite; }
@keyframes nn-wait { 50% { opacity: 0.45; } }

/* what a Python cell learned */
#post .nn-result { margin-top: -1.25rem; }
#post .nn-result .nn-result-title { font-size: 0.85rem; color: #8a93a6; margin-bottom: 1.25rem; }
#post .nn-result.is-fresh { animation: nn-flash 1s ease-out; }

/* static figure */
#post .nn-figure svg { width: 100%; height: auto; display: block; }
#post .nn-figure figcaption { font-size: 0.82rem; color: #5d667a; text-align: center; margin-top: 1rem; }

@keyframes nn-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes nn-flash { from { box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.8); } to { box-shadow: 0 0 0 3px rgba(255, 176, 32, 0); } }
@media (prefers-reduced-motion: reduce) {
    #post .nn-stage p.nn-cheer.is-on, .nn-bar, #post .nn-result.is-fresh { animation: none; }
    .nn-ball, .nn-digit-col i { transition: none; }
}

/* ---------- skimming: numbered steps, one-line section summaries, a title on every scene ---------- */

#post:has([data-nn]) { counter-reset: nnstep; }
#post:has([data-nn]) h2 { counter-increment: nnstep; }
#post:has([data-nn]) h2::before {
    content: "Étape " counter(nnstep) " sur 9";
    display: block;
    margin-bottom: 0.6rem;
    font-size: 1rem;
    line-height: 1;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #ff9f0a;
}
html[lang="en"] #post:has([data-nn]) h2::before { content: "Step " counter(nnstep) " of 9"; }
#post p.nn-sub { margin-top: -0.4rem; font-size: 1.3rem; line-height: 1.45; font-weight: 500; color: #5b6472; }
#post .nn-stage[data-title]::before,
#post .nn-py[data-title]::before {
    content: attr(data-title);
    display: block;
    font-family: Poppins, sans-serif;
    font-weight: 600;
    color: #f2f4f8;
}
#post .nn-stage[data-title]::before { font-size: 1.15rem; line-height: 1.35; margin-bottom: 1.4rem; }
#post .nn-py[data-title]::before { font-size: 0.9rem; padding: 1rem 1.5rem 0; color: #8a93a6; }

/* ---------- code cells: blanks to fill in, and the line-by-line tour ---------- */

.nn-py.is-puzzle textarea.nn-input, .nn-py.is-tour textarea.nn-input { display: none; }
.nn-py.is-puzzle .nn-pybar { display: none; }
.nn-code .nn-blank {
    display: inline-block;
    min-width: 3.2em;
    margin: 0 0.1em;
    padding: 0 0.55em;
    border: 1.5px dashed rgba(255, 255, 255, 0.35);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.05);
    color: #8a93a6;
    font: inherit;
    line-height: 1.35;
    text-align: center;
    cursor: pointer;
}
.nn-code .nn-blank.is-current { border: 1.5px solid #ffb020; background: rgba(255, 176, 32, 0.16); color: #ffb020; animation: nn-wait 1.4s ease-in-out infinite; }
.nn-code span.nn-blank.is-done { min-width: 0; border: 0; padding: 0 0.3em; background: rgba(255, 176, 32, 0.18); color: #ffd27a; cursor: default; animation: nn-pop 0.4s ease-out; }
.nn-py.is-won .nn-code { animation: nn-won 0.9s ease-out; }
@keyframes nn-won { 0% { background: rgba(255, 176, 32, 0.16); } 100% { background: transparent; } }

#post .nn-panel { margin: 0.2rem 1.1rem 1.1rem; padding: 1.1rem 1.25rem 1.15rem; border-radius: 14px; background: #171b26; font-family: Poppins, sans-serif; }
#post:has([data-nn]) .nn-py .nn-panel p { margin: 0; }
#post:has([data-nn]) .nn-py .nn-panel-kicker { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #ffb020; }
#post:has([data-nn]) .nn-py .nn-panel-text { margin-top: 0.3rem; font-size: 1.05rem; line-height: 1.55; color: #f2f4f8; }
#post:has([data-nn]) .nn-py .nn-panel-text code { background: rgba(255, 255, 255, 0.1); color: #ffd27a; padding: 0.1em 0.35em; border-radius: 5px; font-size: 0.9em; }
#post:has([data-nn]) .nn-py .nn-panel-win { color: #ffd27a; font-weight: 500; }
#post:has([data-nn]) .nn-py .nn-panel-why { min-height: 1.5em; margin-top: 0.7rem; font-size: 0.9rem; line-height: 1.5; color: #ff9d8a; }
.nn-choices { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 0.85rem; }
.nn-choice {
    padding: 0.65rem 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    background: #0b0d12;
    color: #f2f4f8;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.nn-choice:hover:not(:disabled) { border-color: #ffb020; background: rgba(255, 176, 32, 0.12); transform: translateY(-1px); }
.nn-choice.is-wrong { opacity: 0.4; text-decoration: line-through; cursor: default; animation: nn-shake 0.3s ease; }
@keyframes nn-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.nn-panel-link { margin-top: 0.6rem; padding: 0; border: 0; background: none; color: #8a93a6; font-family: inherit; font-size: 0.8rem; text-decoration: underline; cursor: pointer; }
.nn-panel-nav { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.9rem; }
.nn-panel-nav .nn-btn { padding: 0.45rem 1.1rem; font-size: 0.85rem; }
.nn-panel-nav .nn-panel-link { margin: 0 0 0 auto; }
.nn-pybar .nn-btn-tour { background: transparent; border: 1px solid rgba(255, 176, 32, 0.6); color: #ffb020; }
.nn-pybar .nn-btn-tour:hover { background: rgba(255, 176, 32, 0.12); }
.nn-py.is-tour .nn-btn-tour { background: #ffb020; color: #0b0d12; }
.nn-code .nn-line { display: inline-block; min-width: 100%; margin: 0 -0.7rem; padding: 0 0.7rem; border-left: 3px solid transparent; transition: opacity 0.25s ease, background 0.25s ease; }
.nn-code .nn-line.is-now { background: rgba(255, 176, 32, 0.12); border-left-color: #ffb020; }
.nn-code .nn-line.is-past { opacity: 0.45; }
.nn-code .nn-line.is-next { opacity: 0.16; }

/* ---------- the running thread: how many knobs, and who turns them ---------- */

#post p.nn-thread {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    margin: 2.5rem 0 0;
    padding: 0.9rem 1.2rem;
    border-radius: 14px;
    background: #fff7e0;
    font-size: 1.02rem;
    line-height: 1.5;
    color: #2b3340;
}
#post p.nn-thread b { flex: none; font-size: 1.25rem; color: #0f172a; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .nn-code .nn-blank.is-current, .nn-choice.is-wrong, .nn-py.is-won .nn-code { animation: none; } }

/* ---------- why this article ---------- */

#post aside.nn-why { margin: 2.2rem 0; padding: 1.3rem 1.5rem 1.4rem; border-left: 4px solid #ffb020; border-radius: 0 16px 16px 0; background: #fff7e0; }
#post:has([data-nn]) aside.nn-why p { margin: 0; font-size: 1.15rem; line-height: 1.65; color: #1f2733; }
#post:has([data-nn]) aside.nn-why p.nn-why-kicker { margin-bottom: 0.45rem; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #b26a00; }

/* ---------- the mixing desk figure ---------- */

.nn-desk .nn-knob-turn { animation: nn-turn 3.2s ease-in-out infinite; }
.nn-desk .nn-desk-meter { transform-box: fill-box; transform-origin: left center; animation: nn-meter 3.2s ease-in-out infinite; }
@keyframes nn-turn { 0%, 100% { transform: rotate(-70deg); } 50% { transform: rotate(60deg); } }
@keyframes nn-meter { 0%, 100% { transform: scaleX(0.55); } 50% { transform: scaleX(0.94); } }
@media (prefers-reduced-motion: reduce) { .nn-desk .nn-knob-turn, .nn-desk .nn-desk-meter { animation: none; } }
#post:has([data-nn]) pre code .hljs-number, #post:has([data-nn]) pre code .hljs-built_in { color: #8cc4ff; }
#post:has([data-nn]) pre code .hljs-keyword, #post:has([data-nn]) pre code .hljs-literal { color: #ffb020; }
#post:has([data-nn]) pre code .hljs-string { color: #c3e88d; }
#post:has([data-nn]) pre code .hljs-comment { color: #6b7488; }
#post:has([data-nn]) pre code, #post:has([data-nn]) pre code .hljs-title, #post:has([data-nn]) pre code .hljs-params { color: #e2e8f0; }

/* Numbered steps: a short procedure set apart from the prose */
#post:has([data-nn]) ol.nn-steps { list-style: none; counter-reset: nnstepno; margin: 1.6rem 0; padding: 0; display: grid; gap: 0.55rem; }
#post:has([data-nn]) ol.nn-steps > li { counter-increment: nnstepno; position: relative; display: block; margin: 0; padding: 0.75rem 1rem 0.75rem 3.5rem; border-radius: 14px; background: #f6f7f9; color: #1d2330; line-height: 1.45; }
#post:has([data-nn]) ol.nn-steps > li::before { content: counter(nnstepno); position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%); width: 1.9rem; height: 1.9rem; border-radius: 50%; background: #0b0d12; color: #ffd84d; font-weight: 700; font-size: 0.95rem; display: grid; place-items: center; }
#post:has([data-nn]) ol.nn-steps > li:last-child { background: #fff6cc; }
#post:has([data-nn]) ol.nn-steps code { font-size: 0.95em; background: #0b0d12; color: #ffd84d; padding: 0.1em 0.45em; border-radius: 6px; white-space: nowrap; }
#post:has([data-nn]) ol.nn-cases > li:last-child { background: #f6f7f9; }

/* Unnumbered rows: a few parallel cases set apart from the prose */
#post:has([data-nn]) ul.nn-rows { list-style: none; margin: 1.6rem 0; padding: 0; display: grid; gap: 0.55rem; }
#post:has([data-nn]) ul.nn-rows > li { margin: 0; padding: 0.75rem 1.1rem; border-radius: 14px; background: #f6f7f9; color: #1d2330; line-height: 1.45; }
#post:has([data-nn]) ul.nn-rows > li::before, #post:has([data-nn]) ul.nn-rows > li::marker { content: none; }
#post:has([data-nn]) p > code, #post:has([data-nn]) li > code { white-space: nowrap; }

/* Section one-liner: labelled so it reads as the goal of the step, not as body text */
#post p.nn-sub { margin-top: 0.2rem; padding: 0.1rem 0 0.1rem 1rem; border-left: 3px solid #ff9f0a; font-size: 1.15rem; }
#post p.nn-sub::before { content: "Ce qu'on va faire"; display: block; margin-bottom: 0.25rem; font-size: 0.75rem; line-height: 1.2; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #ff9f0a; }
html[lang="en"] #post p.nn-sub::before { content: "What we'll do"; }

/* Phones: diagrams keep a readable size and scroll sideways instead of shrinking to nothing */
@media (max-width: 640px) {
    #post figure.nn-figure { padding-left: 14px; padding-right: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    #post figure.nn-figure > svg { min-width: 560px; }
    #post figure.nn-figure > figcaption { position: sticky; left: 0; }
}

/* Comfortable tap target for the small text links inside cell panels */
#post:has([data-nn]) .nn-py .nn-panel-link { padding: 0.6rem 0; min-height: 44px; }

/* Phones: buttons keep their label on one line, toolbars wrap, the keyboard hint goes away */
.nn-btn { white-space: nowrap; }
@media (max-width: 640px) {
    .nn-py .nn-pybar, .nn-py .nn-panel-nav { flex-wrap: wrap; row-gap: 0.5rem; }
    .nn-py .nn-shortcut { display: none; }
}

/* Phones: the wide error-curve chart is scaled down a lot, so its labels are drawn bigger; code is set a bit smaller */
@media (max-width: 640px) {
    [data-nn="descent"] .nn-tick { font-size: 19px; }
    [data-nn="descent"] .nn-axis { font-size: 17px; }
    [data-nn="descent"] .nn-axis:not([transform]) { transform: translateY(14px); }
    [data-nn="descent"] .nn-plot { margin-bottom: 0.8rem; }
    #post .nn-code, #post:has([data-nn]) pre code { font-size: 0.78rem; }
}

/* Series kicker: "Jour 1" above the opening line, "La suite" above the plan */
#post p.nn-kicker { margin: 2.5rem 0 0.6rem; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #ff9d00; }
#post p.nn-kicker:first-of-type { margin-top: 0; }

/* Collapsed "full code" block */
#post details.nn-full { margin: 1.8rem 0; border: 1px solid #e3e6ec; border-radius: 14px; padding: 0.2rem 1.1rem; background: #fafbfc; }
#post details.nn-full > summary { cursor: pointer; font-weight: 600; padding: 0.75rem 0; min-height: 44px; }
#post details.nn-full[open] > summary { margin-bottom: 0.4rem; }
