/* Akane's Way, the course app (E1). Dark only, phone first. Uses the site's tokens from /css/site.css.
   Patterns from the Fujiwara Ladder Academy: top bar, progress pips, kicker and title, the blue how line, the character
   line with a round portrait, the dock with Ask and a big Continue, story scenes with a full background. */
:root {
  --panel: var(--card); --panel2: var(--card2); --inset: #08090b; --dim: #6f747c; --amber: #e0a23c;
  --crema: var(--accent2); --crema-soft: #c8a27a1f; --ok-soft: #4ad17f1c; --blue-soft: #4f8cc922;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --jp: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", "Meiryo", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
}
[hidden] { display: none !important; }
html, body.app { height: 100%; overflow: hidden; }
body.app { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body.app button { margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; border-radius: 0; display: inline-flex; align-items: center; cursor: pointer; }
body.app a { text-decoration: none; }
[lang="ja"] { font-family: var(--jp); }
#app { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100%); display: flex; flex-direction: column; overflow: hidden; max-width: 720px; margin: 0 auto; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Akane never moves when she appears or changes pose: her pictures only fade, in place. */
@keyframes fadeOnly { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px #c8a27a33; } }

/* ---------- buttons */
body.app .btn { min-height: 48px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); justify-content: center; gap: 8px; font-weight: 650; transition: transform .1s, background .15s; user-select: none; }
body.app .btn:active { transform: scale(.97); }
body.app .btn.primary { background: var(--text); color: #111; border-color: var(--text); }
body.app .btn.crema { background: var(--crema); color: #1c140d; border-color: var(--crema); }
body.app .btn.ghost { background: transparent; }
body.app .btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
body.app .btn.block { display: flex; width: 100%; }
body.app .btn.locked { color: var(--muted); border-style: dashed; }
body.app .btn[disabled] { opacity: .35; pointer-events: none; }
a.btn { display: inline-flex; align-items: center; }
body.app .iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); justify-content: center; flex: none; }
.iconbtn svg { width: 22px; height: 22px; }

/* ---------- top bar and pips */
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-t)) 12px 8px; border-bottom: 1px solid var(--line); flex: none; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title b { display: block; font-size: 16px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pips { display: flex; gap: 3px; padding: 6px 12px 0; flex: none; }
.pips i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); transition: background .2s; }
.pips i.done { background: var(--ok); }
.pips i.cur { background: var(--text); }

/* ---------- the screen */
.view { flex: 1; position: relative; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 12px 16px 28px; animation: fadeIn .2s var(--ease); }
.view:focus { outline: none; }
.view > .kicker:first-child, .view > .tiles:first-child + .kicker { margin-top: 10px; }
.view h1 { font-size: 26px; line-height: 1.2; margin: 4px 0 10px; }
.view h1.q { font-size: 23px; }
.view h1 .kw { color: var(--crema); font-size: .8em; margin-left: 6px; }
.view h2 { font-size: 18px; margin: 24px 0 8px; }
.kicker { font-family: var(--mono); letter-spacing: .14em; }
.view .loading { margin-top: 30vh; text-align: center; }
.how { margin: 10px 0 12px; padding: 11px 13px; font-size: 15.5px; font-weight: 600; line-height: 1.4; background: var(--blue-soft); border-color: #4f8cc955; color: #d6e5f5; }
.how-i { flex: none; color: #8fb7e0; display: inline-flex; }
.how-i svg { width: 22px; height: 22px; }
.slide-text { font-size: 16.5px; line-height: 1.55; margin: 10px 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- the character line */
.say-slot { margin-top: 14px; }
.line { display: flex; gap: 10px; align-items: flex-end; animation: fadeOnly .2s ease; }
.line .txt { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 10px 13px; }
.line .txt > b { display: block; color: var(--crema); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.line .txt p b, .vn-text b, .ask-say b, .slide-text b { color: var(--crema); font-weight: 700; }
.line .txt p { margin: 2px 0 0; font-size: 15.5px; line-height: 1.45; }
.line.good .txt { border-color: #4ad17f77; }
.line.bad .txt { border-color: #e0a23c77; }
.face { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; display: inline-block; border: 2px solid var(--crema); background: var(--panel2); flex: none; }
.face img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; transform: scale(2.2); transform-origin: 50% 33%; }
.face.big { width: 64px; height: 64px; }
.face.fallback { display: grid; place-items: center; color: var(--crema); font-weight: 700; font-size: 20px; }

/* ---------- the dock */
.dock { flex: none; padding: 6px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg); }
.dock-keys { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 6px; }
body.app .key { min-width: 42px; height: 32px; padding: 0 10px; justify-content: center; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: 700 13px var(--mono); letter-spacing: .04em; }
body.app .key svg { width: 15px; height: 15px; }
body.app .key.on { color: var(--crema); border-color: var(--crema); background: var(--crema-soft); }
body.app .key.sm { min-width: 34px; height: 30px; padding: 0 8px; }
.dock-main { display: flex; gap: 10px; align-items: center; }
.dock.keys-only .dock-main { display: none; }
.dock.keys-only .dock-keys { margin-bottom: 0; }
body.app .askbtn { flex: none; min-height: 52px; padding: 0 16px 0 5px; border-radius: 999px; border: 1px solid var(--crema); background: var(--crema-soft); color: var(--crema); gap: 8px; font-weight: 700; position: relative; }
.askbtn .face { width: 40px; height: 40px; border-width: 1px; }
.askbtn .face.fallback { font-size: 16px; }
.askbtn.nudge { animation: pulse .8s var(--ease) 2; }
.askbtn.ready::after { content: ""; position: absolute; top: 4px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--crema); box-shadow: 0 0 0 2px var(--bg); }
body.app .btn.go { flex: 1; min-height: 52px; font-size: 17px; }

/* ---------- romaji hints and readings */
ruby.rk { ruby-position: over; }
ruby.rk rt.ro { font: 500 max(10px, .42em) var(--mono); color: var(--muted); letter-spacing: .02em; text-transform: none; }
body.ro-off ruby.rk:not(.peek) rt.ro { visibility: hidden; }
ruby.rk.peek rt.ro { visibility: visible; color: var(--crema); }
ruby.rk { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.kana .oku { opacity: .5; }
.romaji { font-family: var(--mono); letter-spacing: .02em; }
.readings { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
.reading-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 4px 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.rk-kind { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.rd { font-size: 30px; line-height: 1.5; }
.rd-note { grid-column: 1 / -1; font-size: 14.5px; }
.rd-note p { margin: 2px 0; }
.words { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 14px; }
.word-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.word { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.word .w { font-size: 24px; }
.word .r { font-size: 15px; color: #d9d4cc; }
.word-row .mean, .word-info .mean { color: var(--muted); font-size: 14.5px; }
.word-info { display: flex; gap: 12px; align-items: center; min-height: 52px; margin-top: 8px; }

/* ---------- pictures and the kanji box */
.qpic { display: flex; justify-content: center; margin: 6px 0 12px; }
.qpic img.mem, .qpic .plainbox, .after img.mem, .after .plainbox { width: min(300px, 78vw); aspect-ratio: 1; border-radius: 18px; object-fit: cover; border: 1px solid var(--line); background: radial-gradient(circle at 50% 40%, #1d2129, #121419 72%); }
.plainbox { display: grid; place-items: center; font: 400 120px/1 var(--jp); color: #ffffff1a; }
.after { display: flex; justify-content: center; }
.after:not(:empty) { margin-top: 12px; animation: pop .3s var(--ease); }
.after img.mem, .after .plainbox { width: min(220px, 60vw); }
.glyph-frame { width: min(240px, 66vw); aspect-ratio: 1; border-radius: 22px; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, #1d2129 0%, #121419 72%); border: 1px solid var(--line); box-shadow: 0 16px 40px #0007; }
.glyph-frame .glyph { font-size: min(150px, 40vw); line-height: 1; }
.glyph-frame.word-frame { aspect-ratio: auto; min-height: 160px; padding: 18px; }
.glyph-frame.word-frame .w { font-size: 64px; }
.glyph-frame.listen { aspect-ratio: auto; min-height: 140px; padding: 18px; font-size: 40px; }
.kbox-wrap { display: flex; justify-content: center; margin: 8px 0 12px; }
.kbox-wrap.small { margin: 4px 0 10px; }
.kbox-plain { position: relative; aspect-ratio: 1; border-radius: 22px; overflow: hidden; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, #1d2129 0%, #121419 72%); border: 1px solid var(--line); box-shadow: 0 16px 40px #0007; }
.kbox-plain .kbox-pic, .kbox-plain .plainbox { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; border: 0; border-radius: 0; }
.kbox-ch { position: relative; font-size: min(170px, 44vw); line-height: 1; color: #f4f4f2; text-shadow: 0 0 2px #10131a, 0 4px 24px #000c; }
.tiles { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.tile { width: 44px; height: 44px; border-radius: 10px; border: 1.5px dashed var(--line); display: grid; place-items: center; font-size: 26px; color: var(--text); }
.tile.got { border: 1.5px solid #4ad17f88; background: var(--ok-soft); animation: pop .3s var(--ease); }

/* ---------- options and answers */
.opts { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.opts.grid { display: grid; grid-template-columns: repeat(2, 1fr); }
body.app .opt { min-height: 54px; width: 100%; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); text-align: left; font-size: 16.5px; line-height: 1.35; gap: 10px; transition: background .15s, border-color .15s; }
body.app .opts.grid .opt { flex-direction: column; justify-content: center; text-align: center; min-height: 96px; }
.opt .glyph { font-size: 48px; line-height: 1.1; }
.opt small { color: var(--muted); font-size: 12.5px; }
.opt .kana { font-size: 24px; }
body.app .opt.yes { border-color: var(--ok); background: #13261a; }
body.app .opt.no { border-color: #e0a23c66; opacity: .55; animation: shake .35s; }
body.app .opt.shown { border: 1.5px dashed var(--crema); background: var(--crema-soft); }
body.app .opt.chip.sel { border-color: var(--blue); background: #142236; }
.answer-row { display: flex; justify-content: center; margin: 8px 0; }
input.answer { width: min(320px, 100%); text-align: center; font: 500 26px var(--jp); padding: 12px 14px; border-radius: 14px; }
input.answer.guess { font: 16px system-ui, sans-serif; }
input.answer.yes { border-color: var(--ok); background: #13261a; }
input.shake { animation: shake .35s; }
.tally { font-size: 20px; margin: 6px 0 4px; }
.tally b { font-size: 34px; color: var(--ok); }

/* ---------- chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
body.app .chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid #c8a27a66; background: var(--crema-soft); color: var(--crema); display: inline-flex; align-items: center; gap: 6px; font-size: 16px; }
body.app .chip.on { background: var(--crema); color: #1c140d; }
.chip small { color: var(--muted); font-size: 12px; }
body.app .chip.part { --pc: var(--ok); border-color: var(--pc); color: var(--text); background: color-mix(in srgb, var(--pc) 14%, transparent); }
.chip.part .pg { color: var(--pc); font-size: 22px; }
body.app .chip.part.must { animation: pulse 1.4s var(--ease) infinite; }
body.app .chip.part.seen { background: color-mix(in srgb, var(--pc) 26%, transparent); }

/* ---------- today card and wrap-up */
.card.today { padding: 0; overflow: hidden; margin: 6px 0 12px; }
.today-head { aspect-ratio: 16 / 8; background: linear-gradient(160deg, #262b33, #14161b) center / cover no-repeat; }
.today-body { padding: 14px 16px 6px; }
.today-body .kicker { margin-top: 0; }
ol.learn { padding-left: 22px; margin: 6px 0 10px; }
ol.learn li { margin: 4px 0; }
.pins { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.pin { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--text); animation: pop .35s var(--ease) both; }
.pin img.mem, .pin .plainbox { width: 100%; aspect-ratio: 1; border-radius: 10px; object-fit: cover; font-size: 48px; background: radial-gradient(circle at 50% 40%, #1d2129, #121419 72%); }
.pin-ch { font-size: 26px; line-height: 1; }
.pin-kw { font-size: 12.5px; color: var(--muted); }
.next { margin: 14px 0 0; }

/* ---------- story scenes */
.view.has-scene { padding: 0; overflow: hidden; }
.scene { position: absolute; inset: 0; overflow: hidden; background: radial-gradient(110% 70% at 50% 25%, #2a3039 0%, #14161b 70%); cursor: pointer; }
.scene-bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; transition: opacity .4s; }
.scene-bg.has-bg { opacity: 1; }
.scene-shade { position: absolute; inset: 0; background: linear-gradient(180deg, #0005 0%, transparent 25%, transparent 50%, #000a 100%); }
.sprite-slot { position: absolute; inset: 0; pointer-events: none; }
.sprite { position: absolute; left: 50%; bottom: 0; height: 84%; max-width: 130%; transform: translateX(-50%); filter: drop-shadow(0 20px 40px #000a); animation: fadeOnly .18s ease both; }
.sprite.out { animation: none; }   /* the old pose stays under the new one until the new one has loaded */
.scene.narration .sprite { opacity: .45; }
.scene-label { position: absolute; top: 12px; left: 14px; font: 600 11px var(--mono); color: #ffffffb0; letter-spacing: .12em; text-transform: uppercase; max-width: 64%; text-shadow: 0 1px 4px #000; }
body.app .vn-skip { position: absolute; top: 8px; right: 10px; background: #0008; }
.vnbox { position: absolute; left: 10px; right: 10px; bottom: 12px; background: #1b1f26f2; border: 1px solid var(--line); border-radius: 18px; padding: 18px 16px 14px; box-shadow: 0 -10px 40px #0009; cursor: default; }
.vn-extra { max-height: 44vh; overflow-y: auto; }
.vn-name { position: absolute; top: -13px; left: 14px; background: var(--crema); color: #1c140d; font-weight: 700; font-size: 13px; padding: 3px 12px; border-radius: 999px; }
.vn-text { font-size: 17px; line-height: 1.5; min-height: 52px; }
.scene.narration .vn-text { font-style: italic; color: #d9d4cc; }
.vn-opts { margin-top: 10px; }
body.app .vn-opt { min-height: 46px; background: var(--panel2); }
.vn-note { margin-top: 8px; font-size: 15px; color: #f0d9b5; min-height: 1px; }

/* ---------- home, parts, kanji page, settings */
.home-hero { background: linear-gradient(160deg, #1d1b19, var(--card)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 6px 0 4px; }
.home-hero .kicker { margin-top: 0; }
.review-btn { justify-content: space-between !important; margin-top: 12px; }
.review-btn .due { font-size: 14px; opacity: .8; }
.stops { display: flex; flex-direction: column; gap: 6px; }
.stop { display: grid; grid-template-columns: 38px 1fr 28px; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.stop:active { background: var(--panel2); }
.stop-n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line); color: var(--crema); font: 700 13px var(--mono); }
.stop-t b { display: block; font-weight: 600; line-height: 1.3; }
.stop-k { display: block; color: var(--muted); font-size: 15px; letter-spacing: .12em; }
.stop-mark { color: var(--ok); display: grid; place-items: center; }
.stop-mark svg { width: 22px; height: 22px; }
.stop.done .stop-n { background: var(--ok-soft); border-color: #4ad17f88; color: var(--ok); }
.home-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 6px; }
.continue-btn { flex-direction: column; align-items: flex-start !important; gap: 2px; text-align: left; padding-top: 12px; padding-bottom: 12px; border-radius: 16px !important; }
.continue-btn b { font-size: 18px; }
.continue-btn span { font-size: 13.5px; font-weight: 500; opacity: .85; white-space: normal; }
.pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font: inherit; text-align: center; }
.pick-opt .pick-ja { font-size: 19px; line-height: 1.5; }
.pick-opt b { font-size: 15px; }
.pick-opt small { font-size: 11.5px; color: var(--muted); }
.pick-opt.on { background: var(--panel2); border-color: var(--crema); box-shadow: inset 0 0 0 1px var(--crema); cursor: pointer; }
.is-off { opacity: .4; filter: grayscale(1); pointer-events: none; user-select: none; }
.grade-note { display: block; color: var(--muted); font-size: 13px; }
.grade-tag { font: 600 11.5px var(--mono); color: var(--muted); white-space: nowrap; }
.grade-row { grid-template-columns: 38px 1fr auto; }
.grade-row .stop-mark { color: var(--crema); }
.part-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.part-tile { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--text); position: relative; }
.part-tile .pg { font-size: 36px; line-height: 1.2; }
.part-tile .pn { font-size: 13px; color: var(--muted); text-align: center; }
.part-tile .pc { position: absolute; top: 6px; right: 8px; font: 600 11px var(--mono); color: var(--dim); }
.part-big { font-size: 110px; line-height: 1; text-align: center; margin: 10px 0; }
body.app .chip.kchip { font-size: 22px; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.toggle b { display: block; }
.toggle span { display: block; font-size: 13px; color: var(--muted); }
body.app .sw { width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--text); transition: transform .15s var(--ease); }
body.app .sw.on { background: var(--ok); }
.sw.on::after { transform: translateX(20px); }

/* ---------- sheets, Ask, toast, debug */
.sheet-back { position: fixed; inset: 0; background: #000a; z-index: 40; animation: fadeIn .15s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 720px; margin: 0 auto; max-height: 86%; overflow-y: auto; z-index: 41; background: #181b21; border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + var(--safe-b)); box-shadow: 0 -20px 60px #000c; animation: fadeIn .2s var(--ease); }
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 6px; }
body.app .sheet-x { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; }
.sheet .kicker { margin-top: 6px; }
.sheet-title { margin: 4px 40px 8px 0; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.ask-head { display: flex; align-items: center; gap: 12px; margin: 4px 40px 10px 0; }
.ask-head .who b { display: block; font-size: 17px; }
.ask-head .who span { display: block; font-size: 12px; color: var(--crema); text-transform: uppercase; letter-spacing: .08em; }
.ask-say { border-left: 3px solid var(--crema); padding: 2px 0 2px 12px; margin: 0 0 10px; animation: fadeIn .18s var(--ease); }
.ask-say p { margin: 0; font-size: 16px; line-height: 1.5; }
.ask-say.locked { border-color: var(--dim); color: var(--muted); }
.ask-say.answer { border-color: var(--ok); }
.ask-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.why-glyph { font-size: 80px; line-height: 1; text-align: center; margin: 4px 0 8px; font-family: var(--jp); }
.why p { margin: 6px 0; }
.warn { display: flex; flex-direction: column; }
.warn-sprite { height: 180px; object-fit: contain; align-self: center; margin-bottom: 6px; }
.warn p { margin: 6px 0; }
body.app .menu-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 13px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-align: left; }
.menu-item span { font-size: 13px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(118px + var(--safe-b)); transform: translateX(-50%); background: var(--text); color: #111; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 60; animation: toastIn .2s var(--ease) both; max-width: 90%; text-align: center; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.debug { position: fixed; left: 50%; transform: translateX(-50%); top: calc(66px + var(--safe-t)); z-index: 30; max-width: min(340px, 80vw); font: 11.5px/1.4 var(--mono); background: #2a1d10ee; border: 1px solid #e0a23c66; color: #f0c98a; border-radius: 10px; }
body.app .dbg-head { padding: 4px 9px; font: inherit; font-weight: 700; color: inherit; }
.debug ul { display: none; margin: 0; padding: 2px 10px 8px 22px; max-height: 40vh; overflow: auto; }
.debug.open ul { display: block; }

@media (min-width: 560px) { .opts.grid { grid-template-columns: repeat(4, 1fr); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.pg-draw { display: inline-block; width: 1em; height: 1em; vertical-align: -0.14em; }
.pg-draw svg { width: 100%; height: 100%; display: block; }
.wx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Grammar lines (docs/18, section 10): every word in kanji; each kanji tinted by the player's level; unlearned kanji in
   their own slate blue, with furigana and a solid underline; furigana full, faint, held or gone as the kanji grows. */
:root { --unlearned: #86a4d6; }
.gline { font: 500 1.4rem/2.4 var(--jp); margin: .2em 0; overflow-wrap: anywhere; }
.gline .gw, .gline .gw-tie { white-space: nowrap; }
.gline ruby.gk { ruby-position: over; cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.gline ruby.gk > span { text-underline-offset: .24em; text-decoration-thickness: 2px; }
.gline .lv0 > span { color: var(--unlearned); text-decoration-line: underline; text-decoration-style: solid; text-decoration-color: color-mix(in srgb, var(--unlearned) 70%, transparent); }
.gline .lv1 > span { color: var(--crema); text-decoration-line: underline; text-decoration-style: solid; text-decoration-color: color-mix(in srgb, var(--crema) 70%, transparent); }
.gline .lv2 > span { color: color-mix(in srgb, var(--crema) 65%, var(--text)); text-decoration-line: underline; text-decoration-style: dotted; text-decoration-color: color-mix(in srgb, var(--crema) 60%, transparent); }
.gline .lv3 > span { color: color-mix(in srgb, var(--crema) 30%, var(--text)); }
.gline .lv4 > span, .gline .nm > span { color: var(--text); }
.gline rt { font: 500 max(10px, .44em) var(--jp); color: var(--muted); letter-spacing: .02em; }
.gline .lv0 rt { color: var(--unlearned); }
.gline rt.faint { opacity: .5; }
.gline rt.hold { visibility: hidden; }
.gline ruby.peek rt { visibility: visible; opacity: 1; color: var(--crema); }
.gline ruby.gro rt { font: 500 max(10px, .42em) var(--mono); color: var(--muted); }
.gline .gw.tested { background: color-mix(in srgb, var(--crema) 16%, transparent); border-radius: 6px; padding: 0 .12em; box-shadow: 0 0 0 2px color-mix(in srgb, var(--crema) 45%, transparent); }
.kpop .kp-top { display: flex; gap: 14px; align-items: center; }
.kpop .kp-pic { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; }
.kpop .kp-ch { font: 600 64px/1 var(--jp); }
.kpop .kp-mean { font-size: 1.1rem; margin: .4em 0; }
.kpop .kp-r { font: 500 1.4rem var(--jp); }
.kpop .kp-why { color: var(--muted); }
.dv-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 12px 0; }
.dv-ctl { display: inline-flex; align-items: center; gap: 8px; }
.dv-ctl select { min-height: 40px; }
.dv-key { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .95rem; }
.dv-chip { font-size: 1rem; line-height: 1.6; }
.dv-row { border-bottom: 1px solid color-mix(in srgb, var(--muted) 25%, transparent); padding: 4px 0; }
.dv-id { font: 12px var(--mono); }

/* Talking with Akane (#talk, docs/20): the veranda at dusk, Akane above, the chat in a box below. Earlier turns fold
   into a quiet scroll; the current line is large, in the reading display. */
.scene.tk { cursor: default; }
.tk .tk-sprite { height: var(--tk-sprite-h, 62%); bottom: var(--tk-sprite-bottom, 34%); transition: bottom .25s ease, height .25s ease; }
.tk-chip { position: absolute; top: 10px; right: 12px; background: #0009; border: 1px solid var(--line); color: var(--crema); font: 700 14px var(--mono); padding: 5px 12px; border-radius: 999px; }
.tk-box { position: absolute; left: 8px; right: 8px; bottom: 10px; max-height: 64%; display: flex; flex-direction: column; gap: 8px; background: #1b1f26f2; border: 1px solid var(--line); border-radius: 18px; padding: 16px 14px 12px; box-shadow: 0 -10px 40px #0009; overflow-y: auto; }
.tk-title { font-size: 19px; margin: 0; }
.tk-msg { font-size: 17px; margin: 4px 0; }
.tk-small { font-size: 14px; margin: 2px 0; }
.tk-group { display: flex; flex-direction: column; gap: 4px; }
.tk-opt { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15.5px; }
.tk-opt input { width: 20px; height: 20px; accent-color: var(--crema); }
.tk-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tk-log { flex: 1 1 auto; min-height: 0; max-height: 22vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.tk-log:empty { display: none; }
.tk-her, .tk-you { margin: 0; line-height: 1.4; }
.tk-you { align-self: flex-end; text-align: right; color: #d9e6ff; background: var(--blue-soft); border-radius: 12px 12px 4px 12px; padding: 4px 10px; max-width: 85%; }
.tk-her-en { display: block; font-size: 12.5px; opacity: .8; }
.tk-now { position: relative; padding-top: 6px; }
.tk-now .vn-name { position: static; display: inline-block; margin-bottom: 2px; }
.tk-now .gline { font-size: 1.35rem; margin: 2px 0; }
.tk-now.thinking { opacity: .55; }
.tk-en { margin: 2px 0 4px; color: #e6dccd; font-size: 15px; }
.tk-tools .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.tk-note { border-left: 3px solid var(--crema); padding: 4px 10px; background: var(--crema-soft); border-radius: 0 10px 10px 0; font-size: 14.5px; }
.tk-note b { color: var(--crema); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.tk-note p { margin: 2px 0 0; white-space: pre-wrap; }
.tk-bar { display: flex; gap: 8px; align-items: center; }
.tk-input { flex: 1; min-width: 0; min-height: 48px; font: 500 17px var(--jp); padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
body.app .tk-mic { width: 56px; height: 56px; flex: none; border-radius: 50%; border: 2px solid var(--crema); background: var(--crema-soft); color: var(--crema); font: 700 22px var(--jp); justify-content: center; }
body.app .tk-mic.on { background: var(--crema); color: #1c140d; animation: tkPulse 1.2s ease-in-out infinite; }
body.app .tk-mic:disabled, body.app .tk-send:disabled { opacity: .4; }
.tk-end { justify-content: flex-end; }
@keyframes tkPulse { 50% { box-shadow: 0 0 0 8px #c8a27a33; } }
body.app .talk-btn { justify-content: space-between; }

/* Grammar lessons (docs/21): two people in a scene, the phone, the pattern, drills, the notebook and the wrap-up. */
.gs .gs-slot { position: absolute; inset: 0; pointer-events: none; transition: filter .25s; }
.gs .gs-slot.dim, .gs.phone .gs-slot { filter: brightness(.55) saturate(.85); }
.gs .gs-slot .sprite { height: 80%; }
.gs .gs-slot.left .sprite { left: 30%; }
.gs .gs-slot.right .sprite { left: 70%; }
.gs:not(:has(.gs-slot.right img)) .gs-slot.left .sprite, .gs:not(:has(.gs-slot.left img)) .gs-slot.right .sprite { left: 50%; }
.gs-phone { position: absolute; top: 52px; right: 14px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 18px; border-radius: 22px; background: #10141bdd; border: 2px solid var(--crema); box-shadow: 0 10px 30px #000a; }
.gs-phone-ring { width: 46px; height: 46px; border-radius: 50%; background: var(--crema-soft) no-repeat 50% 14% / 190%; border: 2px solid var(--crema); animation: tkPulse 1.2s ease-in-out infinite; }
.gs-phone b { color: var(--crema); }
.gs-phone small { color: var(--muted); }
.gs.event .scene-shade { background: linear-gradient(180deg, transparent 55%, #000a 100%); }
.gs-box .gline { font-size: 1.3rem; margin: 0; }
.gs-tools { display: flex; gap: 8px; margin-top: 8px; }
.gs-tools .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
.gs-en { margin: 6px 0 0; color: #e6dccd; font-size: 15px; }
.gs-ask { font-size: 17px; }
body.app .gs-opt { flex-direction: column; align-items: flex-start; gap: 2px; }
.gs-opt .gline, .gs-optline .gline { font-size: 1.2rem; margin: 0; line-height: 2; }
.gs-opt small, .gs-optline small { color: var(--muted); display: block; }
.gs-flash { position: absolute; top: 56px; left: 12px; display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 14px; background: #1b1f26ee; border: 1px solid var(--line); animation: fadeOnly .3s ease both; }
.gs-flash-pic { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }
.gp-form { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.gp-row { font: 600 1.25rem var(--jp); padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.gp-meaning { font-size: 16px; }
.gp-ex { position: relative; padding: 6px 52px 6px 4px; border-bottom: 1px solid var(--line); }
.gp-ex .gline { font-size: 1.3rem; margin: 0; }
.gp-en { margin: 0; font-size: 14px; }
body.app .gp-ex .gp-play { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.gd-line { margin: 12px 0 6px; }
.gd-line .gline { font-size: 1.45rem; }
.gd-gap { display: inline-block; min-width: 2.4em; border-bottom: 3px solid var(--crema); text-align: center; margin: 0 .1em; color: var(--crema); font: 600 1.3rem var(--jp); line-height: 1.4; }
.gd-gap.filled { border-bottom-color: var(--ok); }
.gd-en { font-size: 15px; }
.gd-built { min-height: 56px; padding: 8px; border-radius: 12px; border: 1px dashed var(--line); margin: 10px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gd-piece { font: 600 1.2rem var(--jp); padding: 4px 8px; border-radius: 8px; background: var(--crema-soft); }
.gd-pool { display: flex; flex-wrap: wrap; gap: 8px; }
body.app .gd-tile { width: auto; min-height: 48px; font: 600 1.2rem var(--jp); }
.gd-base { font: 600 1.6rem var(--jp); margin: 12px 0; }
.gd-prompt { padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); margin: 8px 0; }
.gd-prompt b { color: var(--crema); font-size: 13px; }
.gd-prompt .gline { font-size: 1.3rem; margin: 2px 0; }
body.app .gd-listen { margin: 10px 0; }
.gr-page { border-radius: 14px; padding: 6px 14px; background: var(--panel); border: 1px solid var(--line); }
.gr-line { padding: 8px 0; border-bottom: 1px solid var(--line); }
.gr-line:last-child { border-bottom: 0; }
.gr-ja .gline { font-size: 1.3rem; margin: 0; cursor: pointer; }
.gr-toggle { margin-top: 2px; min-height: 32px; font-size: 13px; }
.gr-en { margin: 4px 0 0; }
.gw-pattern { padding: 12px; border-radius: 12px; background: var(--crema-soft); border: 1px solid #c8a27a55; }
.gw-words { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.gw-word { padding: 6px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.gw-word .gline { font-size: 1.2rem; margin: 0; }
.gw-kanji { font-size: 2rem; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.gd-pic { display: flex; justify-content: center; margin: 2px 0 10px; }
.gd-pic-img { width: 168px; height: 168px; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.gd-pic-word { min-width: 168px; height: 120px; padding: 0 16px; display: grid; place-items: center; border-radius: 16px; background: var(--panel2); border: 1px solid var(--line); font-size: 30px; font-weight: 700; }
.toggle.choice { flex-wrap: wrap; }
.choice-row { display: flex; gap: 6px; flex-wrap: wrap; }
/* Today with Akane (ui/day.js) */
.today-btn { flex-direction: column; align-items: stretch; gap: 6px; padding: 12px 16px; }
.today-btn b { font-size: 18px; }
.day-mini { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.day-mini small { color: inherit; opacity: .8; }
.day-lanterns { display: flex; gap: 14px; }
.day-lantern { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; opacity: .65; }
.day-lantern small { font-size: 11px; }
.day-flame { width: 18px; height: 24px; border-radius: 9px 9px 7px 7px; background: var(--panel2); border: 1px solid var(--line); }
.day-lantern.lit { opacity: 1; }
.day-lantern.lit .day-flame { background: radial-gradient(circle at 50% 60%, #ffe2a0, #f0a03c 60%, #c4511c); border-color: #f0a03c; box-shadow: 0 0 12px #f0a03c88; }
.day-morning { display: flex; gap: 12px; align-items: flex-end; padding: 10px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 12px; }
.day-akane { width: 92px; height: 120px; object-fit: cover; object-position: 50% 8%; border-radius: 12px; flex: none; }
.day-greet { font-size: 20px; font-weight: 700; margin: 2px 0; }
.day-draw { margin-bottom: 12px; }
.day-omikuji { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 12px; }
.day-omikuji img { width: 56px; height: 56px; object-fit: contain; }
.day-omikuji p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.day-kichi { font-size: 22px; }
.day-station { display: flex; gap: 12px; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 10px; }
.day-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line); font-weight: 700; flex: none; }
.day-body { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.day-body p { margin: 0; }
.day-evening { padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); margin: 6px 0 12px; }
.day-length { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.day-say { min-height: 1.4em; }
.day-gap, .day-base { font-size: 24px; line-height: 1.7; margin: 8px 0; }
.day-host { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; }
.day-host img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; background: var(--panel2); }
.day-slip { font-size: 24px; line-height: 2; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 2px; }
.slip-w { font: inherit; padding: 0 4px; border-radius: 8px; border: 1px dashed var(--line); background: var(--panel); color: inherit; }
.slip-w.slip { border: 2px solid #f0a03c; background: #f0a03c22; }
.slip-w.no { opacity: .5; text-decoration: line-through; }
.day-page { padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 10px; }
.day-page .gr-line { padding: 6px 0; border-top: 1px solid var(--line); cursor: pointer; }
.day-page .gr-en { margin: 0; font-size: 13px; }
.day-lamp { width: 26px; height: 39px; object-fit: cover; border-radius: 6px; filter: grayscale(.2) brightness(.8); }
.day-lantern.lit .day-lamp { filter: none; box-shadow: 0 0 14px #f0a03c66; }
.gs-book { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0 16px; }
.gs-page { position: relative; aspect-ratio: 2 / 3; border-radius: 10px; background-size: cover; background-position: center; color: #1b1b1b; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.gs-ink { position: absolute; writing-mode: vertical-rl; font-family: "Klee One", "Yu Mincho", serif; font-size: 22px; font-weight: 600; letter-spacing: .1em; }
.gs-page > .gs-ink:first-child { top: 10%; right: 14%; }
.gs-date { top: 12%; left: 14%; font-size: 15px; }
.gs-seal { position: absolute; left: 50%; top: 42%; width: 52%; transform: translate(-50%, -50%); mix-blend-mode: multiply; }
.gs-title { position: absolute; left: 0; right: 0; bottom: 8%; text-align: center; font-size: 12px; color: #3a3a3a; }
.ema-rack { min-height: 180px; border-radius: 14px; background-size: cover; background-position: center; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-end; padding: 12px; margin-bottom: 12px; }
.ema { width: 88px; height: 70px; background-size: cover; background-position: center; border-radius: 6px; display: grid; place-items: center; padding: 14px 6px 4px; color: #2b1d10; font-size: 12px; font-weight: 700; text-align: center; box-shadow: 0 3px 8px rgba(0,0,0,.4); }
.ema-text { font-size: 24px; min-height: 1.6em; padding: 6px 10px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.ema-tiles { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.ema-row { display: flex; gap: 8px; margin-bottom: 12px; }
/* The start screen, refined: a scene card for the day, then Continue, Review and two tiles. */
.home-hero > * + * { margin-top: 10px; }
.today-card { position: relative; display: flex; align-items: flex-end; min-height: 158px; border-radius: 18px; overflow: hidden; background-size: cover; background-position: center 35%; color: #fff; text-decoration: none; border: 1px solid #f0a03c55; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.today-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,8,6,.05) 0%, rgba(10,8,6,.55) 45%, rgba(10,8,6,.88) 100%); }
.today-body { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; width: 100%; }
.today-kicker { font-size: 21px; font-weight: 750; line-height: 1.2; letter-spacing: .01em; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.today-plan { font-size: 14px; opacity: .92; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.today-lamps .day-lanterns { gap: 12px; margin-top: 4px; }
.today-lamps .day-lantern small { color: #fff; opacity: .9; }
.today-go { position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.45); border: 1px solid #ffffff44; }
.today-go svg { width: 20px; height: 20px; }
.today-card:active { transform: scale(.99); }
.home-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; min-height: 96px; }
.home-tile:active { background: var(--panel2); }
.home-tile-ja { font-size: 22px; line-height: 1.3; color: var(--crema); }
.home-tile b { font-size: 15px; }
.home-tile small { font-size: 12px; color: var(--muted); line-height: 1.35; }
body.app .pick-opt { border-radius: 14px; }
.day-station.now { border-color: var(--crema); box-shadow: inset 0 0 0 1px var(--crema); }
.day-station.now .day-n { background: var(--crema); color: #1a140c; border-color: var(--crema); }
.day-station.done { opacity: .78; }
.day-station.done .day-n { background: var(--ok-soft); border-color: #4ad17f88; color: var(--ok); }
.day-n svg { width: 16px; height: 16px; }
/* The grammar list: a day in Toyooka per row. */
.gl-list { display: flex; flex-direction: column; gap: 8px; }
.gl-row { display: grid; grid-template-columns: 66px 1fr auto; align-items: center; gap: 12px; padding: 8px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.gl-row:active { background: var(--panel2); }
.gl-thumb { position: relative; width: 66px; height: 66px; border-radius: 12px; background: var(--panel2) center / cover no-repeat; }
.gl-n { position: absolute; left: 4px; top: 4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; background: rgba(0,0,0,.62); color: #fff; font: 700 12px var(--mono); }
.gl-row.done .gl-n { background: var(--ok); color: #06210f; }
.gl-t b { display: block; font-weight: 650; line-height: 1.25; }
.gl-t small { display: block; color: var(--muted); font-size: 12px; margin: 1px 0 2px; }
.gl-row.next { border-color: var(--crema); box-shadow: inset 0 0 0 1px var(--crema); }
.gl-next { font: 700 11px var(--mono); color: #1a140c; background: var(--crema); padding: 4px 8px; border-radius: 999px; }
.gl-mark { color: var(--ok); display: grid; place-items: center; padding-right: 4px; }
.gl-mark svg { width: 22px; height: 22px; }
button.gw-word { font: inherit; color: inherit; text-align: left; cursor: pointer; }
.gw-after { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin: 14px 0 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.gw-after svg { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--crema); }
/* Drill feel (docs/22 section 4) */
.day-stage { margin: 4px 0 6px; }
.day-fill { color: var(--ok); font-weight: 750; border-bottom: 2px solid var(--ok); padding: 0 2px; }
.day-tools { display: flex; gap: 8px; margin-top: 8px; }
.day-hint { opacity: .9; }
.slip-w.fixed { border: 2px solid var(--ok); background: var(--ok-soft); color: var(--text); }
.day-slipbtn { margin-top: 8px; }
/* The tested word: a soft outline where its furigana would be, so it reads as a test (docs/22 4.14). */
.gw.tested { outline: 1.5px dashed var(--crema); outline-offset: 3px; border-radius: 6px; }
.tray { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 10px; border-radius: 14px; background: radial-gradient(circle at 50% 40%, #3a2a1a, #1d1610); border: 1px solid #5a4126; }
.tray img { width: 62px; height: 62px; object-fit: contain; filter: drop-shadow(0 3px 6px rgba(0,0,0,.45)); }
/* The sketch card (ui/sketch.js, docs/23): a kanji's placeholder, marked with a dashed border and a Sketch tag. */
.sk-mini { position: relative; display: grid; place-items: center; border-radius: 12px; border: 1.5px dashed #c9a97a; background: radial-gradient(circle at 50% 40%, #2b2620, #1b1916); overflow: hidden; }
.sk-mini .sk-tag { position: absolute; right: 4px; bottom: 4px; transform: scale(.8); transform-origin: right bottom; }
.sk-stage { display: grid; place-items: center; width: 100%; height: 100%; }
.sk-stage .awk-box { background: transparent !important; }
.sk-stage.big { width: 260px; height: 260px; margin: 6px auto 10px; border-radius: 18px; border: 1.5px dashed #c9a97a; background: radial-gradient(circle at 50% 40%, #2e2820, #1b1916); cursor: pointer; }
.sk-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: #c9a97a22; border: 1px solid #c9a97a88; color: #e5c896; font: 700 11px var(--mono); cursor: pointer; }
.sk-tag svg { width: 12px; height: 12px; }
.sk-tagrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sk-place { font-size: 12px; color: var(--muted); }
.sk-plainch { font-size: 72px; color: #f4f4f2; }
.sk-key { text-align: center; margin: 6px 0 2px; text-transform: none; }
.sk-scene { font-size: 16px; line-height: 1.6; }
.sk-scene.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.sk-obj { font-weight: 700; }
.sk-sum { font-size: 17px; line-height: 1.7; }
.sk-part { font-size: 22px; font-weight: 700; }
.sk-readings { display: flex; flex-direction: column; gap: 4px; font-size: 18px; }
.sk-readings small { display: inline-block; width: 34px; color: var(--muted); font: 600 11px var(--mono); }
.sk-readings span + span { margin-left: 12px; }
.sk-oku { opacity: .55; }
.sk-words { display: grid; gap: 6px; margin: 4px 0 10px; }
.sk-word { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.sk-word b { font-size: 20px; } .sk-word small { color: var(--muted); }
.sk-look { font-size: 14px; color: var(--muted); }
.sk-own { margin: 12px 0 18px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.sk-own summary { cursor: pointer; font-weight: 650; }
.sk-story { width: 100%; margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); font: inherit; }
.sk-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.sk-lines { margin-top: 6px; }
.kp .sk-mini { width: 96px !important; height: 96px !important; }
/* Nishida's date box */
.date-form { display: flex; align-items: center; gap: 6px; padding: 10px 12px; margin: 6px 0 10px; border-radius: 12px; background: #f3efe6; color: #1b1b1b; border: 1px solid #d8cfbd; }
.date-label { font-size: 13px; font-weight: 700; color: #6b5d45; margin-right: 6px; }
.date-box { width: 34px; height: 38px; display: grid; place-items: center; border: 1.5px solid #b9ab8f; border-radius: 4px; background: #fffdf8; font-size: 22px; font-family: "Klee One", serif; }
.date-box.now { border-color: #d0602d; box-shadow: 0 0 0 2px #d0602d33; }
.date-form.big .date-box { width: 42px; height: 48px; font-size: 28px; }
.date-pad, .sk-pad { max-width: 320px; margin: 0 auto; }
.sk-trace { margin: 12px 0; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.day-games, .day-keeps { margin: 4px 0 12px; }
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.game-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 10px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.game-tile:active { background: var(--panel2); }
.game-tile img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; background: var(--panel2); margin-bottom: 4px; }
.game-tile b { font-size: 15px; } .game-tile small { font-size: 12px; color: var(--muted); line-height: 1.3; }
.keep-row { display: flex; flex-wrap: wrap; gap: 8px; }
.twin-in { width: 4.5em !important; display: inline-block; margin: 0 4px; padding: 4px 6px !important; font-size: 18px !important; vertical-align: middle; }
.twin-en { margin: -4px 0 10px; font-size: 13px; }
.day-fill.wrongfill { color: #e39a4f; border-color: #e39a4f; }
.label-board { padding: 12px; border-radius: 12px; background: linear-gradient(180deg, #3a2e22, #2a2119); border: 2px solid #6b5333; box-shadow: inset 0 0 0 3px #2a2119, 0 6px 16px rgba(0,0,0,.35); margin: 8px 0 10px; }
.label-title { font: 700 12px var(--mono); color: #e5c896; letter-spacing: .06em; margin-bottom: 6px; text-transform: uppercase; }
.label-line { display: block; width: 100%; text-align: left; padding: 6px 8px; margin: 3px 0; border-radius: 8px; background: transparent; border: 1px dashed transparent; color: inherit; font: inherit; cursor: pointer; }
.label-line:hover { border-color: #e5c89655; }
.label-line.yes { border-color: var(--ok); background: var(--ok-soft); }
.label-line.no { border-color: #e0605e; background: #e0605e22; }
.label-line .gline { margin: 0; font-size: 18px; }
.wire-built { min-height: 54px; display: flex; flex-wrap: wrap; align-items: center; gap: 0; padding: 10px; margin: 8px 0; border-radius: 12px; background: #15130f; border: 1px dashed #5a4126; }
.wire-on { padding: 6px 10px; border-radius: 10px; background: radial-gradient(circle at 50% 40%, #ffe2a0, #f0a03c 70%); color: #2a1a08; font-size: 18px; font-weight: 700; box-shadow: 0 0 12px #f0a03c66; }
.wire-joint { width: 14px; height: 3px; background: #c9a97a; }
.wire-pool { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.wire-seg { padding: 8px 12px; border-radius: 10px; background: var(--panel2); border: 1px solid #6b5333; color: var(--text); font-size: 18px; cursor: pointer; }
.wire-seg.lit { opacity: .3; }
.sk-alike { font-size: 14px; color: var(--muted); padding: 6px 10px; border-left: 3px solid #e39a4f; background: #e39a4f14; border-radius: 6px; }
.sk-alike a, .sk-alike span { font-size: 18px; color: var(--text); }
.sk-beat { opacity: 0; animation: skBeat .6s ease forwards; }
.sk-beats.all .sk-beat { animation: none; opacity: 1; }
@keyframes skBeat { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sk-beat { animation: none; opacity: 1; } }
.gp-steps { margin: 8px 0 12px; padding: 0; list-style: none; display: grid; gap: 6px; }
.gp-steps li { position: relative; padding: 6px 10px 6px 26px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); line-height: 1.55; }
.gp-steps li::before { content: ""; position: absolute; left: 10px; top: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--crema); }
.day-strip { display: flex; gap: 6px; margin: 2px 0 8px; }
.day-dot { width: 10px; height: 14px; border-radius: 5px 5px 4px 4px; background: var(--panel2); border: 1px solid var(--line); }
.day-dot.lit { background: radial-gradient(circle at 50% 60%, #ffe2a0, #f0a03c 65%); border-color: #f0a03c; box-shadow: 0 0 6px #f0a03c88; }
/* Access (docs/24 section 5) */
.gd-listen-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) {
  .shake { animation: none !important; outline: 2px solid #e39a4f; outline-offset: 2px; }
  .today-card:active, .home-tile:active { transform: none; }
}
/* Less motion in Settings: the same as the system setting */
html.less-motion *, html.less-motion *::before, html.less-motion *::after { animation: none !important; transition: none !important; }
html.less-motion .sk-beat { animation: none; opacity: 1; }
html.less-motion .shake { outline: 2px solid #e39a4f; outline-offset: 2px; }
html.less-motion .today-card:active, html.less-motion .home-tile:active { transform: none; }

/* The keyboard is up (docs/26): what is being typed, the question and the button stay in view; the rest makes room. */
html.kb-open .topbar, html.kb-open .pips { display: none; }
html.kb-open .view { padding-top: 8px; padding-bottom: 12px; }
html.kb-open .view .how { display: none; }
html.kb-open .view h1 { font-size: 20px; margin: 2px 0 6px; }
html.kb-open .view > .kicker:first-child, html.kb-open .view > .tiles:first-child + .kicker { margin-top: 2px; }
html.kb-open .tiles { display: none; }
html.kb-open .qpic { margin: 2px 0 6px; }
html.kb-open .qpic img.mem, html.kb-open .qpic .plainbox, html.kb-open .qpic .sk-mini { width: min(120px, 32vw) !important; height: min(120px, 32vw) !important; }
html.kb-open .glyph-frame { width: min(120px, 32vw); border-radius: 16px; box-shadow: none; }
html.kb-open .glyph-frame .glyph { font-size: 64px; }
html.kb-open .say-slot { margin-top: 6px; }
html.kb-open .line .face { display: none; }
html.kb-open .dock { padding-top: 4px; padding-bottom: 6px; }
html.kb-open .dock-keys { display: none; }
html.kb-open .tk .tk-sprite, html.kb-open .tk-chip { display: none; }
html.kb-open .tk-box { top: 6px; max-height: none; }
html.kb-open .tk-log { max-height: 26%; }
html.kb-open .glyph-frame.word-frame, html.kb-open .glyph-frame.listen { width: auto; min-width: min(220px, 60vw); min-height: 0; padding: 8px 14px; font-size: 28px; }
html.kb-open .glyph-frame.word-frame .w { font-size: 40px; }

/* Akane's pictures are waist-up, cut straight across at the hips (docs/26). Their bottom edge fades out, so wherever a
   picture's edge comes into view the cut never shows. */
.sprite, .warn-sprite { -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 82%, transparent 100%); mask-image: linear-gradient(180deg, #000 0%, #000 82%, transparent 100%); }

/* The word card (js/ui/wordpop.js): hold any word in lessons 1 to 20 for its meaning. */
.wp-word { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; border-radius: 4px; transition: background-color .2s var(--ease); }
.wp-word.wp-press { background: #ffffff12; transition-duration: .45s; }
/* Japanese in a grammar lesson's running text (dom.js marks each run jr): a held finger is a look-up, not a selection. */
.view:is(.step-gguess, .step-gscene, .step-pattern, .step-findit, .step-gdrill, .step-case, .step-gread, .step-talk, .step-gwrapup) .jr,
body:has(.view:is(.step-gguess, .step-gscene, .step-pattern, .step-findit, .step-gdrill, .step-case, .step-gread, .step-talk, .step-gwrapup)) .sheet .jr { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.wp-word.wp-open { background: var(--blue-soft); box-shadow: 0 0 0 2px var(--blue-soft); }
.wp-card { position: fixed; z-index: 60; box-sizing: border-box; padding: 12px 14px 14px; background: #181b21; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 14px 44px #000d; color: inherit; max-height: 60vh; overflow-y: auto; animation: wpIn .14s var(--ease); }
.wp-card.above { animation-name: wpInUp; }
@keyframes wpIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes wpInUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.wp-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.wp-word-big { font: 600 1.7rem/1.7 var(--jp); }
.wp-word-big rt { font: 500 .5em var(--jp); color: var(--dim); }
.wp-card .wp-close { appearance: none; border: 0; background: none; color: var(--dim); font-size: 1.5rem; line-height: 1; min-width: 44px; min-height: 44px; margin: -10px -12px 0 0; cursor: pointer; }
.wp-reading { display: flex; gap: 10px; align-items: baseline; font: 500 1rem var(--jp); color: var(--crema); }
.wp-ro { font: 400 .85rem system-ui, sans-serif; color: var(--dim); letter-spacing: .02em; }
.wp-form { font-size: .82rem; color: var(--dim); margin-top: 2px; }
.wp-pos { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: var(--dim); margin-top: 10px; }
.wp-means { margin: 4px 0 0; padding-left: 1.25em; font-size: 1rem; line-height: 1.45; }
.wp-means li:first-child { font-weight: 600; }
.wp-note { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--blue-soft); font-size: .9rem; line-height: 1.4; }
.wp-kanji { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.wp-card .wp-kchip { display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #20242c; color: inherit; font: 500 1.3rem var(--jp); cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .wp-card { animation: none; } .wp-word { transition: none; } }
.wp-card .wp-kchip:active { background: #2a2f39; }
.wp-card .wp-parts { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); display: grid; gap: 7px; }
.wp-card .wp-parts li { display: grid; grid-template-columns: minmax(2.4em, auto) 1fr; gap: 10px; align-items: baseline; font-size: .86rem; line-height: 1.4; color: var(--dim); }
.wp-card .wp-part { font: 600 1.02rem/1.3 var(--jp); color: var(--text); white-space: nowrap; }

/* ---------- the story-first start screen, the first-run question and the new top bar parts (docs/47) */
/* The top bar: a small text button left of the menu (the lesson's あ key), and a pill where the sub line stands. */
body.app .topextra { width: 44px; font-size: 21px; font-weight: 650; line-height: 1; color: var(--crema); }
body.app .topchip { position: relative; display: block; width: fit-content; max-width: 100%; min-height: 24px; margin-top: 0; padding: 0 11px; border-radius: 999px; border: 1px solid var(--crema); background: var(--crema-soft); color: var(--crema); font-size: 12.5px; font-weight: 650; line-height: 16px; padding-top: 3px; padding-bottom: 3px; white-space: normal; text-align: left; }   /* wraps on a narrow phone instead of cutting the text; nothing is clipped, so ::before keeps its larger tap area */
body.app .topchip::before { content: ""; position: absolute; inset: -9px -4px; }
body.app .topchip:active { background: var(--panel2); }
.menu-label { margin: 8px 2px -2px; font: 700 11.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--crema); }
/* The story card: Part One's picture of the lesson's place, and one big button. */
.story-card { display: block; border-radius: 18px; overflow: hidden; background: var(--panel); border: 1px solid #f0a03c55; box-shadow: 0 8px 24px rgba(0,0,0,.35); color: var(--text); }
.story-card:active { transform: scale(.99); }
.story-pic { position: relative; display: block; height: 176px; background: linear-gradient(160deg, #2a2420, #14110f); background-size: cover; background-position: center 35%; }
.story-pic::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,8,6,.2) 0%, rgba(10,8,6,0) 40%, rgba(10,8,6,.45) 100%); }
.story-kick { position: absolute; z-index: 1; left: 14px; top: 12px; padding: 3px 10px; border-radius: 999px; background: rgba(10,8,6,.55); border: 1px solid #ffffff33; color: #fff; font: 700 11.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.story-btn { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px 13px 16px; background: var(--text); color: #111; }
.story-btn-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.story-btn-t b { font-size: 19px; line-height: 1.25; }
.story-btn-t span { font-size: 13.5px; font-weight: 500; line-height: 1.35; opacity: .8; }
.story-go { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #111; color: var(--text); }
.story-go svg { width: 20px; height: 20px; }
/* Side quests: the word on each card, a recommendation until the script is fast or known, the kanji grades folded under Kanji. */
.sq-list { display: flex; flex-direction: column; gap: 8px; }
.sq-card { display: grid; grid-template-columns: 64px 1fr 24px; align-items: center; gap: 12px; padding: 12px 12px 12px 10px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); color: var(--text); cursor: pointer; list-style: none; }
.sq-card:active { background: var(--panel2); }
.sq-card.rec { border-color: #c8a27a77; }
.sq-ja { font-size: 16px; line-height: 1.3; color: var(--crema); text-align: center; white-space: nowrap; }
.sq-ja.big { font-size: 30px; }
.sq-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sq-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sq-kick { font: 700 10.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.sq-tag { font-size: 11.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.sq-card.rec .sq-tag { color: var(--amber); }
.sq-main b { font-size: 16px; line-height: 1.3; }
.sq-line { font-size: 13.5px; line-height: 1.35; opacity: .88; }
.sq-prog { font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.sq-go { display: grid; place-items: center; color: var(--crema); }
.sq-go svg { width: 20px; height: 20px; transition: transform .15s var(--ease); }
.sq-kanji > summary { list-style: none; }
.sq-kanji > summary::-webkit-details-marker { display: none; }
.sq-kanji[open] > summary .sq-go svg { transform: rotate(90deg); }
.sq-kanji > .grades { margin-top: 8px; }
.sq-back { display: inline-block; margin: 12px 2px 0; font-size: 14px; color: var(--crema); }
.home-talk { margin: 12px 2px 0; font-size: 14px; }
.stop-via { display: block; color: var(--muted); font-size: 12.5px; }
/* The Sprint card at the top of a kana page. */
.sprint-card { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; margin: 6px 0 4px; border-radius: 16px; background: var(--panel); border: 1px solid #c8a27a77; color: var(--text); }
.sprint-card:active { background: var(--panel2); }
.sprint-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--crema-soft); color: var(--crema); }
.sprint-ico svg { width: 22px; height: 22px; }
.sprint-main b { display: block; font-size: 16px; }
.sprint-main span { display: block; font-size: 13px; line-height: 1.35; color: var(--muted); }
.sprint-count { font: 700 12.5px var(--mono); color: var(--crema); white-space: nowrap; }
/* The first-run question (#begin): one screen, no scrolling at 375 by 812. */
.begin .say-slot { margin-top: 10px; }
.begin-q { margin-top: 14px; }
.begin-ask { margin: 0; font-size: 17px; font-weight: 650; }
.begin-kana { display: flex; justify-content: center; gap: 16px; margin: 4px 0 8px; font-size: 34px; line-height: 1.3; }
.begin-ans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
body.app .begin-opt { min-height: 56px; justify-content: center; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; font-weight: 650; }
body.app .begin-opt[aria-checked="true"] { background: var(--panel2); border-color: var(--crema); box-shadow: inset 0 0 0 1px var(--crema); }
.begin-line { min-height: 66px; margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--crema-soft); border: 1px solid #c8a27a33; font-size: 15px; line-height: 1.45; }
body.app .begin-go { margin-top: 14px; }
.settings-group { margin-top: 22px; }

/* Settings: the headings and the update panel's box (js/update-ui.js draws the panel itself) */
.view.settings h2.settings-head { font-size: 15px; letter-spacing: .04em; color: var(--muted); margin: 22px 0 10px; font-weight: 650; }
.view.settings .device { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }

/* The start screen while only the new lessons are offered (js/newfmt/home.js) */
.nf-home-card { display: flex; flex-direction: column; gap: 8px; padding: 18px 18px 20px; border-radius: 18px; background: var(--panel); border: 1px solid #f0a03c55; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.nf-home-card h2 { margin: 0; font-size: 21px; line-height: 1.3; }
.nf-home-card p { margin: 0; color: var(--muted); }
.nf-home-card .btn.big { align-self: stretch; justify-content: center; gap: 8px; min-height: 54px; font-size: 17px; font-weight: 700; margin-top: 6px; }
.nf-home-more { color: var(--muted); font-size: 13px; margin: 8px 2px 0; }
