:root{
  --bg:#eef2f8; --card:#ffffff; --ink:#1f2937; --muted:#6b7280;
  --primary:#4f46e5; --primary-d:#4338ca; --accent:#0ea5e9;
  --ok:#16a34a; --ok-bg:#dcfce7; --ng:#dc2626; --ng-bg:#fee2e2;
  --line:#e5e7eb; --chip:#eef2ff; --shadow:0 1px 3px rgba(0,0,0,.08),0 6px 18px rgba(0,0,0,.06);
}
*{box-sizing:border-box}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:system-ui,-apple-system,"Hiragino Kaku Gothic ProN","Noto Sans JP",sans-serif;
  line-height:1.7; -webkit-text-size-adjust:100%;
}
.wrap{max-width:880px; margin:0 auto; padding:16px 16px 96px}
a{color:inherit}
button{font-family:inherit}

/* ---- header ---- */
.hero{
  background:linear-gradient(135deg,var(--primary),#7c3aed); color:#fff;
  border-radius:18px; padding:20px 20px; box-shadow:var(--shadow); margin:4px 0 18px;
}
.hero h1{margin:0 0 4px; font-size:1.25rem; letter-spacing:.02em}
.hero .sub{opacity:.92; font-size:.86rem}
.hero .dates{margin-top:10px; font-size:.82rem; background:rgba(255,255,255,.16); display:inline-block; padding:4px 10px; border-radius:999px}

.crumb{display:flex; align-items:center; gap:8px; margin:2px 0 14px}
.crumb button{
  background:#fff; border:1px solid var(--line); color:var(--primary); font-weight:600;
  padding:8px 14px; border-radius:999px; cursor:pointer; box-shadow:var(--shadow); font-size:.9rem;
}
.crumb button:active{transform:translateY(1px)}
.crumb .here{color:var(--muted); font-size:.9rem}

/* ---- subject grid ---- */
.grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px}
.card{
  background:var(--card); border:1px solid var(--line); border-radius:16px; padding:14px;
  box-shadow:var(--shadow); cursor:pointer; transition:transform .08s, box-shadow .12s; position:relative; overflow:hidden;
}
.card:hover{transform:translateY(-2px)}
.card:active{transform:translateY(0)}
.card .ic{font-size:1.8rem; line-height:1}
.card .nm{font-weight:700; font-size:1.05rem; margin-top:6px}
.card .dt{display:inline-block; font-size:.72rem; color:var(--primary); background:var(--chip); padding:2px 8px; border-radius:999px; margin-top:6px}
.card .sc{font-size:.74rem; color:var(--muted); margin-top:8px; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden}
.card.soon{opacity:.55; cursor:not-allowed}
.card.soon .badge{position:absolute; top:10px; right:10px; font-size:.68rem; background:#f3f4f6; color:var(--muted); padding:2px 8px; border-radius:999px}
.card.ready .badge{position:absolute; top:10px; right:10px; font-size:.68rem; background:var(--ok-bg); color:var(--ok); padding:2px 8px; border-radius:999px; font-weight:700}

/* ---- pattern list ---- */
.scopebox{background:#fff; border:1px solid var(--line); border-left:4px solid var(--accent); border-radius:12px; padding:12px 14px; margin-bottom:16px; font-size:.84rem; color:#374151}
.plist{display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:10px}
.pbtn{
  background:#fff; border:1px solid var(--line); border-radius:14px; padding:14px 10px; cursor:pointer;
  box-shadow:var(--shadow); text-align:center; font-weight:700; font-size:1rem; position:relative;
}
.pbtn:active{transform:translateY(1px)}
.pbtn .mini{display:block; font-size:.7rem; color:var(--muted); font-weight:500; margin-top:4px}
.pbtn .star{position:absolute; top:8px; right:10px; font-size:.72rem}

/* ---- quiz ---- */
.qhead{display:flex; justify-content:space-between; align-items:baseline; margin-bottom:6px}
.qhead h2{margin:0; font-size:1.15rem}
.qhead .meta{font-size:.8rem; color:var(--muted)}
.q{background:#fff; border:1px solid var(--line); border-radius:14px; padding:14px; margin-bottom:12px; box-shadow:var(--shadow)}
.q .tag{display:inline-block; font-size:.7rem; color:var(--primary); background:var(--chip); padding:2px 8px; border-radius:999px; margin-bottom:8px}
.q .num{font-weight:700; margin-right:6px; color:var(--muted)}
.q .prompt{font-size:1.14rem; margin-bottom:12px; line-height:1.75; overflow-wrap:anywhere}
.q input[type=text]{
  width:100%; padding:14px; font-size:1.1rem; min-height:52px; border:1.5px solid var(--line); border-radius:10px; outline:none; background:#fcfcfd;
}
.opts{display:flex; flex-direction:column; gap:9px}
.opt{
  text-align:left; background:#fff; border:1.5px solid var(--line); border-radius:12px;
  padding:14px; font-size:1.06rem; line-height:1.5; min-height:52px; cursor:pointer; width:100%;
}
.opt:active{transform:translateY(1px)}
.opt.sel{border-color:var(--primary); background:var(--chip); font-weight:700}
.opt.opt-correct{border-color:var(--ok); background:var(--ok-bg); font-weight:700}
.opt.opt-wrong{border-color:var(--ng); background:var(--ng-bg)}
.q input:focus{border-color:var(--primary)}
.q.correct{border-color:var(--ok)}
.q.wrong{border-color:var(--ng)}
.verdict{margin-top:10px; font-size:.9rem; padding:10px 12px; border-radius:10px; display:none}
.q.correct .verdict{display:block; background:var(--ok-bg); color:#14532d}
.q.wrong .verdict{display:block; background:var(--ng-bg); color:#7f1d1d}
.verdict .ans{font-weight:700}
.verdict .exp{margin-top:4px; font-size:.86rem; opacity:.95}

/* ---- sticky action bar ---- */
.bar{position:fixed; left:0; right:0; bottom:0; background:rgba(255,255,255,.92); backdrop-filter:blur(8px);
  border-top:1px solid var(--line); padding:10px 16px; display:flex; gap:10px; justify-content:center; z-index:20}
.bar .inner{width:100%; max-width:880px; display:flex; gap:10px}
.btn{flex:1; border:none; border-radius:12px; padding:13px 16px; font-size:1rem; font-weight:700; cursor:pointer; box-shadow:var(--shadow)}
.btn.primary{background:var(--primary); color:#fff}
.btn.primary:active{background:var(--primary-d)}
.btn.ghost{background:#fff; border:1px solid var(--line); color:var(--ink); flex:0 0 auto}
.btn:disabled{opacity:.5}

/* ---- score banner ---- */
.score{display:none; background:#fff; border:2px solid var(--primary); border-radius:16px; padding:16px; margin-bottom:14px; text-align:center; box-shadow:var(--shadow)}
.score.show{display:block}
.score .big{font-size:2rem; font-weight:800; color:var(--primary)}
.score .lbl{color:var(--muted); font-size:.85rem}
.score .msg{margin-top:6px; font-weight:700}

.tip{font-size:.78rem; color:var(--muted); margin:10px 2px}
.foot{text-align:center; color:var(--muted); font-size:.74rem; margin-top:20px}

/* ---- print ---- */
#print-root{display:none}
@media print{
  body{background:#fff}
  #app,.bar{display:none !important}
  #print-root{display:block}
  .pr-sheet{page-break-after:always}
  .pr-h{display:flex; justify-content:space-between; border-bottom:2px solid #000; padding-bottom:6px; margin-bottom:14px}
  .pr-h .t{font-weight:800; font-size:1.1rem}
  .pr-q{margin:0 0 16px; font-size:1rem}
  .pr-q .n{font-weight:700}
  .pr-line{border-bottom:1px solid #999; height:1.4em; margin-top:6px; width:60%}
  .pr-key h3{border-bottom:1px solid #000}
  .pr-key .row{margin:6px 0; font-size:.92rem}
  .pr-key .a{font-weight:700}
  .pr-key .e{color:#333; font-size:.84rem}
}
