:root {
  --primary: #1e5b8a;
  --primary-dark: #143f61;
  --accent: #e8830a;
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --text: #26313a;
  --muted: #6b7885;
  --border: #dde3e8;
  --correct: #2a9d5c;
  --wrong: #d64545;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 20px 16px;
  text-align: center;
}
.app-header h1 { margin: 0 0 4px; font-size: 1.3rem; }
.app-sub { margin: 0; font-size: 0.85rem; opacity: 0.85; }

.app-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

.screen { display: none; }
.screen.active { display: block; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; font-size: 1.05rem; }
.card.center { text-align: center; }

.note-card ul { margin: 8px 0 0; padding-left: 20px; font-size: 0.9rem; color: var(--muted); }
.note-card li { margin-bottom: 6px; }

.mode-desc { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }

.source-line-inline {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: bold;
}

.study-answer { border-left: 4px solid var(--primary); }

.grid-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.choice-btn {
  padding: 12px 8px;
  border: 2px solid var(--border);
  background: #fafcfd;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s;
}
.choice-btn:hover { border-color: var(--primary); }
.choice-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: bold;
}
.select-all-btn {
  border-style: dashed;
  font-weight: bold;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  cursor: pointer;
  margin: 4px;
}
.primary-btn:hover:not(:disabled) { background: var(--primary-dark); }
.primary-btn:disabled { background: #b7c3cb; cursor: not-allowed; }
.primary-btn.large { font-size: 1.1rem; padding: 14px 32px; }

.secondary-btn {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.95rem;
  cursor: pointer;
  margin: 4px;
}
.secondary-btn:hover { background: #eef5fa; }

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 8px;
}
.link-btn:hover { color: var(--wrong); }

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.quiz-header h2 { font-size: 1rem; margin: 0; color: var(--primary-dark); }
.progress-badge {
  background: var(--accent);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.overview-box {
  background: #eef5fa;
  border-left: 4px solid var(--primary);
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.92rem;
}
.overview-box.hidden { display: none; }

.schedule-year-label {
  display: inline-block;
  margin: 0 0 8px;
  padding: 2px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: bold;
}

.schedule-title {
  margin: 0 0 8px;
  font-weight: bold;
}

.overview-heading {
  margin: 0 0 4px;
  font-weight: bold;
}

.overview-list {
  margin: 0;
  padding-left: 1.2em;
}
.overview-list li {
  margin-bottom: 2px;
}

.schedule-leadin {
  background: #f5f5f5;
  border-left: 3px solid var(--muted);
  padding: 8px 10px;
  border-radius: 4px;
  margin: 0 0 10px;
  font-size: 0.9rem;
}
.schedule-group-leadin {
  background: #fff3e0;
  border-left-color: var(--accent);
}

.prev-question-box {
  background: #f0f2f4;
  border: 1px dashed var(--muted);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  color: var(--text);
}
.prev-question-box .prev-label {
  margin: 0 0 6px;
  font-weight: bold;
  color: var(--muted);
  font-size: 0.8rem;
}
.prev-question-box p { margin: 4px 0; white-space: pre-wrap; }

.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 14px;
  white-space: pre-wrap;
}
.term { color: var(--primary-dark); font-size: 1.15rem; }

.vocab-label {
  display: inline-block;
  font-weight: bold;
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: 4px;
  margin: 2px 0;
}
.vocab-label-1 { background: #e6f0f8; color: var(--primary-dark); }
.vocab-label-2 { background: #fff3e0; color: #b5650a; }

.source-line {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 4px;
  font-weight: bold;
}
.sub-question {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 12px;
}

.blank-mark, .underline-mark {
  color: var(--accent);
  font-weight: bold;
  border-bottom: 2px solid var(--accent);
}

.answer-input {
  width: 100%;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}
.answer-input:disabled { background: #f0f2f4; }

.btn-row { margin-top: 12px; }
.btn-row.center-row { text-align: center; }

.blank-group { margin-bottom: 16px; }
.blank-group-label {
  font-weight: bold;
  color: var(--primary-dark);
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.choice-list.num-list {
  flex-direction: row;
  margin-bottom: 12px;
}

.choice-option {
  text-align: left;
  padding: 12px 16px;
  border: 2px solid var(--border);
  background: #fafcfd;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}
.choice-option.small {
  flex: 1;
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
}
.choice-option:hover:not(:disabled) { border-color: var(--primary); }
.choice-option:disabled { cursor: default; }
.choice-option.selected { border-color: var(--primary); background: #eef5fa; }
.choice-option.picked-correct { border-color: var(--correct); background: #e6f6ec; font-weight: bold; }
.choice-option.picked-wrong { border-color: var(--wrong); background: #fbe9e9; font-weight: bold; }
.choice-option.show-correct { border-color: var(--correct); background: #e6f6ec; }

.feedback-card { display: none; }
.feedback-card.show { display: block; }
#quiz-feedback:empty { display: none; }

.badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: bold;
  margin-bottom: 10px;
  font-size: 1.05rem;
}
.badge-correct { background: #e6f6ec; color: var(--correct); }
.badge-wrong { background: #fbe9e9; color: var(--wrong); }

.user-answer, .model-answer, .explanation {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.user-answer { background: #f4f6f8; }
.model-answer { background: #eef5fa; }
.explanation { background: #fff8ec; }

.self-judge {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.judge-btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 2px solid var(--border);
  margin-right: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}
.judge-btn.correct { border-color: var(--correct); color: var(--correct); }
.judge-btn.correct:hover { background: #e6f6ec; }
.judge-btn.wrong { border-color: var(--wrong); color: var(--wrong); }
.judge-btn.wrong:hover { background: #fbe9e9; }
.judge-btn:disabled { opacity: 0.4; cursor: default; }

.hidden { display: none !important; }

.result-rate {
  font-size: 2.6rem;
  font-weight: bold;
  color: var(--primary);
  margin: 8px 0;
}
.result-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 16px 0;
}
.dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: #fff;
}
.dot-correct { background: var(--correct); }
.dot-wrong { background: var(--wrong); }

.dashboard-card { background: #fbfdfe; }

.dash-summary {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.dash-stat {
  flex: 1;
  min-width: 100px;
  background: #eef5fa;
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
}
.dash-num { display: block; font-size: 1.4rem; font-weight: bold; color: var(--primary-dark); }
.dash-label { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

.dash-table { font-size: 0.82rem; }
.dash-table th, .dash-table td { text-align: center; padding: 6px 8px; }
.dash-table thead th { background: #f0f2f4; }
.dash-table tbody th { text-align: left; white-space: nowrap; color: var(--muted); }
.dash-none { color: #b7c3cb; }
.dash-lap { color: var(--accent); font-weight: bold; font-size: 0.78rem; }
.dash-note { font-size: 0.78rem; color: var(--muted); margin: 8px 0 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: bold; }
.rate-good { color: var(--correct); font-weight: bold; }
.rate-bad { color: var(--wrong); font-weight: bold; }

/* ---------- 施工経験記述ページ(keiken.html) ---------- */
.keiken-section {
  margin-bottom: 24px;
}
.keiken-section > h2 {
  font-size: 1.1rem;
  color: var(--primary-dark);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 6px;
}
details.acc {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  padding: 10px 14px;
}
details.acc[open] {
  padding-bottom: 14px;
}
details.acc > summary {
  cursor: pointer;
  font-weight: bold;
  padding: 6px 0;
  color: var(--primary-dark);
  list-style: none;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before {
  content: "▶ ";
  color: var(--accent);
}
details.acc[open] > summary::before {
  content: "▼ ";
}
details.acc-sub {
  background: #fafcfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 10px 0;
}
details.acc-sub > summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 0.9rem;
}
.qa-block {
  border-left: 3px solid var(--border);
  padding: 8px 0 8px 12px;
  margin: 12px 0;
}
.qa-block .qa-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: bold;
  margin: 0 0 4px;
}
.qa-block .qa-text {
  margin: 0 0 8px;
  white-space: pre-wrap;
}
.q-part {
  color: var(--primary);
  font-weight: bold;
}
.a-part {
  color: var(--text);
}
.source-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: bold;
  color: #fff;
  background: var(--muted);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.source-tag.book { background: var(--primary); }
.draft-area {
  width: 100%;
  min-height: 70px;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.92rem;
  resize: vertical;
  margin-bottom: 6px;
}
details.answer {
  margin-top: 4px;
}
details.answer > summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: bold;
}
details.answer .answer-body {
  background: #eef5fa;
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 6px;
  font-size: 0.9rem;
  white-space: pre-wrap;
}
.rule-box {
  background: #fff8ec;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 6px;
}
.keiken-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 8px 0 12px;
}
.keiken-table th, .keiken-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  white-space: normal;
  vertical-align: top;
}
.keiken-table th { background: #f0f2f4; }
.back-link {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

.ref-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: zoom-in;
}

.img-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.img-lightbox.open {
  display: flex;
}
.img-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
.img-lightbox-close {
  position: fixed;
  top: 16px;
  right: 24px;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.q-heading {
  display: inline-block;
  background: var(--primary-dark);
  color: #fff;
  font-weight: bold;
  font-size: 0.9rem;
  padding: 3px 12px;
  border-radius: 999px;
  margin: 14px 0 8px;
}
.q-heading:first-child { margin-top: 0; }

.hl {
  color: var(--accent);
  font-weight: bold;
}

.itemAB-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}
.item-col {
  background: #f7fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
}
.item-col-title {
  font-weight: bold;
  color: var(--primary-dark);
  margin: 0 0 6px;
}
.item-col ul { margin: 0; padding-left: 18px; }
.item-col li { margin-bottom: 5px; }
.item-a { border-left: 3px solid var(--primary); }
.item-b { border-left: 3px solid var(--accent); }

.ban-box {
  background: #fdecea;
  border-left: 4px solid var(--wrong);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 0.85rem;
}
.ban-title {
  font-weight: bold;
  color: var(--wrong);
  margin: 0 0 6px;
}
.ban-box ul { margin: 0; padding-left: 18px; }
.ban-box li { margin-bottom: 4px; }

@media (max-width: 480px) {
  .itemAB-grid { grid-template-columns: 1fr; }
}

.keiken-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg);
  padding: 8px 0 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.keiken-tab-btn {
  flex: 1 1 auto;
  padding: 10px 10px;
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}
.keiken-tab-btn:hover { border-color: var(--primary); }
.keiken-tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.keiken-tab-panel { display: none; }
.keiken-tab-panel.active { display: block; }

.keiken-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.keiken-subtab-btn {
  flex: 1 1 auto;
  padding: 8px 8px;
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}
.keiken-subtab-btn:hover { border-color: var(--accent); }
.keiken-subtab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.keiken-subtab-panel { display: none; }
.keiken-subtab-panel.active { display: block; }

@media (max-width: 600px) {
  .keiken-subtab-btn { flex: 1 1 calc(50% - 6px); font-size: 0.75rem; }
}

@media (max-width: 600px) {
  .keiken-tab-btn { flex: 1 1 calc(50% - 6px); font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .app-header h1 { font-size: 1.05rem; }
  .grid-buttons { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); }
  .choice-btn { font-size: 0.85rem; padding: 10px 6px; }
}
