/* 首都圏 不動産データレポート — スタイル。色はトークン(:root)だけで定義し、明暗は別々に選んだ値を使う。チャートの色は dataviz 検証済み。 */
:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #3f3e3b;
  --ink-muted: #5f5e59;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.12);
  --link: #1c5cab;
  --accent: #184f95;
  --accent-soft: #e6effa;
  --banner-bg: #fff4d6;
  --banner-ink: #5a3d00;
  --focus: #1c5cab;
  /* 都県(カテゴリ)4色: 色と同時にマーカー形も固定(●◆■▲) */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  /* 築年区分(順序あり): 青1系統、築年が大きいほど濃い */
  --age-1: #86b6ef; --age-2: #2a78d6; --age-3: #104281;
  --series-1: #2a78d6;
  --ref-line: #52514e;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 4px 16px rgba(11, 11, 11, 0.04);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --ink: #ffffff; --ink-2: #d6d5cc; --ink-muted: #a8a79f;
    --grid: #2c2c2a; --baseline: #4a4a46; --border: rgba(255, 255, 255, 0.14); --link: #86b6ef; --accent: #86b6ef; --accent-soft: #14233a;
    --banner-bg: #3a2e0a; --banner-ink: #ffe29a; --focus: #86b6ef;
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
    --age-1: #cde2fb; --age-2: #86b6ef; --age-3: #3987e5; --series-1: #3987e5; --ref-line: #c3c2b7;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --ink: #ffffff; --ink-2: #d6d5cc; --ink-muted: #a8a79f;
  --grid: #2c2c2a; --baseline: #4a4a46; --border: rgba(255, 255, 255, 0.14); --link: #86b6ef; --accent: #86b6ef; --accent-soft: #14233a;
  --banner-bg: #3a2e0a; --banner-ink: #ffe29a; --focus: #86b6ef;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --age-1: #cde2fb; --age-2: #86b6ef; --age-3: #3987e5; --series-1: #3987e5; --ref-line: #c3c2b7;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 16px/1.8 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-feature-settings: "palt";
}
a { color: var(--link); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
img, svg { max-width: 100%; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 24px; } }

/* ── プレビュー帯・ヘッダー ── */
.preview-banner { background: var(--banner-bg); color: var(--banner-ink); font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.preview-banner p { margin: 0; }
header.site { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); }
header.site .bar-row { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); text-decoration: none; line-height: 1.3; }
.brand svg { flex: none; width: 28px; height: 28px; }
.brand span { font-size: 15px; }
.menu { margin-left: auto; position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 14px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--accent-soft); }
.menu nav { position: absolute; right: 0; top: calc(100% + 6px); width: min(86vw, 320px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow), 0 8px 32px rgba(0, 0, 0, 0.12); padding: 8px; display: grid; }
.menu nav a { display: block; padding: 12px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; min-height: 44px; }
.menu nav a:hover { background: var(--surface-2); }
.menu nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
/* PC: 一行のメニュー(閉じた details の中身は隠れるので、PC用の nav を別に置き、PCでは details を隠す) */
.desk-nav { display: none; }
@media (min-width: 980px) {
  .menu { display: none; }
  .desk-nav { display: flex; margin-left: auto; gap: 2px; }
  .desk-nav a { padding: 8px 10px; font-size: 14px; color: var(--ink); text-decoration: none; }
  .desk-nav a:hover { color: var(--accent); }
  .desk-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
}

/* ── 本文の骨格 ── */
main { padding: 24px 0 56px; }
.eyebrow { margin: 0 0 4px; font-size: 13px; letter-spacing: 0.04em; color: var(--accent); font-weight: 600; }
h1 { font-size: 1.75rem; line-height: 1.35; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; line-height: 1.4; margin: 48px 0 8px; scroll-margin-top: 72px; }
h3 { font-size: 1.05rem; margin: 28px 0 4px; }
.lede { color: var(--ink-2); margin: 0 0 20px; max-width: 46em; font-size: 1.02rem; }
p, li { max-width: 46em; }
.note { font-size: 14px; color: var(--ink-muted); }
.pagenav { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 16px 0 8px; padding: 0; list-style: none; }
.pagenav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--ink-2); text-decoration: none; font-size: 14px; }
.pagenav a:hover { border-color: var(--accent); color: var(--accent); }

/* ── ホーム ── */
.hero { padding: 24px 0 8px; }
.hero h1 { font-size: 2rem; }
@media (min-width: 720px) { .hero h1 { font-size: 2.5rem; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 20px 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 13px; color: var(--ink-2); }
.tile .value { font-size: 2.1rem; font-weight: 700; line-height: 1.25; }
.tile .sub { font-size: 13px; color: var(--ink-muted); }
.tile .delta { font-size: 13px; font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin: 16px 0; padding: 0; list-style: none; }
.cards li { max-width: none; }
.card { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card .t { font-weight: 700; font-size: 1.02rem; }
.card .d { font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.card .k { margin-top: auto; padding-top: 8px; font-size: 13px; color: var(--accent); font-weight: 600; }
.callout { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c1); border-radius: 6px; padding: 12px 16px; margin: 20px 0; }
.callout p { margin: 4px 0; }

/* ── タブ(JSなしでは全パネルを並べて表示) ── */
.tabs [role="tablist"] { display: none; }
.tabs.is-ready > [role="tablist"] { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 12px; }
.tabs.is-ready [role="tab"] { min-height: 44px; padding: 0 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer; }
.tabs.is-ready [role="tab"][aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .tabs.is-ready [role="tab"][aria-selected="true"] { color: #0b0b0b; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .tabs.is-ready [role="tab"][aria-selected="true"] { color: #0b0b0b; } }
.tabs.is-ready > [role="tabpanel"] > .panel-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tabs.is-ready > [role="tabpanel"][hidden] { display: none; }
.panel-title { margin-top: 32px; }

/* ── 表 ── */
.scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
caption { text-align: left; font-weight: 600; padding: 10px 12px 4px; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child, th[scope="row"] { text-align: left; }
th[scope="row"] { font-weight: 500; position: sticky; left: 0; background: var(--surface); z-index: 1; }
thead th { color: var(--ink-2); font-weight: 600; border-bottom: 1px solid var(--baseline); background: var(--surface-2); position: sticky; top: 0; }
thead th:first-child { left: 0; z-index: 2; }
td .n { color: var(--ink-muted); font-size: 12px; }
table.sortable thead th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 24px; }
table.sortable thead th button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
table.sortable thead th button::after { content: "↕"; color: var(--ink-muted); font-size: 12px; }
table.sortable thead th[aria-sort="ascending"] button::after { content: "↑"; color: var(--accent); }
table.sortable thead th[aria-sort="descending"] button::after { content: "↓"; color: var(--accent); }
.bar { display: inline-block; vertical-align: middle; width: 72px; height: 8px; margin-left: 8px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.pos { color: #006300; } .neg { color: #b42318; }
:root[data-theme="dark"] .pos { color: #4ade80; } :root[data-theme="dark"] .neg { color: #f87171; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .pos { color: #4ade80; } :root:where(:not([data-theme="light"])) .neg { color: #f87171; } }
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0; }
.filter label { font-size: 14px; color: var(--ink-2); }
.filter input[type="search"] { min-height: 44px; min-width: min(100%, 260px); padding: 0 12px; border: 1px solid var(--baseline); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
.filter .count { font-size: 13px; color: var(--ink-muted); }

/* ── チャート ── */
figure.chart { margin: 20px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 12px 10px; box-shadow: var(--shadow); }
figure.chart figcaption { font-size: 15px; font-weight: 600; margin: 0 4px 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--ink-2); margin: 0 4px 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; flex: none; }
.sw.s1 { background: var(--c1); border-radius: 50%; }
.sw.s2 { background: var(--c2); transform: rotate(45deg) scale(0.82); }
.sw.s3 { background: var(--c3); }
.sw.s4 { background: var(--c4); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.sw.age-1 { background: var(--age-1); border-radius: 50%; }
.sw.age-2 { background: var(--age-2); transform: rotate(45deg) scale(0.82); }
.sw.age-3 { background: var(--age-3); }
.chart-wrap { position: relative; }
.chart-scroll { overflow-x: auto; }
.chart-scroll svg { display: block; width: 100%; height: auto; }
.chart-scroll svg.wide { min-width: 440px; }
svg text { fill: var(--ink-2); font-size: 12px; font-family: inherit; }
svg text.muted, svg text.tick { fill: var(--ink-muted); }
svg text.value { fill: var(--ink); font-weight: 600; }
svg text.end-label { fill: var(--ink); font-weight: 600; }
svg .grid { stroke: var(--grid); stroke-width: 1; }
svg .baseline { stroke: var(--baseline); stroke-width: 1; }
svg .ref { stroke: var(--ref-line); stroke-width: 1; }
svg .hit { fill: transparent; }
svg .line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg .s1 .line { stroke: var(--c1); } svg .s1 .mark { fill: var(--c1); }
svg .s2 .line { stroke: var(--c2); } svg .s2 .mark { fill: var(--c2); }
svg .s3 .line { stroke: var(--c3); } svg .s3 .mark { fill: var(--c3); }
svg .s4 .line { stroke: var(--c4); } svg .s4 .mark { fill: var(--c4); }
svg .mark { stroke: var(--surface); stroke-width: 2; }
svg .age-1 { fill: var(--age-1); } svg .age-2 { fill: var(--age-2); } svg .age-3 { fill: var(--age-3); } svg .series-1 { fill: var(--series-1); }
svg .iqr { stroke: var(--series-1); stroke-width: 2; stroke-opacity: 0.4; stroke-linecap: round; }
svg .iqr-age-1, svg .iqr-age-2, svg .iqr-age-3 { stroke-width: 2; stroke-opacity: 0.5; stroke-linecap: round; fill: none; }
svg .iqr-age-1 { stroke: var(--age-1); } svg .iqr-age-2 { stroke: var(--age-2); } svg .iqr-age-3 { stroke: var(--age-3); }
svg .lane:hover .hit, svg .lane:focus-visible .hit { fill: var(--grid); fill-opacity: 0.5; }
svg .lane:focus-visible { outline: none; }
svg .guide { stroke: var(--ink-muted); stroke-width: 1; pointer-events: none; }
svg[data-chart] { touch-action: pan-y; cursor: crosshair; }
.tooltip { position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 240px; padding: 8px 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--baseline); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); font-size: 13px; line-height: 1.5; }
.tooltip strong { display: block; margin-bottom: 2px; }
.tooltip .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tooltip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; }
details.table-view { margin: 6px 4px 2px; font-size: 14px; }
details.table-view summary { cursor: pointer; padding: 8px 0; color: var(--link); min-height: 44px; display: flex; align-items: center; }
details.table-view .scroll + .scroll { margin-top: 12px; }

/* ── ガイド・フッター ── */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.steps li { counter-increment: step; position: relative; padding: 12px 14px 12px 52px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); max-width: none; }
.steps li::before { content: counter(step); position: absolute; left: 14px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
:root[data-theme="dark"] .steps li::before { color: #0b0b0b; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .steps li::before { color: #0b0b0b; } }
.steps strong { display: block; }
dl.terms { display: grid; gap: 4px 16px; grid-template-columns: 1fr; margin: 12px 0; }
@media (min-width: 720px) { dl.terms { grid-template-columns: 12em 1fr; } }
dl.terms dt { font-weight: 700; } dl.terms dd { margin: 0 0 8px; max-width: 46em; }
details.faq { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 8px 0; padding: 0 14px; }
details.faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; min-height: 44px; }
details.faq p { margin: 0 0 12px; }
.dl-list { display: grid; gap: 10px; padding: 0; list-style: none; margin: 12px 0; }
.dl-list li { max-width: none; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color 0.15s, box-shadow 0.15s; }
.dl-list li:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.dl-list .name { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; text-decoration: none; min-width: 12em; }
.dl-list .name::before { content: "↓"; font-weight: 700; }
.dl-list .name:hover { background: var(--accent); color: var(--surface); }
.dl-list .desc { color: var(--ink-2); font-size: 14px; flex: 1 1 18em; }
.dl-list .note { margin-left: auto; white-space: nowrap; }

/* ── フッター(リンクは本文リンクと区別し、控えめな色・ホバーで強調) ── */
footer.site { margin-top: 32px; border-top: 1px solid var(--border); background: var(--surface); font-size: 14px; color: var(--ink-2); padding: 36px 0 28px; }
footer.site .cols { display: grid; gap: 28px 24px; grid-template-columns: 1fr 1fr; }
footer.site .cols > div:first-child { grid-column: 1 / -1; }
@media (min-width: 720px) { footer.site .cols { grid-template-columns: 2fr 1fr 1fr; } footer.site .cols > div:first-child { grid-column: auto; } }
footer.site h2 { font-size: 13px; margin: 0 0 10px; color: var(--ink); letter-spacing: 0.04em; }
footer.site .cols > div:first-child h2 { font-size: 15px; letter-spacing: 0; }
footer.site ul { list-style: none; margin: 0; padding: 0; }
footer.site li { max-width: none; }
footer.site li a { display: inline-flex; align-items: center; min-height: 36px; color: var(--ink-2); text-decoration: none; border-bottom: 1px solid transparent; }
footer.site li a:hover { color: var(--accent); border-bottom-color: currentColor; }
footer.site p { margin: 6px 0; max-width: 60em; }
footer.site .wrap.meta { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--ink-muted); }

/* ── 全体の仕上げ ── */
body { -webkit-font-smoothing: antialiased; }
.hero { padding: 28px 0 12px; }
.hero .lede { font-size: 1.08rem; }
.tile { transition: box-shadow 0.15s; }
.tile .value { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
td, th { font-variant-numeric: tabular-nums; }
tbody tr:hover td, tbody tr:hover th[scope="row"] { background: var(--accent-soft); }
.pagenav a, .tabs.is-ready [role="tab"] { transition: border-color 0.15s, background 0.15s, color 0.15s; }
.tabs.is-ready [role="tab"]:hover:not([aria-selected="true"]) { border-color: var(--accent); color: var(--accent); }
.filter input[type="search"] { box-shadow: inset 0 1px 2px rgba(11, 11, 11, 0.06); transition: border-color 0.15s; }
.filter input[type="search"]:hover { border-color: var(--accent); }
.card:hover { box-shadow: var(--shadow), 0 6px 18px rgba(24, 79, 149, 0.10); }
.menu > summary::after { content: "▾"; font-size: 11px; color: var(--ink-muted); }
.menu[open] > summary::after { content: "▴"; }
.menu > summary:hover { border-color: var(--accent); }
details.faq summary:hover { color: var(--accent); }
details.table-view summary:hover { text-decoration: underline; }

@media (max-width: 600px) {
  h1 { font-size: 1.5rem; }
  .tile .value { font-size: 1.9rem; }
  figure.chart { padding: 10px 6px 6px; }
  svg[data-chart] text, svg.big-text text { font-size: 17px; }
  th, td { padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .card { transition: none; } }
@media print {
  .preview-banner, header.site, .tabs [role="tablist"], .filter, details.table-view > summary { display: none; }
  .tabs [role="tabpanel"][hidden] { display: block; }
  figure.chart, .tile, .card { break-inside: avoid; box-shadow: none; }
  body { background: #fff; font-size: 12px; }
}

/* ── 補助レイアウト ── */
.grid3 { display: grid; gap: 12px; grid-template-columns: 1fr; margin: 8px 0 16px; }
@media (min-width: 900px) { .grid3 { grid-template-columns: repeat(3, 1fr); } }
h4 { font-size: 0.98rem; margin: 24px 0 6px; color: var(--ink-2); }
.pagenav { margin-left: 0; }

/* チャートの最大幅(PCで拡大されすぎて文字・高さが大きくなるのを防ぐ) */
figure.chart .chart-wrap { max-width: 860px; }
.tile .label .note { font-size: 12px; }

/* ── タップ領域(モバイル) ── */
.brand { min-height: 44px; }
table.sortable thead th button { min-height: 36px; }

/* 横スクロールできる表: 端に影を出して続きがあることを示す */
.scroll {
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 24px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(11, 11, 11, 0.18), transparent) left center / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(11, 11, 11, 0.18), transparent) right center / 10px 100% no-repeat scroll,
    var(--surface);
}
.scroll:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
