:root {
  --bg: #0b0a16; --bg2: #110f23; --surface: #17142e; --surface2: #1f1b3d; --line: #79718f;
  --text: #f3f0ff; --muted: #b1abc9; --pink: #ff4fa3; --cyan: #38e8ff; --gold: #ffd45e; --violet: #8b5cff; --green: #4be3a0; --red: #ff7188;
  --radius: 12px; --nav-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
[hidden] { display: none !important; }

#app { max-width: 1200px; margin: 0 auto; padding: 0 24px calc(var(--nav-h) + var(--safe-b) + 24px); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 8px; position: sticky; top: 0; z-index: 20; background: linear-gradient(var(--bg) 70%, transparent); }
.logo { font-weight: 800; letter-spacing: .08em; font-size: 22px; }
.logo b { color: var(--pink); }
.top-right { display: flex; gap: 10px; align-items: center; }
.warn { font-size: 11px; color: var(--gold); max-width: 160px; line-height: 1.2; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.seg button { padding: 6px 12px; border-radius: 7px; font-size: 13px; color: var(--muted); min-height: 44px; min-width: 44px; }
.seg button.on { background: var(--text); color: var(--bg); }
.seg.big button { padding: 10px 16px; font-size: 14px; min-height: 44px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar button { flex: 1; max-width: 220px; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); position: relative; }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.on { color: var(--text); }
.tabbar button.on::before { content: ""; position: absolute; top: 0; width: 36px; height: 3px; border-radius: 0 0 4px 4px; background: var(--pink); }
.badge { position: absolute; top: 8px; margin-left: 22px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--pink); color: var(--bg); font-size: 11px; display: grid; place-items: center; font-weight: 700; }

h1, h2, h3 { margin: 0; }
h2 { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

/* Codex */
.toolbar { display: flex; gap: 8px; margin: 6px 0 10px; }
.input, select.input, textarea.input { width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 12px 14px; font: inherit; min-height: 44px; }
textarea.input { min-height: 160px; resize: vertical; line-height: 1.5; }
select.input { width: auto; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 9px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 13px; min-height: 44px; min-width: 44px; }
.chip.on { color: var(--bg); border-color: var(--text); background: var(--text); }
.dexline { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; font-size: 13px; color: var(--muted); }
.meter { flex: 1; height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; display: flex; }
.meter i { display: block; height: 100%; }
.m-learn { background: var(--cyan); } .m-rem { background: var(--gold); } .m-mas { background: #d1b8ff; }
.tier-h { margin: 18px 0 8px; display: flex; align-items: baseline; gap: 10px; }
.tier-h h2 { font-size: 16px; letter-spacing: .04em; }
.tier-h span { font-size: 12px; color: var(--muted); }
.tier-h .tcount { margin-left: auto; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { position: relative; text-align: left; display: flex; flex-direction: column; gap: 6px; min-height: 148px; padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; isolation: isolate; }
.card:active { background: var(--surface2); }
@media (hover: hover) { .card:hover { background: var(--surface2); } }
.card .no { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; justify-content: space-between; }
.card .name { font-weight: 700; font-size: 14px; line-height: 1.25; }
.card .jp { font-size: 11px; color: var(--muted); line-height: 1.2; }
.card .meta { margin-top: auto; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.pips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.pips i { height: 6px; border-radius: 3px; background: hsl(var(--hue) 70% 62%); width: 14px; opacity: .85; }
.pips i.w2 { width: 22px; } .pips i.w3 { width: 9px; }
.tier-star { color: var(--gold); letter-spacing: -1px; }
.card.st-NOT_LEARNED { border-style: dashed; }
.card.st-LEARNING { border-color: var(--cyan); }
.card.st-REMEMBERED { border-color: var(--gold); }

.card.st-MASTERED { border-color: transparent; background: linear-gradient(160deg, #271a4a, #17142e 70%); }
.card.st-MASTERED::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; padding: 1.5px; background: conic-gradient(from var(--ang, 0deg), #ff4fa3, #ffd45e, #4be3a0, #38e8ff, #8b5cff, #ff4fa3); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: spin 6s linear infinite; }
.card.st-MASTERED::after { content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; border-radius: inherit; background: linear-gradient(115deg, transparent 20%, rgba(255, 255, 255, .22) 36%, rgba(255, 79, 163, .2) 44%, rgba(56, 232, 255, .2) 52%, rgba(255, 212, 94, .2) 60%, transparent 76%); background-size: 250% 250%; background-position: var(--mx, 0%) var(--my, 0%); mix-blend-mode: color-dodge; animation: foil 5s ease-in-out infinite alternate; }
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes spin { to { --ang: 360deg; } }
@keyframes foil { from { background-position: 0% 20%; } to { background-position: 100% 80%; } }
.card.st-MASTERED.touched::after { animation: none; }
.card.st-MASTERED::before, .card.st-MASTERED::after { animation: none; }
@media (hover: hover) { .card.st-MASTERED:hover::before { animation: spin 6s linear infinite; } .card.st-MASTERED:hover:not(.touched)::after { animation: foil 5s ease-in-out infinite alternate; } }
.card:focus-visible { outline-offset: -3px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* sheets */
#sheetRoot { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(4, 3, 12, .72); opacity: 0; transition: opacity .2s; pointer-events: auto; }
.sheet { position: absolute; left: 50%; bottom: 0; transform: translate(-50%, 100%); width: min(100%, 720px); max-height: 92dvh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 18px 18px calc(24px + var(--safe-b)); transition: transform .25s cubic-bezier(.2, .8, .2, 1); pointer-events: auto; overscroll-behavior: contain; }
#sheetRoot.open .scrim { opacity: 1; } #sheetRoot.open .sheet { transform: translate(-50%, 0); }
.grab { width: 44px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 12px; }
.sheet-h { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.sheet-h h2 { font-size: 21px; line-height: 1.2; }
.x { width: 44px; height: 44px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 20px; flex: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.tag.t1 { color: var(--gold); } .tag.pink { color: var(--pink); } .tag.cy { color: var(--cyan); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; margin: 10px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.stanza { margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.line { display: flex; flex-wrap: wrap; gap: 6px; }
.tok { display: inline-flex; flex-direction: column; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); line-height: 1.15; min-width: 38px; text-align: center; }
.tok .a { font-weight: 700; font-size: 16px; } .tok .b { font-size: 10px; color: var(--muted); margin-top: 1px; }
.tok.ext { border-style: dashed; opacity: .85; }
.tok.sil { color: transparent; background: #1a1636; border-color: #1a1636; user-select: none; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn { min-height: 46px; padding: 10px 20px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--line); font-weight: 600; }
.btn.primary { background: var(--pink); border-color: var(--pink); color: var(--bg); }
.btn.cy { background: var(--cyan); border-color: var(--cyan); color: var(--bg); }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .45; }
.btn.block { width: 100%; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.stats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stat b { display: block; font-size: 20px; } .stat span { font-size: 11px; color: var(--muted); }
.notes { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* practice */
.hero { text-align: center; padding: 18px 12px; }
.hero .big { font-size: 56px; font-weight: 800; line-height: 1; background: linear-gradient(90deg, var(--pink), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
input[type=range] { width: 100%; accent-color: var(--pink); min-height: 32px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; min-height: 46px; }
.switch input { width: 22px; height: 22px; accent-color: var(--pink); }

.sess { display: flex; flex-direction: column; min-height: calc(100dvh - var(--nav-h) - 90px); }
.sess-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.pbar { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--cyan)); transition: width .3s; }
.cue { margin: 6px 0 10px; }
.cue h2 { font-size: 20px; line-height: 1.2; }
.cue .init { margin-top: 6px; font-size: 15px; color: var(--gold); font-weight: 600; }
.timer { height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; margin: 4px 0 10px; }
.timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--cyan), var(--pink)); transform-origin: left; }
.slots { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 14px; max-height: 38dvh; overflow: auto; }
.slot { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; padding: 4px 8px; border-radius: 10px; background: #0f0d21; border: 1px dashed var(--line); color: #4a4577; line-height: 1.1; }
.slot.f { color: var(--text); background: var(--surface2); border: 1px solid var(--cyan); }
.slot.cur { border-color: var(--pink); box-shadow: 0 0 0 2px #ff4fa355; animation: pulse 1s infinite; }
.slot .a { font-weight: 700; font-size: 15px; } .slot .b { font-size: 9px; color: var(--muted); }
.slot.j-perfect { border-color: var(--green); } .slot.j-good { border-color: var(--cyan); } .slot.j-ok { border-color: var(--gold); } .slot.j-miss, .slot.j-wrong { border-color: var(--red); color: var(--red); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px #ff4fa322; } }
.bank { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 12px; background: rgba(23, 20, 46, .96); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 20px; max-height: 42dvh; overflow: auto; }
.tile { min-height: 48px; min-width: 56px; padding: 6px 12px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; touch-action: manipulation; user-select: none; }
.tile .a { font-weight: 700; font-size: 16px; } .tile .b { font-size: 10px; color: var(--muted); }
.tile:active { background: var(--violet); }
.tile.shake { animation: shake .3s; border-color: var(--red); }
.tile.hint { animation: pulse 0.6s 3; border-color: var(--gold); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.row-actions { display: flex; justify-content: space-between; align-items: center; margin: 8px 0; }

.rh { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.metro { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; border: 3px solid var(--line); background: radial-gradient(circle, #1f1b3d, #0f0d21); font-size: 34px; font-weight: 800; transition: border-color .05s; }
.metro.beat { border-color: var(--pink); box-shadow: 0 0 36px #ff4fa388, inset 0 0 20px #ff4fa344; animation: boom .18s ease-out; }
.metro.accent { border-color: var(--cyan); box-shadow: 0 0 36px #38e8ff88; }
@keyframes boom { from { transform: scale(1.12); } to { transform: scale(1); } }
.judge { height: 30px; font-weight: 800; font-size: 22px; letter-spacing: .06em; }
.judge.perfect { color: var(--green); } .judge.good { color: var(--cyan); } .judge.ok { color: var(--gold); } .judge.miss, .judge.wrong { color: var(--red); }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.opt { min-height: 78px; border-radius: 16px; background: var(--surface2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; position: relative; touch-action: manipulation; user-select: none; }
.opt .a { font-weight: 800; font-size: 20px; } .opt .b { font-size: 11px; color: var(--muted); }
.opt kbd { position: absolute; top: 6px; left: 8px; font-size: 10px; color: var(--muted); opacity: .7; font-family: inherit; }
.opt:active { background: var(--violet); }
.opt.bad { border-color: var(--red); background: #3a1424; }
.opt.right { border-color: var(--green); background: #12382b; }

.result { text-align: center; padding: 10px 0; }
.gradebig { font-size: 96px; font-weight: 900; line-height: 1; margin: 8px 0 0; background: linear-gradient(135deg, var(--pink), var(--gold), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gradename { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.revlist { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; text-align: left; }
.revlist .it { display: flex; justify-content: space-between; gap: 10px; background: var(--surface); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.g0, .g1 { color: var(--red); } .g2 { color: var(--gold); } .g3 { color: var(--cyan); } .g4, .g5 { color: var(--green); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 104px; padding-top: 14px; }
.bars div { flex: 1; background: var(--pink); border-radius: 3px 3px 0 0; min-height: 0; position: relative; }
.bars span { position: absolute; bottom: 100%; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); line-height: 1.4; }
.bars-l { display: flex; gap: 4px; font-size: 9px; color: var(--muted); } .bars-l span { flex: 1; text-align: center; }
.weak { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px); background: var(--surface2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.fadein { animation: none; }
@keyframes fade { from { opacity: 0; } }

/* onboarding */
#onboard { position: fixed; inset: 0; z-index: 70; background: rgba(4, 3, 12, .8); overflow: auto; overscroll-behavior: contain; padding: 16px; display: grid; place-items: center; }
.ob-wrap { width: min(100%, 700px); max-height: calc(100dvh - 32px); overflow: auto; margin: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 20px; }
.ob-wrap h1 { font-size: 26px; margin: 0; }
.ob-dots { display: flex; gap: 6px; margin-bottom: 14px; } .ob-dots i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface2); } .ob-dots i.on { background: linear-gradient(90deg, var(--pink), var(--cyan)); }
.ob-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 4px; }
.levels { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.level { display: flex; gap: 14px; align-items: center; text-align: left; padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); min-height: 72px; }
.level.on { border-color: var(--pink); box-shadow: 0 0 0 2px #ff4fa344; background: var(--surface2); }
.lv-i { font-size: 30px; }
.krow { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); min-height: 44px; }
.krow span:nth-child(2) { flex: 1; } .krow input { width: 22px; height: 22px; accent-color: var(--pink); }

/* bulk select */
.card .chk { position: absolute; right: 8px; top: 8px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: var(--bg2); display: grid; place-items: center; font-size: 14px; color: #fff; z-index: 2; }
.card .chk + .no { padding-right: 30px; }
body:has(.selbar) #toast { bottom: calc(var(--selbar-h, 0px) + var(--nav-h) + var(--safe-b) + 14px); }
.card.sel { outline: 2px solid var(--pink); outline-offset: -2px; } .card.sel .chk { background: var(--pink); border-color: var(--pink); color: var(--bg); }
.selbar { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 35; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 12px; }
.selbar .in { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.selbar .chips { padding: 0; flex-wrap: wrap; overflow: visible; }
.seltop { display: flex; align-items: center; gap: 8px; justify-content: space-between; }

.page-heading { margin: 28px 0 20px; }
.page-heading h1 { font-size: 30px; }
.page-heading p { max-width: 65ch; line-height: 1.6; }
.library-heading { display: flex; gap: 20px; justify-content: space-between; align-items: center; }
.heading-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.home { max-width: 1080px; margin: 0 auto; }
.home-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 28px 0 22px; }
.home-intro > div { max-width: 790px; }
.eyebrow { color: var(--cyan); font-size: 12px; font-weight: 700; letter-spacing: .14em; margin: 0; }
.home-intro h1 { font-size: clamp(34px, 3.6vw, 46px); line-height: 1.15; letter-spacing: -.035em; margin: 0 0 14px; }
.home-intro > div > p:last-child { max-width: 62ch; font-size: 15px; line-height: 1.65; margin: 0; }
.home-paths { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.home-path { display: flex; flex-direction: column; min-height: 260px; padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.home-path h2 { font-size: 23px; }
.home-path > p { flex: 1; max-width: 48ch; color: var(--muted); line-height: 1.65; margin: 10px 0 20px; }
.home-path-meta { color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.home-path .btn { margin-top: 14px; min-height: 50px; }
.home-shared { color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; margin: 22px auto; }
.chant-preview { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 8px 0; overflow-wrap: anywhere; min-width: 0; }
.chant-preview rt { font-size: .7em; }
.variant-links { display: grid; gap: 8px; }
.library-group { margin-bottom: 12px; }
.sheet.detail-sheet { width: min(100%, 960px); max-height: min(92dvh, 860px); }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(270px, .72fr); gap: 24px; align-items: start; margin-top: 14px; }
.detail-main, .detail-aside { min-width: 0; }
.detail-overview { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.detail-overview .tags { margin: 0 0 10px; }
.detail-overview .kv { margin: 10px 0 0; }
.detail-chant { padding: 8px 0 4px; }
.detail-extension { border-top: 1px solid var(--line); padding-top: 12px; }
.detail-extension h3 { margin-bottom: 10px; }
.detail-aside { border-left: 1px solid var(--line); padding-left: 20px; }
.detail-block { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 16px; }
.detail-block h3 { font-size: 14px; margin-bottom: 10px; }
.detail-block > p { line-height: 1.5; }
.detail-aside .status-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-aside .status-controls .chip { min-width: 0; padding-inline: 8px; text-align: center; white-space: nowrap; }
.detail-aside .source-links { margin: 0; }
.detail-aside .source-links a { padding: 12px 0; }
.detail-aside .suggestion { padding: 12px; }
.detail-actions { display: grid; gap: 8px; }
.detail-actions, .sheet-actions { position: sticky; bottom: calc(-24px - var(--safe-b)); background: var(--bg2); padding: 12px 0 calc(12px + var(--safe-b)); margin-bottom: calc(-24px - var(--safe-b)); border-top: 1px solid var(--line); z-index: 1; }
.selbar select.input { width: auto; min-height: 44px; padding: 6px 10px; font-size: 13px; }
.flash-session .panel { padding: 24px; }
.flash-session .revlist .it { padding: 8px 0; background: none; border-radius: 0; border-bottom: 1px solid var(--line); }
.input[aria-invalid="true"], textarea.input[aria-invalid="true"] { border-color: var(--red); }
.error { color: var(--red); font-size: 13px; margin: 0; flex-basis: 100%; }
.page-title { font-size: 28px; margin: 8px 0 12px; }
.detail-actions .btn { margin: 0; }
.family-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.family-card .card { width: 100%; border: 0; border-radius: 0; flex: 1; }
.family-card summary { cursor: pointer; min-height: 44px; padding: 12px; font-size: 13px; color: var(--text); border-top: 1px solid var(--line); background: var(--surface); }
.family-versions { display: grid; }
.family-versions button { display: flex; flex-direction: column; gap: 6px; padding: 12px; text-align: left; background: var(--bg2); border-top: 1px solid var(--line); font-size: 13px; }
.family-versions button:hover { background: var(--surface2); }
.source-links { margin: 20px 0; }
.source-links a { display: block; min-height: 44px; color: var(--text); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; padding: 12px 0; overflow-wrap: anywhere; }
#catalog-filters { margin: 6px 0 16px; }
#catalog-filters summary { cursor: pointer; padding: 8px 0 12px; color: var(--muted); font-size: 13px; }
.practice-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; }
.practice-layout .panel { padding: 24px; margin: 0; }
.learning-path { margin-bottom: 28px; }
.path-heading { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.path-heading p { font-size: 13px; line-height: 1.6; }
.path-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.path-cards .suggestion { background: var(--surface); }
.queue-preview { padding-left: 24px; margin: 24px 0; }
.queue-preview li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.queue-preview li span { float: right; margin-left: 12px; }
.suggestions { display: grid; gap: 8px; margin: 20px 0; }
.suggestion { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.suggestion:hover { background: var(--surface2); }
.flash-session { width: min(100%, 800px); margin: 24px auto; min-height: 0; }
.flash-session .sess-head { justify-content: space-between; margin-bottom: 18px; }
.flashcard { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px; }
.flash-heading h1 { font-size: clamp(24px, 3vw, 36px); line-height: 1.25; margin-top: 12px; overflow-wrap: anywhere; }
.flash-heading p { margin: 8px 0; }
.flash-context { padding-top: 16px; font-size: 14px; }
.flash-answer { border-top: 1px solid var(--line); margin: 24px 0; padding-top: 12px; }
.flash-answer .tok { background: var(--surface); border: 1px solid var(--line); padding: 6px 10px; text-align: center; align-items: center; }
.flash-answer .tok .a { font-size: 22px; line-height: 1.5; }
.flash-answer .tok .b { font-size: 13px; line-height: 1.4; }
.flash-answer .stanza { gap: 8px; margin: 16px 0; }
.flash-answer .init { color: var(--gold); }
.recall-space { padding: 32px 0; line-height: 1.6; }
.rating-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.rating { display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 16px 12px; text-align: left; min-height: 118px; }
.rating span:first-child { display: flex; gap: 8px; align-items: center; }
.rating kbd { color: var(--muted); font: inherit; font-size: 12px; }
.rating:hover, .rating:focus-visible { background: var(--surface2); border-color: var(--cyan); }
.rating:first-child b { color: var(--red); }
.rating:disabled { opacity: .5; }
.shortcut { text-align: center; margin: 16px 0; }
.status-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.guide-intro { line-height: 1.5; margin: 8px 0 12px; max-width: 62ch; }
.guide-example { padding: 12px; background: var(--surface); border-radius: 12px; }
.guide-example > .small { margin: 4px 0 0; }
.guide-example .stanza { margin: 6px 0 0; gap: 4px; }
.guide-example .line { gap: 4px; }
.guide-example .tok { padding: 4px 7px; min-width: 0; }
.guide-example .tok .a { font-size: 14px; }
.guide-example .tok .b { font-size: 9px; }
.guide-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 10px 0; }
.guide-facts p { margin: 0; font-size: 13px; line-height: 1.45; }
.guide-settings { margin-top: 10px; }
.guide-settings label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.guide-settings select { width: min(240px, 65vw); }
.guide-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.guide-choices .btn { width: 100%; }
@media (min-width: 960px) {
  #app { padding-left: 208px; padding-bottom: 32px; }
  .top { padding-top: 24px; }
  .tabbar { left: max(24px, calc((100vw - 1200px) / 2 + 24px)); right: auto; top: 106px; bottom: auto; width: 152px; display: grid; padding: 0; background: none; backdrop-filter: none; border: 0; gap: 8px; }
  .tabbar button { flex-direction: row; justify-content: flex-start; gap: 12px; height: 48px; font-size: 14px; padding: 0 16px; border-radius: 10px; }
  .tabbar button.on { background: var(--surface2); }
  .tabbar button.on::before { display: none; }
  .badge { right: 8px; top: 14px; }
  .chips { flex-wrap: wrap; }
  .sheet { top: 50%; bottom: auto; border-radius: 20px; border-bottom: 1px solid var(--line); transform: translate(-50%, 100vh); }
  #sheetRoot.open .sheet { transform: translate(-50%, -50%); }
  .grab { display: none; }
  .selbar { bottom: 0; left: 208px; }
  #toast { bottom: 24px; }
  body:has(.selbar) #toast { bottom: calc(var(--selbar-h, 0px) + 24px); }
}
@media (max-width: 640px) {
  #app { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-intro { position: relative; display: block; margin: 12px 0; }
  .home-intro h1 { font-size: clamp(32px, 8vw, 40px); margin: 8px 0 10px; }
  .home-intro > div > p:last-child { font-size: 14px; line-height: 1.45; }
  .home-intro > .chip { margin: 0 0 4px; padding: 6px 9px; font-size: 11px; }

  .home-paths { grid-template-columns: 1fr; gap: 8px; }
  .home-path { min-height: 0; padding: 16px; }
  .home-path h2 { font-size: 20px; margin-top: 8px; }
  .home-path > p { font-size: 13px; line-height: 1.45; margin: 6px 0 10px; }
  .home-path-meta { padding-top: 8px; }
  .home-path .btn { margin-top: 8px; min-height: 44px; }
  .home-shared { margin: 12px auto; }
  .library-heading { display: block; }
  .heading-actions { flex-wrap: wrap; justify-content: flex-start; margin-top: 12px; }
  .sheet.detail-sheet { width: 100%; }
  .detail-layout { grid-template-columns: 1fr; gap: 12px; }
  .detail-aside { border-left: 0; border-top: 1px solid var(--line); padding: 16px 0 0; }
  .practice-layout { grid-template-columns: 1fr; gap: 16px; }
  .path-cards { grid-template-columns: 1fr; }
  .path-heading { align-items: flex-start; }
  .practice-layout .panel { padding: 20px; }
  .flashcard { padding: 20px; }
  .rating { min-height: 0; padding: 12px; gap: 6px; }
  .ob-wrap { padding: 18px; }
  .guide-facts { grid-template-columns: 1fr; gap: 6px; }
  .guide-settings select { flex: 1; width: auto; }
  .guide-choices { grid-template-columns: 1fr; gap: 8px; }
  .shortcut { display: none; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input { flex-basis: 100%; }
}

.share-qr { display: block; width: min(260px, 100%); margin: 16px auto; shape-rendering: crispEdges; }
#share-url { width: 100%; margin-top: 8px; }

.nav-label { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.tabbar .badge { position: static; margin: 0; min-width: 18px; height: 18px; padding: 0 4px; font-style: normal; line-height: 1; font-variant-numeric: tabular-nums; display: flex; align-items: center; justify-content: center; }
.status-badge { display: inline-flex; align-items: center; align-self: flex-start; width: fit-content; gap: 5px; padding: 5px 10px; border-radius: 6px; font-size: 12px; font-weight: 800; line-height: 1.2; background: #d6d2e8; color: #201b35; }
.status-LEARNING { background: #38e8ff; color: #062c33; }
.status-REMEMBERED { background: #ffd45e; color: #3b2c00; }
.status-REMEMBERED::before { content: '✓'; }
.status-MASTERED { background: #d1b8ff; color: #2c1054; }
.status-MASTERED::before { content: '★'; }
.card .status-badge { margin: 4px 0; }
.catalog-view { display: flex; gap: 12px; align-items: end; margin: 12px 0; }
.catalog-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.catalog-options label, .catalog-view > label { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12px; color: var(--muted); }
.catalog-options select.input, .catalog-view select.input { width: 100%; }
.catalog-view .catalog-options { flex: 1; }
.catalog-view > label { flex: 0 1 190px; }
.status-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; overflow: visible; }
.status-choice { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; min-height: 44px; font-size: 13px; background: var(--surface); }
.status-choice span { opacity: .8; }
.status-choice.on { background: #f3f0ff; color: #17142e; border-color: #f3f0ff; font-weight: 700; }
.practice-picker-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.practice-selection { position: sticky; top: 82px; max-height: calc(100dvh - 130px); overflow: auto; }
.practice-selection .panel { margin-top: 0; margin-bottom: 16px; padding: 20px; }
.picker-summary { display: flex; justify-content: space-between; align-items: center; margin: 12px 0; }
.practice-list { display: flex; flex-direction: column; gap: 8px; }
.practice-item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.practice-item.chosen { border: 2px solid var(--pink); padding: 11px; background: #33192e; }
.practice-item > label { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; cursor: pointer; }
.practice-item input { width: 22px; height: 22px; flex: none; accent-color: var(--pink); cursor: pointer; }
.practice-item label > span { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.practice-item b { width: 100%; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.practice-item .chip { padding: 6px 8px; font-size: 11px; }
.selection-count { font-weight: 800; font-size: 20px; margin: 14px 0; }
.selected-mixes { list-style: none; padding: 0; margin: 12px 0; }
.selected-mixes li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.selected-mixes button { width: 44px; height: 44px; flex: none; border-radius: 6px; background: var(--surface2); border: 1px solid var(--line); }
.practice-selection .chip { margin-top: 10px; }
@media (max-width: 959px) {
  .practice-picker-layout { grid-template-columns: 1fr; }
  .practice-selection { position: static; grid-row: 1; max-height: none; overflow: visible; }
  .practice-selection .review-plan { margin-bottom: 8px; }
  .practice-selection .panel { padding: 14px; }
  .selection-count { font-size: 16px; margin: 8px 0; }
}
@media (max-width: 640px) {
  .catalog-view { flex-wrap: wrap; }
  .catalog-view .catalog-options { flex-basis: 100%; }
  .catalog-view > label { flex: 1; }
  .practice-item { gap: 8px; padding: 10px; }
  .practice-item.chosen { padding: 9px; }
}

.review-plan summary { cursor: pointer; font-weight: 700; min-height: 44px; padding-block: 12px; }
@media (max-width: 959px) {
  .practice-selection [data-act="p-start"]:not(:disabled) { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); width: calc(100% - 32px); z-index: 36; }
  .practice-picker { padding-bottom: 70px; }
}

.selection-summary summary { font-weight: 700; cursor: pointer; min-height: 44px; padding-block: 12px; }
.practice-actions { margin-bottom: 16px; }
@media (max-width: 959px) {
  .practice-selection { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .practice-selection .panel { margin: 0; }
  .practice-selection details[open] { grid-column: 1 / -1; }
  .selection-summary[open] + .review-plan { grid-column: 1 / -1; }
  .practice-selection summary { font-size: 12px; }
  .practice-actions { display: contents; }
  .practice-actions:has(button:disabled) { display: none; }
}

.practice-mode { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0 20px; }
.practice-mode label { font-size: 12px; color: var(--muted); }
.practice-mode p { flex-basis: 100%; margin: 0; }
.line-context { padding: 16px; margin: 20px 0; background: var(--bg2); border-radius: 10px; }
.line-context .line { margin: 8px 0; }
.line-options { display: grid; gap: 12px; margin: 16px 0; }
.line-option { display: flex; align-items: center; gap: 12px; padding: 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface2); text-align: left; }
.line-option .line { flex: 1; }
.line-option.correct { border-color: var(--green); background: #0c392c; }
.line-option.incorrect { border-color: var(--red); background: #451d2b; }
.line-option:disabled { color: var(--text); cursor: default; }
.option-number { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 6px; background: var(--bg); font-weight: 700; }
.answer-feedback { font-weight: 700; }
.compact-card { padding: 20px 24px; }
.compact-card .flash-heading h1 { font-size: 20px; margin-top: 4px; }
.flash-session:has(.compact-card) { margin-top: 8px; }
.flash-session:has(.compact-card) .sess-head { margin-bottom: 10px; }
.compact-card .line-context { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 14px; margin: 10px 0; }
.compact-card .line-context p { margin: 0; }
.compact-card .line-context .line { margin: 4px 0; }
.compact-card .line-context .init { color: var(--gold); }
.line-question { font-size: 17px; margin: 12px 0 0; }
.compact-card .line-options { gap: 8px; margin: 10px 0; }
.compact-card .line-option { padding: 8px 12px; }
.compact-card .flash-answer { margin: 12px 0; }
.compact-card .flash-answer .stanza { margin: 8px 0; gap: 6px; }
.compact-card .assessment p { margin: 8px 0; }
.compact-card .line-question + .btn { margin-top: 12px; }
@media (max-width: 640px) { .compact-card .flash-answer .tok .a { font-size: 18px; } .compact-card .flash-answer .tok { padding: 4px 8px; } }
#view:focus, .line-question:focus, .assessment p:focus { outline: none; }
.status-override { margin-top: 12px; }
.status-override summary, .source-notes summary { cursor: pointer; min-height: 44px; padding-block: 12px; font-size: 13px; color: var(--muted); }
.status-override .status-controls { margin-top: 8px; }
.empty .btns { justify-content: center; }
@media (max-width: 640px) { .practice-mode select.input { max-width: 100%; } .line-option { padding: 10px; } }

.tok { max-width: 100%; }
.tok .a, .tok .b { overflow-wrap: anywhere; max-width: 100%; }

.practice-mode { display: grid; grid-template-columns: minmax(0, 320px) 120px; max-width: 520px; align-items: end; }
.mode-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mode-field select.input { width: 100%; }
.practice-mode p { grid-column: 1 / -1; }
@media (max-width: 640px) { .practice-mode { grid-template-columns: minmax(0, 1fr) 100px; } .mode-field select.input { font-size: 13px; padding: 10px; } }

.tok ruby { ruby-position: over; }
.tok rt { font-size: .55em; font-weight: 400; color: var(--muted); }
