:root {
  --ink: #1e2d35;
  --ink-sub: #5b6d76;
  --line: #dde5e4;
  --accent: #0e7a6c;
  --accent-deep: #0a5a50;
  --accent-soft: #e2f2ef;
  --gold: #c08a12;
  --gold-soft: #fbf3df;
  --warn: #b3452f;
  --d1: #2f6db3;
  --d2: #0e7a6c;
  --d3: #a25b12;
  --glass: rgba(255, 255, 255, .93);
  --shadow: 0 2px 8px rgba(20, 40, 50, .18), 0 8px 30px rgba(20, 40, 50, .12);
  --radius: 14px;
  --panel-w: 330px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
  overflow: hidden;
}
button { font-family: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

#map { position: fixed; inset: 0; z-index: 0; background: #cfe0dd; }

/* ============ 上部バー ============ */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 700;
  display: flex; align-items: center; gap: .8rem;
  padding: .5rem .9rem;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand {
  background: var(--glass); backdrop-filter: blur(6px);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .35rem .9rem; line-height: 1.25;
}
.brand-title { display: block; font-weight: 800; font-size: .95rem; }
.brand-sub { display: block; font-size: .66rem; color: var(--ink-sub); }

#chapters {
  display: flex; gap: .25rem;
  background: var(--glass); backdrop-filter: blur(6px);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .3rem;
}
.ch {
  border: none; background: transparent; cursor: pointer;
  border-radius: 10px; padding: .3rem .8rem;
  font-weight: 700; font-size: .85rem; color: var(--ink-sub);
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.ch small { font-size: .6rem; font-weight: 400; }
.ch:hover { background: #eef3f2; }
.ch.active { background: var(--accent); color: #fff; }
.ch[data-ch="1"].active { background: var(--d1); }
.ch[data-ch="2"].active { background: var(--d2); }
.ch[data-ch="3"].active { background: var(--d3); }

.top-actions { margin-left: auto; display: flex; gap: .5rem; }
.pill {
  border: none; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
  background: var(--glass); backdrop-filter: blur(6px);
  border-radius: 99px; box-shadow: var(--shadow);
  padding: .45rem 1rem; font-size: .82rem; font-weight: 700; color: var(--ink);
  max-width: 360px; white-space: nowrap; overflow: hidden;
}
.pill:hover { background: #fff; }
.pill.lib { background: var(--accent); color: #fff; }
.pill.lib:hover { background: var(--accent-deep); }
#route-pill { border: 2px solid var(--accent); }
#route-pill .rp-label { color: var(--ink-sub); font-weight: 400; font-size: .72rem; margin-right: .3em; }

/* ============ 左パネル(行程タイムライン) ============ */
#panel {
  position: fixed; z-index: 650;
  top: 64px; left: .9rem; bottom: .9rem;
  width: var(--panel-w);
  background: var(--glass); backdrop-filter: blur(8px);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel-head {
  padding: .7rem .9rem .55rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .75);
}
.pt-day { font-weight: 800; font-size: 1.02rem; }
.pt-day small { color: var(--ink-sub); font-weight: 600; font-size: .74rem; }
.pt-lead { font-size: .74rem; color: var(--ink-sub); margin-top: .1rem; }
.player-controls { display: flex; gap: .35rem; margin-top: .5rem; }
.player-controls button {
  border: none; background: #e8efed; cursor: pointer;
  height: 30px; border-radius: 8px; font-size: .78rem; font-weight: 700;
  padding: 0 .7rem;
}
.player-controls button:hover { background: var(--accent-soft); }
#btn-play { flex: 1; background: var(--accent); color: #fff; }
#btn-play:hover { background: var(--accent-deep); }
#btn-play.playing { background: var(--gold); }

#panel-body { flex: 1; overflow-y: auto; padding: .5rem .55rem 1rem; scrollbar-width: thin; }

/* タイムライン項目 */
.tl-moment {
  border-radius: 11px; padding: .4rem .55rem .35rem;
  cursor: pointer; border: 2px solid transparent;
  margin-bottom: .15rem;
}
.tl-moment:hover { background: #eef3f2; }
.tl-moment.current { background: #fff; border-color: var(--accent); box-shadow: 0 2px 8px rgba(20, 40, 50, .12); }
.tl-head { display: flex; align-items: baseline; gap: .45rem; }
.tl-no {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
  background: #b9c6c4; color: #fff; font-size: .66rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  align-self: center;
}
.tl-moment.current .tl-no { background: var(--gold); }
.tl-moment.kind-highlight .tl-no { background: var(--accent); }
.tl-name { font-weight: 700; font-size: .84rem; flex: 1; min-width: 0; }
.tl-moment.kind-highlight .tl-name::after { content: " ★"; color: var(--gold); font-size: .72rem; }
.tl-t { font-size: .68rem; color: var(--ink-sub); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-entries { margin: .15rem 0 0 .6rem; padding-left: .95rem; border-left: 2px solid var(--line); display: none; }
.tl-moment.current .tl-entries { display: block; }
.tl-entry { display: flex; gap: .5rem; padding: .12rem 0; font-size: .74rem; align-items: baseline; }
.tl-entry .tl-time { flex: 0 0 74px; color: var(--ink-sub); font-weight: 700; font-variant-numeric: tabular-nums; font-size: .68rem; }
.tl-entry .tl-txt { min-width: 0; }
.tl-entry.type-highlight .tl-txt { font-weight: 700; }
.tl-entry.type-move .tl-txt, .tl-entry.type-task .tl-txt { color: var(--ink-sub); }
.tl-cost { display: block; color: var(--warn); font-size: .68rem; }
.tl-note { display: block; color: var(--ink-sub); font-size: .68rem; }

/* 全体章のデイカード */
.day-card {
  display: flex; gap: .6rem; align-items: stretch;
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 5px rgba(20, 40, 50, .12);
  margin: 0 .15rem .6rem; cursor: pointer;
  text-decoration: none; color: var(--ink);
  border: 2px solid transparent;
}
.day-card:hover { border-color: var(--accent); }
.dc-ph { flex: 0 0 96px; background: #d7e6e2; }
.dc-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dc-txt { padding: .5rem .6rem .5rem 0; font-size: .72rem; color: var(--ink-sub); line-height: 1.45; }
.day-card.lib-card .dc-txt { padding-left: .6rem; }
.dc-b { display: block; font-size: .82rem; color: var(--ink); }
.dc-b.d1 { color: var(--d1); }
.dc-b.d2 { color: var(--d2); }
.dc-b.d3 { color: var(--d3); }

#panel-toggle {
  display: none;
  position: fixed; z-index: 660; left: .9rem; bottom: .9rem;
  border: none; border-radius: 99px; padding: .55rem 1rem;
  background: var(--accent); color: #fff; font-weight: 800; font-size: .85rem;
  box-shadow: var(--shadow); cursor: pointer;
}

/* ============ マーカー ============ */
.stop-marker {
  border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .72rem;
  border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  width: 100%; height: 100%;
  transition: transform .2s ease;
}
.stop-marker.d1 { background: var(--d1); }
.stop-marker.d2 { background: var(--d2); }
.stop-marker.d3 { background: var(--d3); }
.stop-marker.done { opacity: .55; }
.stop-marker.current {
  transform: scale(1.35);
  box-shadow: 0 0 0 5px rgba(192, 138, 18, .35), 0 2px 8px rgba(0, 0, 0, .4);
  background: var(--gold);
}
.car-marker { font-size: 22px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }

/* ============ ポップアップ(場所の紹介) ============ */
.leaflet-popup.step-pop .leaflet-popup-content-wrapper {
  border-radius: 14px; box-shadow: var(--shadow); padding: 0; overflow: hidden;
}
.leaflet-popup.step-pop .leaflet-popup-content { margin: 0; width: 272px !important; }
.pop-ph { height: 126px; overflow: hidden; position: relative; background: #d7e6e2; }
.pop-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pop-ph .pop-time {
  position: absolute; top: .4rem; left: .4rem;
  background: rgba(20, 40, 45, .8); color: #fff; border-radius: 8px;
  padding: .05rem .5rem; font-size: .7rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pop-body { padding: .55rem .8rem .7rem; }
.pop-body h3 { margin: 0 0 .2rem; font-size: .98rem; line-height: 1.3; }
.pop-blurb { margin: 0; font-size: .78rem; line-height: 1.55; }
.pop-chips { margin-top: .4rem; display: flex; flex-direction: column; gap: .2rem; }
.pop-chip {
  font-size: .68rem; color: var(--ink-sub);
  background: #f1f5f4; border-radius: 7px; padding: .12rem .5rem;
}
.pop-chip b { color: var(--ink); margin-right: .3em; }
.pop-more {
  margin-top: .55rem; width: 100%;
  border: none; background: var(--accent); color: #fff;
  border-radius: 9px; padding: .42rem; font-size: .8rem; font-weight: 700; cursor: pointer;
}
.pop-more:hover { background: var(--accent-deep); }

/* ============ 詳細シート ============ */
#sheet {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 880;
  width: min(430px, 96vw);
  background: #fff; box-shadow: -6px 0 30px rgba(0, 0, 0, .25);
  overflow-y: auto;
  animation: slide-in .22s ease;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-close {
  position: absolute; top: .6rem; right: .6rem; z-index: 5;
  border: none; background: rgba(255, 255, 255, .92); border-radius: 50%;
  width: 34px; height: 34px; font-size: 1.15rem; cursor: pointer; box-shadow: var(--shadow);
}
.sheet-hero { position: relative; height: 230px; background: #d7e6e2; }
.sheet-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-hero .credit {
  position: absolute; right: .4rem; bottom: .3rem;
  font-size: .6rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.sheet-thumbs { display: flex; gap: .35rem; padding: .45rem .8rem 0; overflow-x: auto; }
.sheet-thumbs img {
  width: 64px; height: 44px; object-fit: cover; border-radius: 7px; cursor: pointer;
  border: 2px solid transparent; flex: 0 0 auto;
}
.sheet-thumbs img.sel { border-color: var(--accent); }
.sheet-inner { padding: .7rem 1.1rem 1.4rem; }
.sheet-inner h2 { margin: .2rem 0 0; font-size: 1.25rem; }
.sheet-area { font-size: .74rem; color: var(--ink-sub); margin-bottom: .5rem; }
.sheet-desc { font-size: .88rem; }
.sheet-deep {
  font-size: .8rem; background: var(--gold-soft); border-radius: 9px;
  padding: .5rem .7rem; line-height: 1.6;
}
.sheet-info { margin: .7rem 0; border-top: 1px solid var(--line); }
.sheet-info .row {
  display: grid; grid-template-columns: 96px 1fr; gap: .6rem;
  font-size: .8rem; padding: .3rem 0; border-bottom: 1px solid var(--line);
}
.sheet-info .row b { color: var(--ink-sub); font-weight: 700; }
.sheet-h { font-size: .8rem; font-weight: 800; color: var(--ink-sub); margin: 1rem 0 .4rem; letter-spacing: .05em; }

.linkcard {
  display: flex; gap: .6rem; align-items: stretch;
  border: 1px solid var(--line); border-radius: 11px; overflow: hidden;
  margin-bottom: .5rem; text-decoration: none; color: var(--ink);
  transition: border-color .15s;
  min-height: 58px;
}
.linkcard:hover { border-color: var(--accent); }
.linkcard .lc-img {
  flex: 0 0 86px; background: #eef3f2 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.linkcard .lc-img img { width: 20px; height: 20px; }
.linkcard .lc-txt { padding: .4rem .6rem .4rem 0; min-width: 0; align-self: center; }
.linkcard .lc-t { font-size: .78rem; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.linkcard .lc-d { font-size: .68rem; color: var(--ink-sub); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.linkcard .lc-host { font-size: .62rem; color: #9aa7ad; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chips .chip {
  font-size: .7rem; background: var(--accent-soft); color: var(--accent-deep);
  border-radius: 99px; padding: .12rem .6rem; border: none;
  text-decoration: none;
}
.chips .chip.link:hover { background: var(--accent); color: #fff; }

/* ============ ルート選択パネル(右) ============ */
#route-panel {
  position: fixed; z-index: 660;
  top: 64px; right: .9rem; bottom: .9rem;
  width: 316px;
  background: var(--glass); backdrop-filter: blur(8px);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: slide-in .18s ease;
}
.rp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem .5rem .5rem .95rem;
  font-weight: 800; font-size: .92rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .75);
}
.rp-head .sheet-close { position: static; width: 28px; height: 28px; font-size: 1rem; box-shadow: none; background: #eef3f2; }
#rp-body { flex: 1; overflow-y: auto; padding: .55rem .6rem 1rem; scrollbar-width: thin; }
.rp-lead { font-size: .72rem; color: var(--ink-sub); margin: .1rem .2rem .5rem; }
.rp-selected {
  background: var(--accent-soft); border-radius: 10px;
  padding: .45rem .7rem .5rem; margin-bottom: .5rem;
  font-size: .74rem; line-height: 1.55;
}
.rp-selected b { font-size: .82rem; }
.rp-selected p { margin: .15rem 0 0; color: var(--ink-sub); }
.rp-selected .rp-omit { color: var(--ink); font-size: .7rem; margin-top: .3rem; background: #fff; border-radius: 7px; padding: .3rem .45rem; }
.rp-group {
  font-size: .7rem; font-weight: 800; color: var(--ink-sub);
  letter-spacing: .04em; margin: .7rem .2rem .3rem;
}
.rp-opt {
  display: flex; align-items: center; gap: .55rem;
  width: 100%; text-align: left; cursor: pointer;
  border: 2px solid transparent; border-radius: 10px; background: transparent;
  padding: .34rem .5rem; margin-bottom: .1rem; line-height: 1.35;
}
.rp-opt:hover { background: #fff; border-color: var(--line); }
.rp-opt.sel { background: #fff; border-color: var(--accent); box-shadow: 0 1px 5px rgba(20, 40, 50, .1); }
.rp-id {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 7px;
  background: #dce6e4; color: var(--ink-sub);
  font-size: .74rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.rp-opt.sel .rp-id { background: var(--accent); color: #fff; }
.rp-main { flex: 1; min-width: 0; }
.rp-name { display: block; font-size: .78rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-name .star { color: var(--gold); }
.rp-facts { display: block; font-size: .67rem; color: var(--ink-sub); font-variant-numeric: tabular-nums; }
.rp-facts b { color: var(--ink); }
.rp-check { flex: 0 0 14px; color: var(--accent); font-weight: 800; font-size: .8rem; }
.rp-foot { display: flex; flex-direction: column; gap: .25rem; margin: .8rem .2rem 0; font-size: .74rem; }

/* ============ イントロ ============ */
#intro {
  position: fixed; inset: 0; z-index: 900;
  background: linear-gradient(160deg, rgba(10, 60, 52, .88), rgba(15, 70, 95, .85));
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.intro-card {
  background: #fff; border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
  max-width: 640px; max-height: 92vh; overflow-y: auto;
  padding: 1.6rem 1.8rem 1.4rem;
}
.intro-kicker { margin: 0; font-size: .8rem; font-weight: 700; color: var(--accent); }
.intro-card h1 { margin: .1rem 0 .1rem; font-size: 1.55rem; }
.intro-route { margin: 0 0 .6rem; font-size: .85rem; color: var(--ink-sub); font-weight: 700; }
.intro-desc { font-size: .87rem; }
.intro-days { display: flex; gap: .5rem; margin: .8rem 0; flex-wrap: wrap; }
.intro-day {
  flex: 1 1 170px; border-radius: 12px; overflow: hidden; color: #fff; cursor: pointer;
  position: relative; min-height: 108px; display: flex; align-items: flex-end;
  background: #444 center/cover no-repeat;
}
.intro-day .id-shade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 20%, rgba(10, 25, 30, .85)); }
.intro-day .id-txt { position: relative; padding: .5rem .7rem; font-size: .68rem; line-height: 1.4; }
.intro-day .id-txt b { display: block; font-size: .82rem; }
.intro-day:hover { outline: 3px solid var(--gold); }
#intro-start {
  width: 100%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 1rem; font-weight: 800;
  border-radius: 12px; padding: .7rem;
}
#intro-start:hover { background: var(--accent-deep); }
.intro-note { font-size: .72rem; color: var(--ink-sub); margin: .6rem 0 0; text-align: center; }

/* ============ レスポンシブ ============ */
@media (max-width: 900px) {
  .brand { display: none; }
  #topbar { flex-wrap: wrap; gap: .4rem; }
  #chapters { flex: 1 1 auto; justify-content: space-between; }
  .top-actions { margin-left: 0; width: 100%; justify-content: space-between; }
  .pill { max-width: 62vw; font-size: .76rem; }
  #sheet { width: 100vw; }
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%;
    max-height: 55vh; border-radius: 16px 16px 0 0;
    transform: translateY(105%); transition: transform .25s ease;
  }
  body.panel-open #panel { transform: none; }
  #panel-toggle { display: block; }
  body.panel-open #panel-toggle { bottom: calc(55vh + .6rem); }
  #route-panel { top: 96px; right: 0; bottom: 0; width: min(320px, 88vw); border-radius: 14px 0 0 0; }
}
