/* Distill-style article with one large interactive figure. */
:root {
    --text: rgba(0, 0, 0, 0.82);
    --muted: rgba(0, 0, 0, 0.56);
    --faint: rgba(0, 0, 0, 0.34);
    --rule: rgba(0, 0, 0, 0.1);
    --wash: rgba(0, 0, 0, 0.035);
    --panel: #f7f7f6;
    --bg: #fff;
    --lit: 42, 122, 176;                      /* a concept that is picked but not pinned */
    /* pinned concepts, in the order they were pinned */
    --p0: 42, 122, 176;
    --p1: 180, 70, 60;
    --p2: 61, 138, 95;
    --p3: 134, 86, 168;
    --p4: 168, 122, 28;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --text: rgba(255, 255, 255, 0.87);
        --muted: rgba(255, 255, 255, 0.6);
        --faint: rgba(255, 255, 255, 0.36);
        --rule: rgba(255, 255, 255, 0.13);
        --wash: rgba(255, 255, 255, 0.05);
        --panel: #1b1b1b;
        --bg: #121212;
        --lit: 111, 179, 224;
        --p0: 111, 179, 224;
        --p1: 226, 132, 122;
        --p2: 124, 197, 154;
        --p3: 185, 148, 214;
        --p4: 217, 178, 92;
    }
}
:root[data-theme="dark"] {
    --text: rgba(255, 255, 255, 0.87);
    --muted: rgba(255, 255, 255, 0.6);
    --faint: rgba(255, 255, 255, 0.36);
    --rule: rgba(255, 255, 255, 0.13);
    --wash: rgba(255, 255, 255, 0.05);
    --panel: #1b1b1b;
    --bg: #121212;
    --lit: 111, 179, 224;
    --p0: 111, 179, 224;
    --p1: 226, 132, 122;
    --p2: 124, 197, 154;
    --p3: 185, 148, 214;
    --p4: 217, 178, 92;
}

* { box-sizing: border-box; }
html { font-size: 16px; line-height: 1.6; -webkit-text-size-adjust: 100%; }
body { margin: 0; padding: 0 16px 80px; background: var(--bg); color: var(--text); font-family: var(--font); }
.l-text { max-width: 704px; margin-left: auto; margin-right: auto; }
.l-page { max-width: 1120px; margin-left: auto; margin-right: auto; }
:focus-visible { outline: 2px solid rgb(var(--lit)); outline-offset: 2px; }

/* Title, as in Distill's d-title. */
.d-title { padding: 64px 0 44px; }
.d-title h1 { font-size: 42px; line-height: 1.1; font-weight: 700; margin: 0 0 22px; letter-spacing: -0.015em; text-wrap: balance; }
.d-title p { font-size: 20px; line-height: 1.5; font-weight: 300; margin: 0; color: var(--muted); }

/* Controls */
button, input, textarea, select { font: inherit; color: var(--text); }
button {
    font-size: 13px; background: var(--bg); border: 1px solid var(--rule); border-radius: 4px; padding: 6px 12px; cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}
button:hover:not(:disabled) { border-color: var(--faint); }
button:disabled { color: var(--faint); cursor: default; }
select { font-size: 13px; background: var(--bg); border: 1px solid var(--rule); border-radius: 4px; padding: 5px 6px; }
input[type="text"] { font-size: 15px; background: var(--bg); border: 1px solid var(--rule); border-radius: 4px; padding: 7px 10px; }
input[type="text"]:focus { outline: none; border-color: var(--faint); }

/* The figure */
.steer { margin-top: 0; margin-bottom: 56px; }
.pane-title { font-size: 14px; font-weight: 600; margin: 0 0 10px; }
.pane-title span { font-weight: 400; color: var(--muted); margin-left: 6px; }
.note { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 10px 0 0; }

.status { margin-bottom: 20px; font-size: 13px; color: var(--muted); }
.status p { margin: 0 0 6px; }
.status.error { color: rgb(var(--p1)); }
.progress { height: 2px; background: var(--rule); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: rgb(var(--lit)); transition: width 0.2s; }
.status[hidden] { display: none; }

.read { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
.read > .pane:first-child { position: sticky; top: 16px; align-self: start; }   /* stays beside a long list */

/* the passage: a textarea with transparent background over a backdrop that draws the highlights */
.editor { position: relative; }
.editor textarea, .backdrop {
    font-family: var(--serif); font-size: 20px; line-height: 1.8; padding: 14px 16px; margin: 0;
    white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; letter-spacing: normal;
    border: 1px solid var(--rule); border-radius: 4px;
}
.editor textarea { position: relative; display: block; width: 100%; background: transparent; resize: none; overflow: hidden; min-height: 6em; caret-color: var(--text); }
.editor textarea:focus { outline: none; border-color: var(--faint); }
.backdrop { position: absolute; inset: 0; color: transparent; overflow: hidden; border-color: transparent; pointer-events: none; background: var(--panel); }
.backdrop span { border-radius: 2px; transition: background 0.15s; }
.backdrop .lit { background: rgba(var(--c, var(--lit)), calc(0.1 + 0.55 * var(--a))); }
.backdrop .sel { box-shadow: inset 0 -2px 0 var(--text); }

/* concept list */
.concepts-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 10px; min-height: 30px; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 5px; padding: 2px; }
.seg button { border: none; border-radius: 3px; padding: 4px 10px; color: var(--muted); background: none; }
.seg button[aria-pressed="true"] { background: var(--wash); color: var(--text); font-weight: 600; }
.stepper { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.stepper[hidden] { display: none; }
.stepper button { padding: 0 9px; font-size: 17px; line-height: 26px; }
.stepper #word { min-width: 7em; text-align: center; font-variant-numeric: tabular-nums; }
.stepper #word b { font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--text); }

.concept-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.concept {
    display: grid; grid-template-columns: 26px minmax(0, 1fr) 92px; align-items: center; gap: 8px;
    padding: 6px 6px 6px 2px; border-bottom: 1px solid var(--rule); cursor: pointer; font-size: 14px;
}
.concept:hover { background: var(--wash); }
.concept.sel { background: var(--wash); box-shadow: inset 2px 0 0 rgb(var(--c, var(--lit))); }
.concept .what { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.concept.faint .what { color: var(--faint); }
.concept .amount { display: grid; grid-template-columns: 1fr 34px; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.bar { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.bar span { display: block; height: 100%; background: rgb(var(--c, var(--lit))); }
.concept.faint .bar span { opacity: 0.4; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 2px; }

.pin {
    width: 20px; height: 20px; padding: 0; margin: 0 auto; border-radius: 50%;
    border: 1.5px solid var(--faint); background: none; position: relative;
}
.pin:hover:not(:disabled) { border-color: rgb(var(--lit)); }
.pin::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; line-height: 1; color: var(--muted); }
.pin.on { background: rgb(var(--c)); border-color: rgb(var(--c)); }
.pin.on::after { content: "✓"; color: var(--bg); font-size: 11px; font-weight: 700; }
.no-pin { width: 20px; margin: 0 auto; text-align: center; color: var(--faint); font-size: 12px; }

/* the picked concept */
.detail { margin-top: 14px; padding: 14px 16px; background: var(--panel); border-radius: 4px; font-size: 13px; }
.detail[hidden] { display: none; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail h4 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.detail .meta { color: var(--muted); margin: 0; }
.detail .pin-big { flex: none; white-space: nowrap; }
.detail .pin-big.on { background: rgb(var(--c)); border-color: rgb(var(--c)); color: var(--bg); }
.detail h5 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.examples { list-style: none; margin: 0; padding: 0; }
.examples li { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 8px; padding: 3px 0; font-family: var(--serif); font-size: 14px; color: var(--muted); }
.examples .ctx { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; direction: ltr; }
.examples mark { background: rgba(var(--c, var(--lit)), 0.28); color: var(--text); border-radius: 2px; padding: 0 1px; }
.examples .pct { font-family: var(--font); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; }

/* from reading to writing */
.bridge { display: flex; align-items: center; gap: 14px; margin: 26px 0 18px; padding-top: 2px; }
.bridge svg { flex: none; width: 18px; height: 34px; fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.pinned { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    border: 1px solid rgba(var(--c), 0.45); background: rgba(var(--c), 0.08); border-radius: 14px; padding: 2px 2px 2px 10px; color: var(--text);
}
.chip::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: rgb(var(--c)); }
.chip .name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 320px; }
.chip button { border: none; background: none; padding: 0 7px; font-size: 15px; line-height: 20px; color: var(--muted); border-radius: 10px; }
.chip button:hover { color: var(--text); background: var(--wash); }

.composer { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; padding: 12px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.composer label { display: flex; align-items: center; gap: 8px; }
.composer .prompt { flex: 1 1 300px; }
.composer .prompt input { flex: 1; min-width: 0; font-family: var(--serif); font-size: 16px; }
.composer output { min-width: 3em; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.slider { display: inline-flex; }
.slider input { width: 140px; accent-color: rgb(var(--lit)); }

.write { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; margin-top: 22px; }
.gen { font-family: var(--serif); font-size: 19px; line-height: 1.75; margin: 0; min-height: 7em; white-space: pre-wrap; overflow-wrap: break-word; }
.gen .prompt { font-weight: 600; }
.gen .lit { background: rgba(var(--c), calc(0.1 + 0.5 * var(--a))); border-radius: 2px; }
.gen.scored .lit { animation: fade-in 0.4s ease-out; }
.baseline .gen { color: var(--muted); }
.baseline .gen .prompt { color: var(--text); }
.gen.writing::after { content: ""; display: inline-block; width: 0.5em; height: 1em; margin-left: 2px; vertical-align: -0.12em; background: var(--faint); animation: blink 1s steps(1) infinite; }
.gen .wait { font-family: var(--font); font-size: 14px; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }
@keyframes fade-in { from { background: transparent; } }

.presence { list-style: none; margin: 12px 0 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.presence li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 2px 0; }
.presence .dot { width: 8px; height: 8px; border-radius: 50%; background: rgb(var(--c)); }
.presence .name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.presence b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

figcaption { color: var(--muted); font-size: 13px; line-height: 1.55; margin-top: 28px; }
figcaption b { color: var(--text); font-weight: 600; }

/* Article text */
.d-article { font-size: 18px; line-height: 1.7; position: relative; }
.d-article p { margin: 0 0 1.1em; }
.d-article ul { margin: 0 0 1.1em; padding-left: 1.3em; }
.d-article li { margin-bottom: 0.35em; }
.d-article h2 { font-size: 24px; font-weight: 600; line-height: 1.25; margin: 52px 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.d-article a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--faint); }
.d-article a:hover { border-color: var(--text); }
.d-article sup { line-height: 0; }
.d-article sup a { border: none; color: rgb(var(--lit)); font-size: 0.72em; font-weight: 600; }
.sidenote { font-size: 13px; line-height: 1.55; color: var(--muted); margin: -0.4em 0 1.2em; padding-left: 12px; border-left: 2px solid var(--rule); }
.sidenote sup a { font-size: 0.85em; }
@media (min-width: 1180px) {
    .sidenote { float: right; clear: right; width: 220px; margin: 4px -268px 0 0; padding: 0; border: none; }
}

.diagram { margin: 32px 0 36px; }
.diagram svg { display: block; width: 100%; height: auto; font-family: var(--font); }
.diagram figcaption { margin-top: 14px; }
.d-box rect { fill: var(--panel); stroke: var(--rule); }
.d-box text { font-size: 13px; fill: var(--text); text-anchor: middle; font-weight: 600; }
.d-box .d-sub { font-size: 11px; fill: var(--muted); font-weight: 400; }
.d-read rect { stroke: rgba(var(--lit), 0.6); }
.d-steer rect { stroke: rgba(var(--p1), 0.6); fill: rgba(var(--p1), 0.07); }
.d-line { fill: none; stroke: var(--faint); stroke-width: 1.5; }
.d-read-line { stroke: rgba(var(--lit), 0.8); }
.d-steer-line { stroke: rgba(var(--p1), 0.8); }
.d-head { fill: var(--faint); }
.d-node { fill: var(--bg); stroke: var(--text); stroke-width: 1.5; }
.d-plus { font-size: 18px; text-anchor: middle; fill: var(--text); }
.d-label { font-size: 12px; fill: var(--muted); text-anchor: middle; font-style: italic; }

.d-appendix { margin-top: 60px; padding-top: 22px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px; line-height: 1.6; }
.d-appendix h3 { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 10px; }
.d-appendix a { color: inherit; }
.references { padding-left: 20px; margin: 0 0 14px; }
.references li { margin-bottom: 6px; }
.references li:target { color: var(--text); }

@media (max-width: 820px) {
    .d-title { padding-top: 40px; }
    .d-title h1 { font-size: 34px; }
    .d-title p { font-size: 18px; }
    .read, .write { grid-template-columns: minmax(0, 1fr); gap: 28px; }
    .read > .pane:first-child { position: static; }
    .editor textarea, .backdrop { font-size: 18px; }
    .gen { font-size: 18px; min-height: 4em; }
    .chip .name { max-width: 220px; }
    .d-article { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::after { animation: none !important; transition: none !important; }
}
