/* Layout: 白地に深緑ひと色。1カラムの読み物幅を基本に、計算ページだけ「入力｜答え」の2カラム */
:root {
  --bg: #f6f7f6;
  --surface: #ffffff;
  --ink: #191e1c;
  --muted: #69726e;
  --line: #e2e6e4;
  --accent: #1f5c4a;
  --accent-ink: #ffffff;
  --accent-soft: #e7efeb;
  --gold: #c9a24a;
  --logo-key: #cfd9d4;
  --good: #1f7a4d;
  --warn: #a8650c;
  --bad: #b3261e;
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --font-num: "Manrope", "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  --r: 14px;
  color-scheme: light;
}
/* デフォルトはライト。ヘッダーのボタンで data-theme="dark" に切り替える */
:root[data-theme="dark"] {
  --bg: #111413; --surface: #181c1a; --ink: #e8ecea; --muted: #9aa39f; --line: #2a302d;
  --accent: #86cdb0; --accent-ink: #0f1a15; --accent-soft: #1c2924; --gold: #d8b766; --logo-key: #2a322e;
  --good: #6fd3a0; --warn: #f0b35c; --bad: #ff8a80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.8; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
img { max-width: 100%; }

/* Header / footer */
.site-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.bar { max-width: 1080px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo-mark { width: 28px; height: 28px; flex: none; display: block; }
.logo-mark .k { fill: var(--logo-key); }
.logo-mark .a { fill: var(--accent); }
.logo-mark .o { fill: var(--accent-ink); }
.logo b { font-size: 19px; font-weight: 700; letter-spacing: .04em; }
.logo small { font-size: 11px; color: var(--muted); letter-spacing: .1em; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.nav a { font-size: 13px; text-decoration: none; color: var(--muted); padding: 4px 10px; border-radius: 999px; }
.nav a:hover, .nav a[aria-current] { color: var(--ink); background: var(--accent-soft); }

.theme-btn { flex: none; width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; padding: 0; }
.theme-btn:hover { border-color: var(--accent); color: var(--accent); }
.theme-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
html { transition: background-color .2s; }

.wrap { max-width: 1080px; margin: 0 auto; padding-inline: 20px; }
main.wrap { padding-block: 40px 72px; }

.site-footer { border-top: 1px solid var(--line); }
.site-footer .wrap { padding-block: 28px 44px; display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* Home */
.hero { display: grid; gap: 16px; margin-bottom: 44px; max-width: 640px; }
.eyebrow { font-size: 12px; letter-spacing: .18em; color: var(--accent); font-weight: 700; }
.hero h1 { font-size: clamp(30px, 5.4vw, 46px); line-height: 1.3; font-weight: 700; margin: 0; letter-spacing: .01em; text-wrap: balance; }
.hero p { margin: 0; color: var(--muted); }
.search { position: relative; margin-top: 8px; }
.search input { width: 100%; font: inherit; font-size: 16px; padding: 13px 16px 13px 44px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search svg { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; stroke: var(--muted); fill: none; }

.cat { margin-top: 40px; scroll-margin-top: 90px; }
.cat h2 { font-size: 13px; letter-spacing: .14em; color: var(--muted); font-weight: 500; margin: 0 0 14px; display: flex; align-items: center; gap: 12px; }
.cat h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); column-gap: 40px; border-top: 1px solid var(--line); }
.tile { display: block; position: relative; padding: 14px 28px 14px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.tile::after { content: "›"; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 20px; line-height: 1; transition: transform .15s, color .15s; }
.tile:hover b { color: var(--accent); }
.tile:hover::after { color: var(--accent); transform: translate(3px, -50%); }
.tile b { display: block; font-size: 16px; font-weight: 700; line-height: 1.5; }
.tile span.d { display: block; font-size: 13px; color: var(--muted); line-height: 1.6; margin-top: 2px; }
.g { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 17px; }
.empty { color: var(--muted); padding: 20px 0; }

/* Calculator page */
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 18px; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }
.page-head { display: flex; gap: 16px; align-items: center; margin-bottom: 28px; }
.page-head > div { min-width: 0; }
.page-head h1 { font-size: clamp(24px, 4vw, 32px); font-weight: 700; line-height: 1.35; margin: 0; text-wrap: balance; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.calc { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; display: grid; gap: 18px; }
@media (min-width: 861px) { .form { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); } }
.field label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field .opt { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; line-height: 1.6; }
.inp { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.inp:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.inp input, .inp select { flex: 1; min-width: 0; font: inherit; font-family: var(--font-num); font-weight: 500; font-size: 17px; padding: 10px 14px; border: 0; background: transparent; color: var(--ink); }
.inp select { font-family: var(--font-body); font-size: 15px; }
.inp input:focus, .inp select:focus { outline: none; }
.inp .u { display: grid; place-items: center; padding: 0 14px; font-size: 13px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.btn { font: inherit; font-size: 13.5px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { color: var(--accent-ink); filter: brightness(1.08); }

.results { display: grid; gap: 18px; min-width: 0; }
.answer { background: var(--accent-soft); border-radius: var(--r); padding: 24px 26px; display: grid; gap: 18px; }
.answer .l { font-size: 12.5px; color: var(--muted); letter-spacing: .04em; }
.answer .v { font-family: var(--font-num); font-weight: 700; font-size: 22px; line-height: 1.25; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.answer .main .v { font-size: clamp(36px, 6.4vw, 52px); color: var(--accent); letter-spacing: -.02em; }
.answer .v small { font-family: var(--font-body); font-size: 15px; font-weight: 500; margin-left: 4px; color: var(--ink); letter-spacing: 0; }
.answer .subs { display: flex; flex-wrap: wrap; gap: 12px 36px; padding-top: 16px; border-top: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); }
.answer.error p { margin: 4px 0 0; }

.rows { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 22px; }
.rows div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rows div:last-child { border-bottom: 0; }
.rows dt { color: var(--muted); font-size: 13.5px; }
.rows dd { margin: 0; font-family: var(--font-num); font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.rows strong { font-weight: 700; }
.pill { display: inline-block; font-family: var(--font-body); font-size: 11.5px; font-weight: 700; padding: 0 9px; border-radius: 999px; margin-left: 8px; border: 1px solid currentColor; line-height: 1.7; vertical-align: 1px; }
.pill.good { color: var(--good); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }

.chart { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.chart figcaption, .tbl summary { font-size: 13.5px; font-weight: 500; margin-bottom: 8px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .ax { stroke: var(--line); stroke-width: 1; }
.chart .tx { fill: var(--muted); font-size: 11px; font-family: var(--font-num); }
.chart .a1 { fill: var(--accent); opacity: .16; }
.chart .a2 { fill: var(--gold); opacity: .38; }
.chart .l1 { stroke: var(--accent); stroke-width: 2; fill: none; }
.chart .dot { fill: var(--accent); }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw-a1 { background: var(--accent); } .sw-a2 { background: var(--gold); }

.tbl { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; }
.tbl summary { cursor: pointer; margin: 0; }
.scroll { overflow: auto; margin-top: 12px; max-height: 420px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
td { font-family: var(--font-num); }
th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 500; }
th:first-child, td:first-child { text-align: left; }
tr.hl td { background: var(--accent-soft); font-weight: 700; }
.note { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.note p { margin: 0 0 4px; }

/* 解説（記事） */
.article { max-width: 680px; margin-top: 56px; }
.article h2 { font-size: 20px; font-weight: 700; margin: 0 0 8px; }
.article h3 { font-size: 16px; font-weight: 700; margin: 28px 0 6px; }
.article p { margin: 0 0 12px; }
.prose { max-width: 680px; }
.prose h1 { font-size: clamp(24px, 4vw, 30px); margin: 0 0 24px; }
.prose h2 { font-size: 17px; margin: 32px 0 8px; }
.prose p, .prose li { margin: 0 0 10px; }
.prose .mail { font-family: var(--font-num); font-size: 17px; font-weight: 500; user-select: all; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: inline-block; }

.contact { display: grid; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; margin: 24px 0 8px; }
.contact textarea { flex: 1; min-width: 0; font: inherit; font-size: 15px; line-height: 1.7; padding: 10px 14px; border: 0; background: transparent; color: var(--ink); resize: vertical; }
.contact textarea:focus { outline: none; }
.contact .inp input { font-family: var(--font-body); font-size: 16px; }
.contact .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form-note { font-size: 12.5px; color: var(--muted); margin: 0; }
.form-status { margin: 0; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.form-status.ok { background: var(--accent-soft); color: var(--ink); }
.form-status.ng { border: 1px solid var(--bad); color: var(--bad); }
.btn:disabled { opacity: .6; cursor: wait; }

.article .scroll { margin: 8px 0 16px; max-height: none; }
table.quick { font-size: 13.5px; }
table.quick th { position: static; }
table.quick td:not(:first-child) { font-weight: 500; }
.refs { margin: 0 0 12px; padding-left: 1.2em; font-size: 14px; }
.refs li { margin-bottom: 4px; }
.article .meta { font-size: 12.5px; color: var(--muted); margin-top: 20px; }
.news { margin-top: 56px; max-width: 680px; }
.news h2 { font-size: 13px; letter-spacing: .14em; color: var(--muted); font-weight: 500; margin: 0 0 10px; }
.news dl { margin: 0; }
.news dl > div { display: grid; grid-template-columns: 9.5em 1fr; gap: 4px 16px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.news dt { color: var(--muted); font-variant-numeric: tabular-nums; }
.news dd { margin: 0; }
@media (max-width: 520px) { .news dl > div { grid-template-columns: 1fr; } }

.related { margin-top: 56px; }
.related h2 { font-size: 13px; letter-spacing: .14em; color: var(--muted); font-weight: 500; margin: 0 0 14px; }

/* 広告枠：読み込み前後で画面がずれないよう高さを確保 */
.ad { margin: 40px 0; text-align: center; }
.ad-label { display: block; font-size: 11px; letter-spacing: .12em; color: var(--muted); margin-bottom: 6px; }
.ad ins { min-height: 100px; }
.ad-ph { min-height: 110px; border: 1px dashed var(--line); border-radius: var(--r); display: grid; place-items: center; color: var(--muted); font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 18px; border-radius: 999px; font-size: 13px; z-index: 20; }

@media (max-width: 520px) {
  .bar { padding: 10px 16px; gap: 8px 16px; }
  .wrap { padding-inline: 16px; }
  main.wrap { padding-block: 28px 56px; }
  .nav { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; order: 2; }
  .theme-btn { order: 1; margin-left: auto; }
  .nav a { white-space: nowrap; }
  .form, .answer { padding: 18px; }
  .rows { padding: 4px 16px; }
}
@media (prefers-reduced-motion: reduce) { .tile::after, .inp { transition: none; } .tile:hover::after { transform: translateY(-50%); } }
