:root {
  --accent: #7a1f2b;
  --accent-light: #a33b49;
  --gold: #a67c2e;
  --ink: #26262b;
  --sub: #6b6b70;
  --bg: #faf9f6;
  --card: #ffffff;
  --line: #e4e0d6;
  --tabbar-h: 58px;
  --topbar-h: 50px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column;
}

#topbar {
  height: var(--topbar-h); flex: 0 0 auto;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
#brand { font-weight: 800; font-size: 19px; letter-spacing: .02em; }
#brand .torii { font-size: 21px; }
#langBtn {
  background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.4);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700;
}

main { flex: 1 1 auto; position: relative; overflow: hidden; }
.view { display: none; position: absolute; inset: 0; overflow-y: auto; }
.view.active { display: block; }

#view-map { overflow: hidden; }
#map { position: absolute; inset: 0; }
#locateBtn {
  position: absolute; right: 14px; bottom: 20px; z-index: 5;
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.25); font-size: 20px;
}

#legend {
  position: absolute; left: 10px; bottom: 20px; z-index: 5;
  background: rgba(255,255,255,.92); border-radius: 8px; padding: 5px 10px;
  font-size: 11.5px; color: var(--ink); box-shadow: 0 1px 5px rgba(0,0,0,.2);
}
#searchWrap { position: sticky; top: 0; background: var(--bg); padding: 10px 14px 6px; z-index: 2; }
#filterRow { display: flex; gap: 6px; margin-top: 8px; }
#filterRow button {
  flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--sub);
  border-radius: 999px; padding: 6px 4px; font-size: 12px; font-weight: 700;
}
#filterRow button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#sortHint { margin-top: 6px; }
.sharebtn { margin-top: 10px; border-radius: 10px; padding: 9px 14px; font-size: 13px; font-weight: 700; border: none; background: #efe9dd; }
#searchBox {
  width: 100%; padding: 10px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
#spotList, #henroList, #stampList { list-style: none; margin: 0; padding: 0 14px 20px; }
.spot-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 8px;
}
.spot-item img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; background: #eee; flex: 0 0 auto; }
.spot-item .noimg { width: 54px; height: 54px; border-radius: 8px; background: #efe9dd; display: flex; align-items: center; justify-content: center; font-size: 22px; flex: 0 0 auto; }
.spot-item .txt { min-width: 0; flex: 1; }
.spot-item .nm { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-item .sb { font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spot-item .dist { font-size: 11px; color: var(--gold); font-weight: 700; white-space: nowrap; }
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; color: #fff;
  border-radius: 999px; padding: 1px 8px; margin-right: 4px; vertical-align: 1px;
}
.badge.shrine { background: var(--accent); }
.badge.temple { background: #4a5568; }
.badge.henro { background: var(--gold); }
.badge.stamped { background: #1a6b5a; }

#henroHeader { padding: 16px 14px 6px; }
#henroHeader h2 { margin: 0 0 8px; font-size: 19px; }
#seriesList { display: grid; gap: 8px; margin: 8px 0 10px; }
.series-card {
  width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; color: var(--ink);
}
.series-card.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.series-card-title { display: block; font-size: 13px; font-weight: 800; }
.series-card-meta { display: block; margin-top: 2px; font-size: 11.5px; color: var(--sub); font-weight: 700; }
.series-mini-bar { display: block; margin-top: 7px; height: 6px; background: #e8e2d6; border-radius: 999px; overflow: hidden; }
.series-mini-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); }
#henroProgressWrap { height: 10px; background: #e8e2d6; border-radius: 999px; overflow: hidden; }
#henroProgressBar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold), var(--accent)); transition: width .4s; }
#henroProgressText { font-size: 12.5px; color: var(--sub); margin-top: 6px; font-weight: 700; }
.small { font-size: 12.5px; color: var(--sub); line-height: 1.7; }

#view-stamps h2 { padding: 16px 14px 0; margin: 0; font-size: 19px; }
#stampCount { padding: 4px 14px 10px; color: var(--gold); font-weight: 800; }
#medalList { padding: 0 14px 10px; }
.medal-title { color: var(--sub); font-size: 11.5px; font-weight: 800; margin-bottom: 5px; }
.medal-chip {
  display: inline-block; margin: 0 6px 6px 0; padding: 4px 8px; border-radius: 999px;
  background: #efe9dd; color: var(--ink); font-size: 11.5px; font-weight: 800;
}
#about { padding: 8px 14px 30px; }
#about h3 { font-size: 14px; margin: 18px 0 4px; }
#credits a { color: var(--accent); }

#tabbar {
  flex: 0 0 auto; height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom); box-sizing: content-box;
  display: flex; background: #fff; border-top: 1px solid var(--line);
}
#tabbar button {
  flex: 1; border: none; background: none; color: var(--sub);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 19px; padding: 4px 0;
}
#tabbar button label { font-size: 10px; font-weight: 700; pointer-events: none; }
#tabbar button.active { color: var(--accent); }

#sheetBackdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-height: 78vh; overflow-y: auto;
  background: var(--card); border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.25);
  padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
}
#sheetGrip { width: 44px; height: 5px; border-radius: 999px; background: #d5d0c5; margin: 10px auto 4px; }
#sheetContent { padding: 6px 18px 10px; }
#sheet .hero { width: calc(100% + 36px); margin: 4px -18px 10px; height: 180px; object-fit: cover; background: #eee; }
#sheet h2 { margin: 2px 0 0; font-size: 20px; line-height: 1.4; }
#sheet .subname { color: var(--sub); font-size: 14px; margin-bottom: 6px; }
#sheet .desc { font-size: 14.5px; line-height: 1.85; margin: 10px 0; white-space: pre-line; }
#sheet .desc.muted { color: var(--sub); }
#sheet .src { font-size: 11px; color: var(--sub); border-left: 3px solid var(--line); padding-left: 8px; margin: 8px 0 14px; }
#sheet .src a { color: var(--accent); }
.title-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.title-badges span {
  display: inline-block; border: 1px solid var(--line); border-radius: 999px;
  background: #faf7ef; color: var(--ink); padding: 3px 8px; font-size: 11.5px; font-weight: 800;
}
.story-block { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 9px 0; margin: 10px 0 14px; }
.story-block h3 { margin: 0 0 5px; font-size: 13px; }
.story-block p { margin: 0; font-size: 13.5px; line-height: 1.75; white-space: pre-line; }
.btnrow { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.btnrow a, .btnrow button {
  flex: 1 1 40%; text-align: center; text-decoration: none;
  border-radius: 10px; padding: 11px 8px; font-size: 14px; font-weight: 700; border: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { background: #c9bfb2; }
.btn-secondary { background: #efe9dd; color: var(--ink); }
.checkin-ok { background: #1a6b5a !important; }
.hidden { display: none !important; }
