:root{
  --ink:#16211e; --sub:#6b7a76; --line:#e3e8e6; --bg:#f6f8f7; --card:#fff;
  --brand:#1f6f5c; --brand-2:#2f9c80; --brand-soft:#e8f5f0; --ok:#12805c; --warn:#b45309;
  --fs:16.5px;              /* 正文基准字号，A−/A＋ 改它 */
  --hh:104px;               /* 顶栏实际高度（JS 写入） */
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Hiragino Sans","Hiragino Kaku Gothic ProN","PingFang SC","Noto Sans JP",system-ui,sans-serif;
  color:var(--ink); background:var(--bg); font-size:var(--fs); line-height:1.6;
  padding-bottom:104px; -webkit-text-size-adjust:100%;
}
body.fs-s{--fs:15px}
body.fs-l{--fs:19px}
h1,h2,h3,p,ul{margin:0}
button{font:inherit;color:inherit}

/* ---------- 顶栏 ---------- */
#top{
  position:sticky;top:0;z-index:30;background:rgba(255,255,255,.97);
  backdrop-filter:blur(10px);border-bottom:1px solid var(--line);
  padding:10px 14px 9px;display:flex;align-items:flex-start;gap:10px;
}
#top .ttl{flex:1;min-width:0}
#top .ttl h1{font-size:15.5px;font-weight:700;letter-spacing:.2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#top .ttl p{font-size:11.5px;color:var(--sub);margin-top:2px}
#top .hright{display:flex;align-items:center;gap:10px;flex:0 0 auto}
#top .prog{display:flex;flex-direction:column;align-items:flex-end;gap:4px}
#top .prog span{font-size:12.5px;font-variant-numeric:tabular-nums;color:var(--sub)}
.pbar{width:64px;height:5px;border-radius:99px;background:#e8ecea;overflow:hidden}
.pbar i{display:block;height:100%;width:0;background:var(--brand-2);transition:width .25s ease}
.fs{display:flex;gap:4px}
.fs button{
  width:30px;height:28px;border:1px solid var(--line);background:#fff;border-radius:8px;
  font-size:12px;color:var(--sub);cursor:pointer;padding:0
}
.fs button:active{background:var(--brand-soft)}

.banner{margin:10px 14px 0;padding:10px 12px;border-radius:10px;font-size:13px;line-height:1.45}
.banner.warn{background:#fff7ed;color:var(--warn);border:1px solid #fed7aa}
.banner.ok{background:#ecfdf5;color:#065f46;border:1px solid #a7f3d0}
.hide{display:none !important}

/* ---------- 分节切换 ---------- */
#tabs{
  display:flex;gap:8px;padding:9px 14px;overflow-x:auto;scrollbar-width:none;
  position:sticky;top:var(--hh);z-index:20;background:var(--bg);border-bottom:1px solid #eef1f0;
}
#tabs::-webkit-scrollbar{display:none}
#tabs button{
  flex:0 0 auto;border:1px solid var(--line);background:var(--card);border-radius:999px;
  padding:7px 12px;font-size:13px;display:flex;align-items:center;gap:6px;cursor:pointer;white-space:nowrap
}
#tabs button.on{border-color:var(--brand);background:var(--brand-soft);color:#155e4e;font-weight:700}
#tabs button em{font-style:normal;font-size:11px;color:var(--sub);font-variant-numeric:tabular-nums}
#tabs button.done em{color:var(--ok);font-weight:700}

/* ---------- 主体 ---------- */
main{padding:2px 14px 24px}
.who{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:14px;margin:10px 0 14px}
.who label{display:block;font-size:12px;color:var(--sub);margin-bottom:6px}
.who input{
  width:100%;border:1px solid var(--line);border-radius:10px;padding:11px 12px;font-size:16px;background:#fbfcfc;
}
.who input:focus{outline:none;border-color:var(--brand);background:#fff;box-shadow:0 0 0 3px var(--brand-soft)}
.who .rules{margin-top:12px;padding-left:18px;color:var(--sub);font-size:12.5px;line-height:1.7}
.who.compact .rules{display:none}
.who.compact{margin-bottom:10px}
.who .rules b{color:var(--ink);font-weight:600}

.sec{margin-bottom:6px}
.sechead{display:flex;align-items:baseline;gap:8px;margin:16px 2px 8px}
.sechead h2{font-size:16px;font-weight:700}
.sechead .jp{font-size:11.5px;color:var(--sub)}
.sechead .tm{margin-left:auto;font-size:11.5px;color:var(--sub)}

.blk{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:12px 12px 10px;margin-bottom:12px}
.blkh{display:flex;align-items:baseline;gap:8px;padding:0 2px 8px;border-bottom:1px solid #eef1f0;margin-bottom:10px}
.blkh b{font-size:14px;font-weight:700}
.blkh .jp{font-size:11.5px;color:var(--sub)}
.blkh .au{margin-left:auto;font-size:11px;color:var(--sub)}
.instr{font-size:12.5px;color:var(--sub);line-height:1.6;padding:0 2px 8px}
.instr.clip{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}

/* 聴解播放器 */
.audiobox{position:sticky;top:calc(var(--hh) + 48px);z-index:12;background:#f4faf7;border:1px solid #d6ece4;border-radius:12px;padding:6px 10px 7px;margin:0 0 10px;box-shadow:0 2px 8px rgba(18,63,53,.06)}
.audiobox audio{width:100%;height:32px;display:block}
.audiobox .anote{font-size:11px;color:var(--sub);margin-top:3px;display:flex;gap:10px;flex-wrap:wrap;line-height:1.45}
.audiobox .anote b{color:var(--brand);font-weight:600}

/* 本文 */
.passage{background:#fbfcfb;border:1px solid #e7ece9;border-left:3px solid var(--brand-2);border-radius:10px;padding:12px 13px;margin:2px 0 12px}
.passage .ph{font-size:11px;color:var(--brand);font-weight:700;letter-spacing:.08em;margin-bottom:6px}
.passage .ptext{font-size:calc(var(--fs) * .98);line-height:1.95;white-space:pre-wrap;word-break:break-word}
.passage .ptitle{font-weight:700;margin-bottom:6px}
.passage table{width:100%;border-collapse:collapse;margin-top:8px;font-size:calc(var(--fs) * .86);line-height:1.5}
.passage th,.passage td{border:1px solid #dfe6e2;padding:6px 7px;vertical-align:top;text-align:left}
.passage th{background:#f1f7f4;font-weight:700;white-space:nowrap}
.passage td:first-child{text-align:center;font-weight:700;color:var(--brand)}

/* 题目 */
.q{padding:10px 0 4px}
.q + .q{border-top:1px dashed #e8edea}
.qh{display:flex;align-items:center;gap:8px;margin-bottom:6px}
.qn{
  min-width:28px;height:24px;padding:0 8px;border-radius:7px;background:#eef4f1;color:#155e4e;
  font-size:12.5px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;font-variant-numeric:tabular-nums
}
.q.answered .qn{background:var(--brand);color:#fff}
.stem{font-size:var(--fs);line-height:1.95;white-space:pre-wrap;word-break:break-word;margin-bottom:9px}
.stem b{font-weight:700;background:linear-gradient(transparent 62%, #ffe9a8 62%)}
.stem.long{font-size:calc(var(--fs) * .97)}

.opts{display:flex;flex-direction:column;gap:7px}
.opts.two{display:grid;grid-template-columns:1fr 1fr}
.opt{
  display:flex;align-items:center;gap:9px;width:100%;text-align:left;
  border:1px solid var(--line);background:#fff;border-radius:11px;padding:10px 11px;
  font-size:calc(var(--fs) * .97);line-height:1.55;cursor:pointer;min-height:46px;
  transition:background .12s,border-color .12s,color .12s;
}
.opt i{
  font-style:normal;flex:0 0 24px;height:24px;border-radius:50%;background:#f0f3f2;color:#5b6b66;
  font-size:12.5px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;font-variant-numeric:tabular-nums
}
.opt span{flex:1;min-width:0;white-space:pre-wrap;word-break:break-word}
.opt:active{transform:scale(.995)}
.opt.on{border-color:var(--brand);background:var(--brand-soft);color:#0f4f3f;font-weight:600}
.opt.on i{background:var(--brand);color:#fff}
.opts.num{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.opts.num.three{grid-template-columns:repeat(3,1fr)}
.opts.num .opt{justify-content:center;padding:12px 0;min-height:52px}
.opts.num .opt i{flex:0 0 auto;width:30px;height:30px;font-size:14px;background:#f0f3f2}
.opt:disabled{opacity:.72;cursor:default}

/* 聴解的图 */
.figwrap{margin:2px 0 10px;border:1px solid var(--line);border-radius:11px;overflow:hidden;background:#fff}
.figwrap img{display:block;margin:0 auto;max-width:100%;width:auto;max-height:46vh;height:auto;cursor:zoom-in}
.figwrap .fh{font-size:11px;color:var(--sub);padding:6px 9px;border-bottom:1px solid #f0f3f2;background:#fbfcfb}

/* 底部栏 */
#bar{
  position:fixed;left:0;right:0;bottom:0;z-index:40;
  background:rgba(255,255,255,.97);backdrop-filter:blur(10px);
  border-top:1px solid var(--line);padding:10px 14px calc(10px + env(safe-area-inset-bottom));
  display:flex;align-items:center;gap:12px;
}
#bar .hint{flex:1;font-size:12px;color:var(--sub);line-height:1.4}
button.primary{
  background:var(--brand);color:#fff;border:none;border-radius:12px;
  padding:13px 20px;font-size:15px;font-weight:700;cursor:pointer;min-width:110px;
}
button.primary:disabled{background:#c7cdd8;cursor:default}
button.ghost{background:#fff;border:1px solid var(--line);border-radius:12px;padding:12px 16px;font-size:15px}

.modal{position:fixed;inset:0;z-index:60;background:rgba(17,24,39,.42);display:flex;align-items:center;justify-content:center;padding:20px}
.mbox{background:#fff;border-radius:16px;padding:20px;width:100%;max-width:390px;box-shadow:0 20px 50px rgba(0,0,0,.22)}
.mbox h3{font-size:16px;margin-bottom:10px}
.mbox p{font-size:14px;color:#374151;line-height:1.65}
.mbtns{display:flex;gap:10px;justify-content:flex-end;margin-top:18px}

.lightbox{position:fixed;inset:0;z-index:80;background:rgba(9,15,13,.94);display:flex;align-items:center;justify-content:center;padding:10px}
.lightbox img{max-width:100%;max-height:100%;object-fit:contain;border-radius:6px}

.toast{
  position:fixed;left:50%;bottom:112px;transform:translate(-50%,10px);
  background:rgba(17,24,39,.92);color:#fff;font-size:13px;padding:9px 14px;border-radius:20px;
  opacity:0;pointer-events:none;transition:opacity .18s,transform .18s;z-index:70;max-width:80vw;text-align:center;
}
.toast.on{opacity:1;transform:translate(-50%,0)}

@media (min-width:720px){
  main{max-width:760px;margin:0 auto}
  .opts{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .opts.num{display:grid;grid-template-columns:repeat(4,1fr)}
  .opts.num.three{grid-template-columns:repeat(3,1fr)}
  .stem.long{max-width:100%}
}
