:root {
	--bg: #0f1418;
	--panel: rgba(17, 23, 28, 0.92);
	--panel-solid: #11171c;
	--line: rgba(255, 255, 255, 0.12);
	--text: #eef2f5;
	--muted: #9aa7b1;
	--accent: #34d399;
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family:
		system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP",
		"Yu Gothic", sans-serif;
	font-size: 14px;
	overscroll-behavior: none;
}

#map {
	position: absolute;
	inset: 0;
	background: #0b1013;
}

/* ---------- パネル ---------- */

.panel {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 1000;
	width: 350px;
	max-height: calc(100dvh - 24px);
	display: flex;
	flex-direction: column;
	background: var(--panel);
	backdrop-filter: blur(12px);
	border: 1px solid var(--line);
	border-radius: 14px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
	transition:
		transform 0.22s ease,
		opacity 0.22s ease;
}

body.panel-hidden .panel {
	transform: translateX(calc(-100% - 16px));
	opacity: 0;
	pointer-events: none;
}

.panel__header {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 14px 16px 10px;
	border-bottom: 1px solid var(--line);
}

.panel__title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.panel__meta {
	margin: 4px 0 0;
	font-size: 11px;
	line-height: 1.5;
	color: var(--muted);
}

.panel__close {
	margin-left: auto;
	width: 26px;
	height: 26px;
	flex: none;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.05);
	color: var(--muted);
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
}

.panel__body {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 14px 16px;
	overflow-y: auto;
	flex: 1;
}

.panel__footer {
	padding: 8px 16px 10px;
	border-top: 1px solid var(--line);
	font-size: 11px;
	color: var(--muted);
}

.panel__footer a,
.link-btn {
	color: var(--accent);
}

.panel-toggle {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 1001;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--panel);
	backdrop-filter: blur(12px);
	color: var(--text);
	font: inherit;
	font-size: 12px;
	cursor: pointer;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

body.panel-hidden .panel-toggle {
	opacity: 1;
	pointer-events: auto;
}

/* ---------- フォーム部品 ---------- */

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.field--row {
	flex-direction: row;
	gap: 10px;
}

.field--grow {
	min-height: 0;
}

.field__label {
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	color: var(--muted);
}

.field__inline {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.field__inline--check {
	justify-content: flex-start;
}

select,
input[type="search"] {
	width: 100%;
	padding: 7px 9px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.06);
	color: var(--text);
	font: inherit;
	font-size: 13px;
}

/*
 * 選択肢はブラウザが描くので、色を明示しないと配色を継がずに読めなくなる
 * （閉じているときの薄い背景をそのまま使われて、暗い字が暗い地に乗る）。
 */
option {
	background: var(--panel-solid);
	color: var(--text);
}

select:focus-visible,
input:focus-visible,
button:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}

.check {
	display: flex;
	align-items: flex-start;
	gap: 6px;
	font-size: 11px;
	line-height: 1.35;
	color: var(--muted);
	cursor: pointer;
}

.check input {
	margin: 1px 0 0;
	accent-color: var(--accent);
}

.link-btn {
	border: 0;
	background: none;
	padding: 0;
	font: inherit;
	font-size: 11px;
	cursor: pointer;
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
}

.chips--scroll {
	max-height: 92px;
	overflow-y: auto;
	padding-right: 2px;
}

.chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 9px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.05);
	color: var(--muted);
	font: inherit;
	font-size: 11px;
	cursor: pointer;
}

.chip[aria-pressed="true"] {
	border-color: var(--chip, var(--accent));
	background: color-mix(in srgb, var(--chip, var(--accent)) 22%, transparent);
	color: var(--text);
}

.chip__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--chip, var(--accent));
}

.chip__count {
	font-size: 10px;
	opacity: 0.65;
	font-variant-numeric: tabular-nums;
}

.count {
	font-weight: 400;
	color: var(--muted);
}

/* ---------- 一覧 ---------- */

.list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.list__item {
	display: grid;
	grid-template-columns: 52px 1fr;
	align-items: center;
	gap: 9px;
	padding: 6px 4px;
	border-radius: 8px;
	cursor: pointer;
}

.list__item:hover {
	background: rgba(255, 255, 255, 0.07);
}

.list__thumb {
	width: 52px;
	height: 40px;
	border-radius: 6px;
	object-fit: cover;
	background: rgba(255, 255, 255, 0.07);
	border-left: 3px solid var(--pin);
}

.list__body {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.list__name {
	font-size: 12px;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.list__meta {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 10px;
	color: var(--muted);
}

.list__status {
	padding: 0 5px;
	border-radius: 999px;
	background: color-mix(in srgb, var(--pin) 25%, transparent);
	color: var(--text);
	white-space: nowrap;
}

.list__empty {
	padding: 12px 4px;
	color: var(--muted);
	font-size: 12px;
}

.list__more {
	padding: 8px 4px 0;
	color: var(--muted);
	font-size: 11px;
}

/* ---------- ポップアップ ---------- */

/* マーカーとクラスタは WebGL 側 (円レイヤ) で描くので CSS は無い */

.pop-wrap .maplibregl-popup-content {
	padding: 0;
	max-height: min(78dvh, 460px);
	overflow-x: hidden;
	overflow-y: auto;
	background: var(--panel-solid);
	color: var(--text);
	border: 1px solid var(--line);
	border-radius: 12px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.pop-wrap .maplibregl-popup-tip {
	border-top-color: var(--panel-solid);
	border-bottom-color: var(--panel-solid);
}

.pop-wrap .maplibregl-popup-close-button {
	width: 24px;
	height: 24px;
	color: #fff;
	font-size: 18px;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
	background: none;
}

.pop-wrap .maplibregl-popup-close-button:hover {
	background: rgba(255, 255, 255, 0.12);
}

.pop__photo {
	display: block;
	width: 100%;
	height: 150px;
	object-fit: cover;
	background: rgba(255, 255, 255, 0.06);
}

.pop__inner {
	padding: 12px 14px 14px;
}

.pop__name {
	margin: 0 0 6px;
	font-size: 13px;
	line-height: 1.45;
	font-weight: 700;
}

.pop__tags {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-bottom: 8px;
}

.pop__badge {
	padding: 1px 7px;
	border-radius: 999px;
	background: var(--pin);
	color: #06110c;
	font-size: 11px;
	font-weight: 700;
}

.pop__tag {
	padding: 1px 7px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.1);
	color: var(--muted);
	font-size: 11px;
}

.pop__rows {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 3px 10px;
	font-size: 11px;
	line-height: 1.5;
}

.pop__rows dt {
	color: var(--muted);
}

.pop__rows dd {
	margin: 0;
}

.pop__links {
	display: flex;
	gap: 8px;
	margin-top: 12px;
}

.pop__link {
	flex: 1;
	padding: 7px 0;
	border-radius: 8px;
	border: 1px solid var(--line);
	color: var(--text);
	font-size: 12px;
	text-align: center;
	text-decoration: none;
}

.pop__link--primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #06221a;
	font-weight: 700;
}

/* ---------- MapLibre の暗色化 ---------- */

.maplibregl-ctrl-group {
	background: var(--panel-solid);
	border: 1px solid var(--line);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.maplibregl-ctrl-group button + button {
	border-top-color: var(--line);
}

.maplibregl-ctrl-group button .maplibregl-ctrl-icon {
	filter: invert(1) brightness(1.4);
}

.maplibregl-ctrl-group button:not(:disabled):hover {
	background: #1b242b;
}

.maplibregl-ctrl-attrib.maplibregl-compact {
	background: rgba(15, 20, 24, 0.75);
	color: var(--muted);
}

.maplibregl-ctrl-attrib-inner {
	font-size: 10px;
}

.maplibregl-ctrl-attrib a {
	color: var(--accent);
}

.maplibregl-ctrl-attrib-button {
	filter: invert(1);
}

.maplibregl-ctrl-scale {
	background: rgba(15, 20, 24, 0.6);
	border-color: var(--line);
	color: var(--text);
	font-size: 10px;
}

/* 背景切替（自前のコントロール） */

.layers {
	position: relative;
}

.layers__toggle {
	width: 29px;
	height: 29px;
	border: 0;
	background: none;
	color: var(--text);
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
}

.layers__menu {
	position: absolute;
	right: 0;
	bottom: 100%;
	margin-bottom: 6px;
	padding: 8px 10px;
	width: max-content;
	background: var(--panel-solid);
	border: 1px solid var(--line);
	border-radius: 10px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.layers__item {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 3px 0;
	font-size: 12px;
	color: var(--text);
	white-space: nowrap;
	cursor: pointer;
}

.layers__item input {
	accent-color: var(--accent);
}

.layers__sep {
	margin: 6px 0;
	border: 0;
	border-top: 1px solid var(--line);
}

/* ---------- トースト ---------- */

.toast {
	position: absolute;
	bottom: 20px;
	left: 50%;
	translate: -50% 0;
	z-index: 1200;
	padding: 10px 16px;
	border-radius: 10px;
	border: 1px solid var(--line);
	background: var(--panel-solid);
	font-size: 12px;
}

/* ---------- モバイル ---------- */

@media (max-width: 640px) {
	.panel {
		top: auto;
		bottom: 0;
		left: 0;
		width: 100%;
		max-height: 58dvh;
		border-radius: 14px 14px 0 0;
	}

	body.panel-hidden .panel {
		transform: translateY(100%);
	}

	.panel-toggle {
		top: auto;
		/* 下端は出典表示が占めるので、その上に置く */
		bottom: 52px;
		left: 50%;
		translate: -50% 0;
	}

	.field--row {
		flex-direction: column;
	}

	/* パネルが画面の下半分を覆うので、地図のコントロールはその上に逃がす */
	body:not(.panel-hidden) .maplibregl-ctrl-bottom-right {
		bottom: 58dvh;
	}
}
