:root {
  --navy:#123a63; --navy-deep:#082844; --red:#b71c2b; --cream:#fffaf2;
  --paper:#ffffff; --gray:#5b6269; --light:#eef3f7; --gold:#c69a34;
  --green:#1f7a46; --shadow:0 14px 34px rgba(8,40,68,.15);
}
* { box-sizing:border-box; }
[hidden] { display:none !important; }
html { scroll-behavior:smooth; -webkit-text-size-adjust:100%; text-size-adjust:100%; }
body { margin:0; min-height:100vh; color:#17212b; background:linear-gradient(160deg,#f5f8fb 0%,#fffaf2 55%,#eef3f7 100%); font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif; }
button,select,input { font:inherit; font-size:16px; }
button,a,select,input { -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
button { cursor:pointer; }
.skip-link { position:absolute; left:-9999px; top:8px; z-index:1000; background:#fff; color:#000; padding:10px; }
.skip-link:focus { left:8px; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:14px clamp(16px,3vw,44px); padding-top:max(14px, env(safe-area-inset-top)); background:var(--navy-deep); color:#fff; border-bottom:5px solid var(--red); position:sticky; top:0; z-index:30; box-shadow:0 5px 20px rgba(0,0,0,.18); }
.brand-wrap { display:flex; align-items:center; gap:15px; min-width:0; }
.brand-logo { width:68px; height:52px; object-fit:contain; background:#fff; border-radius:8px; padding:4px; }
.eyebrow { font-size:.72rem; letter-spacing:.16em; font-weight:900; color:#f3c55b; }
.book-title { font:800 clamp(1rem,2.5vw,1.5rem)/1.15 Georgia,serif; }
.book-subtitle { opacity:.86; font-size:.8rem; margin-top:3px; }
.top-actions { display:flex; align-items:center; gap:8px; flex:none; }
.lang-switch { display:flex; gap:4px; background:rgba(255,255,255,.1); padding:3px; border-radius:10px; }
.lang-switch button { min-width:40px; min-height:36px; border:0; border-radius:8px; background:transparent; color:#fff; font-weight:900; font-size:.82rem; }
.lang-switch button.is-on { background:#fff; color:var(--navy-deep); }
.return-button { flex:none; border:1px solid rgba(255,255,255,.5); background:rgba(255,255,255,.1); color:#fff; padding:11px 15px; border-radius:10px; font-weight:800; }
.return-button:hover { background:#fff; color:var(--navy); }
.lang-pick { display:grid; gap:10px; margin-top:8px; }
.lang-pick button { min-height:52px; border:0; border-radius:12px; background:var(--navy); color:#fff; font-weight:900; font-size:1.05rem; }
main { width:min(1220px,96vw); margin:22px auto 40px; }
.toolbar { display:grid; grid-template-columns:150px 190px minmax(220px,0.9fr) minmax(240px,1.1fr); gap:12px; background:rgba(255,255,255,.92); padding:14px; border:1px solid #cfd9e2; border-radius:14px; box-shadow:0 8px 22px rgba(8,40,68,.08); }
.toolbar-group { display:flex; flex-direction:column; gap:6px; min-width:0; }
.toolbar label { font-size:.75rem; font-weight:900; text-transform:uppercase; color:var(--navy); letter-spacing:.05em; }
.toolbar select,.toolbar input { min-height:42px; border:1px solid #aebdca; border-radius:8px; background:#fff; padding:8px 10px; color:#18232d; }
.jump-row { display:flex; align-items:center; gap:6px; }
.jump-row span { font-weight:900; color:var(--navy); }
.jump-row input { width:64px; }
.jump-row button { min-height:42px; border:0; border-radius:8px; background:var(--navy); color:#fff; font-weight:800; padding:0 12px; }
.toolbar small { color:var(--gray); line-height:1.25; }
.speed-row { display:flex; align-items:center; gap:8px; }
.speed-row input[type=range] { flex:1; min-width:0; height:32px; accent-color:var(--navy); }
.speed-row button { width:44px; min-width:44px; min-height:44px; border:1px solid #aebdca; border-radius:8px; background:#fff; color:var(--navy); font-weight:900; font-size:1.25rem; line-height:1; }
.speed-presets { display:flex; gap:6px; }
.speed-presets button { flex:1; min-height:38px; border:1px solid #aebdca; border-radius:8px; background:#fff; color:var(--navy); font-weight:800; font-size:.82rem; }
.speed-presets button.is-on { background:var(--navy); color:#fff; border-color:var(--navy); }
.now-card { background:var(--navy-deep); color:#fff; border-radius:16px; padding:14px 16px 16px; margin:0 0 14px; position:sticky; top:72px; z-index:24; box-shadow:0 10px 28px rgba(8,40,68,.28); border-left:6px solid var(--gold); }
.now-kicker { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
.now-kicker strong { font-size:.85rem; letter-spacing:.04em; opacity:.9; }
.now-question { margin:0; font:800 clamp(1.15rem,3.4vw,1.7rem)/1.25 Georgia,serif; }
.now-translation { margin:6px 0 0; font:italic .95rem/1.4 Georgia,serif; opacity:.88; }
.tools-drawer { margin:0 0 12px; }
.tools-drawer > summary { cursor:pointer; list-style:none; background:#fff; border:1px solid #cfd9e2; border-radius:12px; padding:12px 14px; font-weight:800; color:var(--navy); box-shadow:0 6px 16px rgba(8,40,68,.08); }
.tools-drawer > summary::-webkit-details-marker { display:none; }
.tools-drawer[open] > summary { margin-bottom:8px; }
.share-drawer { margin:0 0 12px; }
.share-drawer > summary { cursor:pointer; list-style:none; background:#fff; border:1px solid #cfd9e2; border-radius:12px; padding:12px 14px; font-weight:800; color:var(--navy); }
.share-drawer > summary::-webkit-details-marker { display:none; }
.share-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; padding:12px 0; text-align:center; }
.share-grid img { width:min(220px,42vw); height:auto; background:#fff; padding:8px; border:1px solid #d8e0e6; border-radius:12px; }
.share-grid figcaption { font-size:.8rem; margin-top:6px; line-height:1.35; }
.share-grid a { color:var(--navy); font-weight:800; word-break:break-all; }
.install-hint { margin:0; font-size:.82rem; color:#5b6269; line-height:1.4; }
.progress-section { margin:14px 0; }
.progress-meta { display:flex; justify-content:space-between; color:var(--navy); font-size:.9rem; margin-bottom:6px; }
.progress-track { height:10px; background:#dce5ec; border-radius:999px; overflow:hidden; }
#progress-bar { height:100%; width:0; background:linear-gradient(90deg,var(--navy),var(--red)); transition:width .25s ease; }
.spread { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:20px; align-items:stretch; }
.image-page,.text-page { min-height:690px; background:var(--paper); border:1px solid #cbd6df; box-shadow:var(--shadow); border-radius:16px; padding:clamp(18px,2.5vw,30px); position:relative; overflow:hidden; }
.image-page { display:flex; flex-direction:column; justify-content:center; background:#fdfdfc; }
.image-frame { width:100%; aspect-ratio:1/1; display:grid; place-items:center; border:8px solid var(--navy); outline:3px solid var(--red); outline-offset:-12px; background:#fff; padding:8px; box-shadow:8px 8px 0 #dce3e8; }
.image-frame img { width:100%; height:100%; object-fit:contain; }
.image-instruction { text-align:center; color:var(--gray); font-style:italic; margin:24px 0 0; }
.text-page::before { content:""; position:absolute; inset:0 0 auto 0; height:7px; background:linear-gradient(90deg,var(--navy) 0 68%,var(--red) 68%); }
.badges { display:flex; gap:8px; flex-wrap:wrap; margin:4px 0 16px; }
.badge { display:inline-flex; align-items:center; min-height:29px; padding:5px 10px; border-radius:999px; font-weight:900; font-size:.78rem; letter-spacing:.04em; }
.q-badge { color:#fff; background:var(--navy); }
.special-badge { color:#7d151e; background:#ffe6e9; border:1px solid #e8a7ae; }
.variable-badge { color:#6c4a00; background:#fff3c9; border:1px solid #e2c46f; }
h1 { margin:0; color:var(--navy-deep); font:800 clamp(1.35rem,2.3vw,2rem)/1.2 Georgia,serif; }
.translation { margin:10px 0 24px; color:var(--gray); font:italic 1.03rem/1.45 Georgia,serif; }
.answer-heading-row { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-top:14px; }
.micro-label { display:block; font-size:.74rem; color:var(--gray); font-weight:900; letter-spacing:.08em; }
#required-count { color:var(--red); font-size:.96rem; }
.reveal-button { border:0; border-radius:9px; padding:10px 14px; color:#fff; background:var(--red); font-weight:900; }
.answer-panel { margin:10px 0 14px; padding:17px; background:#f3f6f8; border-left:7px solid var(--red); border-radius:0 11px 11px 0; transition:filter .2s,opacity .2s; }
.answer-hidden > *:not(.custom-answer-box) { filter:blur(9px); opacity:.24; user-select:none; pointer-events:none; }
.answer-text { color:var(--red); font-size:clamp(1.25rem,2vw,1.65rem); line-height:1.3; font-weight:900; margin-bottom:12px; }
.answer-meta { color:#263644; font-size:.9rem; line-height:1.45; margin-top:5px; }
.pron-hint { margin:6px 0 0; color:#5b6269; font-size:.78rem; line-height:1.35; }
.custom-answer-box { padding:12px; background:#fff8dd; border:1px solid #e7c967; border-radius:9px; margin-bottom:12px; }
.custom-answer-box label { display:block; font-weight:900; color:#624500; margin-bottom:8px; }
.custom-row { display:flex; gap:8px; }
.custom-row input { flex:1; min-width:0; border:1px solid #b7a45f; border-radius:8px; padding:10px; }
.custom-row button { border:0; border-radius:8px; background:var(--green); color:#fff; font-weight:900; padding:10px 14px; }
.custom-answer-box small { display:block; margin-top:7px; color:#6e6033; }
.variable-tools { display:grid; grid-template-columns:1fr auto auto; gap:10px; align-items:center; background:#fff8dd; border:1px solid #e7c967; border-radius:10px; padding:12px; margin:12px 0; }
.variable-tools p { margin:3px 0 0; color:#655a35; font-size:.84rem; }
.variable-tools a,.variable-tools button { white-space:nowrap; border:0; border-radius:8px; padding:9px 11px; font-weight:900; text-decoration:none; }
.variable-tools a { background:var(--navy); color:#fff; }
.variable-tools button { background:#fff; color:var(--navy); border:1px solid #aabac8; }
.accepted-details { margin:12px 0; border-top:1px solid #d8e0e6; border-bottom:1px solid #d8e0e6; padding:10px 0; }
.accepted-details summary { cursor:pointer; font-weight:800; color:var(--navy); }
.accepted-details ol { margin:10px 0 0 22px; padding:0; color:#394956; font-size:.88rem; line-height:1.45; }
.audio-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-top:14px; }
.audio-button { border:0; min-height:68px; border-radius:11px; color:#fff; font-weight:900; line-height:1.15; padding:9px; box-shadow:0 4px 0 rgba(0,0,0,.13); }
.audio-button span { display:block; font-size:1.1rem; }
.audio-button small { opacity:.83; }
.audio-button.navy { background:var(--navy); }
.audio-button.red { background:var(--red); }
.audio-button:active { transform:translateY(2px); box-shadow:0 2px 0 rgba(0,0,0,.13); }
.training-panel { margin-top:15px; background:#eef3f7; border-radius:11px; padding:12px; }
.training-title { font-weight:900; color:var(--navy); margin-bottom:8px; }
.training-buttons { display:grid; grid-template-columns:repeat(4,1fr); gap:7px; }
.training-buttons button { min-height:44px; border:1px solid #aebdca; border-radius:8px; background:#fff; color:var(--navy); font-weight:800; padding:8px; }
.training-buttons .stop-button { color:#fff; background:#343a40; border-color:#343a40; }
.audio-status { margin-top:9px; min-height:22px; font-size:.86rem; color:#354958; font-weight:700; }
.mastery-row { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:14px; }
.mastered-button { border:2px solid var(--green); color:var(--green); background:#fff; border-radius:9px; padding:10px 14px; font-weight:900; }
.mastered-button.is-mastered { color:#fff; background:var(--green); }
.voice-status { color:var(--gray); font-size:.78rem; text-align:right; }
.bottom-nav { display:grid; grid-template-columns:1fr auto 1fr; gap:12px; margin-top:20px; }
.bottom-nav button { border:0; border-radius:11px; padding:14px; font-weight:900; background:var(--navy); color:#fff; min-height:48px; }
.bottom-nav #random-button { background:#fff; color:var(--navy); border:1px solid #aebdca; }
.study-dock { display:none; }
footer { text-align:center; padding:24px 16px 40px; color:#52606a; font-size:.8rem; }
footer p { margin:5px auto; max-width:900px; }
button:focus-visible,select:focus-visible,input:focus-visible,a:focus-visible,summary:focus-visible { outline:3px solid #f1b83f; outline-offset:2px; }
button[disabled] { opacity:.45; cursor:not-allowed; }
.place-button { margin-top:6px; min-height:36px; border:1px solid #aebdca; border-radius:8px; background:#fff; color:var(--navy); font-weight:800; }
.setup-modal { position:fixed; inset:0; z-index:80; background:rgba(8,40,68,.55); display:grid; place-items:end center; padding:12px 12px max(12px, env(safe-area-inset-bottom)); overflow:auto; }
.setup-modal[hidden] { display:none !important; }
.setup-card { width:min(560px,100%); background:#fff; border-radius:18px 18px 12px 12px; padding:22px 18px 16px; box-shadow:0 -12px 40px rgba(8,40,68,.28); color:#17212b; }
.setup-card h2 { margin:0 0 8px; color:var(--navy-deep); font:800 1.25rem/1.25 Georgia,serif; }
.setup-card p { margin:0 0 14px; color:#3d4a55; line-height:1.45; }
.setup-card label { display:block; font-size:.75rem; font-weight:900; text-transform:uppercase; letter-spacing:.04em; color:var(--navy); margin:10px 0 5px; }
.setup-card input,.setup-card select { width:100%; min-height:46px; border:1px solid #aebdca; border-radius:8px; padding:8px 10px; background:#fff; font-size:16px; }
.setup-preview { margin:14px 0; padding:12px; background:#eef3f7; border-radius:10px; font-size:.9rem; line-height:1.45; }
.setup-preview strong { color:var(--navy); }
#setup-save { width:100%; min-height:50px; margin-top:8px; border:0; border-radius:10px; background:var(--red); color:#fff; font-weight:900; }
.setup-skip { width:100%; min-height:44px; margin-top:8px; border:0; background:transparent; color:var(--navy); font-weight:800; }
.setup-legal { font-size:.75rem; color:#6a7680; margin-top:10px; }
.zip-hint { display:block; margin:6px 0 0; color:#5b6269; font-size:.78rem; line-height:1.35; }
.exam-open { border-color:var(--red) !important; color:var(--red) !important; }
.exam-bar { background:#fff8dd; border:1px solid #e7c967; border-radius:12px; padding:12px; margin:0 0 12px; }
.exam-bar strong { display:block; color:#624500; margin-bottom:8px; }
.exam-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.exam-actions button { min-height:46px; border:0; border-radius:10px; font-weight:900; }
#exam-knew { background:var(--green); color:#fff; }
#exam-miss { background:var(--red); color:#fff; }
.exam-exit { grid-column:1 / -1; background:#fff; color:var(--navy); border:1px solid #aebdca !important; }
#exam-std, #exam-again { width:100%; min-height:50px; margin-top:8px; border:0; border-radius:10px; background:var(--red); color:#fff; font-weight:900; }
body.exam-on .tools-drawer { display:none; }
.install-banner { position:fixed; left:10px; right:10px; bottom:calc(72px + env(safe-area-inset-bottom)); z-index:56; background:#fff; border:2px solid var(--navy); border-radius:14px; padding:12px 14px; box-shadow:0 12px 32px rgba(8,40,68,.28); }
.install-banner strong { display:block; color:var(--navy-deep); margin-bottom:4px; }
.install-banner p { margin:0 0 10px; color:#3d4a55; font-size:.86rem; line-height:1.4; }
.install-row { display:flex; gap:8px; }
.install-row button { flex:1; min-height:42px; border-radius:10px; font-weight:900; border:1px solid #aebdca; background:#fff; color:var(--navy); }
#install-btn { background:var(--navy); color:#fff; border-color:var(--navy); }
@media (min-width:721px) {
  .install-banner { left:auto; right:20px; width:min(380px,90vw); bottom:20px; }
}
@media (min-width:721px) {
  .tools-drawer > summary { display:none; }
  .tools-drawer { margin-bottom:12px; }
}
@media (max-width:960px) {
  .toolbar { grid-template-columns:1fr 1fr; }
  .spread { grid-template-columns:1fr; }
  .image-page,.text-page { min-height:auto; }
  .image-page { order:1; }
  .text-page { order:2; }
  .image-frame { max-width:680px; margin:auto; }
  .now-card { top:58px; }
}
@media (max-width:960px) and (orientation:landscape) and (max-height:500px) {
  .spread { grid-template-columns:minmax(180px,.7fr) minmax(0,1.3fr); }
  .image-page { order:0; padding:12px; }
  .text-page { order:0; }
  .image-frame { max-width:none; aspect-ratio:1/1; padding:8px; border-width:5px; }
  .image-instruction { display:none; }
}
@media (max-width:640px) {
  .topbar { align-items:center; gap:10px; padding:8px 12px; padding-top:max(8px, env(safe-area-inset-top)); }
  .brand-logo { width:42px; height:36px; }
  .book-title { font-size:.95rem; }
  .book-subtitle { display:none; }
  .return-button { padding:8px 10px; font-size:.74rem; display:none; }
  .lang-switch button { min-width:36px; min-height:34px; }
  main { width:94vw; margin:10px auto 0; padding-bottom:118px; }
  .progress-section { display:none; }
  .now-card { top:52px; margin-bottom:10px; padding:12px 12px 14px; }
  .toolbar { grid-template-columns:1fr 1fr; padding:8px; gap:8px; }
  .toolbar-group.voice-group { grid-column:1 / -1; }
  .toolbar-group.speed-group { grid-column:1 / -1; }
  .toolbar small#voice-note { display:none; }
  .toolbar select,.toolbar input,.jump-row button { min-height:44px; }
  .image-page,.text-page { padding:10px; border-radius:12px; }
  .image-frame { max-width:min(92vw,420px); width:100%; padding:6px; border-width:6px; outline-width:2px; outline-offset:-10px; box-shadow:4px 4px 0 #dce3e8; }
  .image-instruction { margin-top:8px; font-size:.8rem; }
  h1 { font-size:1.28rem; }
  .audio-grid { grid-template-columns:1fr 1fr; }
  .audio-button { min-height:64px; font-size:.95rem; }
  .training-buttons { grid-template-columns:1fr 1fr; }
  .training-buttons button { min-height:48px; }
  .variable-tools { grid-template-columns:1fr; }
  .bottom-nav { grid-template-columns:1fr 1fr; margin-top:16px; }
  .bottom-nav #random-button { grid-column:1 / -1; grid-row:2; }
  .mastery-row { align-items:flex-start; flex-direction:column; }
  .voice-status { text-align:left; }
  .answer-heading-row { flex-wrap:wrap; }
  .reveal-button { min-height:44px; width:100%; }
  .study-dock {
    display:grid;
    grid-template-columns:52px 1fr 1fr 52px;
    gap:7px;
    position:fixed;
    left:0; right:0; bottom:0;
    z-index:50;
    background:var(--navy-deep);
    padding:8px 8px max(8px, env(safe-area-inset-bottom));
    box-shadow:0 -8px 24px rgba(8,40,68,.28);
  }
  .study-dock button {
    min-height:48px;
    border:0;
    border-radius:10px;
    font-weight:900;
    color:#fff;
    background:rgba(255,255,255,.12);
  }
  .study-dock .dock-play { background:var(--red); font-size:.92rem; }
  .study-dock .dock-stop { grid-column:1 / -1; background:#1b1f24; min-height:40px; }
  body.is-playing .study-dock .dock-stop { background:#c62828; }
  footer { padding-bottom:24px; }
}
@media (max-width:640px) and (orientation:landscape) {
  main { padding-bottom:86px; }
  .study-dock { grid-template-columns:48px 1fr 1fr 1fr 48px; }
  .study-dock .dock-stop { grid-column:auto; min-height:44px; }
}
@media print {
  .topbar,.toolbar,.progress-section,.audio-grid,.training-panel,.bottom-nav,.study-dock,.return-button,.mastery-row { display:none !important; }
  body { background:#fff; }
  .spread { grid-template-columns:1fr 1fr; }
  .image-page,.text-page { box-shadow:none; border:0; }
  .answer-hidden > * { filter:none !important; opacity:1 !important; }
}
