:root {
  --bg: #f6efe4;
  --paper: #fdf8f0;
  --paper-edge: #eadfcd;
  --ink: #2b2420;
  --ink-soft: #5e534b;
  --muted: #8a7d72;
  --line: #e2d6c4;
  --accent: #b4573b;
  --accent-ink: #fffaf3;
  --accent-soft: #f3dccf;
  --tool-bg: #eef3ea;
  --tool-line: #c9d8c0;
  --tool-ink: #2f4a2f;
  --warn-bg: #fff1e6;
  --warn-line: #f0b48a;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 12px 40px -12px rgba(60, 40, 20, .25);
  --serif: "Literata", Georgia, serif;
  --display: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1714; --paper: #26201b; --paper-edge: #3a312a; --ink: #f1e8dc; --ink-soft: #cfc3b5;
    --muted: #9b8f82; --line: #3d342c; --accent: #e08664; --accent-ink: #1b1714; --accent-soft: #4a3026;
    --tool-bg: #232c22; --tool-line: #3c4d39; --tool-ink: #cfe3c6; --warn-bg: #3a2a1e; --warn-line: #8a5a36;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 16px 40px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1714; --paper: #26201b; --paper-edge: #3a312a; --ink: #f1e8dc; --ink-soft: #cfc3b5;
  --muted: #9b8f82; --line: #3d342c; --accent: #e08664; --accent-ink: #1b1714; --accent-soft: #4a3026;
  --tool-bg: #232c22; --tool-line: #3c4d39; --tool-ink: #cfe3c6; --warn-bg: #3a2a1e; --warn-line: #8a5a36;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 16px 40px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; width: 100%; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 600; color: var(--accent); margin: 0 0 .75rem; }
.lede { color: var(--ink-soft); font-size: 1.1rem; max-width: 38rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: 999px; padding: .6rem 1.2rem; font: 600 .95rem var(--sans);
  text-decoration: none; cursor: pointer; transition: transform .15s, filter .15s;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:focus-visible, button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-large { padding: .85rem 1.6rem; font-size: 1.05rem; }
.btn-small { padding: .35rem .85rem; font-size: .85rem; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost.danger:hover { color: #c0392b; border-color: #c0392b; }

/* Header / footer */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem clamp(1rem, 4vw, 2.5rem); max-width: 1200px; margin: 0 auto; width: 100%;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 600; font-size: 1.2rem; }
.site-header nav { display: flex; align-items: center; gap: 1.2rem; }
.site-header nav a:not(.btn) { color: var(--ink-soft); text-decoration: none; font-weight: 500; font-size: .95rem; }
.site-footer { border-top: 1px solid var(--line); padding: 1.25rem 1rem; text-align: center; font-size: .82rem; color: var(--muted); }
.site-footer p { max-width: 46rem; margin: 0 auto; }

/* Home */
.hero {
  max-width: 1200px; margin: 0 auto; padding: clamp(2rem, 6vw, 5rem) clamp(1rem, 4vw, 2.5rem) 2.5rem;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 3rem; align-items: center;
}
.hero-art { position: relative; aspect-ratio: 1 / 1; }
.hero-art .mini {
  position: absolute; width: 72%; aspect-ratio: 3 / 4; border-radius: 6px 14px 14px 6px; overflow: hidden;
  background: var(--paper); border: 1px solid var(--paper-edge); box-shadow: var(--shadow);
}
.hero-art .mini svg { width: 100%; height: 76%; display: block; }
.hero-art .mini span { display: block; padding: .9rem 1rem; font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.hero-art .m1 { left: 0; top: 8%; transform: rotate(-6deg); }
.hero-art .m2 { left: 14%; top: 4%; transform: rotate(2deg); }
.hero-art .m3 { right: 0; top: 14%; transform: rotate(7deg); }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } .hero-art { display: none; } }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); max-width: 18ch; margin-bottom: 1.25rem; }
.hero .lede { margin-bottom: 2rem; }
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.library-wrap { max-width: 1200px; margin: 0 auto; padding: 1rem clamp(1rem, 4vw, 2.5rem) 4rem; }
.section-title { font-size: 1.4rem; margin-bottom: 1rem; }
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }
.book-card {
  background: var(--paper); border: 1px solid var(--paper-edge); border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow); text-decoration: none; color: inherit; display: flex; flex-direction: column;
  transition: transform .2s;
}
.book-card:hover { transform: translateY(-3px); }
.book-card .thumb { aspect-ratio: 16 / 9; overflow: hidden; }
.book-card .thumb svg { width: 100%; height: 100%; display: block; }
.book-card .meta { padding: .9rem 1rem 1rem; }
.book-card h3 { font-size: 1.1rem; margin-bottom: .25rem; }
.book-card p { margin: 0; font-size: .85rem; color: var(--muted); }

/* Create */
.create { max-width: 780px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2rem) 4rem; }
.create-head { margin-bottom: 2rem; }
.create-head h1 { font-size: clamp(2rem, 4.5vw, 2.8rem); margin-bottom: .75rem; }
.field { border: 0; padding: 0; margin: 0 0 1.75rem; min-width: 0; }
.field.narrow { max-width: 320px; }
.label { display: block; font-weight: 600; margin-bottom: .6rem; font-size: .95rem; padding: 0; }
.label .muted { font-weight: 400; }
textarea, input[type="text"] {
  width: 100%; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  padding: .85rem 1rem; font: 1.02rem/1.55 var(--serif); resize: vertical;
}
textarea::placeholder, input::placeholder { color: var(--muted); }
.hint { text-align: right; font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; gap: 0; } }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
  border-radius: 999px; padding: .42rem .9rem; font: 500 .9rem var(--sans); cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.examples { display: flex; flex-wrap: wrap; gap: .5rem; }
.example {
  border: 1px dashed var(--line); background: transparent; color: var(--ink-soft);
  border-radius: 10px; padding: .45rem .8rem; font: 500 .85rem var(--sans); cursor: pointer;
}
.example:hover { border-color: var(--accent); color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.card {
  text-align: left; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 12px; overflow: hidden; padding: 0; cursor: pointer; transition: all .15s; font: inherit;
}
.card .art { height: 70px; overflow: hidden; }
.card .art svg { width: 100%; height: 100%; display: block; }
.card .txt { padding: .6rem .8rem .75rem; }
.card strong { display: block; font-family: var(--display); font-size: 1rem; }
.card span { font-size: .8rem; color: var(--muted); }
.card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

.submit-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.submit-row p { margin: 0; }
.form-error { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: .75rem 1rem; color: var(--ink); }

/* Writing */
.writing { max-width: 560px; margin: 0 auto; padding: 5rem 1rem; text-align: center; }
.writing h1 { font-size: 1.8rem; margin: 2rem 0 .5rem; }
.writing .lede { margin: 0 auto 1.5rem; font-size: 1rem; }
.writing-book { position: relative; width: 120px; height: 150px; margin: 0 auto; perspective: 600px; }
.wb-cover, .wb-page { position: absolute; inset: 0; border-radius: 4px 10px 10px 4px; transform-origin: left center; }
.wb-cover { background: var(--accent); box-shadow: var(--shadow); }
.wb-page { background: var(--paper); border: 1px solid var(--paper-edge); left: 6px; right: -2px; top: 4px; bottom: 4px; animation: flip 3.2s infinite ease-in-out; }
.wb-page.p2 { animation-delay: .8s; }
.wb-page.p3 { animation-delay: 1.6s; }
@keyframes flip { 0%, 20% { transform: rotateY(0); } 55%, 100% { transform: rotateY(-170deg); opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .wb-page { animation: none; } }
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
#writing-bar { height: 100%; width: 4%; background: var(--accent); border-radius: 999px; transition: width .6s ease; }
.writing-actions { display: flex; gap: .75rem; justify-content: center; margin-top: 1rem; }

/* Reader */
.reader-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 1100px; margin: 0 auto; padding: .5rem clamp(1rem, 4vw, 2rem);
}
.reader-title { font-family: var(--display); font-weight: 600; text-align: center; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-actions { display: flex; gap: .5rem; }
.book-stage { display: flex; align-items: flex-start; justify-content: center; gap: 1rem; padding: 1rem clamp(.5rem, 3vw, 2rem); max-width: 1100px; margin: 0 auto; }
.nav-btn {
  position: sticky; top: 45vh; flex: none; width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-size: 1.8rem; line-height: 1;
  cursor: pointer; box-shadow: var(--shadow); margin-top: 30vh;
}
.nav-btn:disabled { opacity: .3; cursor: default; }
.page {
  width: 100%; max-width: 760px; background: var(--paper); border: 1px solid var(--paper-edge);
  border-radius: 6px 16px 16px 6px; box-shadow: var(--shadow), inset 10px 0 18px -14px rgba(60,40,20,.35);
  overflow: hidden; min-height: 70vh; animation: pagein .35s ease;
}
@keyframes pagein { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } }
.page .art { aspect-ratio: 800 / 420; overflow: hidden; border-bottom: 1px solid var(--paper-edge); }
.page .art svg { width: 100%; height: 100%; display: block; }
.page-body { padding: clamp(1.5rem, 4vw, 3rem) clamp(1.25rem, 5vw, 3.5rem) 2.5rem; }
.page-body h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 1.25rem; }
.story { font-family: var(--serif); font-size: 1.12rem; line-height: 1.75; color: var(--ink); }
.story p { margin: 0 0 1.1em; }
.story p:first-child::first-letter { font-family: var(--display); float: left; font-size: 3.3em; line-height: .85; padding: .08em .1em 0 0; color: var(--accent); }
.page-label { font: 600 .72rem var(--sans); text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin-bottom: .5rem; }

.cover { position: relative; min-height: 70vh; display: flex; flex-direction: column; }
.cover .art { aspect-ratio: auto; flex: 1; min-height: 340px; border: 0; position: relative; }
.cover .art svg { position: absolute; inset: 0; }
.cover-text { padding: 2rem clamp(1.25rem, 5vw, 3.5rem) 2.5rem; text-align: center; }
.cover-text h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin-bottom: .5rem; }
.cover-text p { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: 1.15rem; margin: 0 0 1.5rem; }

.dedication { text-align: center; padding: clamp(3rem, 10vh, 6rem) clamp(1.25rem, 6vw, 4rem); }
.dedication .ded { font-family: var(--serif); font-style: italic; font-size: 1.35rem; color: var(--ink-soft); max-width: 28rem; margin: 0 auto 3rem; }
.how-to { text-align: left; max-width: 32rem; margin: 0 auto; font-size: .95rem; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 1.5rem; }
.how-to h3 { font-size: 1.05rem; color: var(--ink); margin-bottom: .5rem; }
.how-to ul { padding-left: 1.2rem; margin: 0; }
.how-to li { margin-bottom: .35rem; }
.safety {
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 12px;
  padding: 1rem 1.2rem; text-align: left; max-width: 32rem; margin: 0 auto 2.5rem; font-size: .98rem;
}
.safety strong { display: block; margin-bottom: .3rem; }

.tool {
  margin-top: 2rem; background: var(--tool-bg); border: 1px solid var(--tool-line); border-radius: 14px;
  padding: 1.2rem 1.4rem; color: var(--tool-ink);
}
.tool .tag { font: 600 .7rem var(--sans); letter-spacing: .14em; text-transform: uppercase; opacity: .8; }
.tool h3 { font-size: 1.25rem; margin: .25rem 0 .75rem; }
.tool ol { margin: 0 0 .75rem; padding-left: 1.25rem; }
.tool li { margin-bottom: .35rem; }
.tool .why { margin: 0; font-size: .92rem; font-style: italic; opacity: .9; }

.notes { margin-top: 2rem; }
.notes label { display: block; font: 600 .8rem var(--sans); color: var(--muted); margin-bottom: .4rem; text-transform: uppercase; letter-spacing: .1em; }
.notes textarea {
  background: repeating-linear-gradient(transparent, transparent 31px, var(--line) 31px, var(--line) 32px);
  line-height: 32px; padding: 0 .25rem; border: 0; border-radius: 0; min-height: 96px; font-family: var(--serif);
}
.saved { font-size: .75rem; color: var(--muted); height: 1em; margin-top: .25rem; }

.closing .moral { font-family: var(--display); font-style: italic; font-size: clamp(1.4rem, 3vw, 1.9rem); text-align: center; color: var(--accent); margin: 0 0 2.5rem; line-height: 1.3; }
.letter { font-family: var(--serif); font-size: 1.08rem; line-height: 1.75; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem 1.75rem; }
.letter p { margin: 0 0 1em; }
.letter p:last-child { margin-bottom: 0; }

.guide h2 { margin-bottom: .4rem; }
.guide section { margin-top: 2rem; }
.guide h3 { font-size: 1.15rem; margin-bottom: .75rem; }
.guide dl { margin: 0; display: grid; gap: .75rem; }
.guide dt { font-weight: 600; }
.guide dd { margin: .1rem 0 0; color: var(--ink-soft); font-size: .95rem; }
.plan { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.plan label { display: flex; gap: .75rem; align-items: flex-start; padding: .65rem .85rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--bg); }
.plan input { margin-top: .25rem; accent-color: var(--accent); width: 1.05rem; height: 1.05rem; flex: none; }
.plan .day { font-weight: 600; min-width: 3.5rem; }
.plan input:checked ~ span { text-decoration: line-through; color: var(--muted); }
.reflect { margin-bottom: 1.25rem; }
.reflect p { font-family: var(--serif); font-style: italic; margin: 0 0 .4rem; }
.support { padding-left: 1.2rem; margin: 0; color: var(--ink-soft); }

.reader-foot { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: .5rem 1rem 2rem; flex-wrap: wrap; }
.dots { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: center; }
.dots button { width: 9px; height: 9px; border-radius: 50%; border: 0; padding: 0; background: var(--line); cursor: pointer; }
.dots button[aria-current="true"] { background: var(--accent); transform: scale(1.3); }

@media (max-width: 700px) {
  .nav-btn { display: none; }
  .book-stage { padding: .5rem; }
  .reader-title { display: none; }
  .reader-foot { position: sticky; bottom: 0; background: var(--bg); padding-bottom: 1rem; }
}

/* Print: every page of the book, one after another */
#print-root { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .site-header, .site-footer, main { display: none !important; }
  #print-root { display: block; }
  #print-root .page { box-shadow: none; border: 0; min-height: 0; break-after: page; animation: none; max-width: none; }
  #print-root .page:last-child { break-after: auto; }
  #print-root .notes textarea { display: none; }
  #print-root .notes .printed-note { font-family: var(--serif); white-space: pre-wrap; }
  .tool, .letter, .plan label { break-inside: avoid; }
}

/* Book type switch */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 640px) { .modes { grid-template-columns: 1fr; } }
.mode {
  text-align: left; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 14px; padding: 1rem 1.1rem; cursor: pointer; font: inherit; transition: all .15s;
}
.mode strong { display: block; font-family: var(--display); font-size: 1.1rem; margin-bottom: .25rem; }
.mode span { font-size: .88rem; color: var(--muted); }
.mode:hover { border-color: var(--accent); }
.mode[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* Character builder */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 680px) { .hero-grid { grid-template-columns: 1fr; } }
.hero-preview { border-radius: 14px; overflow: hidden; border: 1px solid var(--paper-edge); aspect-ratio: 800 / 420; position: sticky; top: 1rem; }
.hero-preview svg { width: 100%; height: 100%; display: block; }
.hero-controls { display: flex; flex-direction: column; gap: .45rem; }
.sublabel { font-size: .8rem; font-weight: 600; color: var(--ink-soft); margin-top: .35rem; }
.swatches { display: flex; flex-wrap: wrap; gap: .4rem; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--accent); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; margin-top: .5rem; cursor: pointer; }
.check input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }

/* Picture book pages */
.page.kids { min-height: 0; }
.page.kids .kart { aspect-ratio: 800 / 420; border-bottom: 0; }
.ktext { position: relative; padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1.25rem, 6vw, 4rem) clamp(2rem, 5vw, 3rem); text-align: center; }
.ktext p { font-family: var(--display); font-weight: 400; font-size: clamp(1.45rem, 3.4vw, 2.1rem); line-height: 1.4; margin: 0; color: var(--ink); text-wrap: balance; }
.ktext.end h2 { font-size: clamp(2.2rem, 6vw, 3.4rem); color: var(--accent); margin-top: 1rem; font-style: italic; font-weight: 400; }
.kpn { position: absolute; bottom: .75rem; right: 1.25rem; font-size: .8rem; color: var(--muted); }
.page.kids .cover-text p { font-size: 1.25rem; }
#music-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }

/* Feelings wheel */
.families { display: flex; flex-wrap: wrap; gap: .5rem; }
.fam {
  display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); border-radius: 999px; padding: .45rem .8rem .45rem .7rem; font: 600 .92rem var(--sans); cursor: pointer;
}
.fam:hover { border-color: var(--fam); }
.fam[aria-expanded="true"] { border-color: var(--fam); box-shadow: 0 0 0 2px var(--fam); }
.dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--fam); flex: none; }
.fam .count { background: var(--fam); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .4rem; line-height: 1.4rem; min-width: 1.4rem; text-align: center; }
.fam .caret { font-size: .7rem; color: var(--muted); transition: transform .15s; }
.fam[aria-expanded="true"] .caret { transform: rotate(180deg); }
.feel-panel {
  margin-top: .6rem; padding: .9rem 1rem 1rem; background: var(--paper); border: 1px solid var(--line);
  border-left: 4px solid var(--fam); border-radius: 12px; box-shadow: var(--shadow);
}
.panel-hint { margin: 0 0 .6rem; font-size: .85rem; color: var(--muted); }
.chip.feel[aria-pressed="true"] { background: var(--fam); border-color: var(--fam); color: #fff; }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.picked { margin-top: .9rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.picked-item {
  display: inline-flex; align-items: center; gap: .45rem; background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: .3rem .35rem .3rem .65rem; font-size: .9rem;
}
.picked-item .pname { font-weight: 600; }
.picked-item select {
  font: 500 .82rem var(--sans); color: var(--ink-soft); background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: .15rem .3rem;
}
.picked-item .remove { border: 0; background: transparent; color: var(--muted); font-size: 1.15rem; line-height: 1; cursor: pointer; padding: 0 .3rem; }
.picked-item .remove:hover { color: var(--ink); }
.picked-note { width: 100%; margin: .1rem 0 0; }
.own-word { display: flex; gap: .5rem; margin-top: .75rem; max-width: 420px; }
.own-word input { flex: 1; padding: .5rem .8rem; font-size: .95rem; border-radius: 10px; }

/* Mode label next to the shared brand */
.mode-pill {
  font: 600 .72rem var(--sans); letter-spacing: .04em; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: .22rem .6rem; white-space: nowrap;
}
@media (max-width: 520px) { .mode-pill { display: none; } }

/* Share dialog */
.share-dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(480px, calc(100vw - 32px));
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
}
.share-dialog::backdrop { background: rgba(20, 16, 12, .45); }
.share-body { padding: 1.4rem 1.5rem 1.3rem; }
.share-body h2 { font-size: 1.4rem; margin-bottom: .6rem; }
.share-body p { margin: .4rem 0; color: var(--ink-soft); }
.share-field { display: flex; gap: .5rem; margin: .7rem 0; }
.share-field input { flex: 1; min-width: 0; font: 600 .95rem var(--sans); padding: .55rem .75rem; border-radius: 10px; }
.share-field input.passcode { font-family: ui-monospace, Menlo, monospace; letter-spacing: .2em; font-size: 1.1rem; }
.share-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.share-actions.wrap { flex-wrap: wrap; }

/* Passcode screen for shared links */
.gate { max-width: 460px; margin: 0 auto; padding: 4rem 16px; text-align: center; }
.gate-icon { font-size: 2.6rem; }
.gate h1 { font-size: 1.9rem; margin: .5rem 0; }
.gate .lede { margin: 0 auto 1.5rem; font-size: 1.05rem; }
.gate form { text-align: left; }
.gate-row { display: flex; gap: .5rem; }
.gate-row input { flex: 1; min-width: 0; font: 600 1.1rem ui-monospace, Menlo, monospace; letter-spacing: .15em; text-transform: uppercase; }
.gate-own { margin-top: 2rem; font-weight: 600; }

/* ---------- Phones and touch screens ---------- */

body { min-height: 100dvh; }
.foot-nav { display: none; }

@media (max-width: 700px) {
  /* Footer Back and Next replace the side arrows; the page count replaces the dots. */
  .reader-foot {
    justify-content: space-between; gap: .5rem; border-top: 1px solid var(--line);
    padding: .6rem 16px calc(.6rem + env(safe-area-inset-bottom));
  }
  .reader-foot .dots { display: none; }
  .foot-nav {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 96px;
    border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px;
    font: 600 1rem var(--sans); padding: 0 1rem; cursor: pointer;
  }
  .foot-nav#next-m { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  .foot-nav:disabled { opacity: .35; }
  .reader-bar { flex-wrap: wrap; padding-left: 16px; padding-right: 16px; }
  .reader-actions { flex-wrap: wrap; justify-content: flex-end; }
  .page { border-radius: 14px; }
}

/* Touch screens get 44px tap targets and 16px fields (smaller fields make iOS zoom in). */
@media (pointer: coarse) {
  .site-header .brand, .site-header nav a { min-height: 44px; display: inline-flex; align-items: center; }
  .btn, .chip, .example, .fam, .replay, .mode, .opt, details summary { min-height: 44px; }
  details summary { display: flex; align-items: center; }
  .swatch { width: 44px; height: 44px; }
  .check { min-height: 44px; }
  .picked-item .remove { min-width: 44px; min-height: 44px; }
  input, select, textarea { font-size: max(16px, 1em); }
  /* These set smaller sizes with more specific selectors, so they need naming here. */
  .picked-item select, .own-word input, .share-field input { font-size: 16px; }
  .picked-item select { min-height: 44px; }
}

/* Editing a book in place */
.edit-bar {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
  max-width: 760px; margin: 0 auto .5rem; padding: .6rem .9rem; background: var(--accent-soft); color: var(--ink);
  border: 1px solid var(--accent); border-radius: 12px; font-size: .92rem;
}
.edit-actions { display: flex; gap: .5rem; }
.editable {
  outline: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 3px; border-radius: 4px;
  cursor: text; min-width: 2ch; display: inline-block; max-width: 100%; vertical-align: top;
}
.editable.multi { display: block; white-space: pre-wrap; }
.editable:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.editable:focus { outline: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.edit-list { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .45rem; }
.edit-list li { display: flex; gap: .5rem; align-items: baseline; }
.edit-list .hint, .edit-hint { font-size: .78rem; color: var(--muted); }
.edit-card { display: grid; gap: .6rem; background: var(--tool-bg); border: 1px solid var(--tool-line); border-radius: 18px; padding: 1rem 1.1rem; }
.edit-card small { font: 800 .7rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.rewrite-row { margin-top: 1.25rem; display: flex; justify-content: center; }
.ktext .rewrite-row { margin-top: 1rem; }

.library-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: 1.5rem 0 .4rem; }
.library-tools label { cursor: pointer; }
