/* ===== 経済学入門 試験対策 — スマホ優先スタイル ===== */

:root {
  --bg:      #ffffff;
  --surface: #f6f7f9;
  --fg:      #16181d;
  --muted:   #61656e;
  --line:    #dfe2e7;
  --accent:  #1553c7;
  --accent-fg: #ffffff;

  --ok:      #0f7b3f;  --ok-bg:   #e6f4ea;  --ok-line: #b6dfc4;
  --ng:      #c0271c;  --ng-bg:   #fdecea;  --ng-line: #f2c2bd;
  --miss:    #8a6500;  --miss-bg: #fff6d5;  --miss-line: #e8d38a;
  --skip:    #5f6570;  --skip-bg: #f0f1f3;  --skip-line: #d8dade;

  --radius: 12px;
  --pad: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #14161a;
    --surface: #1d2026;
    --fg:      #eceef2;
    --muted:   #9aa0ac;
    --line:    #2f343d;
    --accent:  #6d9dff;
    --accent-fg: #10131a;

    --ok:      #6fd493;  --ok-bg:   #16301f;  --ok-line: #2c5b3b;
    --ng:      #ff9086;  --ng-bg:   #3a1a17;  --ng-line: #6b2f28;
    --miss:    #e8c46a;  --miss-bg: #33290d;  --miss-line: #5e4c1c;
    --skip:    #9aa0ac;  --skip-bg: #23262c;  --skip-line: #383d46;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic",
               "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* ---------- ヘッダー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 620px; margin: 0 auto;
  padding: 10px var(--pad);
  display: flex; align-items: center; gap: 10px; min-height: 52px;
}
.topbar h1 { font-size: 16px; font-weight: 700; margin: 0; flex: 1; line-height: 1.4; }
.back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; margin-left: -8px; flex: none;
  color: var(--fg); text-decoration: none; font-size: 22px; border-radius: 10px;
}
.back:active { background: var(--surface); }
.counter {
  flex: none; font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- ホーム ---------- */
.hero { padding: 26px 0 18px; }
.hero h2 { font-size: 22px; margin: 0 0 6px; line-height: 1.4; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }

.menu { display: grid; gap: 12px; margin: 4px 0 24px; }
.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card:active { background: var(--line); }
.card .t { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.card .d { color: var(--muted); font-size: 13.5px; margin-top: 4px; line-height: 1.6; }
.card .badge {
  margin-left: auto; font-size: 12px; font-weight: 700;
  background: var(--accent); color: var(--accent-fg);
  border-radius: 999px; padding: 1px 10px; white-space: nowrap;
}
.card.dim { opacity: .5; pointer-events: none; }

.stats {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 20px; font-size: 14px;
}
.stats h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 700; }
.stats .row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.stats .row b { font-variant-numeric: tabular-nums; }

/* ---------- 授業リスト ---------- */
.list { display: grid; gap: 8px; margin: 16px 0 24px; }
.list a {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; min-height: 56px;
}
.list a:active { background: var(--surface); }
.list .no {
  flex: none; font-size: 12px; font-weight: 700; color: var(--muted);
  min-width: 3.4em; font-variant-numeric: tabular-nums;
}
.list .nm { flex: 1; font-size: 15px; line-height: 1.5; }
.list .sc { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 進捗バー ---------- */
.bar { height: 4px; background: var(--line); }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- 1問1答 ---------- */
.qbox { padding: 22px 0 10px; }
.qmeta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.qtext { font-size: 18px; line-height: 1.85; font-weight: 500; margin: 0 0 4px; }

.choices { display: grid; gap: 12px; margin: 22px 0 0; }
.choice {
  width: 100%; min-height: 60px;
  font: inherit; font-size: 17px; font-weight: 700;
  background: var(--bg); color: var(--fg);
  border: 2px solid var(--fg); border-radius: var(--radius);
  cursor: pointer; padding: 12px;
}
.choice:active { background: var(--surface); }
.choice:disabled { cursor: default; opacity: 1; }
.choice.picked-ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.choice.picked-ng { background: var(--ng-bg); border-color: var(--ng); color: var(--ng); }
.choice.reveal    { border-style: dashed; border-color: var(--ok); color: var(--ok); }
.choice.fade      { opacity: .4; }

.verdict {
  margin: 22px 0 0; border-radius: var(--radius);
  border: 1px solid var(--line); padding: 14px 16px;
}
.verdict.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.verdict.ng { background: var(--ng-bg); border-color: var(--ng-line); }
.verdict .head { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.verdict.ok .head { color: var(--ok); }
.verdict.ng .head { color: var(--ng); }
.verdict .body { font-size: 14px; line-height: 1.8; margin-top: 6px; }
.verdict .src { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: 54px; gap: 8px;
  font: inherit; font-size: 16px; font-weight: 700;
  background: var(--accent); color: var(--accent-fg);
  border: 1px solid var(--accent); border-radius: var(--radius);
  cursor: pointer; padding: 10px 16px; text-decoration: none;
}
.btn:active { filter: brightness(.92); }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.ghost:active { background: var(--surface); }
.btn.sm { min-height: 44px; font-size: 14px; }
.btnrow { display: grid; gap: 10px; margin-top: 16px; }
.btnrow.two { grid-template-columns: 1fr 1fr; }

.sticky-foot {
  position: sticky; bottom: 0;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 12px var(--pad) calc(12px + env(safe-area-inset-bottom));
  margin: 24px calc(-1 * var(--pad)) 0;
}

/* ---------- 結果画面 ---------- */
.score { text-align: center; padding: 30px 0 10px; }
.score .big { font-size: 46px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score .sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
.score .pct { font-size: 15px; margin-top: 10px; font-weight: 700; }

.reviewlist { margin: 20px 0 0; display: grid; gap: 10px; }
.reviewitem {
  border: 1px solid var(--line); border-left: 4px solid var(--ng);
  border-radius: 10px; padding: 12px 14px; background: var(--ng-bg);
}
.reviewitem .q { font-size: 14.5px; line-height: 1.7; }
.reviewitem .a { font-size: 13px; font-weight: 700; color: var(--ng); margin-top: 6px; }
.reviewitem .w { font-size: 13px; color: var(--fg); margin-top: 6px; line-height: 1.75; opacity: .9; }

/* ---------- 模擬試験 ---------- */
.section { margin: 26px 0 0; }
.section > h2 {
  font-size: 17px; margin: 0 0 4px;
  padding-bottom: 8px; border-bottom: 2px solid var(--fg);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.section .pick {
  margin-left: auto; font-size: 12px; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.section .pick.done { color: var(--ok); }
.section .pick.over { color: var(--ng); }
.section .instr { font-size: 13.5px; color: var(--muted); margin: 10px 0 14px; }

ol.exam { list-style: none; margin: 0; padding: 0; counter-reset: it; }
ol.exam > li {
  counter-increment: it;
  border: 1px solid var(--line); border-left: 4px solid transparent;
  border-radius: 10px; margin-bottom: 8px; overflow: hidden;
}
ol.exam > li > label {
  display: grid; grid-template-columns: 2.1em 1.5em 1fr; gap: 0 8px;
  align-items: start; padding: 12px 12px 12px 8px; cursor: pointer; min-height: 56px;
}
ol.exam > li > label::before {
  content: "(" counter(it) ")";
  font-size: 12px; color: var(--muted); padding-top: 5px;
  font-variant-numeric: tabular-nums;
}
ol.exam input[type=checkbox] {
  width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent);
}
ol.exam .st { font-size: 15px; line-height: 1.75; }
ol.exam .mk { display: block; font-size: 12.5px; font-weight: 700; margin-top: 6px; }
ol.exam .wy {
  display: none; font-size: 13px; line-height: 1.8;
  padding: 10px 12px; margin: 0 10px 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line);
}
.graded ol.exam .wy { display: block; }
ol.exam .wy .sr { font-size: 11.5px; color: var(--muted); }

li.s-hit   { border-left-color: var(--ok);   background: var(--ok-bg); }
li.s-skip  { border-left-color: var(--skip); background: var(--skip-bg); }
li.s-miss  { border-left-color: var(--miss); background: var(--miss-bg); }
li.s-false { border-left-color: var(--ng);   background: var(--ng-bg); }
li.s-hit   .mk { color: var(--ok); }
li.s-skip  .mk { color: var(--skip); }
li.s-miss  .mk { color: var(--miss); }
li.s-false .mk { color: var(--ng); }

ol.exam.fill > li > label { grid-template-columns: 2.1em 1fr; }
input.blank {
  display: inline-block; width: 5.5em; min-height: 40px;
  font: inherit; font-size: 16px; font-weight: 700; text-align: center;
  color: var(--fg); background: var(--bg);
  border: 1px solid var(--fg); border-radius: 8px;
  padding: 2px 6px; margin: 0 4px; vertical-align: middle;
}
input.blank:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.legend { display: grid; gap: 6px; margin-top: 12px; font-size: 12.5px; }
.legend span { border-radius: 6px; padding: 4px 10px; border: 1px solid; }
.legend .l-hit  { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok); }
.legend .l-skip { background: var(--skip-bg); border-color: var(--skip-line); color: var(--skip); }
.legend .l-miss { background: var(--miss-bg); border-color: var(--miss-line); color: var(--miss); }
.legend .l-fal  { background: var(--ng-bg);   border-color: var(--ng-line);   color: var(--ng); }

.patbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin: 18px 0 0; font-size: 14px;
}
.patbar label { display: flex; align-items: center; gap: 6px; }
.patbar input {
  width: 4.5em; min-height: 40px; font: inherit; font-size: 16px; text-align: center;
  color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
}
.patbar .btn { width: auto; flex: 1; min-width: 8em; }

table.score-t { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.score-t th, table.score-t td {
  border: 1px solid var(--line); padding: 8px 6px; text-align: center;
  font-variant-numeric: tabular-nums;
}
table.score-t th { background: var(--surface); font-size: 13px; }
table.score-t td.tot { font-weight: 800; }

.note { font-size: 13px; color: var(--muted); line-height: 1.8; margin-top: 12px; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.8; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  background: var(--fg); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50;
}
.toast.on { opacity: 1; }

@media (min-width: 560px) {
  .legend { grid-template-columns: 1fr 1fr; }
}
