/* indigo thread on linen: the words change on a swatch, and too small to read they are woven in */
:root {
  --ground: #f3efe6; --raised: #fffdf8; --ink: #22232e; --soft: #615f68; --line: #d8d1c2;
  --deep: #2f3e7a; --on-deep: #ffffff; --mark: #f3cfc4; --lit: #b4553f;
  --weave: rgb(47 62 122 / .045); --warp: #c9bfa9; --selvedge: rgb(47 62 122 / .32); --edge: rgb(34 35 46 / .17); --cast: rgb(34 35 46 / .2);
  --linen: repeating-linear-gradient(0deg, var(--weave) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, var(--weave) 0 1px, transparent 1px 3px), var(--raised);
  --selvedges: repeating-linear-gradient(90deg, var(--selvedge) 0 1px, transparent 1px 2.2px) left / 9px 100% no-repeat, repeating-linear-gradient(90deg, var(--selvedge) 0 1px, transparent 1px 2.2px) right / 9px 100% no-repeat;
  --wound: repeating-linear-gradient(0deg, color-mix(in srgb, var(--on-deep) 14%, transparent) 0 1px, transparent 1px 3px), var(--deep);
  --tint-a: #e9e3f0; --tint-b: #f2e4cf;
  --read: Charter, "Bitstream Charter", "Iowan Old Style", Cambria, serif;
  --ui: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  --fig: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #14161f; --raised: #1f2230; --ink: #ece5d6; --soft: #a5a1a8; --line: #343848;
    --deep: #a9b6f5; --on-deep: #14161f; --mark: #57323a; --lit: #e58f78;
    --weave: rgb(236 229 214 / .035); --warp: #3d4052; --selvedge: rgb(169 182 245 / .3); --edge: rgb(255 255 255 / .15); --cast: rgb(0 0 0 / .5);
    --tint-a: #1e2338; --tint-b: #262129;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--ground); color: var(--ink); font: 16px/1.5 var(--ui); }
body { margin: 0; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: radial-gradient(60vmax 50vmax at 8% 0%, var(--tint-a), transparent 70%), radial-gradient(60vmax 50vmax at 100% 100%, var(--tint-b), transparent 70%); opacity: .35; }
.bar, #status, #peek, #help, #docs li, .button, button, #add textarea, .thumb output {
  background: var(--raised); border: 1px solid var(--edge);
  box-shadow: 0 2px 6px -3px var(--cast);
}
button, .button { font: inherit; color: inherit; border-radius: 4px; padding: .4rem .9rem; cursor: pointer; }
button:hover:not(:disabled), .button:hover { border-color: var(--deep); }
button:disabled { opacity: .4; cursor: default; }
.primary { background: var(--deep); border-color: var(--deep); color: var(--on-deep); }
:focus-visible, #file:focus-visible + .hint { outline: 2px solid var(--deep); outline-offset: 2px; }
a { color: var(--deep); }

#shelf { max-width: 44rem; margin: 0 auto; padding: 4rem 1.25rem; display: grid; gap: 2.5rem; }
#shelf h1 { font: 600 3rem/1 var(--read); margin: 0 0 .5rem; }
#shelf h2 { font-size: 1rem; margin: 0 0 .5rem; }
#shelf header p { margin: 0; color: var(--soft); }
.key { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; gap: .35rem; font-size: .92rem; }
.key li { padding-left: 1.5rem; text-indent: -1.5rem; }
.key svg { width: 1rem; height: 1rem; margin-right: .5rem; vertical-align: -.15em; fill: none; stroke: var(--deep); stroke-width: 1.5; stroke-linecap: round; }
.key b { color: var(--deep); font-weight: 600; }
.key i { color: var(--soft); }
.key .any { color: var(--soft); text-indent: 0; }
#help .key { margin: 0 0 1.25rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--edge); }
#demo { display: grid; gap: 1rem; padding: 1rem 1.25rem; background: var(--linen); border: 1px solid var(--edge); border-radius: 6px; box-shadow: 0 2px 6px -3px var(--cast); }
#demo p, #keyed p { margin: 0; }
#keyForm, #keyed { display: grid; gap: .6rem; justify-items: start; }
#keyForm .row { width: 100%; flex-wrap: nowrap; }
#key { flex: 1; min-width: 0; font: .95rem var(--fig); color: inherit; background: var(--raised); border: 1px solid var(--edge); border-radius: 4px; padding: .45rem .7rem; }
.check { display: flex; gap: .4rem; align-items: center; }
#keyMsg:empty { display: none; }
#keyMsg.bad { color: #b3322b; }
/* the static demo says so, as a strip across the top, and links to the real thing */
#banner { display: block; text-align: center; padding: .5rem 1rem; font-size: .85rem; text-decoration: none; background: var(--wound); color: var(--on-deep); }
#banner:hover { text-decoration: underline; }
#helpStatic { margin: 0 0 1rem; font-size: .92rem; }
#add { display: grid; gap: .75rem; }
#add textarea { font: 1rem/1.5 var(--ui); color: inherit; border-radius: 14px; padding: .75rem; resize: vertical; width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
#file { position: absolute; opacity: 0; width: 1px; height: 1px; }
.hint, #addMsg { color: var(--soft); font-size: .875rem; }
#addMsg { margin: 0; min-height: 1.3em; }
#addMsg.bad { color: #b3322b; }
#docs { list-style: none; margin: 0; padding: 0; }
#docs { display: grid; gap: .75rem; }
#docs li { display: flex; gap: 1rem; align-items: start; border-radius: 18px; padding: 1rem 1.1rem; transition: transform .2s, box-shadow .2s; }
#docs li:has(a:hover) { transform: translateY(-2px); }
#docs li.hint { background: none; border: 0; box-shadow: none; padding: 0; }
#docs a::after { content: ""; position: absolute; inset: 0; border-radius: 18px; }
#docs li { position: relative; }
#docs li button { position: relative; z-index: 1; }
#docs small { display: block; margin-top: .35rem; color: var(--soft); font: .75rem var(--fig); }
.tries button { font-size: .85rem; padding: .25rem .75rem; }
#docs a { flex: 1; min-width: 0; color: inherit; text-decoration: none; overflow-wrap: anywhere; }
#docs a:hover b { color: var(--deep); }
#docs b { font: 600 1.1rem/1.3 var(--read); display: block; }
#docs span { display: block; color: var(--soft); font-size: .9rem; }
#docs button { font-size: .8rem; padding: .2rem .6rem; }
/* the shelf in the same cloth: each source a swatch, buttons squared off, the one to press wound in indigo */
#shelf .primary { background: var(--wound); color: var(--on-deep); border-color: var(--deep); }
#add textarea { border-radius: 6px; background: var(--linen); }
#docs li { border-radius: 6px; background: var(--linen); padding-inline: 1.5rem; }
#docs li:not(.hint)::before, #docs li:not(.hint)::after { content: ""; position: absolute; pointer-events: none; }
#docs li:not(.hint)::before { inset: 0 2px; background: var(--selvedges); }
/* the hem is stitched on the one you are about to open */
#docs li:not(.hint)::after { inset: 5px 14px; border-block: 1px dashed var(--selvedge); opacity: 0; transition: opacity .2s; }
#docs li:has(a:hover)::after { opacity: 1; }
#docs li:has(a:hover) { box-shadow: 0 12px 30px -12px var(--cast); }
#docs a::after { border-radius: 6px; }
body.drop { outline: 3px dashed var(--deep); outline-offset: -8px; min-height: 100vh; }

/* the bar is a band of the swatch's linen: selvedge at its ends, a running stitch along top and bottom */
.bar { background: var(--linen); box-shadow: 0 10px 28px -14px var(--cast), 0 2px 6px -2px var(--cast); }
.bar::before, .bar::after, #swatch::before, #swatch::after { content: ""; position: absolute; pointer-events: none; }
.bar::before, #swatch::before { inset: 0 2px; background: var(--selvedges); }
.bar::after { inset: 6px 14px; border-block: 1.3px dashed var(--selvedge); }
.bar { position: fixed; inset: .6rem .75rem auto; border-radius: 6px; z-index: 3; height: 3.5rem; padding: 0 1.25rem; display: grid; grid-template-columns: auto auto 1fr; gap: 1.25rem; align-items: center; }
.back { text-decoration: none; }
.right { display: flex; justify-content: end; align-items: center; gap: .5rem; min-width: 0; }
.right button { white-space: nowrap; font-size: .8rem; padding: .2rem .7rem; box-shadow: none; }
#moreOpen { display: none; min-width: 2.25rem; min-height: 2rem; font-size: 1rem; line-height: 1; }
#more { inset: 4.6rem .75rem auto auto; margin: 0; padding: .4rem; border: 1px solid var(--edge); border-radius: 6px; background: var(--linen); color: inherit; box-shadow: 0 12px 30px -12px var(--cast); }
#more:popover-open { display: grid; gap: .3rem; }
#more button { text-align: left; padding: .55rem .9rem; box-shadow: none; }
#want { font: .8rem var(--fig); width: 8.5rem; padding: .25rem .7rem; border: 1px solid var(--deep); border-radius: 4px; color: inherit; background: var(--raised); }
#count { background: none; border-color: transparent; box-shadow: none; text-align: right; color: var(--soft); font: .8rem var(--fig); margin-right: .25rem; }
#count i { font-style: normal; }
.stop.lifted { background: var(--ground); border: 2px solid var(--deep); }
#map { position: fixed; z-index: 2; right: 1rem; top: 6rem; width: 3.5rem; height: calc(100vh - 8rem); cursor: pointer; }
#peek { position: fixed; z-index: 6; width: min(26rem, calc(100vw - 24px)); padding: .9rem 1.1rem; border-radius: 6px; pointer-events: none; animation: rise .18s ease-out; background: var(--linen); box-shadow: 0 12px 30px -12px var(--cast); }
#peek q { display: block; quotes: none; font: .95rem/1.5 var(--read); overflow-wrap: anywhere; }
#peek span { display: block; margin-top: .5rem; color: var(--soft); font-size: .78rem; }
@keyframes rise { from { opacity: 0; transform: translateY(6px) scale(.98); } }
#help { color: inherit; width: min(32rem, calc(100vw - 2rem)); padding: 1.5rem 1.75rem; border-radius: 6px; background: var(--linen); box-shadow: 0 22px 60px -20px var(--cast); }
#help[open] { animation: rise .2s ease-out; }
#help::backdrop { background: color-mix(in srgb, var(--ground) 45%, transparent); }
#help h2 { margin: 0 0 1rem; font: 600 1.3rem/1.2 var(--read); }
#help dl { display: grid; grid-template-columns: auto 1fr; gap: .7rem 1.25rem; margin: 0 0 1.25rem; font-size: .92rem; }
#help dt { font-weight: 600; white-space: nowrap; }
#help dd { margin: 0; color: var(--soft); }
kbd { font: .8rem var(--fig); border: 1px solid var(--edge); border-radius: 4px; padding: .1rem .4rem; background: var(--raised); }
.levels { display: flex; }
.levels { gap: .2rem; }
.levels button { border-radius: 4px; font-weight: 500; background: none; border-color: transparent; box-shadow: none; transition: background .3s, color .3s, box-shadow .3s; }
/* each level drawn in threads: one for a sentence, a few for a paragraph, close-set for the whole source */
.levels button { display: inline-flex; align-items: center; gap: .4rem; }
.levels svg { width: 1rem; height: 1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.levels button:active:not(:disabled) { transform: scale(.95); }
/* the level you are at is wound in indigo thread */
.levels [aria-pressed="true"] { background: var(--wound); color: var(--on-deep); box-shadow: 0 2px 6px -2px var(--cast); }

/* words are drawn here while they change, over the swatch */
#stage { position: fixed; inset: 0; z-index: 1; width: 100%; height: 100%; pointer-events: none; }
article.morph { opacity: 0; }
article.small { padding-bottom: 100vh; }
article.small #text { column-gap: 18px; column-fill: balance; }
article.small #text pre { font-size: .85em; padding: 1em; }
#swatch {
  position: fixed; z-index: 0; border-radius: 6px; pointer-events: none; overflow: hidden;
  opacity: 0; visibility: hidden; transform: scale(1.02); transition: opacity .26s, transform .26s, visibility .26s;
  border: 1px solid var(--edge);
  background: repeating-linear-gradient(0deg, var(--weave) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, var(--weave) 0 1px, transparent 1px 3px), var(--raised);
  box-shadow: 0 14px 40px -18px var(--cast), 0 2px 6px -2px var(--cast);
}
#swatch.on { opacity: 1; visibility: visible; transform: none; }
/* the selvedge down each side, a running stitch along the top and bottom */
#swatch::after { inset: 9px 16px; border-block: 1.3px dashed var(--selvedge); }

#gauge { --p: 0; position: fixed; z-index: 2; left: 0; top: 4.5rem; bottom: 0; width: 8rem; touch-action: none; cursor: ns-resize; user-select: none; -webkit-user-select: none; }
#gauge:focus-visible { outline-offset: -4px; }
.track { position: absolute; left: 1.5rem; right: 0; top: 2rem; bottom: 2rem; }
.tick { position: absolute; left: 0; top: calc(var(--t) * 100%); width: .5rem; border-top: 1px solid var(--line); }
.tick.major { width: .9rem; border-color: var(--soft); }
.tick.major::after { content: attr(data-n); position: absolute; left: 1.3rem; top: -.65em; font: .7rem var(--fig); color: var(--soft); }
.stop { position: absolute; left: -.25rem; top: calc(var(--t) * 100% - 4px); width: 8px; height: 8px; border-radius: 50%; background: var(--deep); }
/* names and the count stand clear of the tick numbers */
.stop[data-name]::after { content: attr(data-name); position: absolute; left: 3.3rem; top: -.28rem; font: 600 .7rem/1rem var(--ui); color: var(--deep); background: var(--ground); padding: 0 .3rem; border-radius: 6px; }
.thumb { position: absolute; z-index: 1; left: 1rem; top: calc(2rem + var(--p) * (100% - 4rem)); pointer-events: none; }
.thumb::before { content: ""; position: absolute; left: 0; top: -1px; width: 3.55rem; border-top: 3px solid var(--deep); }
.thumb output { position: absolute; left: 3.55rem; top: -.8rem; background: var(--wound); border-color: var(--deep); color: var(--on-deep); font: .75rem/1.6rem var(--fig); padding: 0 .65rem; border-radius: 4px; white-space: nowrap; }

article { max-width: 44rem; margin: 0 auto; padding: 7rem 1.25rem 60vh; }
.head h1 { font: 600 1.25rem/1.3 var(--read); margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.head p { margin: .25rem 0 2.5rem; color: var(--soft); font-size: .875rem; overflow-wrap: anywhere; }
#text { font-family: var(--read); outline: none; overflow-wrap: anywhere; }
#text[data-key="tldr"] { font-size: clamp(1.6rem, 4.5vw, 2.5rem); line-height: 1.3; text-wrap: pretty; }
#text[data-key="nenm"] { font-size: clamp(1.2rem, 2.6vw, 1.45rem); line-height: 1.6; }
#text { font-size: 1.15rem; line-height: 1.65; }
#text p { margin: 0 0 1.1em; }
#text h2 { font: 600 1.25em/1.3 var(--read); margin: 1.8em 0 .6em; }
#text pre { font: .85rem/1.5 var(--fig); overflow-x: auto; background: var(--raised); padding: 1rem; border: 1px solid var(--line); }
.s { cursor: zoom-in; border-radius: 2px; }
.s:hover { background: color-mix(in srgb, var(--mark) 55%, transparent); }
.here { background: var(--mark); box-shadow: 0 0 0 .2em var(--mark); border-radius: 2px; transition: background .4s, box-shadow .4s; }
.morph .here { background: none; box-shadow: none; }
#text.draft { color: var(--soft); transition: color .3s; }
#status { position: fixed; z-index: 4; left: 50%; bottom: 1.5rem; transform: translateX(-50%); display: flex; gap: 1rem; align-items: center; max-width: calc(100vw - 2rem); border-radius: 6px; background: var(--linen); box-shadow: 0 10px 28px -14px var(--cast); padding: .5rem .6rem .5rem 1.1rem; font-size: .9rem; }

@media (max-width: 64rem) {
  .stop[data-name]::after { display: none; }
  /* the map stays, as a strip at the edge wide enough to tap, between the bar and the gauge */
  #map { right: 0; top: 4.75rem; width: 26px; height: calc(100dvh - 9.75rem - env(safe-area-inset-bottom)); }
  article { padding-right: calc(1.25rem + 10px); }
  #gauge { top: auto; left: 0; right: 0; width: auto; height: calc(4.5rem + env(safe-area-inset-bottom)); cursor: ew-resize; background: var(--linen); border-top: 1px solid var(--edge); box-shadow: 0 -8px 24px -14px var(--cast); }
  .track { left: 2rem; right: 2rem; top: 2.4rem; bottom: 0; }
  .tick { left: calc(var(--t) * 100%); top: 0; width: 0; height: .4rem; border: 0; border-left: 1px solid var(--line); }
  .tick.major { width: 0; height: .7rem; }
  .tick.major::after { left: 0; top: .75rem; transform: translateX(-50%); }
  .stop { left: calc(var(--t) * 100% - 4px); top: -.3rem; }
  .thumb { top: 2.1rem; left: calc(2rem + var(--p) * (100% - 4rem)); }
  .thumb::before { left: -1px; top: 0; width: 0; height: 1rem; border: 0; border-left: 3px solid var(--deep); }
  .thumb output { left: 0; top: -1.8rem; transform: translateX(calc(var(--p) * -100%)); }
  #status { bottom: 6rem; }
  .bar { padding: 0 .9rem; gap: .5rem; }
  .levels button { padding: .4rem .6rem; }
}
/* a phone has room for one name: the level you are at; the others are their threads */
@media (max-width: 30rem) { .levels button:not([aria-pressed="true"]) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } .levels button:not([aria-pressed="true"]) { gap: 0; } }
/* on a phone each way to zoom stands over what it does */
@media (max-width: 30rem) { #help { padding: 1.25rem; } #help dl { grid-template-columns: 1fr; gap: .15rem; } #help dt { white-space: normal; } #help dd { margin-bottom: .6rem; } }
@media (max-width: 48rem) { #count { font-size: .68rem; min-height: 2rem; } .back { padding-block: .4rem; } #count i { display: none; } .right button:not(#count, #moreOpen) { display: none; } #moreOpen { display: inline-block; } #want { width: 6.5rem; } }
@media (prefers-reduced-motion: reduce) { #peek, #help[open] { animation: none; } #docs li { transition: none; } }
