/* ===== カラーとテーマ ===== */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --border: #d9e0ea;
  --text: #1d2733;
  --text-muted: #5c6b7a;
  --primary: #2f6df0;
  --primary-strong: #1f53c4;
  --primary-soft: #e7f0ff;
  --accent: #0f9d8a;
  --danger: #c0392b;
  --shadow: 0 2px 12px rgba(20, 40, 80, 0.08);
  --radius: 14px;
  --maxw: 880px;
}

[data-theme="dark"] {
  --bg: #11161d;
  --surface: #1a212b;
  --surface-2: #222b37;
  --border: #313c4a;
  --text: #e8edf3;
  --text-muted: #a4b1c0;
  --primary: #6ea2ff;
  --primary-strong: #9bc0ff;
  --primary-soft: #1d2c45;
  --accent: #3ed3bd;
  --danger: #ff8b7e;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html { font-size: 100%; }
html[data-fontsize="large"] { font-size: 122%; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 20px;
}

/* ===== アクセシビリティ ===== */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

main:focus { outline: none; }

/* ===== ヘッダー ===== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 14px;
  gap: 10px;
}
.header-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.site-title {
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: 0.02em;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
}
.theme-toggle:hover { border-color: var(--primary); }

/* ===== 共通 ===== */
.view { padding-block: 28px 48px; }
.view-title {
  font-size: 1.5rem;
  margin: 0 0 8px;
}
.view-lead {
  color: var(--text-muted);
  margin: 0 0 24px;
}

.disclaimer {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 22px;
}

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  padding: 12px 22px;
  border: 1px solid transparent;
  min-height: 48px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); }
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  text-decoration: underline;
  padding: 8px;
  min-height: auto;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== 診断選択カード ===== */
.card-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.diag-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
  text-align: left;
  width: 100%;
  cursor: pointer;
  color: inherit;
  transition: transform 0.12s ease, border-color 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
}
.diag-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.diag-card__tag {
  align-self: flex-start;
  font-size: 0.72rem;
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-radius: 999px;
  padding: 3px 10px;
}
.diag-card__name { font-size: 1.1rem; font-weight: 700; margin: 0; }
.diag-card__desc { color: var(--text-muted); font-size: 0.88rem; margin: 0; }
.diag-card__meta {
  margin-top: auto;
  font-size: 0.8rem;
  color: var(--primary-strong);
  background: var(--primary-soft);
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
}

/* ===== 進捗バー ===== */
.progress { margin-bottom: 24px; }
.progress-bar {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.3s ease;
}
.progress-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 8px 0 0;
}

/* ===== 設問 ===== */
.question-list { list-style: none; margin: 0; padding: 0; }
.question-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.question-text {
  font-weight: 600;
  margin: 0 0 14px;
}
.question-num { color: var(--primary); margin-right: 6px; }

.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.scale-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 12px 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface-2);
  min-height: 76px;
  justify-content: center;
}
.scale-option__label { line-height: 1.2; }
.scale-option input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.scale-option .dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
}
.scale-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 700;
}
.scale-option:has(input:checked) .dot {
  background: var(--primary);
  border-color: var(--primary);
}
.scale-option:has(input:focus-visible) {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.quiz-nav {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.quiz-nav .btn-primary { margin-left: auto; }
.quiz-hint { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; }
.quiz-head { margin-bottom: 8px; }

/* ===== 結果 ===== */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.result-kicker { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.result-type {
  font-size: 1.9rem;
  margin: 6px 0 4px;
  line-height: 1.3;
}
.result-code {
  display: inline-block;
  font-family: ui-monospace, monospace;
  letter-spacing: 0.18em;
  background: var(--primary-soft);
  color: var(--primary-strong);
  padding: 2px 12px;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 8px;
}
.result-summary {
  font-size: 1.05rem;
  margin: 10px 0 16px;
}

/* はっきり度・相性タイプ */
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 0 0 22px;
  padding: 12px 16px;
  background: var(--primary-soft);
  border-radius: 12px;
  font-size: 0.92rem;
}
.result-meta b { color: var(--primary-strong); }
.result-meta .stars { letter-spacing: 2px; color: var(--accent); }
.result-meta .star-off { color: var(--border); }

/* 結果まとめ */
.summary-entry { display: inline-block; margin-bottom: 20px; }
.summary-list { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 12px; }
.summary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.summary-item__tag {
  font-size: 0.72rem; background: var(--primary-soft); color: var(--primary-strong);
  border-radius: 999px; padding: 2px 10px;
}
.summary-item__type { font-size: 1.15rem; font-weight: 700; margin: 6px 0 4px; }
.summary-item__code {
  font-family: ui-monospace, monospace; letter-spacing: 0.12em;
  color: var(--primary-strong); font-size: 0.85rem; margin-left: 8px;
}
.summary-item__desc { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

.result-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.result-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.result-section h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--primary-strong);
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
}
.result-section ul { margin: 0; padding-left: 1.1em; }
.result-section li { margin-bottom: 4px; }

/* 軸サマリー */
.axis-summary {
  margin-top: 26px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.axis-summary h3 { margin: 0 0 14px; font-size: 1.05rem; }
.axis-row { margin-bottom: 14px; }
.axis-row:last-child { margin-bottom: 0; }
.axis-row__labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.axis-row__labels .picked { color: var(--primary-strong); font-weight: 700; }
.axis-track {
  position: relative;
  height: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.axis-track__center {
  position: absolute;
  left: 50%; top: -3px; bottom: -3px;
  width: 1px;
  background: var(--border);
}
.axis-track__fill {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--primary);
  border-radius: 999px;
}
/* max/composite用 横棒 */
.bar-row { margin-bottom: 10px; }
.bar-row__head {
  display: flex; justify-content: space-between;
  font-size: 0.82rem; margin-bottom: 4px;
}
.bar-row__head .picked { color: var(--primary-strong); font-weight: 700; }
.bar-track { height: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.bar-track__fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); }

/* レーダーチャート */
.radar { display: block; width: 100%; max-width: 360px; height: auto; margin: 8px auto 0; }
.radar-grid { fill: none; stroke: var(--border); stroke-width: 1; }
.radar-spoke { stroke: var(--border); stroke-width: 1; }
.radar-area { fill: var(--primary); fill-opacity: 0.22; stroke: var(--primary); stroke-width: 2; }
.radar-label { fill: var(--text); font-size: 13px; font-weight: 600; }
.radar-val { fill: var(--text-muted); font-size: 11px; text-anchor: inherit; }
.radar-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radar-block h3 { font-size: 0.9rem; margin: 4px 0; text-align: center; }
@media (max-width: 520px) { .radar-pair { grid-template-columns: 1fr; } }

/* 配布用：氏名・日付 */
.name-date-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
}
.name-date-row label { font-size: 0.85rem; color: var(--text-muted); display: flex; align-items: center; gap: 8px; flex: 1; min-width: 160px; }
.name-date-row input {
  font: inherit;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.save-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.save-status { font-size: 0.9rem; color: var(--text-muted); }
.save-status.ok { color: var(--accent); font-weight: 700; }
.save-status.err { color: var(--danger); }

.result-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.load-error {
  background: #fff3f0;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 14px;
  border-radius: 10px;
}
[data-theme="dark"] .load-error { background: #2a1714; }

/* ===== フッター ===== */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-block: 20px;
}
.footer-note { color: var(--text-muted); font-size: 0.8rem; margin: 0; }

/* ===== スマホ ===== */
@media (max-width: 520px) {
  .view-title { font-size: 1.3rem; }
  .scale { gap: 5px; }
  .scale-option { font-size: 0.68rem; padding: 12px 2px; min-height: 72px; gap: 6px; }
  .scale-option .dot { width: 28px; height: 28px; }
  .scale-option__label { word-break: keep-all; }
  .result-type { font-size: 1.5rem; }
  .result-card { padding: 20px; }
  .quiz-nav .btn { flex: 1; }
  .quiz-nav .btn-primary { margin-left: 0; }
}

/* さらに狭い端末では円を大きく保ち、文字だけ縮める */
@media (max-width: 360px) {
  .scale-option { font-size: 0.6rem; }
}

#shareHint { color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ===== 印刷 ===== */
@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #fff;
    --border: #999; --text: #000; --text-muted: #333;
    --shadow: none; --primary-soft: #fff;
  }
  .site-header, .site-footer, .no-print, #disclaimer { display: none !important; }
  body { font-size: 12pt; background: #fff; }
  .result-card, .result-section, .axis-summary { box-shadow: none; border-color: #999; break-inside: avoid; }
  .result-sections { grid-template-columns: repeat(2, 1fr); }
  .name-date-row { border-color: #999; break-inside: avoid; }
  .name-date-row input { border: none; border-bottom: 1px solid #333; border-radius: 0; }
  .radar-area { fill: #2f6df0; fill-opacity: 0.18; stroke: #2f6df0; }
  .radar { max-width: 320px; }
  .result-type { font-size: 18pt; }
  a[href]:after { content: ""; }
}
