:root {
  --paper: #f4ecdc;
  --card: #fbf6ea;
  --ink: #2b2118;
  --ink-2: #5a4a3a;
  --rule: #d9c9a8;
  --accent: #ab3a23;
  /* Small accent text and text on accent fills, kept at 6:1 or better (see README, contrast). */
  --accent-text: #962f1b;
  --on-accent: #fff;
  --who: #f6d27a;
  --what: #f2a98f;
  --feel: #a9cfe0;
  --where: #b9d7a1;
  --thing: #d6bde6;
  --shadow: 0 1px 0 rgba(43, 33, 24, .08), 0 6px 18px -8px rgba(43, 33, 24, .35);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1d1813;
    --card: #2a231c;
    --ink: #f1e7d4;
    --ink-2: #c7b79d;
    --rule: #4a3e31;
    --accent: #ef7a5c;
    --accent-text: #f5a28a;
    --on-accent: #1d1813;
    --who: #7a6223;
    --what: #7d4032;
    --feel: #2f5a6b;
    --where: #3f5e2e;
    --thing: #5a4170;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 20px -8px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1d1813; --card: #2a231c; --ink: #f1e7d4; --ink-2: #c7b79d; --rule: #4a3e31;
  --accent: #ef7a5c; --accent-text: #f5a28a; --on-accent: #1d1813; --who: #7a6223; --what: #7d4032; --feel: #2f5a6b; --where: #3f5e2e; --thing: #5a4170;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 18px/1.55 "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
}
main { max-width: 900px; margin: 0 auto; padding: 48px 16px 64px; }

.masthead h1 {
  font-size: clamp(44px, 9vw, 76px);
  line-height: 1;
  margin: 0 0 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.lede { max-width: 38em; margin: 0 0 36px; color: var(--ink-2); font-size: 19px; }

.card-label, .eyebrow, .dial-label, kbd, .count, .chip, .ghost-slot, .pk-crumb, .pk-meta, .pk-keys, .pk-group h4, .bw-slot {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-2);
}

/* ---- words in the sentence: the tuning surface ---- */
.ph { -webkit-box-decoration-break: clone; box-decoration-break: clone; border-radius: 4px; }
.ph.top { padding: 0 .12em; }
.ph.nested {
  background: color-mix(in srgb, var(--thing) 35%, var(--card));
  border: 1px dashed color-mix(in srgb, var(--ink) 40%, transparent);
  padding: 0 .1em;
}
.ph.hl { outline: 2px solid var(--ink); outline-offset: 1px; }
.word {
  font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0 .04em;
  text-align: left; cursor: pointer; border-radius: 3px; touch-action: manipulation;
}
.word:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.word.pinned { text-decoration: underline 2px var(--accent); text-underline-offset: 4px; }
.word.sel { background: var(--ink); color: var(--paper); }
.plain { color: inherit; }
/* Beats: the sentences around the words. Tap the plain part of a sentence to tune it. */
.beat { cursor: pointer; border-radius: 4px; transition: background .12s; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.beat:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); text-decoration: underline dotted color-mix(in srgb, var(--ink) 40%, transparent); text-underline-offset: 5px; }
.beat.sel { background: color-mix(in srgb, var(--accent) 16%, transparent); outline: 2px solid var(--accent); outline-offset: 1px; }
.beat.pinned { text-decoration: underline 2px color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 5px; }
.beat:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pk-cur b.pk-sentence { font-size: 16px; font-weight: 500; line-height: 1.35; }
.pk-opt.pk-line { display: block; width: 100%; border-radius: 8px; font-size: 14px; line-height: 1.35; }
.ghost-slot {
  font-size: 10px; letter-spacing: .04em; text-transform: none;
  border: 1.5px dashed var(--ink-2); border-radius: 999px; background: var(--card);
  padding: 1px 8px; margin: 0 1px; vertical-align: .25em; cursor: pointer; line-height: 1.6;
}
.ghost-slot:hover { color: var(--ink); border-color: var(--ink); border-style: solid; }

.page-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.page-top .eyebrow { margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px; color: var(--ink); border: 0; border-radius: 999px; padding: 5px 10px;
  cursor: pointer; letter-spacing: .05em;
}
.chip:hover { filter: brightness(.93); }
.tip { color: var(--ink-2); font-size: 14px; font-style: italic; margin: 4px 0 0; }

/* ---- picker ---- */
.picker {
  position: absolute; z-index: 50; width: 360px; max-width: calc(100vw - 32px);
  background: var(--card); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 12px;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .45);
  padding: 12px 14px 14px;
}
.picker[hidden] { display: none; }
.picker.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none;
  border-radius: 16px 16px 0 0; border-bottom: 0; max-height: 62vh; overflow: auto;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}
.pk-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pk-crumb { font-size: 10px; }
.pk-x { border: 0; background: none; color: var(--ink-2); font-size: 16px; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
.pk-x:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
.pk-step { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; margin-top: 4px; }
.pk-arrow {
  height: 44px; border-radius: 10px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  font: 500 22px/1 "IBM Plex Mono", monospace; cursor: pointer;
}
.pk-arrow:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.pk-arrow:disabled { border-style: dashed; border-color: var(--rule); color: var(--ink-2); cursor: default; }
.pk-cur { text-align: center; min-width: 0; }
.pk-cur b { display: block; font-size: 20px; line-height: 1.2; font-weight: 600; overflow-wrap: anywhere; }
.pk-meta { font-size: 10px; display: inline-flex; gap: 6px; align-items: center; margin-top: 4px; }
.tier { border-radius: 999px; padding: 1px 7px; color: var(--ink); }
.tier.t0 { background: var(--where); }
.tier.t1 { background: var(--who); }
.tier.t2 { background: var(--what); }
.pk-keys { font-size: 10px; text-align: center; margin: 6px 0 0; text-transform: none; letter-spacing: .02em; }
@media (hover: none) { .pk-keys { display: none; } }
.pk-actions { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.pk-actions button, .pk-own button {
  font: 500 13px "IBM Plex Mono", monospace; min-height: 38px; padding: 0 12px;
  border-radius: 8px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer;
}
.pk-actions button:hover, .pk-own button:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.pk-actions [aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pk-list { max-height: 210px; overflow: auto; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 4px 0 8px; }
.picker.sheet .pk-list { max-height: 26vh; }
.pk-group h4 { margin: 8px 0 4px; font-size: 10px; font-weight: 500; }
.pk-opt {
  font: inherit; font-size: 15px; color: var(--ink); background: none; border: 1px solid var(--rule);
  border-radius: 999px; padding: 4px 10px; margin: 0 4px 5px 0; cursor: pointer; text-align: left;
}
.pk-opt:hover { border-color: var(--ink); }
.pk-opt.cur { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pk-opt.yours { border-style: dashed; border-color: var(--accent); }
.pk-own { display: flex; gap: 6px; margin-top: 10px; }
.pk-own input, .bank-form input[type="text"], .bank-form input:not([type]), .bank-form select {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--rule); border-radius: 8px; padding: 8px 10px; min-height: 40px;
}
.pk-own input:focus, .bank-form input:focus, .bank-form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

/* ---- moves: the current word big, chips for lateral moves, three previews at a time ---- */
.picker { width: 400px; }
.pk-step .pk-cur { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.pk-cur b { font-size: 24px; }
.pk-cur b .pk-sentence { display: block; font-size: 16px; font-weight: 500; line-height: 1.35; }
.pk-cur b.from-right { animation: pk-in-r .18s ease-out; }
.pk-cur b.from-left { animation: pk-in-l .18s ease-out; }
@keyframes pk-in-r { from { transform: translateX(24px); opacity: .4; } }
@keyframes pk-in-l { from { transform: translateX(-24px); opacity: .4; } }
.pk-keys .pk-swipe { display: none; }
@media (hover: none) {
  .pk-keys { display: block; }
  .pk-keys .pk-swipe { display: inline; }
  .pk-keys .pk-kbd { display: none; }
}
.pk-moves {
  display: flex; gap: 6px; margin: 12px -14px 0; padding: 2px 14px 4px; overflow-x: auto;
  scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.pk-moves::-webkit-scrollbar { display: none; }
.pk-move {
  flex: none; scroll-snap-align: start; min-height: 44px; padding: 0 16px; border-radius: 999px;
  font: 500 14px "IBM Plex Mono", monospace; color: var(--ink); background: var(--card);
  border: 1.5px solid var(--ink); cursor: pointer; touch-action: manipulation;
}
.pk-move:hover { background: color-mix(in srgb, var(--ink) 10%, var(--card)); }
.pk-move[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.pk-move:focus-visible, .pk-pv:focus-visible, .pk-more:focus-visible, .pk-all > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pk-previews { display: grid; gap: 6px; margin-top: 8px; }
.pk-pv {
  position: relative; display: block; width: 100%; min-height: 44px; text-align: left; cursor: pointer;
  font: 15px/1.4 "Fraunces", Georgia, serif; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--rule); border-radius: 10px; padding: 9px 12px 9px 36px; touch-action: manipulation;
}
.pk-pv:hover, .pk-pv.on { border-color: var(--ink); background: color-mix(in srgb, var(--accent) 7%, var(--paper)); }
.pv-n {
  position: absolute; left: 10px; top: 10px; width: 18px; height: 18px; border-radius: 50%;
  font: 500 11px/18px "IBM Plex Mono", monospace; text-align: center; color: var(--ink); border: 1.5px solid var(--ink);
}
@media (hover: none) { .pv-n { display: none; } .pk-pv { padding-left: 12px; } }
.pv-line .w, .pv-line .plain { font: inherit; }
.pv-line .w.changed {
  background: color-mix(in srgb, var(--accent) 22%, var(--paper)); color: var(--ink); font-weight: 600;
  border-radius: 3px; padding: 0 .12em; box-shadow: inset 0 -2px 0 var(--accent);
}
.pv-line .ph.nested { background: none; border: 0; padding: 0; }
.pv-cost { display: block; margin-top: 4px; font: 500 11px "IBM Plex Mono", monospace; letter-spacing: .04em; color: var(--ink-2); }
.pv-cost.over { color: var(--accent-text); }
.pk-more {
  justify-self: start; min-height: 44px; padding: 0 14px; border-radius: 8px; cursor: pointer;
  font: 500 13px "IBM Plex Mono", monospace; color: var(--ink); background: transparent; border: 1.5px solid var(--ink);
}
.pk-more:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.pv-of { font-weight: 400; color: var(--ink-2); margin-left: 4px; }
.pk-all { margin-top: 4px; }
.pk-all > summary {
  min-height: 44px; display: flex; align-items: center; gap: 4px; cursor: pointer; list-style: none;
  font: 500 13px "IBM Plex Mono", monospace; color: var(--ink);
}
.pk-all > summary::-webkit-details-marker { display: none; }
.pk-all > summary::before { content: "▸"; display: inline-block; width: 1em; transition: transform .15s; }
.pk-all[open] > summary::before { transform: rotate(90deg); }
.picker.readonly .pk-moves, .picker.readonly .pk-previews, .picker.readonly .pk-all { display: none; }
/* A previewed change shows in the piece itself before you use it. */
.word.ghosted, .word.sel.ghosted, .beat.ghosted {
  background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--ink); font-style: italic;
  outline: 1.5px dashed var(--accent); outline-offset: 1px;
}
/* On a phone: a bottom sheet of at most ~55% of the screen; the page gets room to scroll the
   selected line above it. */
.picker.sheet { max-height: 55vh; max-height: 55dvh; overscroll-behavior: contain; padding-left: calc(14px + env(safe-area-inset-left)); padding-right: calc(14px + env(safe-area-inset-right)); }
.picker.sheet .pk-moves { margin-left: calc(-14px - env(safe-area-inset-left)); margin-right: calc(-14px - env(safe-area-inset-right)); padding-left: calc(14px + env(safe-area-inset-left)); }
body.sheet-open { padding-bottom: 55vh; }
body.sheet-open .back-offer { bottom: calc(55vh + 12px); }
.picker.sheet .pk-x { width: 44px; height: 44px; }
.picker.sheet .pk-actions button, .picker.sheet .pk-own button, .picker.sheet .pk-own input { min-height: 44px; }
.picker.sheet .pk-opt { min-height: 40px; }
.picker.sheet .pk-list { max-height: none; border-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .pk-cur b.from-right, .pk-cur b.from-left { animation: none; } .pk-all > summary::before { transition: none; } }

/* ---- change the grammar here (picker-edit.js): a disclosure in the picker, tabs inside ---- */
.pk-edit { margin-top: 10px; border-top: 1px solid var(--rule); }
.pk-edit > summary {
  min-height: 44px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; cursor: pointer; list-style: none;
  font: 500 13px "IBM Plex Mono", monospace; color: var(--ink);
}
.pk-edit > summary::-webkit-details-marker { display: none; }
.pk-edit > summary::before { content: "▸"; display: inline-block; width: 1em; transition: transform .15s; }
.pk-edit[open] > summary::before { transform: rotate(90deg); }
.pk-edit > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ge-note {
  margin: 4px 0 8px; padding: 8px 10px; border-radius: 8px; font-size: 14px; line-height: 1.4;
  background: color-mix(in srgb, var(--accent) 9%, var(--paper)); border: 1.5px solid var(--accent); color: var(--ink);
}
.ge-note b { font-weight: 600; }
.ge-undo { font: 500 13px "IBM Plex Mono", monospace; min-height: 36px; padding: 0 12px; margin-left: 4px; border-radius: 8px; border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer; }
.ge-tabs { display: flex; gap: 4px; margin: 2px 0 10px; }
.ge-tabs button {
  flex: 1; min-height: 40px; font: 500 13px "IBM Plex Mono", monospace; color: var(--ink); background: transparent;
  border: 1.5px solid var(--rule); border-radius: 8px; cursor: pointer;
}
.ge-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ge-tabs button:focus-visible, .ge-btn:focus-visible, .ge-chip:focus-visible, .ge-x:focus-visible, .ge-undo:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ge-body { display: grid; gap: 10px; }
.ge-add, .ge-word { display: grid; gap: 8px; }
.ge-field { display: grid; gap: 4px; }
.ge-field .dial-label { font-size: 10px; }
.ge-text input, .ge-inline input, .ge-field select {
  width: 100%; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--rule); border-radius: 8px; padding: 8px 10px; min-height: 44px;
}
.ge-text input:focus, .ge-inline input:focus, .ge-field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.ge-tags-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.ge-tags-row .ge-field { flex: 1 1 130px; }
.ge-seg { flex-wrap: wrap; border-radius: 12px; }
.ge-seg label { min-height: 40px; display: inline-flex; align-items: center; }
.ge-check { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--ink-2); }
.ge-bad, .ge-err { color: var(--accent-text); }
.ge-err { margin: 0 0 8px; }
.ge-go { min-height: 44px; justify-self: start; font: 500 14px "IBM Plex Mono", monospace; padding: 0 16px; border-radius: 8px; border: 1.5px solid var(--accent); background: var(--accent); color: var(--on-accent); cursor: pointer; }
.ge-go:hover { background: color-mix(in srgb, var(--accent) 85%, black); }
.ge-btn, .ge-inline button {
  font: 500 13px "IBM Plex Mono", monospace; min-height: 44px; padding: 0 12px; text-align: left;
  border-radius: 8px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer;
}
.ge-btn:hover, .ge-inline button:hover, .ge-undo:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.ge-row { margin: 0; }
.ge-help { margin: 0; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.ge-help i { font-style: italic; }
.ge-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ge-chip {
  display: inline-flex; align-items: center; gap: 2px; min-height: 36px; padding: 0 4px 0 10px; border-radius: 999px;
  font: 500 13px "IBM Plex Mono", monospace; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); cursor: pointer;
}
button.ge-chip { padding-right: 10px; border-style: dashed; border-color: var(--ink-2); }
.ge-chip.on { cursor: default; border-color: var(--ink); }
.ge-x { border: 0; background: none; color: var(--ink); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 12px; }
.ge-x:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.ge-inline { display: flex; gap: 6px; }
.ge-slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ge-slots li { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 44px; border-bottom: 1px solid var(--rule); }
.ge-offers { display: grid; gap: 6px; }
.ge-offer[aria-expanded="true"] { background: var(--ink); color: var(--paper); }
.picker.sheet .pk-edit[open] { padding-bottom: 8px; }
.lib-words .bank-word.retired { text-decoration: line-through; border-style: dashed; }
@media (prefers-reduced-motion: reduce) { .pk-edit > summary::before { transition: none; } }

/* ---- word bank ---- */
.bank-wrap { margin-top: 56px; }
.bank-head { display: flex; align-items: baseline; gap: 12px; }
.bank-head h2 { font-size: 32px; margin: 0; font-weight: 600; }
.bank-form {
  margin-top: 16px; background: var(--card); box-shadow: var(--shadow); border-radius: 8px; padding: 18px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 18px; align-items: end;
}
.bf-field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.bf-field[hidden] { display: none; }
.bf-field legend { padding: 0; margin-bottom: 6px; }
.bf-text { grid-column: span 2; }
@media (max-width: 520px) { .bf-text { grid-column: auto; } }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.seg label { font: 13px "IBM Plex Mono", monospace; padding: 8px 11px; cursor: pointer; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--ink); color: var(--paper); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -3px; }
.bf-preview { grid-column: 1 / -1; border-top: 1px dashed var(--rule); padding-top: 12px; }
.bf-frame { font-size: 22px; margin: 0; }
.bf-frame b { background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 3px; padding: 0 .15em; font-weight: 600; }
.bf-frame b.blank { color: var(--ink-2); background: none; }
.bf-hint { color: var(--ink-2); font-size: 14px; margin: 4px 0 0; }
.bf-error { color: var(--accent-text); font-size: 14px; margin: 4px 0 0; min-height: 1em; }
#bf-add { grid-column: 1 / -1; justify-self: start; font: 500 15px "IBM Plex Mono", monospace; padding: 10px 16px; border-radius: 6px; border: 1.5px solid var(--accent); background: var(--accent); color: var(--on-accent); cursor: pointer; }
#bf-add:disabled { background: transparent; border-style: dashed; color: var(--accent-text); cursor: default; }
.bank-list { margin-top: 16px; }
.bank-group h4 { margin: 12px 0 6px; font: 500 11px "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .08em; }
.bank-word {
  display: inline-flex; align-items: center; gap: 6px; background: var(--card); box-shadow: var(--shadow);
  border-radius: 999px; padding: 3px 4px 3px 12px; margin: 0 6px 6px 0; font-size: 15px;
}
.bw-slot { font-size: 9px; }
.bw-x { border: 0; background: none; color: var(--ink-2); width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }
.bw-x:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
.bank-share { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.bank-share button { font: 500 14px "IBM Plex Mono", monospace; padding: 9px 14px; border-radius: 6px; border: 1.5px dashed var(--ink); background: var(--card); color: var(--ink); cursor: pointer; }
.bank-share button:disabled { border-color: var(--rule) !important; color: var(--ink-2); cursor: default; }
.bank-share .help { flex-basis: 100%; margin-top: 0; }

.help { color: var(--ink-2); font-size: 14px; margin: 14px 0 0; }

.controls { margin: 14px 0 4px; padding: 18px 18px 16px; background: var(--card); border: 1.5px solid var(--rule); border-radius: 10px; }
.control-row { display: flex; flex-wrap: wrap; gap: 14px 32px; align-items: center; }
.len { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  font: 500 18px/1 "IBM Plex Mono", monospace; cursor: pointer;
}
.step:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.step:disabled { border-style: dashed; border-color: var(--rule); color: var(--ink-2); cursor: default; }
.len-read { display: inline-flex; align-items: center; gap: 8px; font: 500 15px "IBM Plex Mono", monospace; min-width: 4.5em; }
.pips { display: inline-flex; gap: 3px; }
.pips span { width: 6px; height: 16px; border-radius: 2px; border: 1.5px solid var(--ink); }
.pips span.on { background: var(--ink); }
.len-name { font-style: italic; color: var(--ink-2); font-size: 15px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pairs { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pairs li {
  display: inline-flex; gap: 8px; align-items: center;
  font: 13px "IBM Plex Mono", monospace;
  border: 1.5px solid var(--ink); border-radius: 999px; padding: 4px 12px;
}
.pairs .pair-state { font-weight: 500; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
.pairs li.clash { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pairs li.fit { border-style: dashed; }
.dial { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dial-label { margin-right: 6px; }
.dial button {
  font: 500 14px "IBM Plex Mono", monospace;
  padding: 7px 14px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
}
.dial button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.dial-note { margin: 10px 0 0; color: var(--ink-2); font-size: 15px; font-style: italic; }

.page {
  margin-top: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 4px;
  padding: 32px clamp(20px, 5vw, 48px) 28px;
  background-image: repeating-linear-gradient(transparent 0 31px, color-mix(in srgb, var(--rule) 45%, transparent) 31px 32px);
  background-position: 0 70px;
}
.eyebrow { margin: 0 0 6px; color: var(--accent-text); }
.story:empty { display: none; }
.bit { --fs: clamp(22px, 3.4vw, 30px); font-size: var(--fs); line-height: 1.3; margin: 0 0 24px; font-weight: 600; letter-spacing: -0.01em; }
.story p { margin: 0 0 14px; }
mark { color: inherit; padding: 0 .15em; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
/* Card fills are muted toward the page; text on them stays 6.9:1 or better in light and dark. */
.b-who, .k0 { background: color-mix(in srgb, var(--who) 55%, var(--card)); }
.b-what, .k1 { background: color-mix(in srgb, var(--what) 55%, var(--card)); }
.b-feel, .k2 { background: color-mix(in srgb, var(--feel) 55%, var(--card)); }
.b-where, .k3 { background: color-mix(in srgb, var(--where) 55%, var(--card)); }
.b-thing, .k4 { background: color-mix(in srgb, var(--thing) 55%, var(--card)); }
.k5 { background: color-mix(in srgb, var(--accent) 35%, var(--card)); }
.chip.k0, .chip.k1, .chip.k2, .chip.k3, .chip.k4, .chip.k5 { color: var(--ink); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.actions button, .person-actions button {
  font: 500 15px "IBM Plex Mono", monospace;
  padding: 10px 16px;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex; gap: 8px; align-items: center;
}
.actions button:hover, .person-actions button:hover { background: color-mix(in srgb, var(--ink) 8%, var(--card)); }
.actions .primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.actions .primary:hover { background: color-mix(in srgb, var(--accent) 85%, black); }
.ghost { border-style: dashed !important; }
kbd { border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; font-size: 10px; color: inherit; }
@media (hover: none) { kbd, .kbd-hint { display: none; } }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.cast-wrap { margin-top: 56px; }
.cast-wrap h2 { font-size: 32px; margin: 0; font-weight: 600; }
.cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 18px; }
.empty { color: var(--ink-2); font-style: italic; margin: 0; grid-column: 1 / -1; }
.person { background: var(--card); border-radius: 6px; box-shadow: var(--shadow); padding: 16px 18px; border-left: 6px solid var(--who); }
.person header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.person h3 { margin: 0; font-size: 20px; }
.person ul { margin: 10px 0 12px; padding-left: 18px; font-size: 15px; }
.person li { margin-bottom: 6px; }
.person-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.person-actions button { font-size: 13px; padding: 7px 11px; }
.subtle { color: var(--ink-2) !important; border-color: var(--rule) !important; }

footer { margin-top: 64px; border-top: 1px solid var(--rule); padding-top: 18px; color: var(--ink-2); font-size: 14px; max-width: 40em; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 6px; font: 14px "IBM Plex Mono", monospace;
  opacity: 0; pointer-events: none; transition: .2s ease; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .card { transform: none !important; } }

/* ---- the friends game ---- */
body.in-game #rules, body.in-game #rules-btn, body.in-game .controls, body.in-game .legend, body.in-game #shuffle, body.in-game #retell,
body.in-game #challenge, body.in-game #challenge-panel { display: none !important; }
.challenge-btn { border-color: var(--accent) !important; color: var(--accent-text) !important; }
.challenge-panel { margin-top: 16px; border-top: 1px dashed var(--rule); padding-top: 16px; }
.challenge-panel[hidden], .game-bar[hidden], .compare[hidden] { display: none; }
.cp-lede { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; }
.cp-row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; margin-top: 10px; }
.cp-row button, .gb-row button {
  font: 500 14px "IBM Plex Mono", monospace; padding: 10px 14px; border-radius: 6px;
  border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer; min-height: 42px;
}
.cp-row button.primary, .gb-row button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.cp-row input, .gb-row input, .cmp-add textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--rule); border-radius: 8px; padding: 8px 10px; min-height: 42px;
}
.game-bar {
  margin: -8px 0 20px; padding: 14px 16px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, var(--card)); border: 1.5px solid var(--accent);
}
.gb-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; flex-wrap: wrap; }
.gb-title { margin: 0; font-size: 15px; max-width: 34em; }
.gb-title .eyebrow { display: block; margin-bottom: 2px; }
.gb-moves { display: inline-flex; gap: 4px; align-items: center; font: 500 14px "IBM Plex Mono", monospace; }
.gb-moves span { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--accent); }
.gb-moves span.on { background: var(--accent); }
.gb-moves b { margin-left: 4px; }
.gb-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-top: 12px; }
.gb-name { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; }

.compare { margin-top: 48px; }
.compare .bank-head { justify-content: space-between; }
.cmp-add { margin-top: 12px; }
.cmp-add textarea { width: 100%; resize: vertical; font-size: 14px; }
.compare-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 16px; margin-top: 18px; }
.version { background: var(--card); box-shadow: var(--shadow); border-radius: 8px; padding: 16px 18px; display: flex; flex-direction: column; }
.version.original { border: 1.5px dashed var(--rule); box-shadow: none; }
.version.leading { outline: 3px solid var(--accent); }
.version header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.version h3 { margin: 0; font-size: 20px; }
.version .bit { font-size: 20px; margin: 0 0 10px; }
.version .story { font-size: 15px; }
.version .story p { margin: 0 0 8px; }
.w.changed, .beat-s.changed { background: var(--ink); color: var(--paper); border-radius: 3px; padding: 0 .12em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.beat-s.changed .ph { background: transparent; border-color: transparent; }
.vote { margin-top: auto; padding-top: 10px; display: flex; align-items: center; gap: 10px; }
.clap { font: 500 16px "IBM Plex Mono", monospace; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.clap:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.crown { font: 500 11px "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-text); }

.forms-row { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; margin-bottom: 14px; }
.forms button { font-size: 13px; }
body.in-game #daily { display: none !important; }

/* ---- live rooms ---- */
.room-bar[hidden] { display: none; }
.room-bar {
  margin: -8px 0 20px; padding: 14px 16px; border-radius: 10px;
  background: color-mix(in srgb, var(--feel) 35%, var(--card)); border: 1.5px solid var(--ink);
}
.rb-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.rb-top .eyebrow { display: block; margin: 0; }
.rb-code { font: 600 30px/1 "IBM Plex Mono", monospace; letter-spacing: .12em; }
.rb-off { font: 12px "IBM Plex Mono", monospace; color: var(--accent-text); }
.rb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rb-actions button, .room-bar .cp-row button, .rb-history button {
  font: 500 14px "IBM Plex Mono", monospace; padding: 9px 13px; border-radius: 6px; min-height: 42px;
  border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer;
}
.room-bar .cp-row button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.room-bar button:disabled { border-style: dashed !important; background: transparent !important; color: var(--ink-2) !important; border-color: var(--rule) !important; cursor: default; }
.rb-name { margin-top: 12px; max-width: 320px; }
.rb-name input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 8px; padding: 8px 10px; min-height: 42px; }
.rb-players { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rb-players li { background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 15px; box-shadow: var(--shadow); }
.rb-players li.away { font-style: italic; }
.rb-players li.away::after { content: " · away"; font: 11px "IBM Plex Mono", monospace; color: var(--ink-2); }
.rb-players .ok, .rb-players .claps { font: 500 11px "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-text); }
.rb-phase { margin: 12px 0 0; font-size: 16px; }
.rb-history { margin-top: 12px; font-size: 14px; }
.rb-history summary { cursor: pointer; font: 500 12px "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .06em; }
.rb-history ol { margin: 8px 0; padding-left: 20px; }
.rb-fine { margin: 10px 0 0; font-size: 12px; color: var(--ink-2); }
.gb-note { font-size: 14px; color: var(--ink-2); align-self: center; }
.live-btn { border-color: var(--ink) !important; }
.live-btn[hidden] { display: none !important; }
body.in-room #challenge, body.in-room #daily, body.in-room #live, body.in-room #challenge-panel, body.in-room #share { display: none !important; }
body.room-compare .cmp-add, body.room-compare #cmp-close { display: none !important; }
.clap:disabled { border-style: dashed; border-color: var(--rule); color: var(--ink-2); cursor: default; }
.crown.mine { color: var(--ink-2); }

/* ---- grammars ---- */
.grammar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 12px; }
.grammar-label { display: inline-flex; align-items: center; gap: 10px; }
#grammar-pick {
  font: 600 18px "Fraunces", Georgia, serif; color: var(--ink); background: var(--card);
  border: 1.5px solid var(--ink); border-radius: 8px; padding: 6px 10px; min-height: 40px;
}
.grammar-desc { flex: 1 1 260px; margin: 0; color: var(--ink-2); font-size: 14px; font-style: italic; }
body.in-game .grammar-row { display: none; }
.word.handle { color: var(--ink-2); }

/* Poem forms: each beat on its own line, stanzas spaced, a quieter headline. */
body.verse .story p { margin: 0 0 22px; line-height: 2; }
body.verse .bit { font-weight: 500; font-style: italic; }

/* ---- grammar library ---- */
.library-wrap { margin-top: 56px; }
.lib-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; margin-top: 16px; }
.gram { background: var(--card); box-shadow: var(--shadow); border-radius: 8px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.gram.active { outline: 2px solid var(--ink); }
.gram header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.gram h3 { margin: 0; font-size: 20px; }
.gram-desc { margin: 0; font-size: 14px; color: var(--ink-2); }
.gram-tags { margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.gram-tags span { font: 11px "IBM Plex Mono", monospace; border: 1px dashed var(--rule); border-radius: 999px; padding: 2px 8px; }
.gram-meta { margin: 0; font: 12px "IBM Plex Mono", monospace; color: var(--ink-2); }
.gram .person-actions { margin-top: auto; padding-top: 6px; }
.lib-incoming { margin-top: 14px; padding: 14px 16px; border-radius: 10px; border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.lib-incoming p { margin: 0 0 6px; }
.lib-editor { margin-top: 18px; background: var(--card); box-shadow: var(--shadow); border-radius: 10px; padding: 16px 18px; }
.lib-head { display: flex; justify-content: space-between; align-items: center; }
.lib-head h3 { margin: 0; font-size: 20px; }
.lib-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0 14px; border-bottom: 1px solid var(--rule); }
.lib-tabs button { font: 500 13px "IBM Plex Mono", monospace; border: 0; background: none; color: var(--ink-2); padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.lib-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.lib-body { display: flex; flex-direction: column; gap: 12px; }
.lib-body input, .lib-body textarea, .lib-body select { font: inherit; font-size: 15px; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 8px; padding: 7px 10px; min-height: 38px; }
.lib-body textarea#lib-json { font: 12px/1.5 "IBM Plex Mono", monospace; width: 100%; }
.lib-body code { font: 12px "IBM Plex Mono", monospace; background: var(--paper); padding: 1px 4px; border-radius: 3px; }
.lib-words { display: flex; flex-wrap: wrap; }
.lib-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lib-add input[name="t"] { flex: 1 1 220px; }
.lib-add button, .lib-body .cp-row button { font: 500 14px "IBM Plex Mono", monospace; padding: 8px 14px; border-radius: 6px; border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer; min-height: 38px; }
.lib-add button.primary, .lib-body .cp-row button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.lib-lines { margin: 0; padding-left: 22px; font-size: 15px; }
.lib-lines li { margin-bottom: 6px; }
.lib-cons { display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.lib-cons input[type="checkbox"], .lib-check input { width: 18px; height: 18px; vertical-align: -3px; min-height: 0; }
.lib-cons input:not([type="checkbox"]) { min-height: 30px; padding: 3px 6px; width: auto; }
.lib-check { font-size: 15px; }
.bank-word.filtered { color: var(--ink-2); text-decoration: line-through; border-style: dashed; }

/* ---- jams v2 ---- */
.rb-invites { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.rb-invites button { font: 500 13px "IBM Plex Mono", monospace; padding: 7px 11px; border-radius: 6px; border: 1.5px dashed var(--ink); background: var(--card); color: var(--ink); cursor: pointer; min-height: 38px; }
.rb-mode label { font-size: 12px; padding: 7px 10px; }
.rb-modename { font: 500 12px "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .08em; }
.rb-players li { border-left: 4px solid var(--peer, var(--rule)); }
.rb-players .role, .rb-players .looking { font: 11px "IBM Plex Mono", monospace; color: var(--ink-2); }
.room-bar select { font: inherit; font-size: 15px; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 8px; padding: 6px 8px; min-height: 38px; }

/* Someone else looking at this word or beat. */
.peer { outline: 2px solid var(--peer); outline-offset: 2px; position: relative; }
.word.peer::after, .beat.peer::after {
  content: attr(data-peer); position: absolute; left: 0; top: -1.35em; white-space: nowrap;
  font: 500 10px/1.6 "IBM Plex Mono", monospace; color: #fff; background: var(--peer); padding: 0 5px; border-radius: 3px; pointer-events: none;
}
/* A word or beat with open comments. */
.noted, .word.noted { text-decoration: underline wavy color-mix(in srgb, var(--accent) 70%, transparent); text-underline-offset: 5px; }
.word.noted::before { content: attr(data-notes); font: 500 9px "IBM Plex Mono", monospace; color: var(--on-accent); background: var(--accent); border-radius: 999px; padding: 0 4px; margin-right: 2px; vertical-align: .6em; }

.jam-notes { margin-top: 10px; border-top: 1px dashed var(--rule); padding-top: 8px; }
.jam-notes h4 { margin: 0 0 6px; }
.note { background: color-mix(in srgb, var(--accent) 7%, var(--card)); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; font-size: 14px; }
.note p { margin: 0; }
.note.resolved { color: var(--ink-2); }
.note-quote { font: italic 13px "Fraunces", serif; border: 0; background: none; color: var(--ink-2); padding: 0; cursor: pointer; text-align: left; }
.note-actions { display: flex; gap: 6px; margin-top: 4px; }
.note-actions button { font: 500 11px "IBM Plex Mono", monospace; border: 1px solid var(--rule); background: none; color: var(--ink-2); border-radius: 999px; padding: 2px 8px; cursor: pointer; }
.jam-note-form { display: flex; gap: 6px; margin-top: 6px; }
.jam-note-form input { flex: 1; min-width: 0; font: inherit; font-size: 15px; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 8px; padding: 6px 10px; min-height: 38px; }
.jam-note-form button { font: 500 13px "IBM Plex Mono", monospace; border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); border-radius: 8px; padding: 0 12px; cursor: pointer; }
.jam-thread { margin-top: 8px; }

/* Commenters and viewers in a together jam: read and comment, don't tune. */
body.jam-readonly #rules, body.jam-readonly #rules-btn, body.jam-readonly .undo-pair, body.jam-readonly .controls, body.jam-readonly .legend, body.jam-readonly #shuffle, body.jam-readonly #retell, body.jam-readonly .ghost-slot { display: none !important; }
.picker.readonly .pk-step, .picker.readonly .pk-keys, .picker.readonly .pk-actions, .picker.readonly .pk-list, .picker.readonly .pk-own { display: none; }
.rb-keep { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-top: 12px; }
.rb-keep button { font: 500 13px "IBM Plex Mono", monospace; padding: 8px 12px; border-radius: 6px; border: 1.5px solid var(--rule); background: var(--card); color: var(--ink-2); cursor: pointer; min-height: 38px; }

/* ---------- spaces ---------- */
.lib-list.lib-cols { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); align-items: start; }
.lib-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.lib-col-h { margin: 0; font-size: 18px; display: flex; flex-direction: column; gap: 2px; }
.space-gram { border-left: 4px solid var(--feel); }
.lib-publish { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-top: 4px; border-top: 1px dashed var(--rule); }
.lib-publish select, .lib-publish button { font-size: 13px; padding: 6px 10px; }
.lib-publish select { font: inherit; font-size: 13px; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 8px; max-width: 160px; }
.spaces-wrap { margin-top: 36px; }
.spaces-body { margin-top: 12px; }
.sp-tabs button { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-new input { flex: 1 1 220px; }
.sp-file { display: inline-block; cursor: pointer; font-size: 14px; padding: 8px 12px; border: 1.5px dashed var(--rule); border-radius: 8px; }
.sp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.sp-head .eyebrow { display: block; margin: 0; }
.sp-meta { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); }
.sp-keep.soon { color: var(--accent-text); font-weight: 600; }
.spaces-body h4.dial-label { margin: 20px 0 8px; display: flex; gap: 8px; align-items: baseline; }
.sp-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sp-item { background: var(--card); box-shadow: var(--shadow); border-radius: 8px; padding: 10px 14px; }
.sp-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.sp-item-top b { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.sp-acts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sp-acts button { font-size: 13px; padding: 6px 10px; }
.sp-sub { margin: 4px 0 0; font: 12px "IBM Plex Mono", monospace; color: var(--ink-2); }
.sp-words { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px; }
.sp-words span { font-size: 13px; border: 1px dashed var(--rule); border-radius: 999px; padding: 2px 8px; }
.sp-bits { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.sp-lore { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.sp-lore li { display: flex; align-items: center; gap: 6px; background: var(--card); box-shadow: var(--shadow); border-radius: 999px; padding: 4px 6px 4px 4px; }
.sp-lore .sp-sub { margin: 0; }
.sp-lore-use { font: italic 15px "Fraunces", serif; color: var(--ink); background: none; border: 0; padding: 4px 8px; cursor: pointer; border-radius: 999px; }
.sp-lore-use:hover { background: color-mix(in srgb, var(--who) 50%, transparent); }
.sp-jams { margin: 0; padding-left: 20px; font-size: 14px; }
.sp-settings { margin-top: 18px; }
.rb-space { margin-top: 12px; }
.rb-space .sp-sub button { font-size: 12px; padding: 4px 8px; }
.callbacks { margin: 8px 0 0; font-size: 14px; font-style: italic; }
.callbacks .dial-label { font-style: normal; color: var(--accent-text); margin-right: 4px; }
.sp-acts button:not(.bw-x), .rb-space .sp-sub button { font: 500 13px "IBM Plex Mono", monospace; padding: 6px 10px; border-radius: 6px; border: 1.5px dashed var(--ink); background: var(--card); color: var(--ink); cursor: pointer; min-height: 34px; }

/* Unavailable controls say so with a dashed outline, not by fading (faded reads as gone). */

/* ---- calm layout: the Rules drawer, menus, folded sections ---- */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin-top: 8px; }
summary { cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary { list-style: none; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; width: max-content;
  font: 500 14px "IBM Plex Mono", monospace; color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 999px; padding: 6px 14px; min-height: 38px; background: transparent;
}
.tool:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.tool:focus-visible, .fold > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
details[open] > .tool, .tool[aria-expanded="true"] { background: var(--ink); color: var(--paper); }
button.tool { cursor: pointer; }
.tool[aria-expanded="true"] .caret { transform: rotate(90deg); }
.caret { display: inline-block; transition: transform .15s; font-size: .85em; }
details[open] > summary .caret { transform: rotate(90deg); }
.menu details[open] > summary .caret, details.menu[open] > summary .caret { transform: rotate(180deg); }
.reroll-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 16px; }

.menu { position: relative; }
.menu-list {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; min-width: 260px; max-width: calc(100vw - 32px);
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 10px; padding: 6px;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .45); display: grid; gap: 2px;
}
.actions .menu-list { top: auto; bottom: calc(100% + 6px); }
.menu-item, .actions .menu-item {
  display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: baseline; text-align: left; width: 100%;
  font: 500 14px "IBM Plex Mono", monospace; color: var(--ink); background: none; border: 0; border-radius: 6px;
  padding: 8px 10px; cursor: pointer;
}
.menu-item:hover, .actions .menu-item:hover { background: color-mix(in srgb, var(--ink) 8%, var(--card)); }
.menu-item kbd { justify-self: start; }
.menu-note { grid-column: 1 / -1; font: italic 13px "Fraunces", Georgia, serif; color: var(--ink-2); }
.actions { align-items: center; }
.actions .tool { border-radius: 6px; padding: 10px 14px; font-size: 15px; }
.undo-pair { display: inline-flex; gap: 6px; }
.actions button.icon { padding: 0; width: 44px; height: 44px; justify-content: center; font-size: 20px; }

/* Folded sections below the page: a heading you can open. */
.fold { margin-top: 28px; border-top: 1px solid var(--rule); padding-top: 18px; }
.fold > summary { display: flex; align-items: baseline; gap: 12px; border-radius: 6px; }
.fold > summary h2 { font-size: 28px; margin: 0; font-weight: 600; }
.fold > summary .caret { font-size: 18px; color: var(--ink-2); }
.fold > summary:hover h2 { text-decoration: underline 1.5px; text-underline-offset: 5px; }
.fold .bank-wrap, .fold .library-wrap, .fold .cast-wrap { margin-top: 4px; }
.fold section > .help:first-child { margin-top: 10px; }
.fold h3 { font-size: 22px; margin: 18px 0 0; font-weight: 600; }
.fold .spaces-wrap { margin-top: 28px; }

/* Sentences: a small button opens one from the keyboard; it shows itself when focused. */
.beat-btn {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  border: 0; padding: 0; margin: 0; background: none; color: inherit;
}
.beat-btn:focus-visible {
  position: static; width: auto; height: auto; clip: auto; overflow: visible;
  font: 500 12px "IBM Plex Mono", monospace; background: var(--accent); color: var(--on-accent);
  border-radius: 4px; padding: 0 5px; margin-right: 4px; vertical-align: .15em; outline-offset: 1px;
}
.picker:focus { outline: none; }
.picker:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* First-run hint: a bubble pointing down at a word. */
.first-hint {
  position: absolute; z-index: 45; display: flex; align-items: center; gap: 4px;
  background: var(--ink); color: var(--paper); border-radius: 8px; padding: 6px 4px 6px 12px;
  font: 500 13px "IBM Plex Mono", monospace; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .5);
  animation: hint-in .3s ease both;
}
.first-hint::after {
  content: ""; position: absolute; top: 100%; left: var(--arrow, 18px);
  border: 7px solid transparent; border-top-color: var(--ink);
}
.fh-x { border: 0; background: none; color: var(--paper); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 13px; }
.fh-x:hover { background: color-mix(in srgb, var(--paper) 18%, transparent); }
@keyframes hint-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .first-hint { animation: none; } .caret { transition: none; } }
@media (max-width: 520px) {
  .menu-list { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; min-width: 0; max-width: none; }
  .actions .menu-list { bottom: 16px; }
}

/* ---- mad-lib blanks: every tunable word sits on a dotted line ---- */
.word {
  line-height: inherit;
  text-decoration: underline dotted 2px color-mix(in srgb, var(--ink) 60%, transparent);
  text-underline-offset: .22em; text-decoration-skip-ink: none;
}
.word.sel { text-decoration-color: var(--paper); }
/* Part labels under the headline's phrases: shown on a first visit, then by choice. */
/* Labels sit inline at the start of each card's phrase, in the text flow, so a wrapping phrase
   can never put one on top of another line's words. Only top-level cards are labeled. */
.part-label {
  display: none; position: static; vertical-align: .3em; margin: 0 .35em 0 0; pointer-events: none;
  font: 500 10px/1.5 "IBM Plex Mono", monospace; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  color: var(--ink-2); background: var(--card); border: 1px solid var(--rule); border-radius: 3px; padding: 0 4px;
  font-style: normal; font-weight: 500;
  user-select: none; -webkit-user-select: none;
}
body.show-parts #bit .ph:not(.nested) > .part-label { display: inline-block; }
#bit .ph { position: static; }
.bit { transition: line-height .4s ease; }
.parts-toggle { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: 14px; font: 500 14px "IBM Plex Mono", monospace; cursor: pointer; }
.parts-toggle input { width: 18px; height: 18px; accent-color: var(--accent); align-self: center; }
.parts-toggle .menu-note { flex-basis: 100%; padding-left: 26px; }
/* What the marks mean, in the picker. */
.pk-marks { margin: 8px 0 0; font: 12px/1.5 "IBM Plex Mono", monospace; color: var(--ink-2); }
.pk-marks span { color: var(--ink); }
.mk-blank { text-decoration: underline dotted 2px color-mix(in srgb, var(--ink) 60%, transparent); text-underline-offset: 3px; }
.mk-pin { text-decoration: underline 2px var(--accent); text-underline-offset: 3px; }
.mk-note { text-decoration: underline wavy color-mix(in srgb, var(--accent) 70%, transparent); text-underline-offset: 3px; }
.mk-peer { outline: 2px solid var(--ink-2); outline-offset: 1px; border-radius: 2px; }
/* First visit: one headline word pulses gently. */
.word.pulse { animation: word-pulse 1.8s ease-in-out infinite; }
@keyframes word-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 35%, transparent); }
}
/* After a reload: the piece you had, offered back for a few seconds. */
.back-offer {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--paper); border-radius: 8px; padding: 6px 6px 6px 14px;
  font: 14px "IBM Plex Mono", monospace; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .5);
}
.back-offer button {
  font: 500 14px "IBM Plex Mono", monospace; color: var(--ink); background: var(--paper);
  border: 0; border-radius: 6px; padding: 8px 12px; min-height: 38px; cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  .word.pulse { animation: none; outline: 3px solid var(--accent); outline-offset: 2px; }
  .part-label, .bit { transition: none; }
}

/* ---- history: the thumb bar, the History sheet, drafts, versions ---- */
/* Phones: undo, shuffle, redo and history sit in a bar at the bottom, in reach of a thumb. */
.thumb-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 48; display: none; gap: 6px;
  padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: var(--card); border-top: 1.5px solid var(--ink); box-shadow: 0 -10px 24px -16px rgba(0, 0, 0, .45);
}
.thumb-bar button {
  flex: 1 1 0; min-width: 44px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font: 500 12px/1.2 "IBM Plex Mono", monospace; color: var(--ink); background: transparent;
  border: 1.5px solid var(--ink); border-radius: 10px; cursor: pointer; touch-action: manipulation;
}
.thumb-bar button > span[aria-hidden] { font-size: 20px; line-height: 1; }
.thumb-bar .tb-main { flex-grow: 1.6; background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-size: 15px; }
.thumb-bar button:disabled { border-style: dashed; border-color: var(--rule); color: var(--ink-2); cursor: default; }
.thumb-bar button:active:not(:disabled) { transform: translateY(1px); }
@media (max-width: 639px) {
  .thumb-bar { display: flex; }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .actions #shuffle, .actions .undo-pair, .actions #history-btn { display: none; }
  .toast, .back-offer { bottom: calc(84px + env(safe-area-inset-bottom)); }
  body:has(#picker.sheet:not([hidden])) .thumb-bar, body.hist-open .thumb-bar { display: none; }
}
@media (max-width: 520px) {
  .menu-list, .actions .menu-list { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
body.in-game #tb-shuffle, body.jam-readonly #tb-shuffle, body.jam-readonly #tb-undo, body.jam-readonly #tb-redo { display: none; }

/* The History sheet: full height on phones, a panel at the side on wider screens. */
.hist-scrim { position: fixed; inset: 0; z-index: 64; background: rgba(20, 14, 8, .38); }
.hist {
  position: fixed; z-index: 65; top: 0; right: 0; bottom: 0; width: min(440px, 100vw);
  display: flex; flex-direction: column; background: var(--card); color: var(--ink);
  border-left: 1.5px solid var(--ink); box-shadow: -18px 0 40px -18px rgba(0, 0, 0, .5);
  padding-top: env(safe-area-inset-top);
}
.hist:focus { outline: none; }
.hist-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 12px 0 18px; }
.hist-head h2 { margin: 0; font-size: 26px; font-weight: 600; }
.hist-head .pk-x { width: 44px; height: 44px; }
.hist-tabs { display: flex; gap: 2px; padding: 4px 12px 0; border-bottom: 1px solid var(--rule); }
.hist-tabs button {
  flex: 1 1 0; min-height: 44px; font: 500 13px "IBM Plex Mono", monospace; border: 0; background: none; color: var(--ink-2);
  cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.hist-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.hist-body {
  flex: 1; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 14px 18px calc(24px + env(safe-area-inset-bottom));
}
.hist-body .empty { margin: 8px 0; }
.hist-steps { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.hist-steps .tool { min-height: 44px; padding: 0 14px; border-radius: 8px; font-size: 14px; }
.hist-steps .tool:disabled { border-style: dashed; border-color: var(--rule); color: var(--ink-2); cursor: default; }
.hist-steps .primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.hist-list { list-style: none; margin: 0; padding: 0; }
.hist-list > li { border-bottom: 1px solid var(--rule); }
.hist-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 52px; padding: 8px 6px;
  text-align: left; font: inherit; font-size: 16px; line-height: 1.3; color: var(--ink); background: none; border: 0; cursor: pointer;
}
.hist-row:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.hist-row:disabled { cursor: default; }
.hr-label { overflow-wrap: anywhere; }
.hr-meta { font: 12px/1.4 "IBM Plex Mono", monospace; color: var(--ink-2); }
/* Undone steps: still there to redo. Marked with a dashed rule and italics, not faded. */
.hist-list li.undone { border-left: 3px dashed var(--accent); padding-left: 8px; }
.hist-list li.undone .hr-label { font-style: italic; }
.hist-now { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 0 !important; }
.hist-now::before, .hist-now::after { content: ""; flex: 1; border-top: 2px solid var(--ink); }
.hist-now span { font: 500 11px "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .1em; }
.hist-list li.at .hist-row { background: color-mix(in srgb, var(--accent) 14%, transparent); }

.draft-save { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.draft-save .bf-field { flex: 1 1 160px; display: flex; flex-direction: column; gap: 4px; }
.draft-save input, .hist-body select { font: inherit; font-size: 16px; min-height: 44px; padding: 6px 10px; border: 1.5px solid var(--ink); border-radius: 8px; background: var(--paper); color: var(--ink); }
.draft-save .primary { min-height: 44px; font: 500 14px "IBM Plex Mono", monospace; padding: 0 16px; border-radius: 8px; border: 1.5px solid var(--accent); background: var(--accent); color: var(--on-accent); cursor: pointer; }
.hist-list.drafts { margin-top: 14px; }
.draft { display: grid; grid-template-columns: 44px 1fr; gap: 4px 6px; align-items: start; padding: 10px 0; }
.draft-pick { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; cursor: pointer; }
.draft-pick input { width: 22px; height: 22px; accent-color: var(--accent); }
.draft-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-top: 8px; }
.draft-main b { font-weight: 600; }
.draft-line { font-size: 14px; color: var(--ink-2); font-style: italic; }
.draft-actions { grid-column: 2; display: flex; gap: 8px; }
.draft-actions .tool { min-height: 44px; padding: 0 14px; border-radius: 8px; font-size: 14px; }
.hist-body .bf-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }

.ver-step { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; align-items: center; margin: 4px 0 12px; }
.ver-cur { text-align: center; display: flex; flex-direction: column; }
.ver-preview { margin-bottom: 12px; }
.ver-preview .bit { font-size: 19px; }

/* Compare on phones: swipe between versions instead of a grid. */
.cmp-count { display: none; margin-left: auto; }
.cmp-help-drafts { display: none; }
body.cmp-drafts .cmp-help, body.cmp-drafts .cmp-add, body.cmp-drafts #compare-empty { display: none; }
body.cmp-drafts .cmp-help-drafts { display: block; }
@media (max-width: 639px) {
  .compare-cards {
    display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
    margin: 18px -16px 0; padding: 4px 16px 14px; scroll-padding: 0 16px; -webkit-overflow-scrolling: touch;
  }
  .compare-cards > .version { flex: 0 0 86%; scroll-snap-align: start; }
  .cmp-count { display: inline; }
}
@media (max-width: 639px) { .hist { width: 100%; border-left: 0; box-shadow: none; } .hist-scrim { display: none; } }

/* ---- jam bar: one-line strip + expander (qa-b) ---- */
.rb-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rb-strip .rb-code { font-size: 22px; }
.rb-id { display: grid; gap: 2px; flex: none; }
.rb-role { font: 500 11px "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.rb-faces { display: none; gap: 0; flex: none; }
.rb-face { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; margin-left: -6px; font: 600 13px "IBM Plex Mono", monospace; background: var(--peer, var(--rule)); color: #fff; border: 2px solid var(--card); box-sizing: border-box; }
.rb-face:first-child { margin-left: 0; }
.rb-face.more { background: var(--card); color: var(--ink); font-size: 11px; }
.rb-count { font-size: 13px; }
.rb-act { margin-left: auto; display: inline-flex; gap: 8px; }
.rb-act:empty { display: none; }
.rb-act button { font: 500 14px "IBM Plex Mono", monospace; padding: 8px 14px; border-radius: 6px; border: 1.5px solid var(--accent); background: var(--accent); color: var(--on-accent); cursor: pointer; min-height: 44px; }
.rb-act button:disabled { border-style: dashed; background: transparent; color: var(--ink-2); border-color: var(--rule); cursor: default; }
.rb-toggle { display: none; min-width: 44px; min-height: 44px; font-size: 16px; border-radius: 6px; border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); cursor: pointer; }
.rb-ask { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 10px; }
.rb-ask label { flex: 1 1 160px; display: grid; gap: 4px; }
.rb-ask input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 8px; padding: 8px 10px; min-height: 44px; }
.rb-ask button { font: 500 14px "IBM Plex Mono", monospace; padding: 8px 14px; border-radius: 6px; border: 1.5px solid var(--rule); background: var(--card); color: var(--ink); cursor: pointer; min-height: 44px; }
.rb-ask button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.rb-more { margin-top: 4px; }
@media (max-width: 700px) {
  .room-bar { padding: 8px 12px; margin-bottom: 12px; }
  .rb-faces { display: inline-flex; }
  .rb-toggle { display: inline-grid; place-items: center; }
  .rb-strip { flex-wrap: nowrap; }
  .rb-act button { white-space: nowrap; padding: 8px 10px; }
  .rb-ask label { flex-basis: 120px; }
  .rb-strip .rb-code { font-size: 18px; letter-spacing: .08em; }
  .room-bar:not(.open) .rb-more { display: none; }
  .rb-more { border-top: 1px solid var(--rule); margin-top: 8px; padding-top: 8px; }
}
/* ---- feedback, bank, library (phone QA fixes) ---- */
.toast.top { bottom: auto; top: calc(16px + env(safe-area-inset-top)); transform: translate(-50%, -20px); }
.toast.top.show { transform: translate(-50%, 0); }
@media (max-width: 639px) { .toast.top { bottom: auto; } }
.toast.has-action { pointer-events: auto; }
.toast button { font: inherit; color: inherit; background: none; border: 0; border-bottom: 1.5px solid currentColor; padding: 6px 2px; margin-left: 6px; min-height: 36px; cursor: pointer; }
.copy-fallback { position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 50; display: flex; gap: 8px; align-items: end; background: var(--card); box-shadow: var(--shadow); border: 1.5px solid var(--ink); border-radius: 8px; padding: 12px; }
.copy-fallback label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.copy-fallback input { font: inherit; font-size: 15px; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 8px; padding: 8px 10px; min-height: 44px; min-width: 0; }
.copy-fallback button { min-height: 44px; padding: 0 14px; border-radius: 8px; }
@keyframes kept-flash { 0%, 60% { background: color-mix(in srgb, var(--accent) 22%, transparent); } 100% { background: transparent; } }
summary.kept-flash { animation: kept-flash 2.4s ease-out; }
.fold > summary .count { font-size: 13px; color: var(--ink-2); }
#bf-add:disabled { background: var(--accent); border-style: solid; color: var(--on-accent); }
.bf-error:not(:empty) { color: var(--accent-text); font-weight: 500; }
.sp-new input[name="name"], .lib-body .sp-new input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule); border-radius: 8px; padding: 8px 10px; min-height: 44px; min-width: 0; }
.sp-new input[name="name"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.sp-new button.primary { min-height: 44px; }
.sp-new button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font: 500 14px "IBM Plex Mono", monospace; padding: 8px 14px; border-radius: 6px; border: 1.5px solid var(--accent); cursor: pointer; }
.toast { width: max-content; text-align: center; }
/* ==== Phone QA fixes: layout and picker (docs/qa-phone.md #1 #3 #5 #11 #13 #14 #15) ==== */
/* #13: punctuation stays on the line of the word before it (gluePunct in render.js). */
.nb { white-space: nowrap; }
.nb > .word, .nb > .ghost-slot { white-space: normal; }

/* #1: on a phone, Rules is a bottom sheet; the piece stays in view above it. */
.drawer-head { display: none; }
.drawer.sheet {
  position: fixed; left: 0; right: 0; bottom: var(--kb, 0px); z-index: 49;
  max-height: 50vh; max-height: 50dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--card); color: var(--ink); border-top: 1.5px solid var(--ink); border-radius: 16px 16px 0 0;
  box-shadow: 0 -18px 40px -16px rgba(0, 0, 0, .45);
  padding: 0 calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
}
.drawer.sheet .drawer-head {
  display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1;
  background: var(--card); padding: 6px 0 2px; margin-bottom: 2px;
}
.drawer.sheet .controls { margin: 0; padding: 0; border: 0; background: none; }
body.drawer-open { padding-bottom: 50vh; }
body.drawer-open .thumb-bar, body.drawer-open .back-offer { display: none !important; }

/* #3: a challenge is one line and its actions; how it works folds away. */
.game-bar { padding: 10px 12px; }
.gb-top { align-items: center; gap: 4px 12px; }
.gb-title .eyebrow { margin: 0; }
.game-bar > .gb-row { margin-top: 8px; align-items: center; gap: 8px; }
.gb-row button { min-height: 44px; }
.gb-how > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px; border-radius: 6px;
  font: 500 14px "IBM Plex Mono", monospace; color: var(--ink);
  text-decoration: underline dotted 1.5px; text-underline-offset: 4px;
}
.gb-how > summary::before { content: "▸"; display: inline-block; transition: transform .15s; }
.gb-how[open] { flex-basis: 100%; }
.gb-how[open] > summary::before { transform: rotate(90deg); }
.gb-how > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.gb-how .gb-note { display: block; margin: 4px 0 0; font-size: 15px; color: var(--ink); }
.gb-how .gb-row { margin-top: 8px; align-items: end; }
.gb-name input { min-height: 44px; }

/* #5: Back to your last piece: a slim bar that stays until you use it or put it away. */
.back-offer { padding: 4px 4px 4px 14px; gap: 8px; }
.back-offer .bo-say { flex: 1 1 auto; min-width: 0; }
.back-offer button { white-space: nowrap; min-height: 40px; }
.back-offer .bo-x {
  flex: none; width: 44px; height: 44px; padding: 0; background: none; color: var(--paper); font-size: 16px; border-radius: 50%;
}
.back-offer .bo-x:hover { background: color-mix(in srgb, var(--paper) 15%, transparent); }
.back-offer button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
body.sheet-open .back-offer { display: none; }
@media (max-width: 639px) {
  /* Docked on top of the bottom bar, full width, off the text. */
  .back-offer {
    left: 0; right: 0; transform: none; max-width: none; border-radius: 0;
    bottom: calc(69px + env(safe-area-inset-bottom)); font-size: 13px;
    padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right));
    box-shadow: none;
  }
  .back-offer #back-last { font-size: 13px; padding: 6px 10px; }
  body.back-open main { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  body.back-open .toast:not(.top) { bottom: calc(136px + env(safe-area-inset-bottom)); }
}

/* #14: the moves row has gutters at both ends, snaps inside them, and fades where there's more. */
.pk-moves { scroll-padding-inline: 14px; }
.picker.sheet .pk-moves { scroll-padding-inline: calc(14px + env(safe-area-inset-left)); }
.pk-moves::after { content: ""; flex: 0 0 8px; }
.pk-moves.more-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
.pk-moves.more-l { -webkit-mask-image: linear-gradient(to right, transparent, #000 40px); mask-image: linear-gradient(to right, transparent, #000 40px); }
.pk-moves.more-l.more-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); }
.pk-keys { font-size: 12px; }

/* #15: the focus ring shows for keyboard use, not after a tap. */
html[data-input="pointer"] .word:focus-visible, html[data-input="pointer"] .picker:focus-visible { outline: none; }
html[data-input="pointer"] .beat-btn:focus-visible {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); padding: 0; margin: 0;
}

/* #11: tap targets at least 44px. */
.toolbar .tool { min-height: 44px; }
.pk-x { width: 44px; height: 44px; }
.picker .pk-actions button, .picker .pk-own button, .picker .pk-own input { min-height: 44px; }
.picker.sheet .pk-opt { min-height: 44px; }

/* The soft keyboard: the sheets sit on top of it (--kb, from visualViewport in controls.js) and
   shrink to the room left, so the field you're typing in stays in view. */
.picker.sheet { bottom: var(--kb, 0px); }
body.kb-open .picker.sheet, body.kb-open .drawer.sheet { max-height: calc(var(--vvh, 100vh) - 64px); }
