:root {
    --bg: #060812;
    --panel: rgba(15, 18, 35, 0.78);
    --stroke: rgba(120, 160, 255, 0.22);
    --text: rgba(235, 240, 255, 0.92);
    --muted: rgba(235, 240, 255, 0.62);

    --planning: #7aa2ff;
    --ongoing: #43f2c8;
    --verified: #ffd86b;
    --inventory-available: #68a7ff;
    --inventory-unavailable: #9aa7b8;
    --inventory-applicant-held: #ffd166;

    --land: rgba(255, 255, 255, 0.06);
    --border: rgba(190, 210, 255, 0.34);
    --gutter: 12px;
    --topbar-gap: 14px;
    --topbar-pad-y: 14px;
    --theme-transition-duration: 1000ms;
    --theme-transition-easing: cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-theme="coastal-light"] {
    --bg: #eef7f8;
    --panel: rgba(255, 255, 255, 0.86);
    --stroke: rgba(42, 98, 119, 0.24);
    --text: rgba(23, 49, 59, 0.94);
    --muted: rgba(23, 49, 59, 0.64);

    --planning: #276ad6;
    --ongoing: #008d79;
    --verified: #b77900;
    --inventory-available: #276ad6;
    --inventory-unavailable: #758392;
    --inventory-applicant-held: #c98200;

    --land: rgba(47, 105, 120, 0.16);
    --border: rgba(44, 92, 110, 0.52);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
}
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP",
        sans-serif;
    background: radial-gradient(
            1200px 600px at 20% 0%,
            rgba(90, 120, 255, 0.2),
            transparent 55%
        ),
        radial-gradient(
            900px 500px at 80% 10%,
            rgba(70, 255, 210, 0.18),
            transparent 55%
        ),
        var(--bg);
    color: var(--text);
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: var(--theme-transition-duration);
    animation-timing-function: var(--theme-transition-easing);
}

body.theme-transitioning,
body.theme-transitioning * {
    transition-property: background, background-color, border-color, color, fill,
        stroke, box-shadow, opacity;
    transition-duration: var(--theme-transition-duration);
    transition-timing-function: var(--theme-transition-easing);
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --theme-transition-duration: 1ms;
    }

    body.theme-transitioning,
    body.theme-transitioning * {
        transition-duration: 1ms;
    }
}

body[data-theme="coastal-light"] {
    background: linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.86),
            rgba(230, 246, 246, 0.8)
        ),
        radial-gradient(
            900px 460px at 18% 0%,
            rgba(88, 178, 186, 0.18),
            transparent 58%
        ),
        radial-gradient(
            760px 420px at 92% 10%,
            rgba(246, 194, 111, 0.2),
            transparent 58%
        ),
        var(--bg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand__dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: rgba(120, 160, 255, 0.9);
    box-shadow: 0 0 18px rgba(120, 160, 255, 0.55);
}
.brand__title {
    font-weight: 700;
    letter-spacing: 0.3px;
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.btn {
    border: 1px solid var(--stroke);
    background: rgba(15, 18, 35, 0.55);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 12px;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    line-height: 1.2;
}
.btn--link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.btn:focus {
    outline: 2px solid rgba(120, 160, 255, 0.55);
    outline-offset: 2px;
}

.select {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--stroke);
    border-radius: 12px;
    background: rgba(15, 18, 35, 0.55);
}
.select__label {
    font-size: 12px;
    color: var(--muted);
}
select {
    background: transparent;
    color: var(--text);
    border: none;
    outline: none;
}

.source-body {
    min-height: 100%;
    background: var(--bg);
}

.source-main {
    width: min(840px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.source-heading {
    padding: 12px 0 18px;
}

.source-heading h1 {
    margin: 0 0 10px;
    font-size: 26px;
    letter-spacing: 0;
}

.source-heading p,
.source-section p {
    margin: 0;
    color: var(--muted);
    line-height: 1.8;
}

.source-section {
    border-top: 1px solid var(--stroke);
    padding: 22px 0;
}

.source-section h2 {
    margin: 0 0 14px;
    font-size: 18px;
    letter-spacing: 0;
}

.source-section p + p {
    margin-top: 10px;
}

.source-note {
    margin-top: 12px !important;
    font-size: 12px;
}

.source-facts {
    display: grid;
    gap: 8px;
    margin: 16px 0;
}

.source-facts div {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 16px;
    padding: 10px 0;
    border-top: 1px solid var(--stroke);
}

.source-facts div:last-child {
    border-bottom: 1px solid var(--stroke);
}

.source-facts dt,
.source-facts dd {
    margin: 0;
    line-height: 1.7;
}

.source-facts dt {
    color: var(--text);
    font-weight: 700;
}

.source-facts dd {
    color: var(--muted);
}

.source-inline {
    color: var(--text);
    font-weight: 700;
}

.source-table-wrap {
    overflow-x: auto;
    border-top: 1px solid var(--stroke);
    border-bottom: 1px solid var(--stroke);
}

.source-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    background: transparent;
}

.source-table th,
.source-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--stroke);
    text-align: left;
    vertical-align: top;
    line-height: 1.7;
}

.source-table tr:last-child th,
.source-table tr:last-child td {
    border-bottom: 0;
}

.source-table th {
    width: 180px;
    color: var(--text);
    font-weight: 700;
}

.source-table a {
    color: var(--inventory-available);
    overflow-wrap: anywhere;
}

.map-data-link {
    color: #68a7ff;
    overflow-wrap: anywhere;
}

.source-table thead th {
    color: var(--muted);
    background: transparent;
    font-size: 12px;
    letter-spacing: 0;
}

.source-table--third-party {
    margin: 0;
}

.source-table--map-data {
    margin: 0;
}

.source-table--map-data tbody th {
    width: 140px;
}

.source-table--third-party th,
.source-table--third-party td {
    vertical-align: top;
}

.source-table--third-party th {
    width: auto;
    font-weight: 700;
}

.source-table--third-party th:nth-child(2),
.source-table--third-party td:nth-child(2) {
    width: 140px;
    white-space: nowrap;
}

.source-table--third-party th:nth-child(3),
.source-table--third-party td:nth-child(3) {
    width: 44%;
}

.license-disclosure summary {
    color: var(--inventory-available);
    cursor: pointer;
    display: inline;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.license-disclosure summary:focus-visible {
    outline: 2px solid rgba(120, 160, 255, 0.55);
    outline-offset: 3px;
}

.license-disclosure pre {
    margin: 10px 0 0;
    max-height: 340px;
    overflow: auto;
    padding: 10px 0 0;
    border: 1px solid var(--stroke);
    border-width: 1px 0 0;
    border-radius: 0;
    background: transparent;
    color: rgba(235, 240, 255, 0.82);
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.topbar__row {
    display: flex;
    align-items: center;
    justify-content: space-between;

    /* 端の窮屈さを解消（左右はgutter、上下は少し厚め） */
    padding: var(--topbar-pad-y) var(--gutter);

    /* タイトルと操作群の “間” を確保 */
    gap: var(--topbar-gap);

    /* 折り返し時の見た目を安定させる */
    flex-wrap: wrap;
}

.map-shell {
    position: relative;
    border: 1px solid var(--stroke);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(120, 160, 255, 0.1),
        0 22px 80px rgba(0, 0, 0, 0.45);
}
.map {
    width: 100%;
    height: calc(100vh - 84px);
    min-height: 520px;
    display: block;
    contain: layout paint;
}

.map-overlay-stack {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: grid;
    gap: 10px;
    justify-items: end;
    z-index: 12;
}

.map-attribution {
    width: min(420px, calc(100vw - 48px));
    max-width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--stroke);
    border-radius: 10px;
    background: rgba(15, 18, 35, 0.78);
    color: var(--muted);
    font-size: 10px;
    line-height: 1.45;
    text-align: left;
    backdrop-filter: blur(10px);
}

.map-attribution p {
    margin: 0;
}

.map-attribution p + p {
    margin-top: 4px;
}

.map-attribution a {
    color: var(--inventory-available);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.map-controls {
    display: grid;
    gap: 6px;
}

.map-control-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--stroke);
    background: rgba(15, 18, 35, 0.82);
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    backdrop-filter: blur(10px);
}

.map-control-btn:hover {
    border-color: rgba(120, 160, 255, 0.48);
    box-shadow: 0 0 0 2px rgba(120, 160, 255, 0.14);
}

.map-control-btn:focus-visible {
    outline: 2px solid rgba(120, 160, 255, 0.55);
    outline-offset: 2px;
}

.legend {
    width: 220px;
    padding: 12px;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--stroke);
    backdrop-filter: blur(10px);
}
.legend__title {
    font-weight: 700;
    margin-bottom: 8px;
}
.legend__row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    margin: 6px 0;
}
.chip {
    width: 12px;
    height: 12px;
    border-radius: 999px;
}
.chip--planning,
.chip--operator,
.chip--available {
    background: var(--inventory-available);
    box-shadow: 0 0 16px rgba(104, 167, 255, 0.52);
}
.chip--ongoing,
.chip--none,
.chip--unavailable {
    background: var(--inventory-unavailable);
    box-shadow: 0 0 16px rgba(154, 167, 184, 0.36);
}
.chip--verified,
.chip--transferred,
.chip--applicant-held {
    background: var(--inventory-applicant-held);
    box-shadow: 0 0 16px rgba(255, 209, 102, 0.48);
}

.tooltip {
    position: absolute;
    left: 12px;
    top: 12px;
    width: min(360px, calc(100% - 24px));
    padding: 12px;
    border-radius: 14px;
    background: rgba(15, 18, 35, 0.78);
    border: 1px solid var(--stroke);
    backdrop-filter: blur(10px);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
}
.tooltip__title {
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 8px;
}
.tooltip__version {
    display: grid;
    gap: 5px;
    margin-bottom: 10px;
}
.tooltip__version span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}
.tooltip__version select {
    width: 100%;
    border: 1px solid rgba(120, 160, 255, 0.34);
    background: rgba(4, 6, 16, 0.58);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 10px;
    outline: none;
    color-scheme: dark;
}
.tooltip__version select:focus {
    outline: 2px solid rgba(120, 160, 255, 0.58);
    outline-offset: 2px;
}
.tooltip__facts {
    display: grid;
    gap: 6px;
    margin: 0 0 10px;
}
.tooltip__fact {
    --tooltip-fact-accent: rgba(235, 240, 255, 0.5);
    display: grid;
    grid-template-columns: 9px 74px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
}
.tooltip__fact::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    margin-top: 5px;
    background: var(--tooltip-fact-accent);
    box-shadow: 0 0 10px var(--tooltip-fact-accent);
}
.tooltip__fact--period {
    --tooltip-fact-accent: rgb(82, 180, 255);
}
.tooltip__fact--continuity {
    --tooltip-fact-accent: rgb(187, 134, 252);
}
.tooltip__fact--project-category {
    --tooltip-fact-accent: rgb(255, 177, 82);
}
.tooltip__fact--ecosystem {
    --tooltip-fact-accent: rgb(67, 242, 200);
}
.tooltip__fact--inventory {
    --tooltip-fact-accent: rgb(255, 209, 102);
}
.tooltip__fact--credit {
    --tooltip-fact-accent: rgb(255, 111, 145);
}
.tooltip__fact dt {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}
.tooltip__fact dd {
    margin: 0;
    color: rgba(235, 240, 255, 0.9);
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.tooltip__actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-start;
}
.tooltip__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(120, 160, 255, 0.36);
    background: rgba(120, 160, 255, 0.12);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
}
.tooltip__link:hover,
.tooltip__link:focus-visible {
    border-color: rgba(120, 160, 255, 0.62);
    box-shadow: 0 0 0 2px rgba(120, 160, 255, 0.16);
    outline: none;
}

/* SVG */
.land {
    fill: var(--land);
    stroke: var(--border);
    stroke-width: 0.85;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
    shape-rendering: optimizeSpeed;
}
.marker {
    cursor: pointer;
    vector-effect: non-scaling-stroke;
    shape-rendering: optimizeSpeed;
}

/* ====== Filter Drawer ====== */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(15, 18, 35, 0.55);
    color: var(--muted);
    font-size: 12px;
}

.btn--ghost {
    background: rgba(15, 18, 35, 0.35);
}

.btn--icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
}

.field {
    margin-bottom: 14px;
    --field-accent: 120, 160, 255;
    --field-accent-strong: rgb(var(--field-accent));
    --field-accent-border: rgba(var(--field-accent), 0.58);
    --field-accent-ring: rgba(var(--field-accent), 0.16);
    --field-accent-fill: rgba(var(--field-accent), 0.1);
}
.field__label {
    font-size: 12px;
    color: rgba(235, 240, 255, 0.72);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    font-weight: 700;
}
.field__label::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--field-accent-strong);
    box-shadow: 0 0 12px rgba(var(--field-accent), 0.42);
}
.field__label .help-popover {
    margin-left: 2px;
}
.field__label .help-popover > summary {
    width: 22px;
    height: 22px;
    font-size: 12px;
}
.field__hint {
    margin-top: 8px;
    font-size: 12px;
    color: rgba(235, 240, 255, 0.52);
}

.field--prefecture {
    --field-accent: 105, 205, 255;
}
.field--continuity {
    --field-accent: 187, 134, 252;
}
.field--project-category {
    --field-accent: 255, 177, 82;
}
.field--ecosystem {
    --field-accent: 67, 242, 200;
}
.field--inventory {
    --field-accent: 255, 209, 102;
}
.field--credit {
    --field-accent: 255, 111, 145;
}
.field--projectlist {
    --field-accent: 255, 111, 145;
}

/* segmented control */
/* ===== segmented control（基盤）を chips と同等の見た目・サイズへ ===== */
.seg {
    display: flex; /* grid から変更 */
    flex-wrap: wrap;
    gap: 8px;
}

.seg__item {
    position: relative;

    /* chips と同じ形状・サイズ感 */
    border: 1px solid var(--stroke);
    background: rgba(15, 18, 35, 0.45); /* 背景は“常に同じ”でOK */
    border-radius: 999px; /* pill */
    padding: 8px 12px; /* chipbtn と同じ */
    cursor: pointer;
    user-select: none;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    font-size: 13px; /* chipbtn と同じ */
    color: var(--text);
    line-height: 1.2;
    min-height: 34px; /* 触りやすい高さ（chipbtn 相当） */
}

.seg__item input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* 選択状態：枠線だけを“強い色”へ（背景は変更しない） */
.seg__item:has(input:checked) {
    border-color: rgba(255, 216, 107, 0.9); /* 例：verified 系の黄で明確化 */
    box-shadow: 0 0 0 2px rgba(255, 216, 107, 0.2); /* 枠の強調（背景は変えない） */
    background: rgba(15, 18, 35, 0.45); /* 明示：背景は据え置き */
}

/* キーボード操作の視認性（枠線扱い） */

/* chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.chipbtn {
    position: relative;
    border: 1px solid var(--stroke);
    background: rgba(15, 18, 35, 0.45);
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.25;
    min-height: 34px;
    max-width: 100%;
}
.chipbtn span {
    overflow-wrap: anywhere;
}
.chipbtn input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.chipbtn:has(input:checked) {
    border-color: var(--field-accent-border);
    box-shadow: 0 0 0 2px var(--field-accent-ring);
    background: linear-gradient(
            0deg,
            var(--field-accent-fill),
            var(--field-accent-fill)
        ),
        rgba(15, 18, 35, 0.68);
}

.combo {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 38px;
}

.combo__input {
    width: 100%;
    border: 1px solid rgba(var(--field-accent), 0.32);
    border-right: 0;
    background: rgba(4, 6, 16, 0.45);
    color: var(--text);
    border-radius: 12px 0 0 12px;
    padding: 10px;
    outline: none;
    min-width: 0;
}

.combo__input::placeholder {
    color: rgba(235, 240, 255, 0.42);
}

.combo__input:focus {
    outline: 2px solid var(--field-accent-border);
    outline-offset: 2px;
}

.combo__toggle {
    border: 1px solid rgba(var(--field-accent), 0.32);
    background: rgba(15, 18, 35, 0.72);
    color: rgba(235, 240, 255, 0.72);
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.combo__toggle:hover,
.combo__toggle:focus-visible {
    color: var(--text);
    border-color: var(--field-accent-border);
    outline: none;
}

.combo__list {
    position: absolute;
    z-index: 120;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    max-height: 220px;
    overflow: auto;
    padding: 6px;
    border: 1px solid rgba(var(--field-accent), 0.32);
    border-radius: 12px;
    background: rgba(10, 12, 24, 0.98);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
}

.combo__option {
    width: 100%;
    border: 0;
    background: transparent;
    color: rgba(235, 240, 255, 0.86);
    border-radius: 8px;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.combo__option:hover,
.combo__option:focus-visible,
.combo__option[aria-selected="true"] {
    background: rgba(var(--field-accent), 0.16);
    color: var(--text);
    outline: none;
}

.combo__empty {
    padding: 8px 10px;
    color: rgba(235, 240, 255, 0.56);
    font-size: 12px;
}

.option-list {
    display: grid;
    gap: 8px;
}

.field--inventory .option-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field--inventory .chipbtn {
    width: 100%;
    justify-content: center;
    padding-inline: 8px;
    white-space: nowrap;
}

@media (max-width: 980px) {
    .field--inventory .option-list {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }
}

.help-popover {
    position: relative;
}

.help-popover > summary {
    list-style: none;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(var(--field-accent), 0.38);
    background: rgba(15, 18, 35, 0.65);
    color: rgba(235, 240, 255, 0.72);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    user-select: none;
}

.help-popover > summary::-webkit-details-marker {
    display: none;
}

.help-popover > summary:focus-visible {
    outline: 2px solid var(--field-accent-border);
    outline-offset: 2px;
}

.help-popover > summary:hover {
    border-color: rgba(var(--field-accent), 0.72);
    color: var(--text);
    background: rgba(var(--field-accent), 0.14);
}

.help-popover[open] > summary {
    border-color: var(--field-accent-border);
    color: var(--text);
    box-shadow: 0 0 0 2px var(--field-accent-ring);
}

.help-popover__body {
    position: fixed;
    z-index: 100;
    left: var(--help-popover-left, 12px);
    top: var(--help-popover-top, 12px);
    width: var(--help-popover-width, min(360px, calc(100vw - 24px)));
    max-height: var(--help-popover-max-height, 260px);
    overflow: auto;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(120, 160, 255, 0.28);
    background: rgba(12, 15, 29, 0.98);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
    color: rgba(235, 240, 255, 0.86);
    font-size: 12px;
    line-height: 1.6;
}
.help-list {
    display: grid;
    gap: 7px;
    margin: 0;
}
.help-list div {
    display: grid;
    grid-template-columns: minmax(132px, 0.42fr) 1fr;
    gap: 6px 12px;
    align-items: start;
    padding-bottom: 7px;
    border-bottom: 1px solid rgba(235, 240, 255, 0.08);
}
.help-list div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}
.help-list dt {
    color: var(--text);
    font-weight: 800;
    line-height: 1.45;
}
.help-list dd {
    margin: 0;
    color: rgba(235, 240, 255, 0.76);
}

@media (max-width: 520px) {
    .help-list div {
        grid-template-columns: 1fr;
        gap: 3px;
    }
}

.rangebox {
    border: 1px solid var(--stroke);
    background: rgba(15, 18, 35, 0.45);
    border-radius: 16px;
    padding: 12px;
}
.rangebox__meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}
.rangebox__value {
    font-weight: 800;
    letter-spacing: 0.2px;
}
.rangebox__unit {
    font-size: 12px;
    color: var(--muted);
}
/* ===== dual range track rendering ===== */
.dualrange {
    position: relative;
    height: 32px;

    /* min/max の位置（%）をJSで更新する */
    --min-pct: 0%;
    --max-pct: 100%;
}

/* 1本のトラックをここで描く（左=除外 / 中=選択 / 右=除外） */
.dualrange::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 6px;
    transform: translateY(-50%);
    border-radius: 999px;

    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0.85) 0 var(--min-pct),
        rgba(var(--field-accent), 0.72) var(--min-pct) var(--max-pct),
        rgba(255, 255, 255, 0.85) var(--max-pct) 100%
    );

    box-shadow: 0 0 0 1px rgba(var(--field-accent), 0.2) inset;
}

/* range入力は「つまみだけ」にする：トラックは透明 */
.dualrange input[type="range"] {
    position: absolute;
    inset: 0;
    width: 100%;
    margin: 0;
    background: transparent;
    pointer-events: none; /* 下でthumbだけ有効化 */

    -webkit-appearance: none;
    appearance: none;
}

/* WebKit track */
.dualrange input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: transparent;
    border: 0;
}

/* Firefox track */
.dualrange input[type="range"]::-moz-range-track {
    height: 6px;
    background: transparent;
    border: 0;
}

/* thumb は操作可能にする */
.dualrange input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto;

    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(15, 18, 35, 0.95);
    box-shadow: 0 0 0 3px var(--field-accent-ring);
    margin-top: calc((6px - 18px) / 2);
}

.dualrange input[type="range"]::-moz-range-thumb {
    pointer-events: auto;

    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(15, 18, 35, 0.95);
    box-shadow: 0 0 0 3px var(--field-accent-ring);
}

/* つまみが重なる時に操作性が落ちるので z-index を制御 */
#creditMin {
    z-index: 2;
}
#creditMax {
    z-index: 3;
}

.rangebox__nums {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.num {
    display: grid;
    gap: 6px;
}
.num__label {
    font-size: 12px;
    color: var(--muted);
}
.num input[type="number"] {
    width: 100%;
    border: 1px solid rgba(var(--field-accent), 0.32);
    background: rgba(4, 6, 16, 0.45);
    color: var(--text);
    border-radius: 12px;
    padding: 10px 10px;
    outline: none;
}
.num input[type="number"]:focus {
    outline: 2px solid var(--field-accent-border);
    outline-offset: 2px;
}

/* ====== topbar 2段（フィルタサマリー常時表示） ====== */
.topbar {
    /* 既存の topbar を上書き：2段化 */
    flex-direction: column;
    align-items: stretch;
}

.filters-live {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

/* ===== map + dock layout ===== */
.map-shell--dock {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 12px;
    border: 1px solid var(--stroke);
    border-radius: 18px;
    padding: 12px;
    box-shadow: 0 0 0 1px rgba(120, 160, 255, 0.1),
        0 22px 80px rgba(0, 0, 0, 0.45);
    background: rgba(4, 6, 16, 0.25);
}

.map-area {
    position: relative;
    border: 1px solid var(--stroke);
    border-radius: 18px;
    overflow: hidden; /* 地図と凡例をこの枠内に閉じる */
    background: rgba(0, 0, 0, 0.15);
}

.map {
    height: calc(100vh - 140px);
    min-height: 520px;
}

/* 常設フィルタパネル（drawer__panel の見た目を踏襲） */
.filters-dock {
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--stroke);
    background: rgba(10, 12, 24, 0.88);
    backdrop-filter: blur(14px);
    box-shadow: 0 22px 80px rgba(0, 0, 0, 0.55);
    display: grid;
    grid-template-rows: auto 1fr auto;
    max-height: calc(100vh - 140px);
}

.filters-dock__header {
    padding: 12px 12px;
    border-bottom: 1px solid var(--stroke);
}

.filters-dock__title {
    font-weight: 800;
    letter-spacing: 0.2px;
}
.filters-dock__sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.filters-dock__body {
    padding: 12px;
    overflow: auto;
}

.filters-dock__footer {
    padding: 12px;
    border-top: 1px solid var(--stroke);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* モバイル：右ペインは無理なので下に固定（常時見える） */
@media (max-width: 720px) {
    .map-shell--dock {
        grid-template-columns: 1fr;
        padding-bottom: calc(52vh + 24px); /* 下ドック分の余白 */
    }

    .filters-dock {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 12px;
        height: 52vh;
        max-height: 52vh;
        z-index: 40;
    }

    .map {
        height: calc(100vh - 140px);
        min-height: 420px;
    }
}

/* ===== Credit accordion (details/summary) ===== */

/* details 既定の三角マーカーを消す */
.rangebox > summary {
    list-style: none;
}
.rangebox > summary::-webkit-details-marker {
    display: none;
}

/* rangebox: 既存 .rangebox を details に適用 */
.rangebox {
    border: 1px solid rgba(var(--field-accent), 0.26);
    background: rgba(15, 18, 35, 0.45);
    border-radius: 16px;
    padding: 0; /* summary/content側で余白を管理 */
    overflow: hidden; /* 角丸を効かせる */
}

/* summary（クリック領域） */
.rangebox__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    padding: 12px;
    user-select: none;
}

.rangebox__summary:focus-visible {
    outline: 2px solid var(--field-accent-border);
    outline-offset: -2px; /* 枠内に収める */
}

/* meta は既存のクラスを継続利用 */
.rangebox__meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    width: 100%;
}

/* chevron */
.rangebox__chev {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-right: 2px solid rgba(235, 240, 255, 0.55);
    border-bottom: 2px solid rgba(235, 240, 255, 0.55);
    transform: rotate(45deg);
    transition: transform 140ms ease;
}

/* open のとき回転 */
.rangebox[open] .rangebox__chev {
    transform: rotate(-135deg);
}

/* 開いた時の中身 */
.rangebox__content {
    padding: 0 12px 12px 12px;
}

/* 閉じた時は中身の余白を持たない（見通し改善） */
.rangebox:not([open]) .rangebox__content {
    padding: 0 12px 12px 12px; /* display:none相当のため影響しないが明示 */
}

/* summary 下に区切り線（開いた時だけ） */
.rangebox[open] .rangebox__summary {
    border-bottom: 1px solid rgba(var(--field-accent), 0.18);
}

/* motion を抑制 */
@media (prefers-reduced-motion: reduce) {
    .rangebox__chev {
        transition: none;
    }
}

/* ===== D3(SVG) 版の地図を安定させる ===== */

/* #map が <svg> になるので、SVGとしての挙動を明示 */
svg.map {
    width: 100%;
    height: 100%;
    display: block; /* 余計なinline隙間を消す */
    overflow: visible; /* stroke等が切れないように */
    touch-action: none; /* D3 zoom/pan を邪魔しない */
}

/* マーカー等の hover が必要なら */
.marker {
    pointer-events: all;
}

/* 背景パスがマーカー操作を邪魔しないようにする */
.land {
    pointer-events: none; /* 背景パスがマーカー操作を邪魔しない */
}

/* ===== Project list under credit range ===== */
.projectlist {
    border: 1px solid var(--stroke);
    background: rgba(15, 18, 35, 0.35);
    border-radius: 16px;
    padding: 10px;
    margin-top: 10px;
}

.projectlist__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.projectlist__title {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.2px;
}

.projectlist__count {
    font-size: 12px;
    color: rgba(235, 240, 255, 0.72);
}

.projectlist__items {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 220px;
    overflow: auto;
    display: grid;
    gap: 6px;
}

.projectlist__btn {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(120, 160, 255, 0.16);
    background: rgba(10, 12, 24, 0.55);
    color: var(--text);
    border-radius: 12px;
    padding: 8px 10px;
    cursor: pointer;
    display: grid;
    gap: 2px;
}

.projectlist__btn:hover {
    border-color: rgba(120, 160, 255, 0.42);
    box-shadow: 0 0 0 2px rgba(120, 160, 255, 0.14);
}

.projectlist__btn:focus-visible {
    outline: 2px solid rgba(120, 160, 255, 0.55);
    outline-offset: 2px;
}

.projectlist__meta {
    font-size: 12px;
    color: rgba(235, 240, 255, 0.62);
}

/* hover / selected を赤にする（fill属性より強く上書き） */
.marker.is-hovered,
.marker.is-selected {
    fill: rgba(255, 59, 48, 0.98) !important;
    stroke: none !important;
    filter: drop-shadow(0 0 6px rgba(255, 59, 48, 0.75))
        drop-shadow(0 0 14px rgba(255, 59, 48, 0.35)) !important;
}

/* ===== Light comparison theme ===== */
.theme-switch {
    min-width: 86px;
}

body[data-theme="coastal-light"] .brand__dot {
    background: rgba(39, 106, 214, 0.9);
    box-shadow: 0 0 16px rgba(39, 106, 214, 0.34);
}

body[data-theme="coastal-light"] .btn,
body[data-theme="coastal-light"] .select,
body[data-theme="coastal-light"] .pill,
body[data-theme="coastal-light"] .map-control-btn,
body[data-theme="coastal-light"] .chipbtn,
body[data-theme="coastal-light"] .seg__item,
body[data-theme="coastal-light"] .rangebox,
body[data-theme="coastal-light"] .projectlist {
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    border-color: var(--stroke);
}

body[data-theme="coastal-light"] .btn:hover,
body[data-theme="coastal-light"] .map-control-btn:hover,
body[data-theme="coastal-light"] .projectlist__btn:hover {
    border-color: rgba(39, 106, 214, 0.42);
    box-shadow: 0 0 0 2px rgba(39, 106, 214, 0.12);
}

body[data-theme="coastal-light"] .map-shell--dock {
    background: rgba(255, 255, 255, 0.42);
    box-shadow: 0 18px 60px rgba(31, 77, 88, 0.16);
}

body[data-theme="coastal-light"] .map-area {
    background: linear-gradient(
        180deg,
        rgba(248, 253, 253, 0.92),
        rgba(225, 242, 243, 0.72)
    );
}

body[data-theme="coastal-light"] .filters-dock {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 18px 56px rgba(31, 77, 88, 0.18);
}

body[data-theme="coastal-light"] .legend,
body[data-theme="coastal-light"] .tooltip,
body[data-theme="coastal-light"] .help-popover__body {
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    box-shadow: 0 16px 44px rgba(31, 77, 88, 0.18);
}

body[data-theme="coastal-light"] .map-attribution {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(42, 98, 119, 0.24);
    color: rgba(23, 49, 59, 0.78);
    box-shadow: 0 12px 32px rgba(31, 77, 88, 0.16);
}

body[data-theme="coastal-light"] .map-attribution a {
    color: #276ad6;
}

body[data-theme="coastal-light"] .tooltip__fact dd,
body[data-theme="coastal-light"] .help-list dd,
body[data-theme="coastal-light"] .projectlist__count,
body[data-theme="coastal-light"] .projectlist__meta {
    color: rgba(23, 49, 59, 0.68);
}

body[data-theme="coastal-light"] .field__label,
body[data-theme="coastal-light"] .num__label,
body[data-theme="coastal-light"] .projectlist__title,
body[data-theme="coastal-light"] .legend__row,
body[data-theme="coastal-light"] .tooltip__version span,
body[data-theme="coastal-light"] .tooltip__fact dt {
    color: rgba(23, 49, 59, 0.68);
}

body[data-theme="coastal-light"] .tooltip__fact--period {
    --tooltip-fact-accent: rgb(82, 180, 255);
}

body[data-theme="coastal-light"] .tooltip__fact--continuity {
    --tooltip-fact-accent: rgb(187, 134, 252);
}

body[data-theme="coastal-light"] .tooltip__fact--project-category {
    --tooltip-fact-accent: rgb(255, 177, 82);
}

body[data-theme="coastal-light"] .tooltip__fact--ecosystem {
    --tooltip-fact-accent: rgb(67, 242, 200);
}

body[data-theme="coastal-light"] .tooltip__fact--inventory {
    --tooltip-fact-accent: rgb(255, 209, 102);
}

body[data-theme="coastal-light"] .tooltip__fact--credit {
    --tooltip-fact-accent: rgb(255, 111, 145);
}

body[data-theme="coastal-light"] .tooltip__version select,
body[data-theme="coastal-light"] .combo__input,
body[data-theme="coastal-light"] .num input[type="number"] {
    background: rgba(255, 255, 255, 0.86);
    color: var(--text);
    border-color: rgba(var(--field-accent), 0.34);
    color-scheme: light;
}

body[data-theme="coastal-light"] .combo__input::placeholder {
    color: rgba(23, 49, 59, 0.42);
}

body[data-theme="coastal-light"] .combo__toggle,
body[data-theme="coastal-light"] .help-popover > summary {
    background: rgba(255, 255, 255, 0.82);
    color: rgba(23, 49, 59, 0.68);
}

body[data-theme="coastal-light"] .combo__list {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 42px rgba(31, 77, 88, 0.18);
}

body[data-theme="coastal-light"] .combo__option {
    color: rgba(23, 49, 59, 0.84);
}

body[data-theme="coastal-light"] .combo__empty {
    color: rgba(23, 49, 59, 0.56);
}

body[data-theme="coastal-light"] .chipbtn:has(input:checked),
body[data-theme="coastal-light"] .seg__item:has(input:checked) {
    background: linear-gradient(
            0deg,
            var(--field-accent-fill),
            var(--field-accent-fill)
        ),
        rgba(255, 255, 255, 0.92);
}

body[data-theme="coastal-light"] .projectlist__btn {
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(42, 98, 119, 0.18);
    color: var(--text);
}

body[data-theme="coastal-light"] .rangebox__chev {
    border-color: rgba(23, 49, 59, 0.55);
}

body[data-theme="coastal-light"] .tooltip__link {
    background: rgba(39, 106, 214, 0.08);
    border-color: rgba(39, 106, 214, 0.28);
    color: var(--text);
}
