* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:    #1a5c2e;
  --green2:   #236b38;
  --green3:   #2d8047;
  --accent:   #1a5c2e;
  --gold:     #c8a400;
  --bg:       #f5f5f5;
  --white:    #ffffff;
  --border:   #d8dde6;
  --border2:  #e8ece8;
  --text:     #1a1a1a;
  --muted:    #6b7280;
  --correct:  #166534;
  --wrong:    #991b1b;
  --correct-bg: #f0fdf4;
  --wrong-bg:   #fef2f2;
}

body {
  font-family: 'Hiragino Kaku Gothic Pro', 'Yu Gothic UI', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.75;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
header {
  background: var(--green);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.header-inner {
  display: flex; align-items: center;
  max-width: 1100px; margin: 0 auto; padding: 0 24px;
  height: 52px; gap: 0;
}
.header-logo {
  font-size: 15px; font-weight: 700;
  color: #fff; letter-spacing: 0.02em;
  margin-right: 40px; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.header-logo-mark {
  background: var(--gold);
  color: var(--green);
  font-weight: 900; font-size: 13px;
  padding: 2px 8px; border-radius: 3px;
  letter-spacing: 0;
}
header nav { display: flex; height: 100%; }
header nav a {
  display: flex; align-items: center;
  font-size: 13px; color: rgba(255,255,255,0.85);
  padding: 0 18px; height: 100%;
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
}
header nav a:hover {
  color: #fff; background: rgba(255,255,255,0.1);
  text-decoration: none; border-bottom-color: var(--gold);
}

/* ===== Layout ===== */
.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }
main { padding: 28px 0 80px; }

/* ===== Page title ===== */
.page-title {
  font-size: 18px; font-weight: 700;
  color: var(--green); margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--green);
}

/* ===== Section title ===== */
.section-title {
  font-size: 11px; font-weight: 700;
  color: var(--muted); letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 28px 0 12px;
  padding-left: 8px;
  border-left: 3px solid var(--green);
}

/* ===== Stat boxes ===== */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 3px solid var(--green);
  border-radius: 4px;
  padding: 16px 24px;
  min-width: 130px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-box .num { font-size: 30px; font-weight: 700; color: var(--green); }
.stat-box .label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat-box.alert .num { color: var(--wrong); }
.stat-box.alert { border-top-color: var(--wrong); }

/* ===== Subject grid ===== */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.subject-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px; padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.subject-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
}
.subject-name {
  font-size: 16px; font-weight: 700; color: var(--text);
}
.subject-rate { font-size: 20px; font-weight: 700; }
.rate-good { color: var(--correct); }
.rate-ok   { color: #b45309; }
.rate-bad  { color: var(--wrong); }
.rate-none { color: var(--muted); font-size: 16px; }

.progress-bar {
  height: 6px; background: #e5e7eb;
  border-radius: 3px; margin-bottom: 8px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--green);
  border-radius: 3px; transition: width 0.4s;
}
.subject-meta { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

.subject-actions {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: 3px; border: none;
  cursor: pointer; font-size: 13px;
  font-family: inherit; font-weight: 600;
  transition: all 0.15s; white-space: nowrap; text-align: center;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-primary { background: var(--green); color: #fff; }
.btn-gold    { background: var(--gold); color: #fff; }
.btn-ghost   {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: #f3f4f6; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
}
.btn-outline:hover { background: var(--green); color: #fff; }
.btn-correct { background: #15803d; color: #fff; }
.btn-wrong   { background: #dc2626; color: #fff; }
.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: 4px; font-weight: 700; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 4px; padding: 12px 16px;
  margin-bottom: 24px;
}

/* ===== Tags ===== */
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 3px;
  font-size: 11px; font-weight: 600;
}
.tag-important { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.tag-precedent { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.tag-heavy     { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.tag-hundred   { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* ===== Quiz screen ===== */
.quiz-breadcrumb {
  font-size: 12px; color: var(--muted);
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.quiz-breadcrumb .subj-badge {
  background: var(--green); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 2px;
}
.quiz-breadcrumb .sep { color: #ccc; }

.progress-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.progress-label { font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 60px; }
.session-bar-wrap {
  flex: 1; background: #e5e7eb; border-radius: 3px; height: 8px; overflow: hidden;
}
.session-bar {
  height: 100%; background: var(--green);
  border-radius: 3px; transition: width 0.3s;
}

.question-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 5px solid var(--green);
  border-radius: 4px;
  padding: 24px 28px;
  font-size: 16px; line-height: 2.0;
  margin-bottom: 28px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  min-height: 100px;
}

.answer-btns {
  display: flex; gap: 12px; margin-bottom: 16px;
}
.answer-btns .btn {
  flex: 1; font-size: 18px; padding: 20px;
  font-weight: 700; border-radius: 4px;
}
.answer-btns .btn-correct { background: #16a34a; }
.answer-btns .btn-correct:hover { background: #15803d; }
.answer-btns .btn-wrong   { background: #dc2626; }
.answer-btns .btn-wrong:hover   { background: #b91c1c; }

/* ===== Result ===== */
.result-banner {
  border-radius: 4px; padding: 16px 24px;
  font-size: 20px; font-weight: 700;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
.result-banner.correct {
  background: var(--correct-bg);
  color: var(--correct);
  border: 1px solid #bbf7d0;
}
.result-banner.wrong {
  background: var(--wrong-bg);
  color: var(--wrong);
  border: 1px solid #fecaca;
}

.answer-compare {
  display: flex; gap: 32px;
  padding: 14px 0; border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 16px 0;
}
.answer-compare .col { display: flex; flex-direction: column; gap: 4px; }
.answer-compare .col-label { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: 0.05em; }
.answer-compare .col-val { font-size: 17px; font-weight: 700; }

.next-review { font-size: 11px; color: var(--muted); margin-bottom: 16px; }

.commentary-header {
  font-size: 11px; font-weight: 700; color: var(--green);
  letter-spacing: 0.06em; margin-bottom: 8px;
  padding: 6px 12px;
  background: #f0fdf4; border-bottom: 1px solid #bbf7d0;
  border-radius: 4px 4px 0 0;
}
.commentary-box {
  background: #fafffe;
  border: 1px solid #bbf7d0;
  border-top: none;
  border-radius: 0 0 4px 4px;
  padding: 14px 16px;
  font-size: 13px; line-height: 1.85;
  white-space: pre-wrap;
}

/* ===== Summary ===== */
.summary-rate-box {
  text-align: center; padding: 48px;
  background: var(--white); border: 1px solid var(--border);
  border-top: 4px solid var(--green);
  border-radius: 4px; margin-bottom: 20px;
}
.summary-rate { font-size: 80px; font-weight: 700; line-height: 1; }
.summary-sub  { font-size: 15px; color: var(--muted); margin-top: 10px; }

/* ===== Set mode ===== */
.set-instruction {
  background: #f0fdf4; border: 1px solid #bbf7d0;
  border-left: 4px solid var(--green);
  border-radius: 4px; padding: 12px 18px;
  font-size: 13px; margin-bottom: 20px; color: var(--green);
  font-weight: 600;
}
.set-item {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 4px; padding: 20px 22px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.set-label-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  background: var(--green); color: #fff;
  font-size: 15px; font-weight: 700; border-radius: 50%;
  margin-bottom: 12px;
}
.set-question {
  font-size: 15px; line-height: 1.9; margin-bottom: 14px;
}
.radio-row { display: flex; gap: 10px; }
.radio-row label {
  flex: 1; text-align: center; padding: 12px;
  border: 2px solid var(--border); border-radius: 4px;
  cursor: pointer; font-size: 15px; font-weight: 700;
  color: var(--muted); transition: all 0.15s; user-select: none;
}
.radio-row input[type=radio] { display: none; }
.radio-row input[type=radio]:checked + label {
  border-color: var(--green); background: #f0fdf4; color: var(--green);
}

/* ===== Set result ===== */
.combo-box {
  background: var(--white); border: 1px solid var(--border);
  border-top: 3px solid var(--green);
  border-radius: 4px; padding: 18px 24px;
  margin-bottom: 16px; display: flex; gap: 40px;
}
.combo-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.combo-value { font-size: 24px; font-weight: 700; color: var(--green); }
.combo-user-correct { color: var(--correct); }
.combo-user-wrong   { color: var(--wrong); }

.set-result-item {
  border: 1px solid var(--border); border-radius: 4px;
  padding: 16px 20px; margin-bottom: 10px;
  background: var(--white);
}
.set-result-item.correct { border-left: 4px solid #16a34a; background: var(--correct-bg); }
.set-result-item.wrong   { border-left: 4px solid #dc2626; background: var(--wrong-bg); }
.set-result-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}

/* ===== Cards ===== */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 4px; padding: 20px 24px;
  margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* ===== Bottom Nav (mobile only) ===== */
.bottom-nav { display: none; }

/* ===== PC Nav ===== */
.pc-nav { display: flex; height: 100%; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  /* ヘッダー */
  .pc-nav { display: none; }
  .header-inner { padding: 0 16px; height: 48px; }
  .header-logo-text { display: none; }

  /* ボトムナビ */
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  }
  .bottom-nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 8px 0; gap: 2px;
    color: var(--muted); text-decoration: none;
    font-size: 10px;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-item:hover, .bottom-nav-item:active {
    color: var(--green); text-decoration: none;
    background: #f0fdf4;
  }
  .bottom-nav-icon { font-size: 20px; line-height: 1; }
  .bottom-nav-label { font-size: 10px; }

  /* コンテナ・余白 */
  .container { padding: 0 0; }
  main { padding: 16px 0 80px; }

  /* ページタイトル */
  .page-title { font-size: 16px; margin: 0 16px 16px; }
  .section-title { margin: 20px 16px 10px; }

  /* stat boxes */
  .stat-row { gap: 8px; margin: 0 16px 20px; }
  .stat-box { padding: 12px 16px; min-width: 0; flex: 1; }
  .stat-box .num { font-size: 24px; }

  /* 科目グリッド → 縦1列 */
  .subject-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .subject-card {
    border-radius: 0;
    border-left: none; border-right: none;
    border-bottom: none;
    padding: 16px;
    box-shadow: none;
  }
  .subject-card:first-child { border-top: none; }
  .subject-card-header { margin-bottom: 10px; }
  .subject-name { font-size: 15px; }
  .subject-rate { font-size: 18px; }
  .subject-actions {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .btn-full { padding: 10px 8px; font-size: 12px; }

  /* フィルターバー */
  .filter-bar { margin: 0 16px 20px; padding: 10px 12px; gap: 6px; }
  .filter-bar .btn { font-size: 12px; padding: 6px 10px; }

  /* 直前期モード */
  .exam-countdown-row { padding: 0 16px; }

  /* ===== クイズ画面（メイン改良） ===== */
  .progress-row { margin: 0 16px 12px; gap: 8px; }
  .progress-label { font-size: 11px; min-width: 50px; }

  .quiz-breadcrumb { margin: 0 16px 8px; font-size: 11px; }

  /* 問題文: 画面の大半を占める */
  .question-box {
    margin: 0 0 0 0;
    border-left: none; border-right: none; border-radius: 0;
    padding: 20px 16px;
    font-size: 15px; line-height: 1.9;
    min-height: calc(100vh - 260px);
    box-shadow: none;
  }

  /* ○/× ボタン: 画面下部に固定・大きく */
  form { position: fixed; bottom: 56px; left: 0; right: 0; z-index: 100; }
  .answer-btns {
    display: flex; gap: 0; margin: 0;
    border-top: 2px solid var(--border);
  }
  .answer-btns .btn {
    flex: 1; font-size: 22px; font-weight: 700;
    padding: 22px 16px; border-radius: 0;
    border: none;
  }
  .answer-btns .btn-correct { background: #16a34a; }
  .answer-btns .btn-wrong   { background: #dc2626; }

  /* 結果画面 */
  .result-banner {
    border-radius: 0; margin: 0 0 16px;
    font-size: 18px; padding: 14px 16px;
  }
  .card {
    border-radius: 0; border-left: none; border-right: none;
    padding: 16px; box-shadow: none;
  }
  .answer-compare { gap: 20px; }
  .answer-compare .col-val { font-size: 16px; }
  .commentary-box { font-size: 13px; padding: 12px 14px; }

  /* ボタン行 */
  .btn-row { padding: 0 16px; gap: 8px; }
  .btn-row .btn-lg { font-size: 14px; padding: 12px 20px; }
  .btn-lg { font-size: 14px; padding: 12px 20px; }

  /* サマリー */
  .summary-rate-box { padding: 32px 16px; }
  .summary-rate { font-size: 60px; }

  /* 科目詳細 */
  .section-title + div { padding: 0; }

  /* combo box (5肢択一) */
  .combo-box { flex-direction: column; gap: 12px; padding: 14px 16px; }
  .set-item { border-radius: 0; border-left: none; border-right: none; margin-bottom: 0; border-bottom: none; }
  .radio-row label { padding: 14px 8px; font-size: 16px; }
}
