/* Articles: shared stylesheet for /writing/. WCAG 2.2 AA in light and dark. */
:root {
  --ink: #0b1020; --ink-2: #131a33; --bg: #fff; --bg-alt: #f5f7fb; --text: #141824; --muted: #4b5468;
  --line: #e0e4ec; --link: #2449c9; --code-bg: #0f1424; --code-fg: #e6ebff; --hl: #ffe58a;
  --n-fill: #f2f5ff; --n-stroke: #b9c5f0; --a-fill: #e7e5ff; --a-stroke: #6d5ce8; --a-text: #2b1d8f;
  --x-fill: #ffe9e9; --x-stroke: #e46a6a; --x-text: #8a1010; --d-fill: #f3f4f7; --d-stroke: #cfd4de;
  --arrow: #5b6478; --c-tip: #047857; --c-warn: #92400e; --c-ins: #5b21b6; --star: #a14b00; --grad: linear-gradient(120deg, #5b8cff, #8b5cf6 55%, #22d3ee);
  --max: 1180px; --prose: 72ch;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1118; --bg-alt: #151a24; --text: #e9edf5; --muted: #a9b2c3; --line: #283040; --link: #9cb8ff;
    --n-fill: #1a2133; --n-stroke: #3a4870; --a-fill: #2a2560; --a-stroke: #9b8cff; --a-text: #ddd6ff;
    --x-fill: #3a1d22; --x-stroke: #e57b7b; --x-text: #ffd0d0; --d-fill: #1a1e27; --d-stroke: #333b4b; --arrow: #8e98ad; --c-tip: #86efac; --c-warn: #fde68a; --c-ins: #ddd6fe; --star: #fbbf24;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { margin: 0; font: 18px/1.7 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--link); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible { outline: 3px solid #22d3ee; outline-offset: 3px; border-radius: 4px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }
.skip { position: absolute; left: -9999px; } .skip:focus { left: 1rem; top: 1rem; background: #fff; color: #000; padding: .5rem 1rem; z-index: 99; }

.bar { position: sticky; top: 0; z-index: 40; background: rgba(11,16,32,.94); backdrop-filter: blur(8px); border-bottom: 1px solid rgba(255,255,255,.08); }
.bar .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 3.6rem; gap: 1rem; }
.brand { color: #fff; font-weight: 800; text-decoration: none; display: inline-flex; gap: .55rem; align-items: center; }
.mono { width: 30px; height: 30px; border-radius: 8px; background: var(--grad); display: grid; place-items: center; font-size: .8rem; }
.bar nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.bar nav a { color: #c3cbe2; text-decoration: none; font-size: .92rem; padding: .5rem 0; }
.bar nav a:hover { color: #fff; }
@media (max-width: 640px) { .bar nav a:not(:nth-child(2)) { display: none; } }
#progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--grad); z-index: 60; }

/* ---------- Systems Journal editorial identity ---------- */
.ahero { position: relative; overflow: hidden; }
.ahero::after { content: ""; position: absolute; width: 420px; height: 420px; right: -160px; top: 24px; border: 1px solid rgba(150,181,255,.16); border-radius: 50%; box-shadow: 0 0 0 38px rgba(150,181,255,.035), 0 0 0 82px rgba(150,181,255,.025); pointer-events: none; }
.ahero .wrap { position: relative; z-index: 1; }
.ahero.idx { padding-top: 4rem; padding-bottom: 3.5rem; }
.kickerline { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-bottom: 1rem; color: #c2cbe0; font-size: .74rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.kickerline .issue { border: 1px solid rgba(255,255,255,.22); border-radius: 999px; padding: .22rem .62rem; color: #dce6ff; background: rgba(255,255,255,.06); }
.kickerline .sep { color: #72809b; }
.ahero h1 { max-width: 26ch; }
.ahero .dek { max-width: 64ch; }
.ahero .meta { display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center; }
.ahero .meta .meta-item { white-space: nowrap; }
.brand-rail { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.16); }
.brand-rail .rail-label { flex-basis: 100%; color: #aeb9d6; font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; margin-bottom: .05rem; }
.brand-chip { display: inline-flex; align-items: center; gap: .48rem; min-height: 44px; padding: .32rem .75rem; color: #f0f4ff; text-decoration: none; font-size: .82rem; font-weight: 650; border: 1px solid rgba(255,255,255,.18); border-radius: 9px; background: rgba(255,255,255,.055); transition: background .15s, border-color .15s, transform .15s; }
.brand-chip:hover { background: rgba(255,255,255,.12); border-color: rgba(180,205,255,.55); transform: translateY(-1px); }
.brand-chip img { display: block; width: 20px; height: 20px; object-fit: contain; filter: brightness(0) invert(1); }
.brand-chip:focus-visible { outline-color: #67e8f9; }
.index-rail { margin: .8rem 0 0; padding: .65rem 0 0; border-top-color: var(--line); }
.index-rail .rail-label { color: var(--muted); font-size: .6rem; }
.index-rail ul { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: 0; padding: 0; }
.index-rail li { color: var(--muted); background: var(--bg-alt); border: 1px solid var(--line); border-radius: 999px; padding: .12rem .5rem; font-size: .68rem; font-weight: 700; }
@media (max-width: 680px) { .brand-rail { gap: .38rem; margin-top: .9rem; padding-top: .75rem; } .brand-chip { min-height: 44px; padding: .32rem .6rem; font-size: .76rem; } .brand-chip img { width: 18px; height: 18px; } }

.index-rail { margin: .8rem 0 0; padding: .65rem 0 0; border-top-color: var(--line); }
.index-rail .rail-label { color: var(--muted); font-size: .6rem; }
.index-rail ul { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: 0; padding: 0; }
.index-rail li { color: var(--muted); background: var(--bg-alt); border: 1px solid var(--line); border-radius: 999px; padding: .12rem .5rem; font-size: .68rem; font-weight: 700; }


.ahero { background: radial-gradient(900px 400px at 85% -20%, rgba(139,92,246,.45), transparent 60%), radial-gradient(700px 360px at 0% 120%, rgba(34,211,238,.25), transparent 60%), var(--ink); color: #eef2ff; padding: 3.2rem 0 2.6rem; }
.ahero.review .wrap { display: grid; grid-template-columns: 1fr 360px; gap: 0 2.5rem; align-items: start; }
.ahero.review .wrap > *:not(.bookcard) { grid-column: 1; }
.ahero.review .bookcard { grid-column: 2; grid-row: 1 / span 6; }
@media (max-width: 900px) { .ahero.review .wrap { grid-template-columns: 1fr; } .ahero.review .bookcard { grid-column: 1; grid-row: auto; margin-top: 1.5rem; } }
.crumbs { font-size: .88rem; color: #b8c2de; margin: 0 0 .8rem; } .crumbs a { color: #b8c2de; }
.ahero h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); line-height: 1.12; letter-spacing: -.025em; margin: 0 0 .8rem; max-width: 22ch; }
.ahero .dek { font-size: 1.18rem; color: #c9d2ea; max-width: 60ch; margin: 0 0 1rem; }
.ahero .meta { color: #aeb9d6; font-size: .9rem; margin: 0 0 .9rem; } .ahero .meta a { color: #c9d6ff; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; }
.tags li { font-size: .76rem; font-weight: 700; letter-spacing: .03em; padding: .12rem .6rem; border-radius: 999px; background: rgba(255,255,255,.1); color: #dfe6ff; }

.bookcard { background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(255,255,255,.03)); border: 1px solid rgba(255,255,255,.15); border-radius: 18px; padding: 1.3rem; }
.cover3d { margin: 0 auto 1.1rem; width: 180px; perspective: 900px; }
.cover3d img { display: block; width: 180px; height: auto; border-radius: 3px 8px 8px 3px; transform: rotateY(-14deg); box-shadow: 18px 22px 40px -12px rgba(0,0,0,.7), inset 4px 0 6px rgba(0,0,0,.25); transition: transform .4s; }
.cover3d:hover img { transform: rotateY(0); }
.bookcard dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem .8rem; margin: 0 0 1rem; font-size: .88rem; }
.bookcard dt { color: #aeb9d6; } .bookcard dd { margin: 0; color: #fff; }
.stars { color: #fbbf24; letter-spacing: .08em; }
.kicker .stars { color: var(--star); }
.verdict { margin: 0; font-size: .95rem; color: #eef2ff; background: rgba(0,0,0,.25); border-left: 4px solid #fbbf24; padding: .7rem .9rem; border-radius: 0 10px 10px 0; }
.verdict span { display: block; font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #fcd34d; }

/* Layout */
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 3rem; padding-top: 2.5rem; padding-bottom: 3rem; }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }
.toc { position: sticky; top: 5rem; align-self: start; font-size: .86rem; }
.toc p { font-weight: 800; letter-spacing: .1em; text-transform: uppercase; font-size: .72rem; color: var(--muted); margin: 0 0 .5rem; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc a { display: block; padding: .3rem 0 .3rem .9rem; margin-left: -2px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.35; }
.toc a:hover, .toc a.on { color: var(--text); border-left-color: #8b5cf6; }

/* Prose */
.prose { max-width: 820px; min-width: 0; }
figure.diagram { min-width: 0; }
.prose > p, .prose > ul, .prose > ol, .prose > blockquote, .prose > h2, .prose > h3 { max-width: var(--prose); }
.prose h2 { font-size: 1.7rem; letter-spacing: -.02em; line-height: 1.2; margin: 2.6rem 0 .8rem; padding-top: .4rem; }
.prose h2::before { content: ""; display: block; width: 44px; height: 4px; border-radius: 4px; background: var(--grad); margin-bottom: .8rem; }
.prose h3 { font-size: 1.2rem; margin: 1.8rem 0 .5rem; }
.prose p { margin: 0 0 1.1rem; }
.prose li { margin: .3rem 0; }
.prose code { font: .86em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg-alt); border: 1px solid var(--line); padding: .05rem .35rem; border-radius: 5px; }
.prose blockquote { margin: 1.5rem 0; padding: .9rem 1.2rem; border-left: 4px solid #8b5cf6; background: var(--bg-alt); border-radius: 0 12px 12px 0; font-size: 1.08rem; }
pre.code { position: relative; background: var(--code-bg); color: var(--code-fg); padding: 1.1rem 1.2rem; border-radius: 12px; overflow-x: auto; font: .86rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; margin: 1.4rem 0; }
pre.code code { background: none; border: 0; padding: 0; color: inherit; font: inherit; }
pre.code .lang { position: absolute; top: .45rem; right: .7rem; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: #93a0c8; }
.callout { margin: 1.5rem 0; padding: 1rem 1.2rem; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-alt); max-width: var(--prose); }
.callout strong { display: block; font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: .2rem; }
.c-tip { border-left: 5px solid #10b981; } .c-tip strong { color: var(--c-tip); }
.c-warning { border-left: 5px solid #f59e0b; } .c-warning strong { color: var(--c-warn); }
.c-insight { border-left: 5px solid #8b5cf6; } .c-insight strong { color: var(--c-ins); }
.table { overflow-x: auto; margin: 1.4rem 0; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-alt); font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }

/* Diagrams */
figure.diagram { margin: 2rem 0; }
.diagram { position: relative; }
.diagram::before { content: "SYSTEMS MAP"; display: block; color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .16em; margin: 0 0 .35rem .15rem; }
.dg-wrap { background: linear-gradient(145deg, var(--bg-alt), var(--bg)); border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem; overflow-x: auto; box-shadow: 0 12px 34px -30px rgba(9,18,42,.42); }
figure.diagram:nth-of-type(3n + 1) .dg-wrap { border-top: 3px solid #5278e8; }
figure.diagram:nth-of-type(3n + 2) .dg-wrap { border-top: 3px solid #8b5cf6; }
figure.diagram:nth-of-type(3n) .dg-wrap { border-top: 3px solid #138b92; }
.dg-hint { display: none; }
@media (max-width: 680px) { .dg-wrap { padding: .8rem; } .dg-hint { display: inline; } }
svg.dg { width: 100%; min-width: 600px; height: auto; display: block; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
figcaption { font-size: .9rem; color: var(--muted); margin-top: .6rem; }
figcaption span { font-weight: 800; color: var(--text); margin-right: .3rem; }
.dg .t { font-size: 13px; fill: var(--text); }
.dg .t-sm { font-size: 12px; fill: var(--muted); }
.dg .t-strong { font-weight: 700; }
.dg .t-cap { font-size: 11px; font-weight: 800; letter-spacing: .12em; fill: var(--muted); }
.dg .t-head { font-weight: 800; fill: #fff; font-size: 14px; }
.dg .t-acc { fill: var(--a-text); font-weight: 700; } .dg .t-bad { fill: var(--x-text); font-weight: 700; } .dg .t-dim { fill: var(--muted); }
.dg .t-accx { fill: var(--a-text); font-weight: 700; } .dg .t-badx { fill: var(--x-text); font-weight: 700; } .dg .t-nodex, .dg .t-dimx { fill: var(--text); font-weight: 600; }
.dg .b-node { fill: var(--n-fill); stroke: var(--n-stroke); stroke-width: 1.5; }
.dg .b-acc { fill: var(--a-fill); stroke: var(--a-stroke); stroke-width: 2; }
.dg .b-bad { fill: var(--x-fill); stroke: var(--x-stroke); stroke-width: 2; }
.dg .b-dim { fill: var(--d-fill); stroke: var(--d-stroke); stroke-width: 1.5; stroke-dasharray: 5 4; }
.dg .b-panel { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.dg .b-head.p0 { fill: #3b5bdb; } .dg .b-head.p1 { fill: #7048e8; } .dg .b-head.p2 { fill: #0c7c8c; }
.dg .dot.p0 { fill: #3b5bdb; } .dg .dot.p1 { fill: #7048e8; } .dg .dot.p2 { fill: #0c7c8c; }
.dg .b-layer { stroke-width: 1.5; }
.dg .l0 { fill: #e8edff; stroke: #9fb0f5; } .dg .l1 { fill: #efe9ff; stroke: #b9a4f6; } .dg .l2 { fill: #e3f7fb; stroke: #8fd3e3; }
.dg .l3 { fill: #fff3dd; stroke: #f1c26a; } .dg .l4 { fill: #e9f8ef; stroke: #8fd5aa; } .dg .l5 { fill: #fde8f1; stroke: #ee9cc0; }
@media (prefers-color-scheme: dark) {
  .dg .l0 { fill: #1c2547; stroke: #4a5ea8; } .dg .l1 { fill: #261d47; stroke: #6c55b8; } .dg .l2 { fill: #13303a; stroke: #2f8aa0; }
  .dg .l3 { fill: #3a2c12; stroke: #b4862b; } .dg .l4 { fill: #15301f; stroke: #3c9a62; } .dg .l5 { fill: #3a1729; stroke: #b0507d; }
}
.dg .b-layer.b-acc { stroke: var(--a-stroke); stroke-width: 2.5; }
.dg .arr { stroke: var(--arrow); stroke-width: 1.8; }
.dg .ah { fill: var(--arrow); } .dg .ah.big { fill: #7c5ce0; }
.dg .ring { fill: none; stroke: var(--line); stroke-width: 2; stroke-dasharray: 6 6; }
.dg .life { stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 4 4; }
.dg .pt { stroke: var(--bg); stroke-width: 2; } .dg .pt-node, .dg .pt-dim { fill: #5b6cf6; } .dg .pt-acc { fill: #7c3aed; } .dg .pt-bad { fill: #dc2626; }
.dg .ln { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.dg .ln-node { stroke: #5b6cf6; } .dg .ln-acc { stroke: #7c3aed; } .dg .ln-bad { stroke: #dc2626; } .dg .ln-dim { stroke: #9aa3b5; stroke-dasharray: 6 5; }
.dg .lbl-bg { fill: var(--bg); opacity: .92; }
.dg .track { fill: var(--line); opacity: .6; }
.dg .bar { fill: #5b6cf6; } .dg .bar-acc { fill: #7c3aed; } .dg .bar-bad { fill: #dc2626; } .dg .bar-dim { fill: #9aa3b5; }

.author { display: flex; gap: 1rem; align-items: center; margin: 3rem 0 1.5rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-alt); font-size: .95rem; }
.author img { border-radius: 50%; object-fit: cover; flex: none; }
.author p { margin: 0; }
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pn a { display: block; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; font-weight: 700; line-height: 1.35; }
.pn a span { display: block; font-size: .75rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .2rem; }
.pn a.next { text-align: right; grid-column: 2; }
.pn a:hover { border-color: var(--link); }

/* Index */
.sec { font-size: 1.6rem; letter-spacing: -.02em; margin: 3rem 0 1.2rem; }
.sec::before { content: ""; display: block; width: 44px; height: 4px; border-radius: 4px; background: var(--grad); margin-bottom: .7rem; }
.ggrid, .rgrid { list-style: none; margin: 0 0 2rem; padding: 0; display: grid; gap: 1rem; }
.ggrid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.rgrid { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); margin-bottom: 4rem; }
@media (max-width: 560px) { .ggrid, .rgrid { grid-template-columns: 1fr; } }
.gcard a, .rcard a { display: block; height: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 1.3rem; text-decoration: none; color: var(--text); background: var(--bg); transition: transform .2s, box-shadow .2s, border-color .2s; position: relative; overflow: hidden; }
.gcard a::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--grad); }
.gcard a:hover, .rcard a:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -24px rgba(16,24,64,.5); border-color: #8b5cf6; }
.gcard h3, .rcard h3 { margin: .3rem 0 .4rem; font-size: 1.12rem; line-height: 1.3; }
.gcard p, .rcard p { color: var(--muted); font-size: .95rem; margin: 0 0 .7rem; }
.kicker { font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--link); }
.rcard a { display: grid; grid-template-columns: 110px 1fr; gap: 1.1rem; }
.rcard img { width: 110px; height: auto; border-radius: 3px 6px 6px 3px; box-shadow: 8px 10px 20px -8px rgba(0,0,0,.45); align-self: start; }
.rcard .by { font-size: .88rem; margin: -.2rem 0 .5rem; }
.gcard .tags li, .rcard .tags li { background: var(--bg-alt); color: var(--muted); border: 1px solid var(--line); }
.foot { border-top: 1px solid var(--line); padding: 1.5rem 0 2.5rem; color: var(--muted); font-size: .85rem; }
.foot p { max-width: 100ch; }

@media print { .bar, .toc, .pn, #progress { display: none !important; } :focus { outline: 2px solid #000; outline-offset: 2px; } .ahero { background: #fff; color: #000; } .ahero * { color: #000 !important; } }
