.cache-figure{background:var(--surface);padding:16px 18px}
.cache-figure h4,.matrix-layout h4{font:600 1.18rem/1.35 var(--serif);margin:0 0 14px}
.cache-figure small,.packed-line small,.word small,.cache-copy small,.cache-memory small{color:var(--muted);font:600 .78rem/1.4 var(--sans)}
.cache-figure p{margin:10px 0 0}
.word{display:inline-grid;place-items:center;min-height:34px;min-width:0;border:1px solid var(--line);background:var(--quiet);padding:5px;border-radius:4px;font:600 .9rem/1.4 var(--mono)}
.word.selected,.level.selected,.matrix-layout .word.selected{background:var(--accent);color:var(--on-accent);border-color:var(--accent)}
.word.selected small{color:inherit}
.word.resident,.cache-copy.state-E,.cache-copy.state-M{color:var(--accent);background:var(--selection);border-color:var(--accent)}
.word.complete{color:var(--success);background:var(--success-bg)}
.line-words,.ring{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:2px;margin:8px 0}
.route,.batch,#slots{display:flex;align-items:center;flex-wrap:wrap;gap:6px}
.route .word+.word{margin-left:18px;position:relative}.route .word+.word::before{content:"→";position:absolute;right:calc(100% + 5px);color:var(--accent)}
.bar-row{display:grid;grid-template-columns:minmax(80px,24%) 1fr 3ch;align-items:center;gap:10px;margin:9px 0;font-size:.87rem}
.bar-row>div{height:17px;background:var(--quiet)}.bar-row i{display:block;height:100%;background:var(--accent)}
.level{width:var(--width);text-align:center;margin:4px auto;background:var(--quiet);border:1px solid var(--line);border-radius:4px;font:.9rem/1.6 var(--mono)}
.tile-grid{display:grid;grid-template-columns:repeat(8,1fr);gap:2px;max-width:240px;margin:auto}
.tile-grid i{aspect-ratio:1;background:var(--quiet);border:1px solid var(--line)}.tile-grid .hot{background:var(--selection);border-color:var(--accent)}
.time-row{display:grid;grid-template-columns:1fr repeat(3,minmax(0,1fr));align-items:center;gap:4px;margin:5px 0}
.cache-board{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:12px 0}
.cache-copy{display:grid;grid-template-columns:1fr auto;gap:2px 6px;align-items:center;padding:12px;border:1px solid var(--line);border-radius:7px;background:var(--quiet)}
.cache-copy strong{grid-column:2;grid-row:1/3;font:600 2.2rem/1 var(--mono)}
.cache-copy b,.cache-memory b{font:600 1rem var(--mono)}
.cache-copy span{font-size:.85rem}.cache-copy.state-I{border-style:dashed;color:var(--muted)}.cache-copy.state-S{border-color:var(--success);background:var(--success-bg)}
.cache-memory{grid-column:1/-1;display:flex;align-items:center;justify-content:center;gap:15px;border-block:1px solid var(--line);padding:8px}
.matrix-layout{display:grid;grid-template-columns:1.3fr 1fr;gap:20px;align-items:center;margin-top:18px}
#matrix-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:3px}
#matrix-grid .word{min-height:45px}
#slots .word{min-width:56px}
#stats,#sharing-note{font:600 .92rem/1.5 var(--mono)}
.packed-line{margin:12px 0;padding:10px;border:1px solid var(--line);border-radius:6px}
.chapter select{max-width:100%;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:5px;padding:5px;font:inherit}
@media(max-width:620px){.cache-figure{padding:10px}.matrix-layout{grid-template-columns:1fr;gap:8px}.matrix-layout h4{margin:4px 0}.line-words .word{font-size:.7rem;padding:3px 0}.cache-copy{padding:7px;grid-template-columns:1fr}.cache-copy strong{grid-column:1;grid-row:auto}.time-row .word{font-size:.7rem}.packed-line{padding:6px}.route .word{font-size:.78rem}.ring .word{font-size:.85rem}}

.cache-copy strong {white-space:nowrap}
.cache-copy em {font:600 .95rem var(--mono);color:var(--muted);vertical-align:middle}
.cache-memory {flex-wrap:wrap;gap:4px 12px}
.cache-memory span,.figure-key {font:.88rem/1.45 var(--sans);color:var(--muted)}
.atlas-figure .cache-tree {display:block;max-width:340px}
.cache-tree line {stroke:var(--line);stroke-width:2}
.cache-tree line.on-path {stroke:var(--accent);stroke-width:4}
.cache-tree g circle {fill:var(--surface);stroke:var(--line);stroke-width:2}
.cache-tree .on-path circle {fill:var(--selection);stroke:var(--accent)}
.cache-tree text {fill:var(--ink);font:600 16px var(--mono);text-anchor:middle}
.lock-attempts,.handoff,.ring-map {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px}
.lock-attempts>div,.handoff>div,.ring-map>div {display:flex;flex-flow:column;align-items:stretch;text-align:center;gap:3px}
.lock-attempts strong,.handoff b {font:600 1.12rem/1.6 var(--mono);background:var(--quiet);border:1px solid var(--line);border-radius:4px}
.lock-attempts .modify,.handoff .winner b {background:var(--selection);color:var(--accent);border-color:var(--accent)}
.lock-attempts span,.handoff span,.ring-map span {font:.82rem/1.3 var(--sans)}
.ring-map {grid-template-columns:repeat(5,minmax(0,1fr));gap:3px}
.ring-map .new-word {border:2px dashed var(--accent)}
.ring-map span:not(:empty){border-top:2px solid var(--accent);padding:4px 0;color:var(--accent);overflow-wrap:anywhere}
