:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --surface-3: #e8e7e1;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --line: #e1e0d9;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #1f5fae;
  --accent-soft: #e3edf9;
  --on-accent: #ffffff;
  --warn: #9a5b00;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 20px rgba(0, 0, 0, .10);
  /* 印の色は2色（橙=料金・プランあり、青=掲載・公式サイトあり）。検証スクリプトで CVD・コントラストを確認済み。
     登録簿だけの船宿は色ではなく「中抜きの輪」で区別する */
  --c-plan: #eb6834;
  --c-web: #2a78d6;
  --c-reg: #6f6d68;
  --font: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", "Segoe UI", sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2e2e2b;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --line: #2c2c2a;
  --ring: rgba(255, 255, 255, 0.10);
  --accent: #6aa5ee;
  --accent-soft: #1c2a3b;
  --on-accent: #0b0b0b;
  --warn: #f0b04a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .5);
  --c-plan: #d95926;
  --c-web: #3987e5;
  --c-reg: #a8a69d;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

#app { display: flex; height: 100vh; height: 100dvh; }
#map { flex: 1; min-width: 0; position: relative; background: var(--bg); }

/* ---------- panel ---------- */
.panel {
  width: 410px; max-width: 46vw; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
  position: relative; z-index: 3;
}
.sheet-handle { display: none; }
.panel-head { padding: 14px 16px 6px; }
.panel-head h1 { margin: 0; font-size: 19px; line-height: 1.3; letter-spacing: .02em; }
.panel-head .sub { margin: 2px 0 0; color: var(--ink-2); font-size: 12.5px; }

.search { padding: 6px 16px 8px; }
.search input {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.toggles { display: flex; gap: 8px; padding: 0 16px 8px; }
.toggle {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 6px 10px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 13.5px;
}
.toggle:hover { background: var(--surface-2); }
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.toggle .ico { font-size: 15px; }

.filters { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.filters summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 8px;
  padding: 8px 16px; font-weight: 600; font-size: 13px; color: var(--ink-2); user-select: none;
}
.filters summary::-webkit-details-marker { display: none; }
.filters summary::before { content: "▸"; display: inline-block; transition: transform .15s; color: var(--muted); }
.filters[open] summary::before { transform: rotate(90deg); }
.fsum { font-weight: 400; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fgroup { padding: 2px 16px 8px; }
.flabel { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 3px 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 12.5px;
  color: var(--ink-2);
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--surface-3); border-color: var(--ink-2); color: var(--ink); font-weight: 600; }
.chip .n { color: var(--muted); font-weight: 400; font-size: 11px; }
.chip.zero { border-style: dashed; }  /* 押しても一覧が変わらない（文字は薄くせずコントラストを保つ） */
.detail h2:focus { outline: none; }
.map-error {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center;
  color: var(--ink-2); background: var(--bg); font-size: 14px; line-height: 1.7;
}
.more-fish { margin: 4px 0 0; }
.pref-select {
  margin-top: 8px; width: 100%; height: 34px; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
}
.options { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); padding-bottom: 10px; }
.options label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; font-size: 12.5px; }
.options .linkbtn { margin-left: auto; }
.linkbtn:hover { text-decoration: underline; }

/* 凡例キー: 地図の印をそのまま小さく描く */
.key { flex: none; display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--k); box-shadow: 0 0 0 1.5px var(--surface); }
.key.c0 { --k: var(--c-plan); }
.key.c1 { --k: var(--c-web); }
.key.c2 { background: var(--surface); border: 2px solid var(--c-reg); box-shadow: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 16px 0; font-size: 12px; color: var(--ink-2); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend .clu { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-3); border: 1.5px solid var(--ink-2); font-size: 9px; font-weight: 700; color: var(--ink); }
.home-ctl button { width: auto !important; padding: 0 8px !important; font-size: 12px; color: #333; }
.tip-pop { pointer-events: none; }

.count { padding: 8px 16px; font-size: 12.5px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.count b { color: var(--ink); font-size: 14px; }

.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.item {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 9px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer;
}
.item:first-child { border-top: 1px solid var(--line); }
.item:hover, .item:focus-visible { background: var(--surface-2); outline: none; }
.item .main { flex: 1; min-width: 0; }
.item .name { display: block; font-weight: 600; font-size: 13.5px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .op { display: block; color: var(--ink-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .price { flex: none; font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.item .price small { font-weight: 400; color: var(--muted); }
.list-more { display: block; width: calc(100% - 32px); margin: 10px 16px; min-height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--ink-2); }
.list-more:hover { background: var(--surface-2); }
.tag { display: inline-block; font-size: 10.5px; line-height: 1.45; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--ink-2); margin-right: 4px; vertical-align: 1px; font-weight: 500; white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-2); }

/* ---------- detail ---------- */
.detail { padding: 10px 16px 16px; }
.back { display: flex; align-items: center; gap: 4px; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 0; margin: 0 0 6px; font-size: 13px; }
.back:hover { text-decoration: underline; }
.detail .cat { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.detail h2 { font-size: 19px; line-height: 1.35; margin: 6px 0 0; }
.detail .kana { color: var(--muted); font-size: 12px; margin: 0; }
.detail .place { color: var(--ink-2); margin: 2px 0 8px; }
.detail h3 { font-size: 14px; margin: 18px 0 8px; display: flex; align-items: baseline; gap: 8px; }
.detail h3 .n { font-weight: 400; color: var(--muted); font-size: 12px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); }
.pill.yes { background: var(--accent-soft); border-color: transparent; color: var(--ink); font-weight: 600; }
.actions { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 6px; }
.actions .row { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .row > * { flex: 1 1 140px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 14px;
  border-radius: 10px; text-decoration: none; font-weight: 700; border: 1px solid var(--line); color: var(--ink); background: var(--surface);
  text-align: center; line-height: 1.3;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn:hover { filter: brightness(1.05); background-color: var(--surface-2); }
.btn.primary:hover { background-color: var(--accent); }
.btn .ext { font-weight: 400; opacity: .8; }
.btn.small { min-height: 36px; font-size: 12.5px; font-weight: 600; padding: 6px 10px; }

.plans { display: flex; flex-direction: column; gap: 8px; }
.plan { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--surface); }
.plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.plan-name { font-weight: 600; font-size: 13.5px; line-height: 1.4; }
.plan-price { flex: none; font-weight: 700; font-size: 14px; white-space: nowrap; text-align: right; }
.plan-price small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.plan-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }
.plan-meta .time { font-variant-numeric: tabular-nums; color: var(--ink); }
.plan-sub { margin-top: 3px; font-size: 12px; color: var(--muted); }
.plan-sub a { font-size: 12px; }
.plans-more { align-self: flex-start; }

.kv { display: grid; grid-template-columns: 6.8em 1fr; gap: 6px 10px; margin: 14px 0 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.note { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.box-note { margin: 4px 0 0; padding: 9px 11px; border-radius: 10px; background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); }
.sources { margin: 4px 0 0; padding-left: 1.2em; font-size: 12px; }
.sources a { overflow-wrap: anywhere; }
.loading { color: var(--muted); font-size: 12.5px; margin-top: 10px; }

.panel-foot { padding: 14px 16px 22px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 8px; }
.panel-foot p { margin: 0 0 6px; }

/* ---------- map UI ---------- */
.maplibregl-popup-content {
  background: var(--surface); color: var(--ink); border-radius: 10px; box-shadow: var(--shadow);
  padding: 8px 10px; font: 13px/1.45 var(--font); border: 1px solid var(--ring);
}
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
.maplibregl-popup-close-button { color: var(--ink-2); font-size: 18px; padding: 0 6px; }
.tip { max-width: 280px; pointer-events: none; }
.tip .t-row { display: flex; align-items: center; gap: 7px; }
.tip .t-name { font-weight: 700; }
.tip .t-sub { color: var(--ink-2); font-size: 12px; margin-left: 18px; }
.tip .more { color: var(--muted); font-size: 12px; margin-top: 2px; }

.basemap-ctl { display: flex; overflow: hidden; }
.basemap-ctl button { width: auto !important; padding: 0 9px !important; font-size: 12px; color: #333; }
.basemap-ctl button + button { border-top: 0; border-left: 1px solid #ddd; }
.basemap-ctl button[aria-pressed="true"] { background: #1f5fae; color: #fff; }
.maplibregl-ctrl-attrib { font-size: 10.5px; }

/* ---------- small screens: bottom sheet ---------- */
@media (max-width: 820px) {
  #app { display: block; }
  #map { position: fixed; inset: 0; }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-width: none;
    border-right: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 24px rgba(0, 0, 0, .18);
    height: max(46vh, 220px); height: max(46dvh, 220px); transition: height .22s ease; padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.peek { height: 176px; }
  .panel.full { height: 90vh; height: 90dvh; }
  .sheet-handle {
    display: flex; justify-content: center; align-items: center; width: 100%; height: 32px; flex: none;
    background: none; border: 0; cursor: grab; padding: 0; touch-action: none;
  }
  .sheet-handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--muted); }
  .panel-head { padding: 0 16px 2px; display: flex; align-items: baseline; gap: 8px; }
  .panel-head h1 { font-size: 16px; white-space: nowrap; }
  .panel-head .sub { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search { padding: 4px 16px 6px; }
  .toggle { min-height: 36px; font-size: 13px; }
  .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: max(46dvh, 220px); }
  .panel.peek ~ #map .maplibregl-ctrl-bottom-left, .panel.peek ~ #map .maplibregl-ctrl-bottom-right { bottom: 176px; }
  .panel.full ~ #map .maplibregl-ctrl-bottom-right { bottom: 90dvh; }
  /* 地図を表示できないときの案内は、シートに隠れないよう上に寄せる */
  .map-error { place-items: start center; padding-top: calc(env(safe-area-inset-top) + 32px); }
}

/* 横向きのスマホ: シートを低くして、地図右上のボタンと地図の表示範囲を残す（app.js の mapPadding と同じ値） */
@media (max-width: 820px) and (max-height: 480px) {
  .panel { height: max(46vh, 150px); height: max(46dvh, 150px); }
  .panel.peek { height: 120px; }
  .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: max(46dvh, 150px); }
  .panel.peek ~ #map .maplibregl-ctrl-bottom-left, .panel.peek ~ #map .maplibregl-ctrl-bottom-right { bottom: 120px; }
  /* 右上のボタンは横一列に並べる（縦に積むと地図の下端の帰属表示に重なる） */
  .maplibregl-ctrl-top-right .maplibregl-ctrl { clear: none; }
}
