:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #5d6670;
  --line: #d9dee3;
  --soft: #f3f5f7;
  --accent: #0b5cad;
  --c-food: #d9480f;
  --c-stay: #1c6ed6;
  --c-exp: #2b8a3e;
  --c-spot: #8e3aa8;
  --fav: #f08c00;
  --shadow: 0 2px 12px rgba(0, 0, 0, .15);
  --top-h: 132px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1e22;
    --fg: #e8eaed;
    --muted: #a3abb5;
    --line: #3a4048;
    --soft: #262a30;
    --accent: #6cb3ff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  color: var(--fg);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  overflow: hidden;
}
a { color: var(--accent); }

/* ---- 上部バー ---- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 3;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
}
.title { font-size: 17px; margin: 0 0 6px; letter-spacing: .02em; }
.search input {
  width: 100%; font-size: 16px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--soft); color: var(--fg);
}
.chips { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 999px; padding: 4px 12px; font-size: 14px; cursor: pointer;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.chip .n { color: var(--muted); font-size: 12px; }
/* 選んでいるカテゴリ(「すべて」を含む)は塗りつぶす */
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip[aria-pressed="true"] .n { color: #dbe9ff; }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px #fff; }

/* ---- 地図とパネル ---- */
.layout { position: fixed; inset: var(--top-h) 0 0 0; }
.map { position: absolute; inset: 0; }

.panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  background: var(--bg);
  border-radius: 14px 14px 0 0;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  height: 45%;
  transition: height .2s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.panel[data-state="min"] { height: 64px; }
.panel[data-state="full"] { height: calc(100% - 12px); }
.handle {
  border: 0; background: transparent; padding: 8px 0 2px; cursor: pointer; width: 100%;
}
.handle span { display: block; margin: 0 auto; width: 44px; height: 5px; border-radius: 3px; background: var(--line); }
.panel-head {
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center;
  padding: 0 16px 6px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.count { font-weight: 600; margin-right: auto; }
.toggle { color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.panel-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.note { font-size: 11px; color: var(--muted); padding: 6px 16px 8px; border-top: 1px solid var(--line); }
.panel[data-state="min"] .panel-body,
.panel[data-state="min"] .note { display: none; }

/* ---- 並び順・絞り込み ---- */
.panel-head select, .filter-btn {
  font-size: 13px; padding: 4px 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
.filter-btn { cursor: pointer; }
.filter-btn[aria-expanded="true"] { background: var(--soft); }
#filterCount:not(:empty) {
  margin-left: 4px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px;
}
.filters { padding: 8px 16px 10px; border-bottom: 1px solid var(--line); max-height: 45vh; overflow-y: auto; background: var(--soft); }
.filter-sec { margin-bottom: 10px; }
.filter-title { font-size: 13px; font-weight: 700; margin: 4px 0 6px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; margin-bottom: 4px; }
.filter-row .toggle { color: var(--fg); }
.filter-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.filter-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.filter-foot .btn { cursor: pointer; font-family: inherit; }
.filter-foot .link-btn { padding: 0; }

/* いま効いている条件(個別に ✕ で外せる) */
.active-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 6px 16px; border-bottom: 1px solid var(--line); font-size: 13px; background: #fff4e6;
}
@media (prefers-color-scheme: dark) { .active-bar { background: #3a2a14; } }
.active-bar[hidden] { display: none; }
.active-label { color: var(--muted); font-size: 12px; }
.active-chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--fav); background: var(--bg);
  color: var(--fg); border-radius: 999px; padding: 2px 6px 2px 10px; font-size: 13px; cursor: pointer;
}
.active-chip span { color: var(--muted); font-size: 11px; }
.active-bar .link-btn { padding: 0; }
.tab-n:not(:empty) {
  margin-left: 4px; background: var(--fav); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; font-weight: 600;
}
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 999px; padding: 2px 10px; font-size: 13px; cursor: pointer;
}
.tag-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag-chip .n { color: var(--muted); font-size: 11px; margin-left: 3px; }
.tag-chip[aria-pressed="true"] .n { color: #dbe9ff; }
.link-btn { border: 0; background: none; color: var(--accent); padding: 6px 0 0; font-size: 13px; cursor: pointer; }

/* ---- 一覧 ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 2px 10px;
  padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.list .star {
  grid-column: 3; grid-row: 1 / span 2; align-self: center;
  border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
}
.list .star:hover { background: var(--line); }
.list .star[aria-pressed="true"] { color: var(--fav); }
.list li:hover, .list li:focus-visible { background: var(--soft); outline: none; }
.list .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; }
.list .name { font-weight: 600; }
.list .sub { grid-column: 2; color: var(--muted); font-size: 13px; }
.list .fav-mark { color: var(--fav); margin-left: 4px; }
.list .dist { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.badge {
  display: inline-block; font-size: 11px; padding: 0 6px; margin-left: 6px;
  border-radius: 4px; border: 1px solid var(--line); color: var(--muted); font-weight: 400;
  vertical-align: 1px;
}
.badge.warn { border-color: #e8590c; color: #e8590c; }
.empty { padding: 24px 16px; color: var(--muted); }
.list li.empty { display: block; cursor: default; }
.list li.empty:hover { background: none; }
.list li.empty .btn { margin-top: 10px; cursor: pointer; font-family: inherit; }

/* ---- お気に入り ---- */
.fav-lead { font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.fav-list { list-style: none; margin: 0; padding: 0; }
.fav-list li {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.fav-list .num {
  width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.fav-name {
  border: 0; background: none; color: var(--fg); text-align: left; padding: 0; cursor: pointer;
  font: inherit; font-weight: 600; min-width: 0;
}
.fav-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.fav-ops { display: inline-flex; gap: 4px; }
.mini {
  width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg); cursor: pointer; font-size: 15px;
}
.mini:disabled { opacity: .35; cursor: default; }
#viewFavs .actions .btn { cursor: pointer; font-family: inherit; }
#viewFavs .btn:disabled { opacity: .5; cursor: default; }

/* ---- 詳細 ---- */
.detail { padding: 12px 16px 20px; }
.detail .back {
  border: 0; background: none; color: var(--accent); padding: 0; font-size: 14px; cursor: pointer;
}
.detail h2 { font-size: 19px; margin: 8px 0 2px; }
.detail .head-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 10px;
  padding: 6px 10px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.icon-btn[aria-pressed="true"] { color: var(--fav); border-color: var(--fav); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; padding: 0; list-style: none; }
.tags li { font-size: 12px; background: var(--soft); border-radius: 4px; padding: 1px 7px; color: var(--muted); }
.detail .cat { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.detail dl { display: grid; grid-template-columns: 5.5em 1fr; gap: 6px 10px; margin: 0 0 12px; font-size: 14px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btn {
  display: inline-block; text-decoration: none; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--fg); background: var(--soft); font-size: 14px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.detail details { font-size: 13px; color: var(--muted); }
.detail details ul { padding-left: 18px; margin: 6px 0; }
.detail details li { overflow-wrap: anywhere; }
.caution { font-size: 13px; color: #e8590c; margin: 6px 0; }

/* ---- PC: 左に一覧 ---- */
@media (min-width: 860px) {
  :root { --top-h: 64px; }
  .topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; }
  .title { margin: 0; white-space: nowrap; }
  .search { width: 320px; }
  .chips { margin: 0; }
  .panel, .panel[data-state] {
    top: 0; bottom: 0; right: auto; width: 380px; height: auto;
    border-radius: 0; box-shadow: 1px 0 0 var(--line);
  }
  .panel[data-state="min"] .panel-body, .panel[data-state="min"] .note { display: block; }
  .handle { display: none; }
  .panel-head { padding-top: 10px; }
  .map { left: 380px; }
}

.maplibregl-popup-content { color: #1f2328; font-size: 14px; padding: 8px 12px; }

/* ---- 右端のパネル(モデルコース・季節・お役立ち) ---- */
.drawer-ctrl button {
  display: block; width: auto; min-width: 72px; height: auto; padding: 8px 10px;
  font-size: 13px; font-weight: 600; color: #1f2328; background: #fff; cursor: pointer;
}
.drawer-ctrl button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.drawer {
  position: absolute; z-index: 5; inset: 0;
  background: var(--bg); display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.drawer[hidden] { display: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 17px; margin: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 10px 16px 16px; -webkit-overflow-scrolling: touch; }
.drawer-body[hidden] { display: none; }

/* コースを地図に出しているときの帯(地図の左上) */
.course-banner {
  position: absolute; z-index: 1; top: 10px; left: 10px; max-width: calc(100% - 130px);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg); border: 2px solid var(--fav); border-radius: 10px;
  padding: 4px 10px; font-size: 13px; box-shadow: var(--shadow);
}
.course-banner[hidden] { display: none; }
.course-banner .link-btn { padding: 0; font-weight: 600; }

@media (min-width: 860px) {
  .drawer { inset: 0 0 0 auto; width: 380px; }
  /* PCは地図の左上。右上のボタン(幅 約140px)と右のパネルに重ならない幅にする */
  .course-banner { left: 392px; max-width: min(460px, calc(100% - 532px)); }
  body.drawer-open .course-banner { max-width: min(460px, calc(100% - 912px)); }
  /* 右のパネルを開いている間は、地図のボタンをパネルの左に寄せる */
  body.drawer-open .maplibregl-ctrl-top-right,
  body.drawer-open .maplibregl-ctrl-bottom-right { right: 380px; }
}

/* 背景地図の切り替え(地図の右上) */
.basemap-ctrl select {
  display: block; border: 0; background: #fff; color: #1f2328;
  font-size: 13px; padding: 6px 8px; min-height: 29px; border-radius: 4px; cursor: pointer;
}

/* ---- 言語・タブ・ビュー ---- */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lang-btn {
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  border-radius: 8px; padding: 2px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab {
  flex: none; border: 0; background: none; color: var(--muted); padding: 6px 10px 8px; font-size: 14px;
  border-bottom: 3px solid transparent; cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none; }
.view.panel-body { display: block; padding: 8px 16px 16px; }
.view.panel-body[hidden] { display: none; }
.shared-note { font-size: 13px; margin: 8px 0 0; padding: 6px 8px; border-radius: 6px; background: var(--soft); }

.card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 0 10px; }
.card.active { border-color: #f08c00; box-shadow: 0 0 0 1px #f08c00 inset; }
.card h3 { font-size: 16px; margin: 2px 0 4px; }
.card p { margin: 4px 0; font-size: 14px; }
.card .btn { margin: 6px 0; cursor: pointer; font-family: inherit; }
.stops { margin: 6px 0 0; padding-left: 22px; font-size: 14px; }
.stops li { margin: 4px 0; }
.spot-links { display: flex; flex-wrap: wrap; gap: 6px; }
.spot-link {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg);
  color: var(--fg); border-radius: 999px; padding: 2px 10px; font-size: 13px; cursor: pointer; text-align: left;
}
.spot-link .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 10px; }
.month {
  border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 8px;
  padding: 4px 0; font-size: 13px; cursor: pointer; position: relative;
}
.month.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.month small { position: absolute; top: 0; right: 3px; font-size: 8px; color: #e8590c; }
.emg { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 6px 0; font-size: 14px; }
.emg dd { margin: 0; }
.tel { font-weight: 700; font-size: 16px; text-decoration: none; }

/* ---- 印刷: 一覧だけを紙に出す ---- */
@media print {
  body { overflow: visible; }
  .topbar, .map, .handle, .tabs, .panel-head, .filters, .active-bar, .drawer, .course-banner, .list .star,
  .maplibregl-control-container { display: none !important; }
  .layout, .panel { position: static !important; height: auto !important; width: auto !important; box-shadow: none; }
  .panel-body { overflow: visible; }
  .list li { break-inside: avoid; padding: 4px 0; }
  .note { border: 0; }
}

/* スマホでは下部の注意書きを隠す(同じ内容は「お役立ち」タブにある) */
@media (max-width: 859px) {
  .note { display: none; }
}
