/* ===== 二海特ドリル ===== */
:root {
  --navy: #0a3d62;
  --navy-deep: #072f4c;
  --accent: #0b6bcb;
  --accent-soft: #e3f0fc;
  --ok: #1a8a4a;
  --ok-soft: #e2f5e9;
  --ng: #c72c41;
  --ng-soft: #fde8eb;
  --warn: #b8860b;
  --warn-soft: #fdf3d7;
  --bg: #f4f7fa;
  --card: #ffffff;
  --text: #1c2733;
  --text-sub: #5b6b7b;
  --line: #dde5ec;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(10, 61, 98, .08), 0 4px 16px rgba(10, 61, 98, .06);
  --header-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --navy: #0d2f47;
    --navy-deep: #081f30;
    --accent: #4d9fe8;
    --accent-soft: #12314a;
    --ok: #4cc07a;
    --ok-soft: #12331f;
    --ng: #e8637a;
    --ng-soft: #3a1620;
    --warn: #d9b24a;
    --warn-soft: #34290c;
    --bg: #0f1720;
    --card: #182430;
    --text: #e6edf3;
    --text-sub: #94a6b8;
    --line: #2a3b4c;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* ---- Header ---- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-inner {
  max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h); padding: 0 16px;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; }
.top-nav { display: none; gap: 4px; }
.top-nav a {
  color: rgba(255,255,255,.85); text-decoration: none; font-size: .95rem;
  padding: 6px 14px; border-radius: 8px; transition: background .15s;
}
.top-nav a:hover { background: rgba(255,255,255,.12); }
.top-nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }

/* ---- Bottom tab bar (mobile) ---- */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; text-decoration: none;
  color: var(--text-sub); font-size: .68rem;
}
.tab-bar a.active { color: var(--accent); font-weight: 700; }
.tab-icon { font-size: 1.25rem; line-height: 1; }

@media (min-width: 720px) {
  .top-nav { display: flex; }
  .tab-bar { display: none; }
  body { padding-bottom: 40px; }
}

/* ---- Layout ---- */
.view { max-width: 960px; margin: 0 auto; padding: 20px 16px 40px; }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2.section-title { font-size: 1.15rem; margin: 24px 0 12px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--text-sub); font-size: .9rem; }

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--accent) 130%);
  color: #fff; border-radius: var(--radius); padding: 28px 22px; margin-bottom: 20px;
}
.hero h1 { margin: 0 0 6px; font-size: 1.4rem; }
.hero p { opacity: .92; font-size: .92rem; }

/* ---- Flow steps ---- */
.flow { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .flow { grid-template-columns: repeat(3, 1fr); } }
.flow-step {
  display: block; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; text-decoration: none; color: var(--text);
  border: 1px solid transparent; transition: border-color .15s, transform .1s;
  position: relative;
}
.flow-step:hover { border-color: var(--accent); }
.flow-step .step-no {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: .75rem; border-radius: 999px; padding: 2px 10px; margin-bottom: 8px;
}
.flow-step h3 { font-size: 1.05rem; margin-bottom: 4px; }
.flow-step p { font-size: .85rem; color: var(--text-sub); }

/* ---- Stats ---- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 10px; text-align: center;
}
.stat .num { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.stat .label { font-size: .72rem; color: var(--text-sub); }

/* ---- Progress bar ---- */
.pbar { background: var(--line); border-radius: 999px; height: 8px; overflow: hidden; }
.pbar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.pbar.ok > i { background: var(--ok); }

/* ---- Lesson list ---- */
.subject-badge {
  display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 6px;
  padding: 2px 8px; vertical-align: middle;
}
.subject-badge.eng { background: var(--accent-soft); color: var(--accent); }
.subject-badge.law { background: var(--warn-soft); color: var(--warn); }
.subject-badge.guide { background: var(--ok-soft); color: var(--ok); }
.lesson-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px; text-decoration: none; color: var(--text);
  border: 1px solid transparent; transition: border-color .15s;
}
.lesson-item:hover { border-color: var(--accent); }
.lesson-item .no {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem;
}
.lesson-item.done .no { background: var(--ok-soft); color: var(--ok); }
.lesson-item .t { flex: 1; font-weight: 600; font-size: .95rem; }
.lesson-item .check { flex: none; color: var(--ok); font-size: 1.1rem; }

/* ---- Lesson body ---- */
.lesson-body h3 {
  font-size: 1.05rem; margin: 22px 0 10px; padding-left: 10px;
  border-left: 4px solid var(--accent);
}
.lesson-body h3:first-child { margin-top: 0; }
.lesson-body p { margin-bottom: 10px; font-size: .95rem; }
.lesson-body ul, .lesson-body ol { margin: 0 0 12px 1.4em; font-size: .95rem; }
.lesson-body li { margin-bottom: 4px; }
.lesson-body table {
  width: 100%; border-collapse: collapse; margin: 10px 0 14px; font-size: .88rem;
}
.lesson-body th, .lesson-body td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.lesson-body th { background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.lesson-body .table-wrap { overflow-x: auto; }
.keypoint {
  background: var(--accent-soft); border-radius: 10px; padding: 14px 16px; margin: 14px 0;
  font-size: .92rem;
}
.keypoint .kp-title { font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.keypoint ul { margin-bottom: 0; }
.formula {
  background: var(--bg); border: 1px dashed var(--line); border-radius: 10px;
  padding: 10px 14px; margin: 10px 0; font-family: "Hiragino Sans", sans-serif; text-align: center;
}

/* ---- Figures & diagrams ---- */
.fig { margin: 14px 0 18px; text-align: center; }
.fig img {
  max-width: 100%; height: auto; border-radius: 10px;
  border: 1px solid var(--line); background: #fff;
}
.fig figcaption { font-size: .8rem; color: var(--text-sub); margin-top: 6px; }
.dia { max-width: 100%; height: auto; display: block; margin: 4px auto; }
.dia .st  { stroke: var(--text); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dia .st-acc { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linecap: round; }
.dia .st-ng  { stroke: var(--ng); stroke-width: 2; fill: none; stroke-linecap: round; }
.dia .st-thin { stroke: var(--text-sub); stroke-width: 1; fill: none; stroke-dasharray: 4 3; }
.dia .fl  { fill: var(--text); stroke: none; }
.dia .fl-acc { fill: var(--accent); stroke: none; }
.dia .fl-ng { fill: var(--ng); stroke: none; }
.dia .box { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.dia .box-hl { fill: var(--warn-soft); stroke: var(--warn); stroke-width: 2; }
.dia text { fill: var(--text); font-size: 13px; font-family: inherit; }
.dia .tx-sub { fill: var(--text-sub); font-size: 11px; }
.dia .tx-acc { fill: var(--accent); font-weight: 700; }
.dia .tx-ng { fill: var(--ng); font-weight: 700; }

/* ---- Buttons ---- */
.btn {
  display: inline-block; border: none; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .95rem;
  padding: 12px 22px; border-radius: 10px; transition: filter .15s;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: var(--card); color: var(--accent); border: 1.5px solid var(--accent); }
.btn.ghost { background: transparent; color: var(--text-sub); border: 1.5px solid var(--line); }
.btn.ok { background: var(--ok); }
.btn.ng { background: var(--ng); }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn-row .btn { flex: 1; min-width: 140px; }

/* ---- Practice category cards ---- */
.cat-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px; text-decoration: none; color: var(--text);
  border: 1px solid transparent;
}
.cat-card:hover { border-color: var(--accent); }
.cat-card .info { flex: 1; min-width: 0; }
.cat-card .name { font-weight: 600; font-size: .95rem; }
.cat-card .detail { font-size: .78rem; color: var(--text-sub); margin-top: 2px; }
.cat-card .acc { flex: none; text-align: right; font-size: .8rem; color: var(--text-sub); min-width: 64px; }
.cat-card .acc b { display: block; font-size: 1.05rem; color: var(--accent); }

/* ---- Quiz ---- */
.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.quiz-head .count { font-weight: 700; }
.q-text { font-size: 1rem; font-weight: 600; margin-bottom: 16px; white-space: pre-line; }
.q-fig { margin: 0 0 16px; text-align: center; }
.q-fig svg { max-width: 100%; height: auto; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; font-size: .93rem; color: var(--text);
  font-family: inherit; line-height: 1.6; width: 100%;
  transition: border-color .12s, background .12s;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice .cno {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--text-sub); color: var(--text-sub);
  display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700;
}
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.selected .cno { border-color: var(--accent); background: var(--accent); color: #fff; }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.correct .cno { border-color: var(--ok); background: var(--ok); color: #fff; }
.choice.wrong { border-color: var(--ng); background: var(--ng-soft); }
.choice.wrong .cno { border-color: var(--ng); background: var(--ng); color: #fff; }
.choice:disabled { cursor: default; }

.judge { font-size: 1.05rem; font-weight: 700; margin: 16px 0 8px; }
.judge.ok { color: var(--ok); }
.judge.ng { color: var(--ng); }
.expl {
  background: var(--bg); border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0; padding: 12px 14px; font-size: .9rem; margin-bottom: 8px;
}
.expl b.label { color: var(--accent); }

/* ---- Exam ---- */
.exam-bar {
  position: sticky; top: var(--header-h); z-index: 40;
  background: var(--card); border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; margin: -20px -4px 16px;
}
.exam-bar .timer { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.exam-bar .timer.low { color: var(--ng); }
.qnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 16px; }
.qnav button {
  width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--text-sub); font-weight: 600; cursor: pointer; font-size: .8rem;
  font-family: inherit;
}
.qnav button.answered { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.qnav button.current { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.result-banner {
  text-align: center; padding: 26px 16px; border-radius: var(--radius); margin-bottom: 16px;
}
.result-banner.pass { background: var(--ok-soft); color: var(--ok); }
.result-banner.fail { background: var(--ng-soft); color: var(--ng); }
.result-banner .big { font-size: 1.8rem; font-weight: 800; }
.score-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.score-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; text-align: center; }
.score-box .subj { font-size: .8rem; color: var(--text-sub); }
.score-box .pts { font-size: 1.6rem; font-weight: 800; }
.score-box .pts small { font-size: .9rem; font-weight: 600; color: var(--text-sub); }
.score-box .verdict { font-size: .82rem; font-weight: 700; }
.score-box .verdict.ok { color: var(--ok); }
.score-box .verdict.ng { color: var(--ng); }

.review-item { border-top: 1px solid var(--line); padding: 16px 0; }
.review-item .rq { font-weight: 600; font-size: .93rem; margin-bottom: 8px; white-space: pre-line; }
.review-item .rmark { font-weight: 700; }
.review-item .rmark.ok { color: var(--ok); }
.review-item .rmark.ng { color: var(--ng); }
.review-item .rchoice { font-size: .88rem; margin: 2px 0; }

.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .9rem;
}
.history-item .hdate { color: var(--text-sub); font-size: .8rem; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .75rem; font-weight: 700; }
.pill.pass { background: var(--ok-soft); color: var(--ok); }
.pill.fail { background: var(--ng-soft); color: var(--ng); }

.empty { text-align: center; color: var(--text-sub); padding: 30px 10px; font-size: .9rem; }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
