:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #eef3f7;
  --line: #d8e0e8;
  --text: #1d2733;
  --muted: #617081;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b42318;
  --ok: #15803d;
  font-family:
    Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.status-dot::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 999px;
  background: #c084fc;
}

.status-dot.ok::before {
  background: var(--ok);
}

.status-dot.error::before {
  background: var(--danger);
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.layout.single {
  grid-template-columns: minmax(0, 1fr);
}

.side-nav {
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #f8fafc;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.nav-item.active {
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
  font-weight: 700;
}

.workspace {
  padding: 22px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-top: 22px;
  margin-bottom: 12px;
}

.section-block {
  margin-top: 22px;
}

.toolbar,
.submission-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.toolbar {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 2fr) auto;
  align-items: end;
  margin-bottom: 16px;
}

.toolbar.user-toolbar {
  grid-template-columns: repeat(5, minmax(150px, 1fr)) auto;
}

.toolbar.customer-toolbar {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.toolbar.customer-toolbar button[type="submit"] {
  min-width: 110px;
}

.toolbar.audit-toolbar {
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
}

.toolbar.overview-toolbar {
  grid-template-columns: minmax(220px, 2fr) auto auto;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

select {
  min-height: 38px;
}

textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.6;
}

button[type="submit"],
.action-button,
.icon-button,
.auth-button {
  min-height: 38px;
  border: 1px solid #0f766e;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.action-button.secondary,
.auth-button.secondary {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.action-button.danger {
  border-color: var(--danger);
  background: #fff;
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 160px;
  gap: 12px;
}

.compact-form {
  margin-bottom: 18px;
}

.authoring-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.authoring-panel h4 {
  margin: 0;
  font-size: 15px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.compact-stack {
  margin-top: 4px;
}

.check-label,
.choice-label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.check-label input,
.choice-label input {
  width: auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric-card,
.dashboard-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.dashboard-detail {
  grid-column: span 2;
}

.question-draft textarea {
  min-height: 88px;
}

/* 知識問題は1問ずつ読ませる画面なので、可読性そのものが機能要件。実技課題のフォーム部品と
   同じ字送りだと選択肢が小さすぎて読めないため、この中だけ本文サイズを一段上げる。
   display:block なのは legend の float（下記）を確実に効かせるため。grid にすると
   legend が grid item 化して float が無効になり、ブラウザ差が出る。 */
.knowledge-question {
  display: block;
  /* 1行が長すぎると視線が戻れなくなるので行長を制限する。 */
  max-width: 760px;
  /* fieldset の既定 min-width は min-content。狭い画面で横スクロールが出るので解除する。 */
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
  /* カンニング対策: 問題文・選択肢テキストのドラッグ選択によるコピーを抑止する（Issue #2）。
     DevTools 等では回避可能な軽い対策。ラジオボタンの操作は阻害しない。 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* display 指定は [hidden] のUA既定(display:none)より強いので、非表示の問は明示的に隠す。 */
.knowledge-question[hidden] {
  display: none;
}

/* float + width:100% で legend を通常のブロックとして流す。そのままだと問題文が2行以上に
   なったとき、rendered legend の仕様で2行目が fieldset の枠線を横切ってしまう。 */
.knowledge-question legend {
  float: left;
  width: 100%;
  margin-bottom: 14px;
  padding: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.65;
  color: var(--text);
}

/* グローバルの label（12px・グレー・太字）は入力フォーム用。選択肢に効くと読めないので
   ここで本文として読める字面に上書きする。 */
.knowledge-question .choice-label {
  align-items: flex-start;
  margin-top: 10px;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  cursor: pointer;
}

.knowledge-question .choice-label:hover {
  border-color: var(--accent);
  background: #f0fdfa;
}

/* 選んだ選択肢が一目で分かるようにする（:has 非対応環境でもラジオ自体で判別できる）。 */
.knowledge-question .choice-label:has(input:checked) {
  border-color: var(--accent);
  background: #e6fffb;
}

.knowledge-question .choice-label input[type="radio"] {
  width: 20px;
  height: 20px;
  /* 選択肢が折り返しても1行目の中心に留まるように、行の高さぶんだけ下げる。 */
  margin-top: 3px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}

/* 知識テストのウィザード操作バー（前へ / 進捗 / 次へ）。 */
.knowledge-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 760px;
  margin-top: 16px;
}

.knowledge-nav .knowledge-progress {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted, #64748b);
}


.knowledge-nav .action-button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 15px;
}

.knowledge-nav .action-button[hidden] {
  display: none;
}

.help-result {
  margin-top: 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  padding: 12px;
}

.help-result p {
  white-space: pre-wrap;
}

.subheading {
  margin-top: 18px;
}

.stack {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.compact-item {
  padding: 12px;
}

.item-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-weight: 700;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 700;
}

.badge.scored {
  background: #dcfce7;
  color: #166534;
}

/* 採点失敗は「採点中」と別の色で出す。同じ見た目だと待てば終わると誤解される。 */
.badge.failed {
  background: #fee2e2;
  color: #b91c1c;
}

.meta .muted,
.meta.muted {
  color: var(--muted);
}

.result-panel {
  margin-top: 16px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  padding: 16px;
}

.candidate-progress {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.candidate-progress li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.candidate-progress li.active,
.candidate-progress li.complete {
  border-color: #99f6e4;
  background: #f0fdfa;
  color: var(--accent);
}

.candidate-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.7fr);
  gap: 18px;
  align-items: start;
}

.task-card,
.artifact-section,
.candidate-side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}

.task-card h3,
.artifact-section h3 {
  margin-bottom: 8px;
}

.task-card p {
  white-space: pre-wrap;
}

.candidate-side-panel {
  position: sticky;
  top: 18px;
  background: var(--panel);
}

.candidate-side-panel ul {
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.candidate-help {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.candidate-help textarea {
  min-height: 84px;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.artifact-dropzone {
  min-height: 140px;
  display: grid;
  place-content: center;
  gap: 8px;
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.artifact-dropzone.dragging {
  border-color: var(--accent);
  background: #f0fdfa;
}

.selected-artifact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #99f6e4;
  border-radius: 6px;
  background: #f0fdfa;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-content: center;
  padding: 32px;
  text-align: center;
  background:
    radial-gradient(circle at top left, rgba(63, 81, 181, 0.14), transparent 36%),
    var(--bg);
}

.auth-gate[hidden] {
  display: none;
}

.auth-gate-card {
  width: min(680px, calc(100vw - 48px));
  padding: clamp(28px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(25, 35, 70, 0.12);
}

.auth-gate-actions,
.admin-consent-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.auth-link-button {
  padding: 8px;
  border: 0;
  color: var(--accent);
  background: transparent;
  text-decoration: underline;
  cursor: pointer;
}

.admin-consent-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.admin-consent-panel[hidden] {
  display: none;
}

.admin-consent-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 28px;
  font-weight: 800;
}

.admin-consent-panel h2,
.admin-consent-panel p {
  margin: 0;
}

.admin-consent-link {
  display: inline-block;
  text-decoration: none;
}

.admin-consent-help {
  max-width: 560px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 14px;
}

.admin-consent-url {
  max-width: 100%;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  text-align: left;
  font-size: 12px;
}

@media (max-width: 820px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-item {
    min-width: 150px;
  }

  .toolbar,
  .split,
  .field-grid,
  .candidate-layout,
  .candidate-progress {
    grid-template-columns: 1fr;
  }

  .candidate-side-panel {
    position: static;
  }
}

.identity-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
}

.identity-label {
  font-size: 12px;
  color: var(--muted);
}

.rubric-result {
  list-style: none;
  margin: 6px 0 10px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.rubric-result li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rubric-result li[data-rubric-passed='true'] .rubric-mark {
  color: var(--ok);
}

.rubric-result li[data-rubric-passed='false'] .rubric-mark {
  color: var(--danger);
}

.rubric-mark {
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.task-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.task-card-head h3 {
  margin: 0;
}

.task-summary {
  margin: 8px 0 4px;
  font-weight: 600;
}

.task-prompt {
  margin: 0 0 12px;
  white-space: pre-wrap;
}

.task-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 16px;
  margin: 0;
}

.task-facts div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-facts dt {
  font-size: 12px;
  color: var(--muted);
}

.task-facts dd {
  margin: 0;
  font-weight: 600;
}

.knowledge-question.unanswered {
  border-color: var(--danger);
  background: #fef3f2;
}

.history-item .rubric-result.compact {
  gap: 2px;
  font-size: 13px;
}

.candidate-side-panel #candidateHistory {
  max-height: 320px;
  overflow-y: auto;
}

/* ─── 受験者：タブナビ（管理系 .side-nav は使わない専用実装） ─────────────── */
.candidate-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.candidate-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 16px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  min-height: 42px;
}

.candidate-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* 管理者だけに出る導線。受験タブと同列に並べつつ、別画面へ出ることが分かる見た目にする */
.candidate-tab.console-link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--accent);
}

.candidate-tab.console-link[hidden] {
  display: none;
}

.candidate-view {
  display: none;
}

.candidate-view.active {
  display: block;
}

/* 進め方：クリックできる「タブ」と誤認されないよう、軽い案内表示にする */
.candidate-guide {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.candidate-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 4px;
  align-items: center;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.candidate-progress li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.candidate-progress li:not(:last-child)::after {
  content: "›";
  margin-left: 8px;
  color: var(--line);
}

.candidate-progress li.active,
.candidate-progress li.complete {
  background: #f0fdfa;
  color: var(--accent);
}

/* 折りたたみ（チェックリスト・AIヘルプ） */
.collapsible {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 6px 12px;
}

.collapsible > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  padding: 6px 0;
}

.collapsible[open] {
  padding-bottom: 12px;
}

.collapsible ul {
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

/* ─── マイページ：最新結果ハイライト ─────────────────────────────── */
.latest-highlight {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  background: linear-gradient(180deg, #f0fdfa, #ffffff);
}

.latest-score {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.latest-score-value {
  font-size: 52px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}

.latest-score-unit {
  font-size: 18px;
  color: var(--muted);
}

.latest-level {
  margin-left: 8px;
  align-self: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 13px;
  font-weight: 700;
}

.latest-meta strong {
  font-size: 16px;
}

.delta {
  display: inline-block;
  margin-left: 10px;
  font-size: 13px;
  font-weight: 700;
}

.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.delta.neutral { color: var(--muted); }

/* ─── マイページ：スコア推移グラフ ─────────────────────────────── */
.score-chart svg {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.chart-grid { stroke: #eef2f6; stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 10px; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.chart-value { fill: var(--muted); font-size: 11px; font-weight: 700; }

/* 履歴カードをクリック可能に */
.history-item.clickable { cursor: pointer; transition: border-color 120ms ease, box-shadow 120ms ease; }
.history-item.clickable:hover { border-color: #99f6e4; box-shadow: 0 2px 8px rgba(15, 118, 110, 0.08); }
.history-open-hint { margin-top: 6px; color: var(--accent); font-size: 12px; }

/* ─── 採点結果オーバーレイ ─────────────────────────────────────── */
.result-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.5);
  z-index: 50;
}

.result-dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.result-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.result-body { margin: 8px 0 16px; }

.result-body > strong:first-child {
  display: block;
  font-size: 26px;
  margin-bottom: 6px;
}

.result-body h4 {
  margin: 14px 0 8px;
  font-size: 14px;
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 820px) {
  .latest-highlight {
    grid-template-columns: 1fr;
    text-align: left;
  }
}

/* ─── 課題カタログ（selectの置き換え） ─────────────────────────── */
.challenge-catalog {
  display: grid;
  gap: 28px;
  margin-bottom: 18px;
}

/* 実技と知識は別のテスト種別。色だけに頼らず、枠・太い上辺・余白でも領域を分ける。 */
.catalog-group {
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--catalog-accent);
  border-radius: 12px;
  background: var(--catalog-background);
}

.catalog-group--practical {
  --catalog-accent: var(--accent);
  --catalog-background: #f0fdfa;
}

.catalog-group--knowledge {
  --catalog-accent: #6d28d9;
  --catalog-background: #faf5ff;
}

.catalog-group h3 {
  margin-bottom: 14px;
  font-size: 20px;
  line-height: 1.35;
}

.catalog-group h3 .meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.challenge-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.challenge-card {
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 14px;
  min-height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 400;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.challenge-card-group {
  display: grid;
  gap: 0.55rem;
}

.challenge-card-group .challenge-card {
  width: 100%;
}

.certification-button {
  width: 100%;
  background: linear-gradient(135deg, #6d28d9, #4338ca);
  border-color: #8b5cf6;
}

.badge.certification {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #5b21b6;
}

.verification-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #8b5cf6;
  border-radius: 0.75rem;
  background: #f5f3ff;
}

.verification-panel form {
  display: grid;
  gap: 1rem;
}

.certification-status {
  padding: 0.85rem 1rem;
  border-radius: 0.65rem;
  background: #ede9fe;
  color: #4c1d95;
}

.challenge-card:hover { border-color: #99f6e4; box-shadow: 0 2px 8px rgba(15, 118, 110, 0.08); }

.challenge-card.selected {
  border-color: var(--accent);
  background: #f0fdfa;
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.challenge-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.challenge-card-title { font-size: 15px; font-weight: 700; line-height: 1.4; }

.badge.muted { background: #eef2f6; color: var(--muted); }
.badge.difficulty { background: #eef2ff; color: #3730a3; }
.badge.difficulty.diff-1 { background: #ecfdf5; color: #047857; }
.badge.difficulty.diff-2 { background: #fef9c3; color: #854d0e; }
.badge.difficulty.diff-3 { background: #fee2e2; color: #b91c1c; }

/* ─── ゲーミフィケーション：チャレンジ・アリーナ ───────────────────── */
/* 挑戦モード中はタブを隠して没入させる */
#appRoot.immersive .candidate-tabs { display: none; }

.stage-select { animation: fade-in 200ms ease; }

.stage-arena { animation: pop-in 320ms cubic-bezier(0.18, 0.9, 0.3, 1.2); }

@keyframes pop-in {
  0% { opacity: 0; transform: translateY(10px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.arena-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #0f766e08, var(--panel));
}

.arena-stage { display: flex; align-items: center; gap: 10px; min-width: 0; }
.arena-stage strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* タイマー */
.challenge-timer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  padding: 4px 12px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  min-width: 96px;
}
.challenge-timer .timer-label { font-size: 10px; color: #94a3b8; letter-spacing: 0.04em; }
.challenge-timer .timer-value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.challenge-timer.low { background: #7c2d12; animation: timer-pulse 1s ease-in-out infinite; }
.challenge-timer.overtime { background: var(--danger); }
@keyframes timer-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ステージカードの「挑戦」CTA */
.challenge-card .challenge-cta {
  margin-top: 4px;
  font-weight: 800;
  color: var(--accent);
  font-size: 13px;
}
.challenge-card:hover .challenge-cta { text-decoration: underline; }

/* ─── 採点結果の演出（ババーン／ハイスコア） ─────────────────────── */
.result-dialog { overflow: hidden; }

.celebrate-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 800;
  animation: banner-pop 420ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.celebrate-banner.highscore { background: linear-gradient(90deg, #fde68a, #fca5a5); color: #7c2d12; }
.celebrate-banner.clear { background: #dcfce7; color: #166534; }
.celebrate-banner.miss { background: #eef2f6; color: var(--muted); }
@keyframes banner-pop { 0% { opacity: 0; transform: scale(0.6); } 60% { transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }

.result-score-hero { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 8px; }
.result-score-big {
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  color: var(--accent);
  animation: score-punch 500ms cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.result-score-unit { font-size: 20px; color: var(--muted); }
.result-score-level { align-self: center; margin-left: 6px; padding: 3px 12px; border-radius: 999px; background: #dcfce7; color: #166534; font-weight: 700; }
.result-prev { margin: 0 0 8px; }
@keyframes score-punch { 0% { opacity: 0; transform: scale(0.4); } 55% { transform: scale(1.15); } 100% { opacity: 1; transform: scale(1); } }

/* コンフェッティ（JSで紙片を生成、CSSで落下） */
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
.confetti-piece {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: #0f766e;
  opacity: 0.9;
  animation: confetti-fall 1600ms ease-in 0ms forwards;
}
.confetti-piece:nth-child(10n + 1) { left: 4%; animation-duration: 1250ms; animation-delay: 20ms; background: #0f766e; --spin: 540deg; }
.confetti-piece:nth-child(10n + 2) { left: 14%; animation-duration: 1700ms; animation-delay: 180ms; background: #2563eb; --spin: -720deg; }
.confetti-piece:nth-child(10n + 3) { left: 24%; animation-duration: 2100ms; animation-delay: 80ms; background: #f59e0b; --spin: 900deg; }
.confetti-piece:nth-child(10n + 4) { left: 34%; animation-duration: 1450ms; animation-delay: 300ms; background: #ef4444; --spin: -540deg; }
.confetti-piece:nth-child(10n + 5) { left: 44%; animation-duration: 2350ms; animation-delay: 120ms; background: #10b981; --spin: 720deg; }
.confetti-piece:nth-child(10n + 6) { left: 54%; animation-duration: 1550ms; animation-delay: 240ms; background: #a855f7; --spin: -900deg; }
.confetti-piece:nth-child(10n + 7) { left: 64%; animation-duration: 1950ms; animation-delay: 40ms; background: #2563eb; --spin: 540deg; }
.confetti-piece:nth-child(10n + 8) { left: 74%; animation-duration: 2250ms; animation-delay: 340ms; background: #f59e0b; --spin: -720deg; }
.confetti-piece:nth-child(10n + 9) { left: 84%; animation-duration: 1350ms; animation-delay: 150ms; background: #ef4444; --spin: 900deg; }
.confetti-piece:nth-child(10n) { left: 94%; animation-duration: 1850ms; animation-delay: 260ms; background: #10b981; --spin: -540deg; }
@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(560px) rotate(var(--spin, 360deg)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-arena, .celebrate-banner, .result-score-big, .confetti-piece, .challenge-timer.low { animation: none !important; }
  .confetti { display: none; }
}

@media (max-width: 820px) {
  .arena-topbar { grid-template-columns: 1fr; }
  .challenge-timer { align-items: flex-start; }
}

/* ---- 個人レベル（Issue #3）---- */
/* レベルはハイスコアから算出する共通尺度。マイページ最上部に大きく置く。 */
.level-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, #ecfdf5, var(--panel));
}

.level-panel:empty { display: none; }

.level-badge {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}

.level-badge-label { font-size: 14px; opacity: 0.85; }
.level-badge-value { font-size: 36px; font-weight: 800; line-height: 1; }
.level-badge-name { font-size: 14px; font-weight: 600; margin-left: 6px; }

.level-detail { flex: 1 1 260px; min-width: 240px; }
.level-points strong { font-size: 24px; font-weight: 800; }
.level-note { font-size: 12px; }

.level-bar {
  display: block;
  width: 100%;
  height: 10px;
  margin: 8px 0 6px;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: var(--panel-2);
  overflow: hidden;
}

.level-bar::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--panel-2);
}

.level-bar::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.level-bar::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* ステージ選択の上に出す1行サマリー */
.level-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.level-summary:empty { display: none; }

.level-summary-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* 課題カードの獲得ポイント（★＝段階） */
.challenge-points { display: flex; align-items: center; gap: 6px; }
.tier-stars { color: #f59e0b; letter-spacing: 1px; font-size: 13px; }

/* スキル別到達度 */
.skill-profile { display: grid; gap: 8px; }

.skill-row {
  display: grid;
  grid-template-columns: minmax(120px, 160px) 1fr minmax(140px, auto);
  align-items: center;
  gap: 12px;
}

.skill-label { font-size: 13px; font-weight: 600; }

.skill-bar {
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: var(--panel-2);
  overflow: hidden;
}

.skill-bar::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--panel-2);
}

.skill-bar::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}

.skill-bar::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent);
}

@media (max-width: 720px) {
  .skill-row { grid-template-columns: 1fr; gap: 4px; }
  .level-badge-value { font-size: 30px; }
  /* 画面が狭いぶん余白は詰めるが、字の大きさは落とさない（読みやすさが目的のため）。 */
  .knowledge-question { padding: 16px; }
  .knowledge-question legend { font-size: 19px; }
  .knowledge-question .choice-label { padding: 12px; }
}
