/* Babel Quest
   Idea: a pocket phrasebook that turns into a game. The whole app re-tints to the language you're learning,
   phrases are set in a serif like printed phrasebooks, and controls are chunky and pressable like arcade buttons. */
:root {
  --accent: #0b7a43; --accent-t: #0b7a43;
  --ink: #171a2b; --mute: #5f647b;
  --paper: color-mix(in srgb, var(--accent) 6%, #fbfbfd);
  --card: #ffffff;
  --line: color-mix(in srgb, var(--accent) 16%, #dde1ec);
  --soft: color-mix(in srgb, var(--accent) 9%, #ffffff);
  --deep: color-mix(in srgb, var(--accent) 68%, #000);
  --gold: #f2b01e; --gold-deep: #c98a00;
  --good: #12894a; --good-bg: #e2f6ea; --bad: #d23840; --bad-bg: #fdeaea;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
[data-theme=dark] {
  --ink: #eef0fb; --mute: #a3a8c0;
  --paper: color-mix(in srgb, var(--accent) 10%, #0d0f18);
  --card: #171a27;
  --line: color-mix(in srgb, var(--accent) 22%, #2a2f42);
  --soft: color-mix(in srgb, var(--accent) 16%, #171a27);
  --good: #4fd18b; --good-bg: #12301f; --bad: #ff7b80; --bad-bg: #3a1a1e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 500 16px/1.45 var(--sans); padding: 0 0 92px; min-height: 100dvh; }
h1 { font: 800 1.6rem/1.15 var(--sans); margin: 8px 0 14px; letter-spacing: -.01em; }
h2 { font: 800 1.05rem/1.2 var(--sans); margin: 22px 0 10px; }
p { margin: 0 0 8px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent-t); outline-offset: 2px; }
.mute { color: var(--mute); }
.small { font-size: .86rem; }
[hidden] { display: none !important; }

/* ---- shell ---- */
#top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 2px solid var(--line); }
.brand { white-space: nowrap; display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; margin-right: auto; font-weight: 800; }
.logo { width: 30px; height: 30px; border-radius: 9px 9px 9px 3px; background: var(--accent); color: #fff; display: grid; place-items: center; font: 800 1.05rem var(--serif); }
.logo.big { width: 64px; height: 64px; font-size: 2rem; border-radius: 20px 20px 20px 6px; margin: 0 auto 10px; }
.pair { display: flex; align-items: center; gap: 4px; border: 2px solid var(--line); background: var(--card); border-radius: 99px; padding: 3px 8px 3px 4px; }
.pair i { font-style: normal; color: var(--mute); }
.chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 99px; background: var(--card); border: 2px solid var(--line); font-weight: 800; font-size: .9rem; }
.lb { display: inline-grid; place-items: center; min-width: 30px; height: 24px; padding: 0 6px; border-radius: 99px; background: var(--c); color: #fff; font: 800 .74rem var(--sans); letter-spacing: .02em; }
#app { max-width: 720px; margin: 0 auto; padding: 14px 16px 24px; }
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--card); border-top: 2px solid var(--line); }
#nav a { flex: 1; max-width: 100px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; border-radius: 14px; color: var(--mute); text-decoration: none; font-weight: 700; font-size: .72rem; }
#nav a span { font-size: 1.35rem; line-height: 1; filter: grayscale(1); opacity: .75; }
#nav a.on { color: var(--accent-t); background: var(--soft); }
#nav a.on span { filter: none; opacity: 1; }
@media (max-width: 470px) { .bn { display: none; } }
@media (max-width: 420px) { #nav { padding-left: 2px; padding-right: 2px; } #nav a { padding: 6px 0; font-size: .62rem; letter-spacing: -.015em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
@media (max-width: 380px) { #nav a { font-size: .56rem; } }
@media (max-width: 340px) { #nav a { font-size: .52rem; } #nav a span { font-size: 1.2rem; } }
@media (min-width: 900px) {
  body { padding: 0 0 0 96px; }
  #nav { right: auto; top: 0; bottom: 0; width: 96px; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 76px 8px 8px; border-top: 0; border-right: 2px solid var(--line); }
  #nav a { flex: 0 0 auto; max-width: none; }
  #top { margin-left: -96px; padding-left: calc(96px + 14px); }
}
body.in-session { padding: 0; }
body.in-session #top, body.in-session #nav { display: none; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 13px 20px; background: var(--accent); color: #fff; font-weight: 800; box-shadow: 0 4px 0 var(--deep); transition: transform .08s, box-shadow .08s; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--deep); }
.btn.wide { width: 100%; }
.btn.sec { background: var(--card); color: var(--accent-t); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.sec:active:not(:disabled) { box-shadow: 0 1px 0 var(--line); }
.btn.gold { background: var(--gold); color: #3b2a00; box-shadow: 0 4px 0 var(--gold-deep); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 1rem; padding: 0; flex: none; }
.icon.on { background: var(--gold); border-color: var(--gold-deep); color: #3b2a00; }
.row { display: flex; align-items: center; gap: 12px; }
.row > :first-child { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.lp { display: flex; align-items: center; gap: 10px; }
.lp .bar { flex: 1; }
.lp b { min-width: 2ch; text-align: right; }
details.xplang summary { cursor: pointer; color: var(--accent-t); list-style: none; }
details.xplang summary::-webkit-details-marker { display: none; }
details.xplang summary::after { content: ' ▾'; }
details.xplang[open] summary::after { content: ' ▴'; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 14px; }
select, .txt { width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); }
select { appearance: auto; }
.txt:focus { border-color: var(--accent-t); outline: none; }
.seg { display: flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; font-weight: 700; font-size: .9rem; }
.seg button.on { background: var(--accent); color: #fff; }
.bar { height: 14px; border-radius: 99px; background: var(--soft); overflow: hidden; border: 2px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .35s; }
.bar.gold > i { background: var(--gold); }
.pips { display: inline-flex; gap: 3px; }
.pips b { width: 8px; height: 8px; border-radius: 3px; background: var(--line); }
.pips b.f { background: var(--accent); }

/* ---- setup ---- */
.setup { max-width: 520px; margin: 0 auto; padding: 28px 16px 40px; }
.hero { text-align: center; margin-bottom: 10px; }
.hero h1 { font: 800 2.2rem/1 var(--serif); margin: 4px 0 8px; }
.langs { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; }
.lang, .goal { display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); box-shadow: 0 3px 0 var(--line); font-weight: 700; text-align: left; }
.lang { flex-direction: column; align-items: flex-start; gap: 6px; font-size: .94rem; }
.lang.on, .goal.on { border-color: var(--accent); box-shadow: 0 3px 0 var(--accent); background: var(--soft); }
.goals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.goal { flex-direction: column; align-items: flex-start; gap: 0; }
.goal span { color: var(--mute); font-weight: 600; font-size: .9rem; }
.setup .btn { margin-top: 24px; }

/* ---- home ---- */
.plan { display: flex; gap: 16px; align-items: center; border-radius: 22px 22px 22px 6px; padding: 16px; }
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 800 1.05rem var(--sans); }
.plan .lvl { font: 800 1.25rem var(--serif); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.wk { display: flex; align-items: flex-end; gap: 8px; height: 96px; padding-top: 6px; }
.wk div { flex: 1; text-align: center; font-size: .75rem; color: var(--mute); display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 4px; }
.wk i { display: block; width: 100%; background: var(--line); border-radius: 6px 6px 3px 3px; min-height: 4px; }
.wk i.hit { background: var(--accent); }
.wk div.today { color: var(--accent-t); font-weight: 800; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 2px; }
.heat i { display: block; width: 11px; height: 11px; border-radius: 3px; background: var(--soft); border: 1px solid var(--line); }
.heat i.l1 { background: color-mix(in srgb, var(--accent) 30%, var(--soft)); border-color: transparent; }
.heat i.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--soft)); border-color: transparent; }
.heat i.l3 { background: color-mix(in srgb, var(--accent) 78%, var(--soft)); border-color: transparent; }
.heat i.l4 { background: var(--accent); border-color: transparent; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cat { position: relative; text-align: left; padding: 16px 12px 12px; margin-top: 10px; border: 2px solid var(--line); border-radius: 6px 14px 14px 14px; background: var(--card); box-shadow: 0 3px 0 var(--line); }
.cat::before { content: attr(data-ic); position: absolute; top: -13px; left: 10px; height: 26px; padding: 0 9px; border-radius: 9px 9px 0 0; background: var(--soft); border: 2px solid var(--line); border-bottom: 0; font-size: 1rem; line-height: 24px; }
.cat b { display: block; font-size: .95rem; line-height: 1.2; margin-bottom: 8px; min-height: 2.4em; }
.cat small { display: block; margin-top: 6px; color: var(--mute); font-weight: 600; }
.cat.done { border-color: var(--gold-deep); }
.cat .bar { height: 10px; }
.daily { display: flex; align-items: center; gap: 12px; margin-top: 14px; background: var(--soft); border-style: dashed; }
.daily .em { font-size: 1.8rem; flex: none; }
.daily > div { flex: 1; min-width: 0; }

/* ---- flashcards (the memorable part) ---- */
.sess { max-width: 640px; min-height: 100dvh; margin: 0 auto; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sess header { display: flex; align-items: center; gap: 12px; }
.sess header .bar { flex: 1; }
.sess main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.sess footer { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); padding-top: 6px; }
.lab { color: var(--mute); font-weight: 700; margin: 0; text-align: center; }
.fc { position: relative; height: min(56vh, 360px); min-height: 270px; perspective: 1200px; cursor: pointer; }
.fc .in { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3, .7, .2, 1); }
.fc.flipped .in { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 28px 22px; text-align: center; background: var(--card); border: 2px solid var(--line); border-radius: 8px 24px 24px 8px; box-shadow: 0 6px 0 var(--line), inset 8px 0 0 var(--soft); }
.face.back { transform: rotateY(180deg); background: var(--soft); }
.ribbon { position: absolute; top: -2px; right: 22px; width: 34px; padding: 8px 0 16px; background: var(--accent); color: #fff; font: 800 .74rem var(--sans); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); }
.ph { font: 600 clamp(1.55rem, 5.6vw, 2.2rem)/1.25 var(--serif); overflow-wrap: anywhere; }
.ph.t { color: var(--accent-t); }
.ph.sm { font-size: 1.1rem; color: var(--mute); }
.tag { font-weight: 800; font-size: .85rem; color: var(--accent-t); }
.spk { color: var(--accent-t); }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate button { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 10px 4px; border-radius: 14px; border: 0; color: #fff; font-weight: 800; box-shadow: 0 4px 0 rgba(0, 0, 0, .28); }
.rate button small { font-weight: 600; opacity: .9; }
.rate button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .28); }
.r0 { background: #d23840; } .r1 { background: #c76a12; } .r2 { background: #12894a; } .r3 { background: #2d5be3; }

/* ---- question sessions ---- */
.qcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 18px; text-align: center; background: var(--card); border: 2px solid var(--line); border-radius: 8px 22px 22px 8px; box-shadow: 0 5px 0 var(--line), inset 8px 0 0 var(--soft); }
.opts { display: grid; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 13px 14px; text-align: left; border-radius: 14px; border: 2px solid var(--line); background: var(--card); box-shadow: 0 4px 0 var(--line); font: 600 1.02rem/1.3 var(--serif); }
.opt kbd { flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font: 800 .78rem var(--sans); background: var(--soft); color: var(--mute); }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.opt.ok { border-color: var(--good); background: var(--good-bg); box-shadow: 0 4px 0 var(--good); }
.opt.no { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 4px 0 var(--bad); }
.bigspk { width: 92px; height: 92px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 2.2rem; box-shadow: 0 6px 0 var(--deep); }
.bigspk:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--deep); }
.chars { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chars button { min-width: 38px; height: 38px; border-radius: 10px; border: 2px solid var(--line); background: var(--card); font: 700 1.05rem var(--serif); }
.ansline { min-height: 64px; display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-radius: 14px; border: 2px dashed var(--line); background: var(--card); }
.bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 52px; }
.tile { padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); box-shadow: 0 3px 0 var(--line); font: 600 1.05rem var(--serif); }
.tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.fb { border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.fb.ok { background: var(--good-bg); color: var(--good); }
.fb.no { background: var(--bad-bg); color: var(--bad); }
.fb b { font-size: 1.05rem; }
.fb .ans { display: flex; align-items: center; gap: 8px; color: var(--ink); font: 600 1.1rem/1.3 var(--serif); }
.combo { font-weight: 800; padding: 4px 10px; border-radius: 99px; background: var(--gold); color: #3b2a00; white-space: nowrap; }
.hd { font-weight: 800; white-space: nowrap; }
.done { text-align: center; padding-top: 6vh; }
.trophy { font-size: 4rem; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stats3 div { padding: 12px 6px; border-radius: 14px; background: var(--card); border: 2px solid var(--line); }
.stats3 b { display: block; font: 800 1.4rem var(--serif); }
.stats3 span { color: var(--mute); font-size: .82rem; font-weight: 700; }
.miss { text-align: left; }
.miss .pr { margin-top: 8px; }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---- match ---- */
.mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mgrid button { width: 100%; min-height: 62px; padding: 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); box-shadow: 0 3px 0 var(--line); font: 600 .98rem/1.25 var(--serif); }
.mgrid button.sel { border-color: var(--accent); background: var(--soft); box-shadow: 0 3px 0 var(--accent); }
.mgrid button.gone { visibility: hidden; }
.mgrid button.bad { border-color: var(--bad); background: var(--bad-bg); }

.ph.kana { font-size: clamp(3rem, 22vw, 5rem); }
.krow { margin-top: 14px; }
.kglab { display: block; font: 800 .74rem var(--sans); color: var(--mute); letter-spacing: .03em; margin-bottom: 6px; }
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }
.kcell { aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; border: 2px solid var(--line); background: var(--card); font: 600 1.1rem var(--serif); }
.kcell.lr { border-color: var(--gold-deep); background: color-mix(in srgb, var(--gold) 18%, var(--card)); }
.kcell.kn { border-color: var(--accent); background: var(--soft); color: var(--accent-t); }

/* ---- lists, practice, profile ---- */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.mode { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; text-align: left; border-radius: 16px; border: 2px solid var(--line); background: var(--card); box-shadow: 0 4px 0 var(--line); }
.mode:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.mode .mi { font-size: 1.6rem; }
.mode b { font-size: 1.02rem; }
.mode small { color: var(--mute); font-weight: 600; line-height: 1.3; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.filters .seg, .filters .span2 { grid-column: 1 / -1; }
.pr { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; margin-top: 8px; background: var(--card); border: 2px solid var(--line); border-left: 6px solid var(--accent); border-radius: 6px 14px 14px 6px; }
.pr .tx { flex: 1; min-width: 0; }
.pr .nat { font: 600 1.05rem/1.3 var(--serif); }
.pr .tgt { font: 600 1rem/1.3 var(--serif); color: var(--accent-t); }
.pr .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.pr .acts { display: flex; gap: 6px; }
.pr .icon { width: 34px; height: 34px; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ach div { padding: 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); }
.ach div.lock { opacity: .5; filter: grayscale(1); }
.ach b { display: block; font-size: .95rem; }
.ach span { font-size: .8rem; color: var(--mute); line-height: 1.3; display: block; }
.ach i { font-style: normal; font-size: 1.5rem; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.kv div { padding: 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); }
.kv b { display: block; font: 800 1.5rem var(--serif); }
.kv span { color: var(--mute); font-size: .82rem; font-weight: 700; }
.set > * + * { margin-top: 12px; }
.set .row { padding: 4px 0; }
.set label { font-weight: 700; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.empty { text-align: center; padding: 28px 10px; color: var(--mute); }

/* ---- feedback layers ---- */
#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 10px 14px; font-size: .92rem; border-radius: 14px; background: var(--ink); color: var(--paper); font-weight: 700; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: pop .3s; }
.toast.gold { background: var(--gold); color: #3b2a00; }
@keyframes pop { from { transform: translateY(-10px) scale(.96); opacity: 0; } }
.confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .fc .in { transition: none; } .toast, .shake { animation: none; } .bar > i { transition: none; }
}

/* ---- stories ---- */
.scards { display: grid; gap: 14px; margin-top: 14px; }
.scard { display: flex; gap: 12px; padding: 14px 14px 14px 12px; background: var(--card); border: 2px solid var(--line); border-left: 6px solid var(--accent); border-radius: 6px 16px 16px 6px; box-shadow: 0 3px 0 var(--line); }
.scard.lock { border-left-color: var(--line); }
.scard.lock .sic { filter: grayscale(1); opacity: .55; }
.scard .sic { flex: none; width: 44px; font-size: 2rem; line-height: 1.1; text-align: center; }
.scard .sbd { flex: 1; min-width: 0; }
.scard .stt { display: flex; align-items: center; gap: 8px; }
.scard .stt b { font: 700 1.12rem/1.25 var(--serif); }
.lv { flex: none; padding: 1px 8px; border-radius: 99px; background: var(--soft); border: 2px solid var(--line); color: var(--accent-t); font: 800 .7rem var(--sans); }
.stars { color: var(--gold-deep); letter-spacing: 2px; font-size: 1.1rem; }
.stars .off { color: var(--line); }
.sfoot { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.bar.tk { position: relative; height: 12px; margin: 10px 0 6px; }
.bar.tk s { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--ink); opacity: .4; }
.scard .go { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.scard .go .btn { padding: 9px 14px; font-size: .92rem; }

/* reader: a conversation. Anna is on the right, everyone else on the left */
.story main { justify-content: flex-start; gap: 12px; }
.story footer { bottom: 0; margin-top: -8px; padding: 22px 0 calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--paper) 72%, transparent); }
.story footer .actions { grid-template-columns: 1fr 1.4fr; }
.story footer .btn { padding-left: 10px; padding-right: 10px; white-space: nowrap; }
.sess header .th { flex: 1; min-width: 0; font: 800 1.02rem/1.2 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sline { display: flex; align-items: flex-end; gap: 8px; }
.sline.me { flex-direction: row-reverse; }
.sline .av { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); border: 2px solid var(--line); font-size: 1.2rem; }
.sline .bub { max-width: min(86%, 500px); padding: 8px 12px 10px; cursor: pointer; background: var(--card); border: 2px solid var(--line); border-radius: 16px 16px 16px 4px; box-shadow: 0 3px 0 var(--line); }
.sline.me .bub { background: var(--soft); border-radius: 16px 16px 4px 16px; border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); }
.sline.speaking .bub { border-color: var(--accent); box-shadow: 0 3px 0 var(--accent); }
.sline .who { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--mute); font: 800 .72rem var(--sans); }
.sline .who .icon { width: 28px; height: 28px; border-radius: 9px; font-size: .78rem; }
.sline .tx { font: 600 1.12rem/1.4 var(--serif); overflow-wrap: anywhere; }
.sline .tr { display: none; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); color: var(--mute); font-size: .92rem; }
.sline.open .tr, .alltr .sline .tr { display: block; }
mark { color: inherit; background: none; }
mark.u { background: color-mix(in srgb, var(--gold) 24%, transparent); border-bottom: 2px dotted var(--gold-deep); border-radius: 3px; cursor: help; }
mark.k { border-bottom: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); }

/* fill the gaps */
.gap { display: inline-block; min-width: 4.2ch; padding: 0 4px; text-align: center; border-bottom: 3px solid var(--accent); }
.gap.ok { color: var(--good); border-color: var(--good); }
.gap.no { color: var(--bad); border-color: var(--bad); }

/* ---------- tap a word (js/words.js) ---------- */
.w { cursor: pointer; border-radius: 4px; transition: background .12s; }
.w:hover { background: var(--soft); }
.w.wsel { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.fc:not(.flipped) .back .w { pointer-events: none; }   /* the hidden answer side must not give the answer away */
.gloss { position: absolute; z-index: 50; max-width: min(300px, calc(100vw - 16px)); padding: 10px 12px; border-radius: 14px; background: var(--card); color: var(--ink);
  border: 2px solid var(--accent); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-weight: 600; text-align: left; animation: pop .18s; }
.gloss::before { content: ''; position: absolute; left: calc(var(--ax, 50%) - 7px); width: 12px; height: 12px; background: var(--card); border: 2px solid var(--accent); transform: rotate(45deg); }
.gloss.dn::before { top: -8px; border-right: 0; border-bottom: 0; }
.gloss.up::before { bottom: -8px; border-left: 0; border-top: 0; }
.gloss .gw { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gloss .gw b { font: 700 1.1rem var(--serif); color: var(--accent-t); }
.gloss .gw .icon { width: 30px; height: 30px; border-radius: 9px; font-size: .8rem; }
.gloss .gm { margin-top: 2px; font-size: 1rem; }
.gloss .gp { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--line); color: var(--mute); font-size: .85rem; }

/* ---------- Build game: drag to rearrange ---------- */
.ansline .tile, .bank .tile { touch-action: none; user-select: none; -webkit-user-select: none; }
.tile.dragging { opacity: .3; }
.tile.ghost { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; margin: 0; box-shadow: 0 8px 20px rgba(0, 0, 0, .22); border-color: var(--accent); }
.ansline .caret { align-self: stretch; width: 3px; margin: 0 -1px; border-radius: 2px; background: var(--accent); }
.bank.over { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 12px; }
@media (prefers-reduced-motion: reduce) { .gloss { animation: none; } }

/* ---------- Speak mode ---------- */
.spk-box { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 18px; }
.mic.on { background: var(--bad, #d63b3b); box-shadow: 0 6px 0 color-mix(in srgb, var(--bad, #d63b3b) 60%, #000); animation: micpulse 1.2s infinite; }
@keyframes micpulse { 50% { transform: scale(1.06); } }
.heard { min-height: 3em; margin: 0; text-align: center; font: 600 1.05rem/1.4 var(--serif); }
.heard.no { color: var(--bad, #d63b3b); font-family: var(--sans); font-size: .95rem; }
.heard small { color: var(--mute); }
@media (prefers-reduced-motion: reduce) { .mic.on { animation: none; } }

/* ---------- My texts (js/reading.js) ---------- */
.notice { padding: 10px 14px; margin-bottom: 12px; border-radius: 12px; background: color-mix(in srgb, var(--gold) 16%, var(--card)); border: 2px solid var(--gold-deep); font-size: .88rem; }
textarea.txt.txarea { min-height: 160px; resize: vertical; font: 500 1.02rem/1.5 var(--serif); }
#txCount.bad { color: var(--bad); font-weight: 800; }
.rtext { display: flex; flex-direction: column; gap: 10px; }
.rline { padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); cursor: pointer; font: 600 1.08rem/1.55 var(--serif); }
.rline.speaking { border-color: var(--accent); box-shadow: 0 3px 0 var(--accent); }
.w.cur { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.rspeed { max-width: 280px; }
