:root {
  --green: #00684a;        /* 青山学院カラー */
  --green-d: #004d37;
  --green-l: #e6f2ee;
  --accent: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --ok: #16a34a;
  --ink: #1a1a1a;
  --muted: #5b6b66;
  --line: #e2e8e5;
  --bg: #f6f8f7;
  --card: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 24px rgba(0,0,0,.05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  font-size: 15.5px;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { line-height: 1.35; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.appbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 11px; color: #fff; }
.brand-mark {
  width: 38px; height: 38px; flex: none; border-radius: 9px;
  background: #fff; color: var(--green);
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
  font-family: serif;
}
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; }
.brand-text small { font-size: 11.5px; opacity: .85; }
.appnav { display: flex; gap: 6px; }
.appnav a {
  color: #fff; padding: 7px 12px; border-radius: 8px; font-size: 13.5px;
  opacity: .9;
}
.appnav a:hover, .appnav a.active { background: rgba(255,255,255,.16); opacity: 1; }

.container { max-width: 1080px; margin: 0 auto; padding: 22px 16px 60px; }
.appfoot { max-width: 1080px; margin: 0 auto; padding: 0 16px 40px; }
.appfoot p { color: var(--muted); font-size: 12px; }

/* ---------- Cards & generic ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 22px; }
.stack > * + * { margin-top: 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 600; padding: 11px 18px; transition: .15s;
  background: #eef2f0; color: var(--ink);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-d); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Hero / Home ---------- */
.hero { text-align: center; padding: 30px 22px; }
.hero h1 { font-size: 26px; margin: 6px 0 4px; }
.hero .sub { color: var(--muted); margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0 4px; }
.chip {
  font-size: 12.5px; padding: 5px 11px; border-radius: 999px;
  background: var(--green-l); color: var(--green-d); font-weight: 600;
}
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 18px; }
.feature { padding: 18px; }
.feature .ico { font-size: 22px; }
.feature h3 { margin: 8px 0 4px; font-size: 15.5px; }
.feature p { margin: 0; font-size: 13px; color: var(--muted); }

.section-pills { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 10px; }
.section-pill { padding: 13px 15px; border-radius: 11px; background: #fff; border: 1px solid var(--line); }
.section-pill b { display: block; font-size: 14px; }
.section-pill span { font-size: 12px; color: var(--muted); }

/* ---------- Exam ---------- */
.exam-head {
  position: sticky; top: 60px; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(246,248,247,.94); backdrop-filter: blur(6px);
  padding: 10px 4px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
}
.progress-wrap { flex: 1; }
.progress-bar { height: 8px; background: #e6ece9; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); width: 0; transition: width .3s; }
.progress-label { font-size: 12px; color: var(--muted); margin-top: 3px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; padding: 6px 12px; border-radius: 9px; background: #fff; border: 1px solid var(--line); }
.timer.warn { color: var(--red); border-color: #f3c4c4; }

.section-block { margin-top: 22px; }
.section-title {
  display: flex; align-items: center; gap: 10px; margin: 0 0 8px;
  font-size: 18px; color: var(--green-d);
}
.section-title .num { background: var(--green); color: #fff; border-radius: 8px; padding: 2px 10px; font-size: 15px; }
.instruction { font-size: 13.5px; color: var(--muted); background: var(--green-l); padding: 11px 14px; border-radius: 10px; }

.passage { font-size: 15px; }
.passage-title { font-weight: 700; color: var(--green-d); margin: 0 0 6px; }
.passage p { margin: 0 0 12px; text-align: justify; }
.passage sup { color: var(--accent); font-weight: 700; font-size: .7em; }
.cloze-blank { display: inline-block; min-width: 34px; text-align: center; font-weight: 800; color: var(--green-d); background: var(--green-l); border-radius: 6px; padding: 0 8px; }
.cloze-blank.filled { background: #d8ece3; }

.glossary { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.glossary summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.glossary ol { margin: 8px 0 0; padding-left: 20px; font-size: 13px; color: var(--muted); }

/* Question */
.q { padding: 16px 18px; scroll-margin-top: 130px; }
.q.unanswered-flag { border-left: 3px solid var(--amber); }
.q-head { display: flex; gap: 10px; align-items: baseline; }
.q-no { flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.q-stem { font-size: 15.5px; font-weight: 500; }
.q-tags { margin: 6px 0 0 40px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef2f0; color: var(--muted); }

.opts { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.opt {
  display: flex; gap: 11px; align-items: flex-start; padding: 11px 14px;
  border: 1.5px solid var(--line); border-radius: 11px; cursor: pointer; transition: .12s;
  background: #fff;
}
.opt:hover { border-color: var(--green); background: var(--green-l); }
.opt.selected { border-color: var(--green); background: var(--green-l); box-shadow: inset 0 0 0 1px var(--green); }
.opt .marker { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.opt.selected .marker { background: var(--green); border-color: var(--green); color: #fff; }
.opt .otext { flex: 1; }

/* error-identification sentence */
.err-sentence { font-size: 15.5px; margin-bottom: 4px; }
.err-u { border-bottom: 2px solid var(--ink); padding: 0 1px; position: relative; white-space: nowrap; }
.err-u sub { font-weight: 700; color: var(--accent); font-size: .72em; }

/* dialogue */
.dialogue { font-size: 15px; }
.dialogue .setup { font-style: italic; color: var(--muted); margin: 0 0 8px; }
.d-line { display: grid; grid-template-columns: 64px 1fr; gap: 8px; margin-bottom: 6px; }
.d-line b { color: var(--green-d); }

.submit-bar { margin-top: 24px; }

/* ---------- Result ---------- */
.score-hero { text-align: center; padding: 26px; }
.score-ring { width: 160px; height: 160px; margin: 6px auto 10px; }
.score-big { font-size: 30px; font-weight: 800; }
.score-sub { color: var(--muted); }
.grade-badge { display: inline-block; padding: 5px 16px; border-radius: 999px; font-weight: 800; font-size: 15px; margin-top: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: 12px; }
.stat { padding: 14px; text-align: center; }
.stat .v { font-size: 22px; font-weight: 800; }
.stat .k { font-size: 12px; color: var(--muted); }

.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .analysis-grid { grid-template-columns: 1fr; } }

.bar-row { display: grid; grid-template-columns: 92px 1fr 54px; align-items: center; gap: 10px; margin: 9px 0; font-size: 13px; }
.bar-track { height: 12px; background: #eef2f0; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .6s; }
.bar-pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-stat { font-size: 12.5px; padding: 5px 11px; border-radius: 999px; font-weight: 600; }

.feedback-box { border-left: 4px solid var(--green); background: var(--green-l); padding: 14px 16px; border-radius: 0 10px 10px 0; }
.feedback-box.warn { border-color: var(--amber); background: #fef3e2; }
.advice-list { margin: 6px 0 0; padding-left: 20px; }
.advice-list li { margin: 5px 0; }

/* ---------- Review ---------- */
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; background: #eef2f0; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.active { background: #fff; color: var(--green-d); box-shadow: var(--shadow); }

.rev-q { padding: 16px 18px; }
.rev-q.correct { border-left: 4px solid var(--ok); }
.rev-q.wrong { border-left: 4px solid var(--red); }
.rev-badge { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.rev-badge.correct { background: #dcfce7; color: #166534; }
.rev-badge.wrong { background: #fee2e2; color: #991b1b; }
.rev-opts { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.rev-opt { display: flex; gap: 9px; padding: 8px 12px; border-radius: 9px; font-size: 14px; border: 1px solid var(--line); }
.rev-opt .m { flex: none; font-weight: 700; }
.rev-opt.ans { background: #ecfdf3; border-color: #b6ebc9; }
.rev-opt.you-wrong { background: #fef2f2; border-color: #f3c4c4; }
.rev-opt .pill { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.rev-opt.ans .pill { background: var(--ok); color: #fff; }
.rev-opt.you-wrong .pill { background: var(--red); color: #fff; }
.exp { margin-top: 11px; background: #f8faf9; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; font-size: 13.5px; }
.exp b { color: var(--green-d); }
.bookmark-btn { border: 0; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; }

/* ---------- History ---------- */
.hist-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 14px 16px; }
.hist-item .date { font-weight: 600; }
.hist-item .meta { font-size: 12.5px; color: var(--muted); }
.hist-score { font-size: 20px; font-weight: 800; }
.trend { height: 60px; }

/* utilities */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); margin: 8px 0; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ico { font-size: 40px; }
.sticky-jump { position: fixed; right: 14px; bottom: 18px; z-index: 40; }
@media (max-width: 560px) {
  .brand-text strong { font-size: 13px; }
  .brand-text small { display: none; }
  .q-tags { margin-left: 0; }
  .pad { padding: 16px; }
}
