/* Every Letter a Number. A compositor's bench at night: a wooden type case,
   paper-faced type, steel byte tiles, and two inks: red for marker bits,
   blue for payload bits. */
:root {
  --ink: #14171d; --bench: #1b2029; --rule: #303847;
  --wood: #5a3f29; --wood2: #3d2a1b; --recess: #1d150e;
  --paper: #efe6d0; --paperdim: #b5aa93; --typeink: #1b1a17;
  --steel: #232a36; --steeledge: #3a4557;
  --text: #ebe6da; --dim: #a2a8b3;
  --red: #ff7657; --blue: #74c7ec; --blue2: #b8a6f5; --brass: #e6b755; --ok: #8fd694;
  --serif: 'Libre Caslon Text', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  --glyph: 'IBM Plex Sans', system-ui, 'Noto Sans', 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Sans CJK SC', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ink); color: var(--text); font: 15px/1.5 var(--sans); }
a { color: var(--brass); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
code { font-family: var(--mono); font-size: .92em; background: #262d3a; padding: 1px 4px; border-radius: 3px; }

.app { display: grid; grid-template-rows: auto 1fr auto; height: 100vh; height: 100dvh; }
.top { display: flex; align-items: baseline; gap: 14px; padding: 10px 20px; border-bottom: 1px solid var(--rule); }
.brand { font: 700 20px/1.2 var(--serif); color: var(--paper); text-decoration: none; }
.tag { color: var(--dim); font: italic 14px var(--serif); }
.main { display: grid; grid-template-columns: minmax(0, 1fr) 390px; min-height: 0; }
.pic { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.textbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 12px 20px; border-bottom: 1px solid var(--rule); background: var(--bench); }
.textbar label { font-weight: 600; }
#txt { flex: 1 1 220px; min-width: 0; height: 44px; padding: 0 12px; font: 20px var(--glyph); background: var(--paper); color: var(--typeink); border: 0; border-radius: 3px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.stage { flex: 1; overflow: auto; padding: 18px 20px 28px; min-height: 0; }
.stage h3 { font: 600 14px var(--sans); color: var(--dim); margin: 20px 0 8px; }
.stage h3:first-child { margin-top: 0; }
.panel { overflow: auto; padding: 20px 22px 24px; background: var(--bench); border-left: 1px solid var(--rule); }
.panel .count { margin: 0; color: var(--dim); font-size: 13px; }
.panel h1 { font: 700 27px/1.15 var(--serif); margin: 4px 0 14px; color: var(--paper); }
.panel h2 { font: 600 14px var(--sans); color: var(--brass); margin: 18px 0 4px; }
.panel p { margin: 0 0 9px; max-width: 62ch; }
.panel .mix { border-left: 3px solid var(--red); padding-left: 12px; }
.panel .mix h2 { color: var(--red); }
.panel .out { border-left: 3px solid var(--rule); padding-left: 12px; color: var(--dim); }
.starts { margin: 14px 0; display: grid; gap: 6px; }
.starts h2 { margin-top: 4px; }
.start { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; border: 1px solid var(--rule); border-radius: 4px; text-decoration: none; color: var(--text); background: var(--ink); }
.start span { color: var(--dim); font-size: 13px; text-align: right; }
.start:hover { border-color: var(--brass); }
.foot { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--rule); display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 14px; }

.bar { display: flex; align-items: center; gap: 10px; padding: 8px 20px; border-top: 1px solid var(--rule); background: var(--bench); }
.btn, .b { min-height: 40px; min-width: 40px; padding: 6px 14px; border: 1px solid var(--steeledge); border-radius: 4px; background: var(--steel); cursor: pointer; }
.btn:hover, .b:hover { border-color: var(--brass); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.go, .b.act { background: var(--brass); color: var(--typeink); border-color: var(--brass); font-weight: 600; }
.dots { display: flex; gap: 2px; list-style: none; margin: 0 auto 0 6px; padding: 0; }
.dot { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 4px; color: var(--dim); text-decoration: none; font: 14px var(--mono); }
.dot:hover { background: var(--steel); }
.dot.on { background: var(--paper); color: var(--typeink); font-weight: 700; }
.jump select, .pick select { height: 40px; background: var(--steel); border: 1px solid var(--steeledge); border-radius: 4px; padding: 0 8px; max-width: 100%; }
.jump { min-width: 0; }

/* controls inside the picture */
.b.chip { min-height: 40px; padding: 4px 12px; border-radius: 20px; font-size: 14px; background: transparent; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 12px 0; }
.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.tablab { color: var(--dim); margin-right: 4px; }
.b[aria-pressed="true"] { background: var(--paper); color: var(--typeink); border-color: var(--paper); font-weight: 600; }
.pick { display: flex; align-items: center; gap: 8px; }
.pick input { height: 40px; width: 96px; padding: 0 8px; font-family: var(--mono); background: var(--steel); border: 1px solid var(--steeledge); border-radius: 4px; }
input[type=range] { flex: 1 1 160px; min-width: 120px; height: 40px; accent-color: var(--brass); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); }
.note { color: var(--dim); margin: 10px 0; max-width: 70ch; }
.note.big { font: italic 18px var(--serif); color: var(--paperdim); }
.legend { color: var(--dim); font-size: 14px; margin: 12px 0 0; }
.mk { color: var(--red); } .pl { color: var(--blue); } .pl2 { color: var(--blue2); } .xs { color: #66707f; }
.verdict { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--rule); background: var(--bench); max-width: 78ch; }
.verdict.good { border-color: var(--ok); } .verdict.bad { border-color: var(--red); }
.why { margin: 12px 0; padding: 10px 14px; background: var(--bench); border: 1px solid var(--rule); border-radius: 4px; max-width: 78ch; }
.why p { margin: 0 0 6px; } .why p:last-child { margin: 0; }
.line { font: 20px var(--glyph); color: var(--paper); margin: 0 8px; overflow-wrap: anywhere; }
.tagline { margin-left: 10px; font-weight: 400; } .tagline.good { color: var(--ok); } .tagline.bad { color: var(--red); }

/* type */
.sort { display: inline-grid; place-items: center; min-width: 40px; height: 44px; padding: 0 6px 3px; background: var(--paper); color: var(--typeink); border: 0; border-radius: 3px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .16), 0 2px 0 #7f848e; font: 23px/1 var(--glyph); white-space: nowrap; }
button.sort { cursor: pointer; }
button.sort:hover { background: #fff7e0; }
.sort.big { min-width: 60px; height: 64px; font-size: 36px; }
.sort.sel { outline: 3px solid var(--brass); outline-offset: 1px; }
.sort.wrong, .sort.bad { background: #ffb7a3; }
.sort.void { background: repeating-linear-gradient(45deg, #2a2f3a 0 5px, #20242d 5px 10px); color: var(--dim); box-shadow: none; }
.sort.gone, .byte.gone { opacity: .28; }
.g.lab, .spec.lab { font: italic 11px/1 var(--serif); letter-spacing: .02em; opacity: .75; }
.sortu { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; height: 63px; }
.u { font: 10.5px/1.2 var(--mono); color: var(--dim); white-space: nowrap; }
.spec { font: 26px/1.2 var(--glyph); color: var(--paper); white-space: nowrap; }
.sort .spec { color: var(--typeink); font-size: inherit; }
.sort .spec.lab { font-size: 11px; }
.spec.huge { font-size: 46px; }
.role { font: italic 11px/1.2 var(--serif); color: var(--brass); text-align: center; max-width: 64px; }

/* bytes */
.byte { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 30px; padding: 4px 5px; background: var(--steel); border: 1px solid var(--steeledge); border-radius: 3px; color: var(--text); }
button.byte { min-height: 44px; min-width: 40px; cursor: pointer; }
button.byte:hover { border-color: var(--brass); }
.byte .hx { font: 600 14px/1 var(--mono); }
.byte .bn { font: 10.5px/1 var(--mono); letter-spacing: .04em; color: var(--dim); }
.byte.big { padding: 10px 12px; } .byte.big .hx { font-size: 26px; } .byte.big .bn { font-size: 13px; }
.byte.zero { opacity: .38; }
.byte.bad { border-color: var(--red); color: var(--red); } .byte.bad .bn { color: var(--red); }
.byte.hit { border-color: var(--ok); background: #1f3a2a; }
.byte.falsehit { border-color: var(--red); background: #4a2019; opacity: 1; }
.byte.struck { border-color: var(--brass); background: #4a3b16; }
.bytes { display: flex; gap: 2px; justify-content: center; }
.bytes.pair .byte { border-color: var(--blue2); }
.unit { font: 12px/1 var(--mono); padding: 3px 4px; border: 1px solid var(--rule); border-radius: 3px; }
.none { font: italic 11px var(--serif); color: var(--red); }

/* the galley: characters set in a row that wraps */
.galley { display: flex; flex-wrap: wrap; gap: 10px 8px; align-items: flex-start; }
.stage > .galley:not(.tight) { padding: 10px 10px 12px 12px; border-left: 6px solid var(--wood); border-bottom: 6px solid var(--wood); border-radius: 0 0 0 5px; background: linear-gradient(180deg, transparent, rgba(90, 63, 41, .12)); }
.phoneonly { display: none; }
.galley.tight { gap: 8px 6px; align-items: center; }
.col { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.gr { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px; border: 1px solid transparent; border-radius: 5px; }
.gr.multi { border-color: var(--wood); background: rgba(90, 63, 41, .16); }
.cols { display: flex; gap: 6px; align-items: flex-start; }
.r-seen { height: 44px; display: grid; place-items: center; }
.gr.tall .r-seen { height: 70px; }
.r-b8 { height: 40px; } .r-16, .r-leg { height: 22px; display: flex; gap: 2px; align-items: center; }
.gr.key { align-items: flex-end; color: var(--dim); font: italic 13px var(--serif); padding-right: 0; }
.gr.key .col { align-items: flex-end; text-align: right; }
.gr.key .r-seen, .gr.key .r-b8 { display: flex; align-items: center; }
.k-sort { height: 63px; display: flex; align-items: center; max-width: 80px; }
.bomcol { padding-right: 8px; border-right: 1px dashed var(--rule); }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.stat { display: flex; flex-direction: column; padding: 8px 14px; min-width: 96px; background: var(--bench); border: 1px solid var(--rule); border-radius: 4px; text-align: left; }
.stat b { font: 700 24px/1.1 var(--serif); color: var(--paper); }
.stat span { font-size: 13px; color: var(--dim); }
.stat.bad b { color: var(--red); font-size: 18px; line-height: 1.5; }
.b.statbtn { background: var(--bench); cursor: pointer; }
.b.statbtn[aria-pressed="true"] { background: var(--paper); border-color: var(--paper); }
.b.statbtn[aria-pressed="true"] b, .b.statbtn[aria-pressed="true"] span { color: var(--typeink); }

/* the type case */
.case { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; padding: 8px; border-radius: 6px; max-width: 860px;
  background: linear-gradient(180deg, var(--wood), var(--wood2)); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .25); }
.b.slot { min-width: 0; min-height: 40px; height: 40px; padding: 0; border: 0; border-radius: 2px; background: var(--recess); color: var(--paperdim); font: 19px/1 var(--glyph); box-shadow: inset 0 3px 5px rgba(0, 0, 0, .6); overflow: hidden; }
.b.slot .g.lab { font-size: 10px; }
.b.slot.lit { background: var(--paper); color: var(--typeink); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .16); }
.b.slot.sel, .b.slot[aria-pressed="true"] { outline: 3px solid var(--brass); outline-offset: -1px; font-weight: 400; }
.b.slot[aria-pressed="true"]:not(.lit) { background: #3a2b16; color: var(--paper); border: 0; }
.b.slot.void { background: repeating-linear-gradient(45deg, #2a1f15 0 4px, #1d150e 4px 8px); }
.card { display: flex; gap: 16px; align-items: flex-start; margin: 14px 0 4px; padding: 14px; background: var(--bench); border: 1px solid var(--rule); border-radius: 5px; max-width: 860px; }
.facts { min-width: 0; flex: 1; } .facts p { margin: 0 0 8px; }
.switches { display: flex; gap: 4px; margin: 4px 0 10px; }
.b.sw { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 42px; min-height: 48px; padding: 2px; font: 600 18px/1 var(--mono); color: var(--dim); }
.b.sw small { font: 10px var(--mono); color: var(--dim); margin-top: 3px; }
.b.sw.on { background: var(--steel); color: var(--blue); border-color: var(--blue); font-weight: 600; }
.means { display: flex; flex-wrap: wrap; gap: 10px; }
.mean { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--dim); padding: 4px; border-radius: 4px; }
.mean.on { background: rgba(230, 183, 85, .14); color: var(--text); }
.planes { display: flex; gap: 2px; margin: 4px 0 10px; }
.planes span { flex: 1; max-width: 30px; height: 22px; display: grid; place-items: center; font: 10px var(--mono); color: var(--dim); background: var(--ink); border-radius: 2px; }
.planes .on { background: var(--brass); color: var(--typeink); font-weight: 700; }

/* mojibake */
.segs { display: flex; flex-wrap: wrap; gap: 8px 4px; align-items: stretch; }
.b.seg, .seg.key { display: inline-grid; grid-auto-rows: auto; gap: 5px 2px; justify-items: center; align-items: center; padding: 6px 4px; background: transparent; border: 1px solid transparent; min-width: 0; }
.seg .cell { display: grid; place-items: center; width: 100%; }
.seg .cell .sort { width: 100%; }
.b.seg.changed { border-color: var(--wood); background: rgba(90, 63, 41, .2); }
.b.seg.sel, .b.seg[aria-pressed="true"] { border-color: var(--brass); background: rgba(230, 183, 85, .1); color: inherit; font-weight: 400; }
.seg.key { grid-template-columns: auto; color: var(--dim); font: italic 13px var(--serif); justify-items: end; padding-right: 6px; }
.seg.key .cell { height: 44px; display: flex; align-items: center; justify-content: flex-end; }
.chain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.chain li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; padding: 4px 0; border-bottom: 1px dotted var(--rule); }

/* widths */
.bars { display: grid; gap: 6px; max-width: 760px; }
.b.barbtn { display: grid; grid-template-columns: 70px 1fr 84px; align-items: center; gap: 10px; text-align: left; }
.track { display: block; height: 14px; background: var(--ink); border-radius: 2px; overflow: hidden; }
.fill { display: block; height: 100%; background: var(--blue); transition: width .3s; }
.b.barbtn[aria-pressed="true"] .track { background: #cfc5ad; } .b.barbtn[aria-pressed="true"] .fill { background: #23608a; }
.ct { text-align: right; font: 13px var(--mono); }
.sum { padding: 12px 14px; background: var(--bench); border: 1px solid var(--rule); border-radius: 5px; max-width: 760px; }
.sum p { margin: 0 0 6px; } .sum .mono { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* UTF-8 workbench */
.bigbits { font-size: 18px; margin: 0; overflow-wrap: anywhere; }
.tpls { display: grid; gap: 5px; max-width: 760px; }
.b.tpl { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 14px; align-items: center; text-align: left; }
.pat { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 15px; }
.rng { font: 12px var(--mono); color: var(--dim); white-space: nowrap; }
.b.tpl[aria-pressed="true"] { background: var(--steel); color: var(--text); font-weight: 400; }
.b.tpl.right { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.b.tpl.wrong { border-color: var(--red); box-shadow: inset 4px 0 0 var(--red); }
.benchwrap { display: grid; gap: 6px; padding: 14px; background: var(--bench); border: 1px solid var(--rule); border-radius: 5px; max-width: 760px; }
.bench { display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: 19px; }
.grp { display: inline-flex; flex-direction: column; align-items: flex-end; padding: 4px 6px; border-radius: 3px; border: 1px dashed var(--rule); transition: opacity .3s; }
.grp > span { display: inline; }
.grp.slot8 { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; border-style: solid; background: var(--steel); width: 8.9ch; box-sizing: content-box; }
.grp.slot8 small { flex-basis: 100%; text-align: center; font-size: 12px; color: var(--dim); margin-top: 3px; }
.grp.used { opacity: .3; }
.grp.in { border-color: var(--blue); }
.drop { animation: drop .35s ease-out; display: inline-block; }
@keyframes drop { from { transform: translateY(-38px); opacity: 0; } to { transform: none; opacity: 1; } }

/* knife, sorting, story */
.knife { width: 3px; align-self: stretch; min-height: 44px; background: var(--red); border-radius: 2px; box-shadow: 0 0 0 3px rgba(255, 118, 87, .2); }
.cutbox { padding: 12px 0 0; }
.result { min-height: 64px; }
.sortcols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.sortcol { background: var(--bench); border: 1px solid var(--rule); border-radius: 5px; padding: 10px; min-width: 0; }
.sortcol h3 { margin: 0 0 6px; color: var(--text); }
.sortcol ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.sortcol p { margin: 6px 0 0; font-size: 12px; }
.word, .b.word { display: flex; align-items: center; width: 100%; min-height: 34px; padding: 2px 8px; font: 17px var(--glyph); border-radius: 3px; text-align: left; overflow-wrap: anywhere; }
.b.word { min-height: 40px; }
span.word.moved { background: rgba(255, 118, 87, .16); box-shadow: inset 3px 0 0 var(--red); }
.cmp { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.cmp .line { min-width: 90px; margin: 0; }
.cmp .bytes { flex-wrap: wrap; justify-content: flex-start; }
.story { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 860px; }
.story li { counter-increment: s; padding: 10px 14px 6px; background: var(--bench); border: 1px solid var(--rule); border-left: 3px solid var(--wood); border-radius: 4px; }
.story li.fresh { border-left-color: var(--brass); animation: set .4s ease-out; }
@keyframes set { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.storyhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 8px; }
.storyhead b::before { content: counter(s) '. '; color: var(--brass); }
.story .more { display: inline-flex; align-items: center; min-height: 40px; margin: -8px 0; font-size: 13px; }
.story p { margin: 6px 0; }
.bigline { font-size: 26px; margin: 0; } .wrongline { color: var(--red); }
.wrap { overflow-wrap: anywhere; margin: 0; font-size: 15px; }
.grp1 { padding: 2px; border-bottom: 2px solid var(--wood); }

@media (max-width: 860px) {
  html, body { height: auto; }
  .app { display: block; height: auto; padding-bottom: 58px; }
  .top { flex-direction: column; gap: 0; padding: 10px 16px; }
  .main { display: block; }
  .textbar { padding: 10px 16px; }
  .stage { overflow: visible; padding: 14px 16px 22px; }
  .panel { border-left: 0; border-top: 1px solid var(--rule); padding: 18px 16px 24px; }
  .bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 8px 16px; z-index: 5; }
  .dots { display: none; }
  .jump { flex: 1; } .jump select { width: 100%; }
  .case { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .card { flex-direction: column; }
  .sortcols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .b.tpl { grid-template-columns: 1fr auto; } .b.tpl .pat { grid-column: 1 / -1; }
  .b.barbtn { grid-template-columns: 60px 1fr 74px; }
  .gr.key { display: none; }
  .phoneonly { display: block; }
  .seg.key { display: none; }
  .b.sw { width: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
