:root {
  --bg: #f7f7f5; --panel: #ffffff; --text: #1f2328; --muted: #6a737d; --line: #d8dbdf;
  --head: #2b3a4a; --headtext: #ffffff; --link: #0b5cad;
  --keep: #d8f0dc; --keep-b: #2e8b45; --maybe: #fff3d6; --maybe-b: #b7791f; --drop: #eeeeee; --drop-b: #8a8f96; --shade: rgba(0,0,0,.45);
  --warn: #c0392b; --out: #b35c00; --badge: #e8eaed;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; padding: 16px; background: var(--bg); color: var(--text);
  font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", sans-serif; font-size: 14px; line-height: 1.45; }
h1 { font-size: 20px; margin: 0 0 4px; }
.note, .hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
code { font-family: Consolas, monospace; font-size: 12px; }
select, input, button { font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--head); color: var(--headtext); border-color: var(--head); }

.top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-start; justify-content: space-between; }
.heading { flex: 1 1 auto; }
.datanote { flex: 1 1 100%; margin: 0 0 12px; }
.toollink { font-size: 13px; }
.filebar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fname { font-weight: 600; max-width: 22em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 状態の文言が変わっても周りが動かないよう、最長の文言が入る幅を確保する */
.savestate { display: inline-block; min-width: 19em; font-size: 12px; color: var(--muted); }
.savestate.bad { color: var(--warn); }

.start { max-width: 760px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.startbtns { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.format { overflow-x: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 12px; }
.formatnotes { font-size: 12px; color: var(--muted); padding-left: 18px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.controls label { display: flex; gap: 4px; align-items: center; white-space: nowrap; }
input.short { width: 72px; }
/* 乗る駅の選択欄は重ねて開き、ほかの要素を動かさない */
.stpick { position: relative; }
.stpick summary { cursor: pointer; display: inline-block; min-width: 10em; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: var(--panel); }
.stpanel { position: absolute; top: calc(100% + 4px); left: 0; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; max-height: 60vh; overflow: auto; box-shadow: 0 4px 16px rgba(0, 0, 0, .12); }
.stpanel label { display: flex; gap: 6px; align-items: center; white-space: nowrap; padding: 2px 0; }
.stpanel button { margin-top: 6px; }
/* 件数は絞り込みの欄の下に1行で固定（文言の長さで入力欄が動かないように） */
.counts { color: var(--muted); font-size: 12px; margin: -6px 0 8px; min-height: 1.45em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 表は画面の残りの高さに収め、表の中でスクロールする（見出しの行を常に上に出すため。高さは app.js が --wrap-top に入れる） */
.wrap { overflow: auto; max-height: max(320px, calc(100vh - var(--wrap-top, 200px) - 12px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; vertical-align: middle; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 2; background: var(--head); color: var(--headtext); font-weight: 600; }
td.num { text-align: right; }
/* 見出しの並べ替えボタン（矢印の幅を常に取り、切り替えで見出しの幅が変わらないようにする） */
th button.sortbtn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; }
th button.sortbtn:hover, th button.sortbtn.on { text-decoration: underline; }
th button.sortbtn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
th button.sortbtn .arrow { display: inline-block; width: 1em; font-size: 10px; text-align: center; }
/* 並べ替えできる見出し: 薄い ⇅ を常に出し、押せることが分かるようにする（並べ替え中は ▲▼） */
th button.sortbtn:not(.on) .arrow { opacity: .6; }
th:has(> button.sortbtn) { background: #34495e; }
td.wrapcell { white-space: normal; min-width: 160px; max-width: 260px; font-size: 12px; color: var(--muted); }
/* 推しポイント（pitch）は本文の色で。掲載情報のメモは札に重ねたときだけ全文を出す */
td.wrapcell .pitch { color: var(--text); }
.badge.memo { cursor: help; }
td.out, td.out b { color: var(--out); }
tr.group td { background: var(--bg); font-weight: 700; color: var(--muted); }
tr.s-keep td { background: var(--keep); }
tr.s-maybe td { background: var(--maybe); }
tr.s-drop td { background: var(--drop); color: var(--muted); }
tr.s-drop a, tr.s-drop b, tr.s-drop .pitch { color: var(--muted); }
/* モーダルで開いた（開いていた）物件の行: 枠を付け、閉じた直後は一瞬黄色くする */
tr.focus td { box-shadow: inset 0 2px 0 var(--link), inset 0 -2px 0 var(--link); }
tr.focus td:first-child { box-shadow: inset 3px 0 0 var(--link), inset 0 2px 0 var(--link), inset 0 -2px 0 var(--link); }
tr.focus td:last-child { box-shadow: inset -3px 0 0 var(--link), inset 0 2px 0 var(--link), inset 0 -2px 0 var(--link); }
tr.flash td { animation: rowflash 1.8s ease-out; }
@keyframes rowflash { from { background-color: #ffe98a; } }
.st { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.st button { border: 0; border-radius: 0; padding: 3px 8px; font-size: 12px; }
.st button + button { border-left: 1px solid var(--line); }
.st button.on-keep { background: var(--keep-b); color: #fff; }
.st button.on-maybe { background: var(--maybe-b); color: #fff; }
.st button.on-drop { background: var(--drop-b); color: #fff; }
a.open { color: var(--link); cursor: pointer; text-decoration: underline; }
.sub { display: block; font-size: 11px; color: var(--muted); }
.inl { display: inline; margin-left: 8px; }
.warn { color: var(--warn); font-size: 12px; }
.caution { color: var(--out); font-size: 12px; }
.badge.ended { background: #fde2e1; color: #b3261e; }
.badge.tag { background: #e3edfb; color: #1558b0; font-weight: 700; }
.badge { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 4px; background: var(--badge);
  color: var(--muted); font-size: 11px; }

details.panel { margin-top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
details.panel form { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
details.panel form input { width: 140px; }
details.panel form input.wide { width: 260px; }

/* モーダル: 左に物件ページ、右に地図（境目はドラッグで動かせる） */
.modal { position: fixed; inset: 0; background: var(--shade); display: none; z-index: 10; }
.modal.open { display: flex; align-items: center; justify-content: center; }
.box { background: var(--panel); border-radius: 10px; width: 90vw; height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.mtitle { font-weight: 700; margin: 0 4px; }
.mmeta { color: var(--muted); font-size: 12px; }
.winnote { color: var(--muted); font-size: 12px; margin-right: 6px; }
.bar .sp { flex: 1; }
.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 6px 1fr; }
.panes iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.pagepane { position: relative; width: 100%; height: 100%; min-width: 0; }
.noembed { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 24px; text-align: center; color: var(--muted); background: var(--bg); }
a.btnlink { display: inline-block; padding: 8px 14px; border-radius: 6px; background: var(--head); color: var(--headtext); text-decoration: none; }
.mappane { position: relative; width: 100%; height: 100%; }
.mappane > .map, .mappane > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.gkeyrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.gkeyrow input.wide { width: 360px; }
.split { cursor: col-resize; background: var(--line); }
.split:hover, .panes.dragging .split { background: var(--muted); }
.panes.dragging iframe, .panes.dragging .map { pointer-events: none; }
.panes.maponly { grid-template-columns: 1fr; }
.panes.maponly .pagepane, .panes.maponly .split { display: none; }
@media (max-width: 800px) {
  .box { width: 96vw; }
  .panes, .panes.maponly { grid-template-columns: 1fr !important; grid-template-rows: 1fr 1fr; }
  .split { display: none; }
}
/* 地図のラベル */
.leaflet-tooltip.lbl-home { font-weight: 700; color: #b3261e; }
.leaflet-tooltip.lbl-origin { font-weight: 700; color: var(--head); }
.star-pin { color: #f2b705; font-size: 30px; line-height: 30px; text-align: center;
  text-shadow: 0 0 2px #3a2a00, 0 1px 4px rgba(0,0,0,.45); }
/* 地図上の札（徒歩の輪・物件までの距離） */
.ring-lbl span, .dist-lbl span, .train-lbl span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-size: 11px;
  padding: 1px 6px; border-radius: 9px; background: rgba(255,255,255,.9); border: 1px solid #c9ced4; color: #2b3a4a; }
.dist-lbl span { font-size: 12px; font-weight: 700; color: #b3261e; border-color: #e5a29c; }
.train-lbl span { font-size: 12px; font-weight: 700; color: #1558b0; border-color: #9cbcf0; }
.leaflet-tooltip.lbl-station { font-weight: 700; color: #1558b0; }
.map.dim .base-tiles { filter: grayscale(.9) contrast(.8) brightness(1.08); opacity: .7; }
