/* レイアウト: 地図は全面。スマホ=上に検索とカテゴリ、下に引き出すシート。PC=左に1枚のパネル。
   色: 藍(芭蕉布の絣)を操作色に、カテゴリ色は村の素材(海・森・夕日・車輪梅)から。 */
:root {
  --ink: #14231b;
  --ink-2: #44544a;
  --ink-3: #75827a;
  --paper: #ffffff;
  --wash: #f3f5f1;
  --wash-2: #e9ede6;
  --line: #e1e6de;
  --ai: #1d4580;          /* 藍 */
  --ai-soft: #e7edf7;
  --shadow: 0 1px 2px rgba(20, 35, 27, .08), 0 8px 28px rgba(20, 35, 27, .14);
  --shadow-s: 0 1px 2px rgba(20, 35, 27, .10), 0 3px 10px rgba(20, 35, 27, .10);
  --r: 16px;
  --f-ui: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  --f-mark: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --side-w: 400px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--wash);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; background: #eef0e8; }

/* ───────── 上部（ブランド・検索・カテゴリ） ───────── */
#side { display: contents; }
#top {
  position: fixed; z-index: 20; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(12px, env(safe-area-inset-right, 0px)) 6px max(12px, env(safe-area-inset-left, 0px));
  display: grid; gap: 8px;
  pointer-events: none;
}
#top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px;
  background: var(--paper); border-radius: 14px; padding: 8px 8px 8px 12px; box-shadow: var(--shadow-s);
}
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--ai); color: #fff; display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; stroke-width: 2.4; }
.brand-text { min-width: 0; flex: 1; line-height: 1.2; }
.brand h1 { margin: 0; font-family: var(--f-mark); font-weight: 700; font-size: 19px; letter-spacing: .04em; }
.brand p { margin: 2px 0 0; font-size: 11px; color: var(--ink-3); letter-spacing: .08em; }
.lang {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  height: 32px; min-width: 52px; padding: 0 12px; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--ai);
}
.lang:hover { background: var(--ai-soft); }

.search {
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 6px 0 14px;
  background: var(--paper); border-radius: 14px; box-shadow: var(--shadow-s);
}
.search > svg { font-size: 18px; color: var(--ink-3); }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 16px; color: var(--ink);
}
.search input::placeholder { color: var(--ink-3); }
.search input::-webkit-search-cancel-button { display: none; }
.qclear { border: 0; background: var(--wash); width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; color: var(--ink-2); }

.chips {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; margin: 0 -12px; padding-left: 12px; padding-right: 12px;
  scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px 0 10px;
  border: 0; border-radius: 999px; background: var(--paper); box-shadow: var(--shadow-s);
  font-size: 13px; font-weight: 500; white-space: nowrap; scroll-snap-align: start;
}
.chip i { width: 18px; height: 18px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-style: normal; font-size: 11px; }
.chip i svg { width: 11px; height: 11px; stroke-width: 2.4; }
.chip.on { background: var(--ink); color: #fff; }
.chip.on i { box-shadow: 0 0 0 2px var(--ink), 0 0 0 3px rgba(255,255,255,.5); }
.chip[data-k="all"] { padding-left: 13px; }

/* ───────── シート（一覧・詳細） ───────── */
#sheet {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  height: 80dvh; /* JSで上書き */
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -2px 24px rgba(20, 35, 27, .16);
  display: flex; flex-direction: column;
  transition: transform .32s cubic-bezier(.2, .8, .2, 1);
  will-change: transform;
}
#sheet.dragging { transition: none; }
.grab { height: 22px; display: grid; place-items: center; touch-action: none; cursor: grab; flex: none; }
.grab span { width: 40px; height: 5px; border-radius: 3px; background: #cfd6cc; }
.tabs {
  display: flex; gap: 4px; padding: 0 max(14px, env(safe-area-inset-right, 0px)) 8px max(14px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line); flex: none; touch-action: none;
}
.tab {
  border: 0; background: transparent; height: 38px; padding: 0 12px; border-radius: 10px;
  font-size: 14px; font-weight: 700; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px;
}
.tab em { font-style: normal; font-size: 11px; font-weight: 700; background: var(--wash-2); color: var(--ink-2); border-radius: 999px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.tab.on { color: var(--ink); background: var(--wash); }
.tab.on em { background: var(--ink); color: #fff; }
.body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px max(14px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
}

/* おすすめ */
.feat-h, .grp-h {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin: 14px 2px 8px; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--ink-3);
}
.grp-h b { color: var(--ink); font-size: 14px; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 8px; }
.grp-h b i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.grp-h span { font-variant-numeric: tabular-nums; font-weight: 500; }
.featrow {
  display: grid; grid-auto-flow: column; grid-auto-columns: 214px; gap: 10px;
  overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px 4px; scroll-snap-type: x mandatory;
}
.featrow::-webkit-scrollbar { display: none; }
.fcard {
  scroll-snap-align: start; text-align: left; border: 1px solid var(--line); background: var(--paper);
  border-radius: 14px; padding: 0; overflow: hidden; display: flex; flex-direction: column;
}
.fcard .art {
  height: 74px; position: relative; overflow: hidden;
  background: var(--c);
  background-image: var(--pattern);
  color: #fff;
}
.fcard .art svg { position: absolute; right: 10px; bottom: 8px; width: 40px; height: 40px; stroke-width: 1.6; opacity: .95; }
.fcard .art small { position: absolute; left: 12px; top: 10px; font-size: 11px; font-weight: 700; letter-spacing: .06em; background: rgba(255,255,255,.18); padding: 1px 8px; border-radius: 999px; }
.fcard .tx { padding: 10px 12px 12px; display: grid; gap: 4px; }
.fcard b { font-size: 15px; line-height: 1.35; }
.fcard p { margin: 0; font-size: 12px; color: var(--ink-2); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 一覧の行 */
.list { display: grid; gap: 2px; }
.row {
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px;
  width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 6px; border-radius: 12px;
}
.row:hover { background: var(--wash); }
.row.sel { background: var(--ai-soft); }
.ico {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 13%, white); color: var(--c); font-size: 20px;
}
.ico b { font-size: 12px; font-weight: 700; letter-spacing: -.02em; font-family: var(--f-ui); }
.row .nm { min-width: 0; }
.row .nm b { display: block; font-size: 15px; font-weight: 700; line-height: 1.35; }
.row .nm small { display: block; font-size: 12px; color: var(--ink-3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .nm .star { color: #c8862d; font-size: 11px; margin-left: 4px; vertical-align: 1px; }
.row .dist { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .chev { color: #b9c2b8; font-size: 16px; }
.empty { padding: 32px 8px; text-align: center; color: var(--ink-2); }
.empty b { display: block; font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.note { font-size: 11px; color: var(--ink-3); margin: 18px 4px 0; line-height: 1.6; }

/* 詳細 */
.d-top { display: flex; align-items: center; justify-content: space-between; margin: 6px -4px 4px; }
.btn-back, .btn-x {
  border: 0; background: transparent; display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 10px; border-radius: 10px;
  font-size: 13px; font-weight: 700; color: var(--ai);
}
.btn-back:hover, .btn-x:hover { background: var(--ai-soft); }
.d-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--c); color: #fff; font-weight: 700; font-size: 11.5px; }
.pill svg { width: 12px; height: 12px; stroke-width: 2.4; }
.pill.ghost { background: var(--wash); color: var(--ink-2); font-weight: 500; }
.d-name { font-size: 24px; line-height: 1.3; margin: 10px 0 2px; font-weight: 700; text-wrap: balance; word-break: auto-phrase; letter-spacing: .01em; }
.d-alt { font-size: 13px; color: var(--ink-3); margin: 0; }
.d-desc { font-size: 15px; line-height: 1.85; margin: 12px 0 0; color: var(--ink); }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 4px; }
.act {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); font-size: 14px; font-weight: 700; text-decoration: none; color: var(--ink);
}
.act svg { font-size: 18px; }
.act.primary { background: var(--ai); color: #fff; border-color: var(--ai); grid-column: 1 / -1; }
.act:hover { filter: brightness(.97); }
.box { margin-top: 18px; }
.box h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; background: var(--wash); border-radius: 12px; padding: 12px 14px; }
.kv dt { color: var(--ink-3); font-size: 12.5px; padding-top: 1px; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.kv .fine { grid-column: 1 / -1; font-size: 11.5px; color: var(--ink-3); }
.subs { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.subs > div { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: center; padding: 10px 12px; }
.subs > div + div { border-top: 1px solid var(--line); }
.subs .ico { width: 28px; height: 28px; border-radius: 8px; font-size: 15px; }
.subs b { font-size: 14px; display: block; line-height: 1.35; }
.subs small { color: var(--ink-3); font-size: 12px; }
.links { display: grid; gap: 8px; }
.links a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--wash);
  color: var(--ink); text-decoration: none; font-weight: 700; font-size: 14px;
}
.links a svg { color: var(--ai); }
.src { font-size: 11px; color: var(--ink-3); margin-top: 18px; }

/* コース */
.ccard {
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 14px; padding: 14px; display: grid; gap: 6px; margin-top: 10px;
}
.ccard:hover { border-color: #c9d2c6; }
.ccard .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--ink-2); }
.ccard b { font-size: 16px; line-height: 1.4; word-break: auto-phrase; }
.ccard p { margin: 0; font-size: 13px; color: var(--ink-2); }
.ccard .dots { display: flex; align-items: center; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.ccard .dots i { width: 22px; height: 22px; border-radius: 50%; background: var(--c); color: #fff; font-style: normal; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.ccard .dots s { width: 10px; height: 2px; background: var(--line); }
.tl { list-style: none; margin: 14px 0 0; padding: 0; position: relative; }
.tl li { position: relative; padding-left: 44px; }
.tl li::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: -6px; width: 2px; background: var(--line); }
.tl li:last-child::before { display: none; }
.tl .num { position: absolute; left: 2px; top: 6px; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.tl button.stop { width: 100%; text-align: left; border: 0; background: var(--wash); border-radius: 12px; padding: 10px 12px; display: grid; gap: 1px; }
.tl button.stop:hover { background: var(--wash-2); }
.tl button.stop b { font-size: 15px; }
.tl button.stop small { font-size: 12px; color: var(--ink-3); }
.tl .leg { font-size: 12px; color: var(--ink-2); padding: 8px 0 10px; display: flex; align-items: center; gap: 6px; }
.tl .leg svg { color: var(--ink-3); }

/* ───────── 地図のピン ───────── */
.pin {
  --s: 30px;
  border: 0; padding: 0; background: transparent; width: var(--s); height: var(--s);
  display: grid; place-items: center; cursor: pointer; /* position は MapLibre が absolute に設定する */
}
.pin .dot {
  width: var(--s); height: var(--s); border-radius: 50%; background: var(--c); color: #fff;
  display: grid; place-items: center; font-size: calc(var(--s) * .52);
  box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(20, 35, 27, .35);
  transition: transform .18s ease, box-shadow .18s ease;
}
.pin .dot b { font-size: calc(var(--s) * .34); font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.pin.feat { --s: 36px; }
.pin.mini { --s: 22px; }
.pin .lbl {
  position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--ink); line-height: 1.25;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff;
  pointer-events: none; display: none; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}
.pin .num {
  position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; display: none; place-items: center; box-shadow: 0 0 0 2px #fff;
}
.pin[data-num] .num { display: grid; }
.pin:hover .dot { transform: scale(1.08); }
.pin.sel { z-index: 5; }
.pin.sel .dot { transform: scale(1.22); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c), 0 4px 12px rgba(20, 35, 27, .4); }
.pin.sel .lbl { display: block; font-size: 13px; }
.pin.off { display: none; }
.pin.nolbl .lbl { display: none !important; }
.pin.dim { opacity: .28; }
/* 引きの地図: 小さな点 */
#map.zs .pin:not(.feat):not(.sel):not([data-num]) { --s: 11px; }
#map.zs .pin:not(.feat):not(.sel):not([data-num]) .dot { font-size: 0; box-shadow: 0 0 0 1.5px #fff, 0 1px 3px rgba(20,35,27,.35); }
#map.zs .pin:not(.feat):not(.sel):not([data-num]) .dot b { display: none; }
#map.zs:not(.showlow) .pin.lowz:not(.sel) { display: none; }
#map.zs .pin.feat:not(.sel):not([data-num]) { --s: 28px; }
@media (max-width: 859px) {
  #map.zs .pin.feat:not(.sel):not([data-num]) { --s: 24px; }
  #map.zs .pin:not(.feat):not(.sel):not([data-num]) { --s: 9px; }
}
#map.zs .pin.feat .lbl, #map.zm .pin.feat .lbl, #map.zl .pin .lbl, .pin[data-num] .lbl { display: block; }
#map.zm .pin.mini:not(.sel) .dot { font-size: calc(var(--s) * .5); }
.me { width: 18px; height: 18px; border-radius: 50%; background: #2a7de1; box-shadow: 0 0 0 3px #fff, 0 0 0 10px rgba(42, 125, 225, .18); }

/* ───────── 右の操作ボタン ───────── */
.ctrls {
  position: fixed; z-index: 15; right: max(12px, env(safe-area-inset-right, 0px)); top: 190px;
  display: grid; gap: 8px;
}
.ctrl {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--paper); box-shadow: var(--shadow-s);
  display: grid; place-items: center; color: var(--ink); font-size: 20px;
}
.ctrl b { font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.ctrl.on { background: var(--ai); color: #fff; }
.ctrl .fillr { fill: #d24b3a; stroke: #d24b3a; }
.toast {
  position: fixed; z-index: 50; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 150px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 13px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px); text-align: center;
}

/* MapLibre */
.maplibregl-ctrl-attrib { font-family: var(--f-ui); font-size: 10.5px; }
.maplibregl-ctrl-bottom-right { bottom: var(--attrib-b, 0px); }
.maplibregl-ctrl-attrib.maplibregl-compact { margin: 0 8px 8px 0; }

/* ───────── PC ───────── */
@media (min-width: 860px) {
  #side {
    display: flex; flex-direction: column; position: fixed; z-index: 30; left: 16px; top: 16px; bottom: 16px; width: var(--side-w);
    background: var(--paper); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden;
  }
  #top { position: static; padding: 14px 16px 4px; pointer-events: auto; gap: 10px; }
  .brand, .search, .chip { box-shadow: none; }
  .brand { padding: 0; }
  .search { background: var(--wash); }
  .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0 0 6px; gap: 6px; }
  .chip { background: var(--wash); height: 32px; }
  .chip:hover { background: var(--wash-2); }
  .chip.on, .chip.on:hover { background: var(--ink); }
  #sheet { position: static; height: auto !important; transform: none !important; flex: 1; min-height: 0; box-shadow: none; border-radius: 0; }
  .grab { display: none; }
  .tabs { padding-top: 4px; }
  .ctrls { top: 16px; }
  .toast { top: 24px; left: calc(50% + var(--side-w) / 2); }
}
@media (prefers-reduced-motion: reduce) {
  #sheet, .pin .dot { transition: none; }
}
