:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #5d6576;
  --border: #dfe3ea;
  --accent: #1a64d8;
  --accent-soft: #e8f0fe;
  --good: #137a4b;
  --radius: 12px;
  --field-border: #848d9f;
  --danger: #c0262d;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b2029;
    --text: #e7eaf0;
    --muted: #a0a8b8;
    --border: #2d3442;
    --accent: #6ea8ff;
    --accent-soft: #1f2b40;
    --good: #5fd39a;
    --field-border: #66718a;
    --danger: #ff8f8f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.75;
}
a { color: var(--accent); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: .9rem; margin-left: 16px; }

main { padding: 24px 0 48px; }
h1 { font-size: 1.5rem; line-height: 1.4; margin: 8px 0 8px; }
h2 { font-size: 1.2rem; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
h3 { font-size: 1.05rem; margin: 24px 0 8px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.breadcrumb { font-size: .82rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; }
.field label { font-size: .88rem; font-weight: 600; }
input[type="date"], select {
  font: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  min-height: 46px;
}
.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 8px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 46px;
}
.btn-sub { background: transparent; color: var(--accent); border: 1px solid var(--accent); font-weight: 600; padding: 8px 14px; min-height: 0; }
.hint { font-size: .82rem; color: var(--muted); margin: 0; }

.result { margin-top: 20px; }
.result[hidden] { display: none; }
.big {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}
.big .label { font-size: .9rem; color: var(--muted); }
.big .value { font-size: 2.2rem; font-weight: 800; line-height: 1.3; }
.big .sub { font-size: .95rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.kv th { width: 42%; }
.age-table td, .age-table th { white-space: nowrap; }
.age-table tr.current td { background: var(--accent-soft); font-weight: 700; }

.tool-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tool-list a {
  display: block; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-decoration: none; color: var(--text);
}
.tool-list a:hover { border-color: var(--accent); }
.tool-list strong { display: block; margin-bottom: 4px; }
.tool-list span { font-size: .88rem; color: var(--muted); }
.soon { opacity: .6; }

.ad-slot { margin: 24px 0; min-height: 0; }
/* 広告のコードを入れたら、読み込み中に下の文章がずれないよう高さを先に確保する */
.ad-slot:not(:empty) { min-height: 280px; }
/* エラーメッセージ（role="alert" の欄に文字が入ったときだけ赤く目立たせる） */
[role="alert"]:not(:empty) { color: var(--danger); font-weight: 700; }

.site-footer { border-top: 1px solid var(--border); padding: 24px 0 32px; font-size: .85rem; color: var(--muted); }
.site-footer a { color: var(--muted); margin-right: 16px; }

@media (max-width: 480px) {
  h1 { font-size: 1.3rem; }
  .big .value { font-size: 1.9rem; }
  .card { padding: 16px; }
  .site-header nav a { margin-left: 12px; }
}

/* 入力欄（数値・文字・複数行） */
input[type="number"], input[type="text"], textarea {
  font: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  min-height: 46px;
}
textarea { min-height: 220px; resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .92rem; }
.check input { width: 18px; height: 18px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-top: 0; border: 0; padding: 0; font-size: 1.1rem; }
.answer { margin-top: 14px; padding: 14px 16px; background: var(--accent-soft); border-radius: 10px; font-size: 1.05rem; }
.answer:empty { display: none; }
.answer strong { font-size: 1.35rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: var(--accent-soft); border-radius: 10px; padding: 12px; }
.stat .label { font-size: .8rem; color: var(--muted); }
.stat .value { font-size: 1.4rem; font-weight: 800; }
.unit { font-size: .9rem; font-weight: 400; margin-left: 2px; }

/* 「何人に1人」診断の結果表示（診断ページと項目別の早見表で共用） */
.res { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--surface); }
.res + .res { margin-top: 10px; }
.res-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.res-top .name { font-weight: 700; }
.res-top .rank { font-size: 1.35rem; font-weight: 800; color: var(--accent); }
.res p { margin: 4px 0 0; font-size: .92rem; }
.res .src { font-size: .75rem; color: var(--muted); }
.hist { width: 100%; height: 64px; display: block; margin-top: 8px; }
.hist .bar { fill: var(--border); }
.hist .bar.on { fill: var(--accent); opacity: .55; }
.hist .mark { stroke: var(--accent); stroke-width: 2; }
.hist .curve { fill: var(--border); }
.hist text { fill: var(--muted); font-size: 9px; }
.lookup td, .lookup th { white-space: nowrap; padding: 7px 10px; }
.lookup td small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.lookup th[scope="row"] { color: var(--text); font-weight: 700; }
.lookup tr.hl td, .lookup tr.hl th { background: var(--accent-soft); }
.pill-links { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.pill-links a { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); text-decoration: none; font-size: .9rem; }
.pill-links a:hover { border-color: var(--accent); }
.pill-links .here { padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); font-size: .9rem; font-weight: 700; }

/* トップの目玉ツール */
.feature { display: grid; grid-template-columns: 1fr 190px; gap: 18px; align-items: center; margin-top: 8px; padding: 22px; border-radius: 18px; text-decoration: none; color: #fff;
  background: radial-gradient(120% 140% at 90% 0%, #2b5591 0%, #1a3260 50%, #101d38 100%); box-shadow: 0 10px 30px rgba(16,29,56,.25); transition: transform .15s; }
.feature:hover { transform: translateY(-2px); }
.feature img { width: 190px; height: 190px; object-fit: cover; border-radius: 42% 58% 55% 45% / 48% 42% 58% 52%; border: 3px solid rgba(255,255,255,.18); }
@media (max-width: 560px) { .feature { grid-template-columns: 1fr; } .feature img { width: 150px; height: 150px; justify-self: center; order: -1; } }
.feature strong { display: block; font-size: 1.35rem; line-height: 1.4; margin: 6px 0; }
.feature span { display: block; font-size: .92rem; color: #d5def0; }
.feature .feature-tag { display: inline-block; font-size: .78rem; font-weight: 700; color: #13233f; background: #ffd36e; border-radius: 999px; padding: 2px 10px; }
.feature .feature-go { display: inline-block; margin-top: 12px; font-weight: 700; color: #ffd36e; }
.feature:hover .feature-go { text-decoration: underline; }

/* 項目のアイコン（お金・からだ・くらしで色分け） */
.ico { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.ico svg { width: 22px; height: 22px; }
.g-money .ico { color: #b7791f; background: #fdf3dc; }
.g-life .ico { color: #c2410c; background: #fde9df; }
@media (prefers-color-scheme: dark) { .g-money .ico { color: #f3c86b; background: #3a3020; } .g-life .ico { color: #ff9a6b; background: #3d261d; } }

/* ロゴのマスコット */
.logo { display: inline-flex; align-items: center; gap: 8px; }
.logo img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

/* 早見表ページのタイプ紹介 */
.type-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.type-pair figure { margin: 0; text-align: center; }
.type-pair img { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; background: #fbf3e4; border: 3px solid #ffd36e; }
.type-pair figcaption { font-size: .8rem; color: var(--muted); line-height: 1.4; margin-top: 4px; }
.type-pair figcaption strong { display: block; color: var(--text); font-size: .92rem; }
.type-pair p { grid-column: 1 / -1; margin: 0; font-size: .88rem; }

/* 結果の項目名とアイコン */
.res-top .name { display: flex; align-items: center; gap: 8px; }
.res-top .ico { width: 30px; height: 30px; border-radius: 8px; }
.res-top .ico svg { width: 18px; height: 18px; }

.type-pair figcaption small { display: block; text-align: left; font-size: .78rem; margin-top: 6px; color: var(--text); opacity: .85; }

/* 全ページ共通の仕上げ */
main.wrap > h1 { position: relative; padding-left: 14px; }
main.wrap > h1::before { content: ""; position: absolute; left: 0; top: .2em; bottom: .2em; width: 5px; border-radius: 3px; background: linear-gradient(#ffd36e, #1f6feb); }
h2 { border-bottom: 0; position: relative; }
h2::after { content: ""; position: absolute; left: 0; bottom: 0; width: 100%; height: 2px; background: var(--border); }
h2::before { content: ""; position: absolute; left: 0; bottom: 0; width: 56px; height: 2px; background: var(--accent); z-index: 1; }
.card h2::before, .card h2::after, .friend h2::before, .friend h2::after { display: none; }
.card { box-shadow: 0 4px 18px rgba(16,29,56,.06); }
.btn { transition: filter .15s, transform .1s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.tool-list a { transition: border-color .15s, transform .15s, box-shadow .15s; }
.tool-list a:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(16,29,56,.1); }

/* グラフの目盛り（SVGの外に文字で出す）と暗い背景でのボタン文字 */
.hist { height: 52px; }
.hist-labels { display: flex; justify-content: space-between; font-size: .7rem; color: var(--muted); line-height: 1.2; margin-top: 2px; }
@media (prefers-color-scheme: dark) { .btn:not(.btn-sub) { color: #0b1426; } }
