/* 神社とお寺のおまいり帖: 和紙の白地に墨、朱は印と大事な操作だけに使う。参拝帳は御朱印帳の見開きのように縦長の札を並べる */
:root {
  --paper: #f5f6f2;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #646c66;
  --line: #d9dcd4;
  --shu: #c23b2a;
  --shu-soft: #f6e3df;
  --moss: #4f6146;
  --moss-soft: #e5eadf;
  --gold: #a07a2c;
  --font-display: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121614; --card: #1a201d; --ink: #e6e9e3; --muted: #a2aaa3; --line: #2f3833;
    --shu: #e0644f; --shu-soft: #3a211c; --moss: #a5b897; --moss-soft: #232d24; --gold: #d2ad5f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121614; --card: #1a201d; --ink: #e6e9e3; --muted: #a2aaa3; --line: #2f3833;
  --shu: #e0644f; --shu-soft: #3a211c; --moss: #a5b897; --moss-soft: #232d24; --gold: #d2ad5f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.8; }
pb-t { word-break: keep-all; overflow-wrap: anywhere; }
a { color: inherit; }
main { max-width: 1040px; margin: 0 auto; padding-inline: 16px; padding-block: 8px 48px; }
h1, h2 { font-family: var(--font-display); text-wrap: balance; line-height: 1.35; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--shu); outline-offset: 2px; }

/* ヘッダー */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 1000; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 10px 16px; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 19px; }
.brand small { font-family: var(--font-body); font-weight: 500; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }
.seal { display: grid; place-items: center; width: 32px; height: 32px; border: 2px solid var(--shu); color: var(--shu); border-radius: 4px; font-size: 17px; transform: rotate(-4deg); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 4px 10px; border-radius: 999px; font-size: 14px; color: var(--muted); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--moss-soft); font-weight: 700; }
.account { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; min-height: 32px; }
.account button { font: inherit; }

/* 共通部品 */
.btn { appearance: none; border: 0; background: var(--shu); color: #fff; font: inherit; font-weight: 700; padding: 12px 20px; border-radius: 8px; cursor: pointer; width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { appearance: none; display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; }
.link-btn { appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 0; }
.kind { display: inline-block; font-size: 12px; font-weight: 700; padding: 0 8px; border-radius: 4px; line-height: 1.7; }
.kind-jinja { color: var(--shu); background: var(--shu-soft); }
.kind-tera { color: var(--moss); background: var(--moss-soft); }
.tag { display: inline-block; font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 0 6px; border-radius: 4px; line-height: 1.7; }

.intro { padding-block: 28px 8px; max-width: 40em; }
.intro h1 { font-size: clamp(28px, 6vw, 44px); margin: 0 0 12px; letter-spacing: .02em; }
.intro p { margin: 0 0 8px; color: var(--muted); }
.progress { font-weight: 700; color: var(--ink) !important; }
.sub { font-size: 20px; margin: 28px 0 8px; }

/* 絞り込み・地図・一覧 */
.finder { display: grid; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.f { appearance: none; font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.f b { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; margin-left: 2px; }
.f[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.f[aria-pressed="true"] b { color: inherit; }
.search { display: flex; gap: 8px; flex-wrap: wrap; }
.search input { flex: 1 1 220px; min-width: 0; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.map { height: min(56vh, 460px); border-radius: 10px; border: 1px solid var(--line); background: var(--moss-soft); z-index: 0; }
.map-small { height: 260px; margin-top: 24px; }
.count { margin: 0; font-size: 13px; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.row { position: relative; border-bottom: 1px solid var(--line); }
.row a { display: grid; gap: 2px; padding: 12px 96px 12px 4px; text-decoration: none; }
.row-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.row-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.row-kana { font-size: 12px; color: var(--muted); }
.row-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--muted); }
.row-done { position: absolute; right: 4px; top: 12px; font-family: var(--font-display); font-weight: 800; font-size: 12px; color: var(--shu); border: 1.5px solid var(--shu); border-radius: 50%; width: 44px; height: 44px; display: grid; place-items: center; transform: rotate(-10deg); }
.row-dist { position: absolute; right: 4px; bottom: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-done:not([hidden]) ~ .row-dist { display: none; }
.row:hover .row-name { color: var(--shu); }

/* 社寺ページ */
.crumb { font-size: 13px; color: var(--muted); margin: 16px 0 0; }
.site-head h1 { font-size: clamp(30px, 7vw, 48px); margin: 4px 0 0; }
.site-kind { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.site-kana { margin: 0; color: var(--muted); letter-spacing: .08em; }
.site-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; margin-top: 20px; align-items: start; }
.summary { font-size: 17px; max-width: 36em; margin: 0; }
.src { font-size: 12px; color: var(--muted); }
.facts { display: grid; gap: 0; margin: 20px 0; border-top: 1px solid var(--line); }
.facts div { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.checkin { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; position: sticky; top: 76px; }
.checkin h2 { font-size: 19px; margin: 0 0 4px; }
.ck-note { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
#ck-body { display: grid; gap: 10px; }
.ck-msg { font-size: 14px; margin: 0; }
.ck-msg.err { color: var(--shu); }
.ck-manual { display: grid; gap: 8px; border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 4px; font-size: 14px; }
.ck-manual input { font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }
.ck-history { font-size: 13px; color: var(--muted); margin: 0; padding-left: 1.2em; }
.near { margin-top: 32px; }
.near h2 { font-size: 20px; }

/* 一宮 */
.region h2 { font-size: 22px; margin: 32px 0 8px; display: flex; align-items: baseline; gap: 10px; }
.region h2 small { font-family: var(--font-body); font-size: 13px; color: var(--muted); font-weight: 400; }
.kuni { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 0 24px; }
.kuni-row { display: grid; grid-template-columns: 5.5em minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kuni-name { font-family: var(--font-display); font-weight: 700; }
.kuni-sites { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.kuni-sites a { text-decoration: none; }
.kuni-sites a small { font-size: 11px; color: var(--muted); margin-left: 4px; }
.kuni-sites a.done { color: var(--shu); font-weight: 700; }
.kuni-sites a.done::before { content: "●"; font-size: 10px; margin-right: 3px; vertical-align: 2px; }

/* 参拝帳 */
.me-head { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; min-width: 9em; flex: 1 1 9em; }
.stat b { display: block; font-family: var(--font-display); font-size: 28px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { font-size: 13px; color: var(--muted); }
.stat .bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--shu); }
.book { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 20px; }
.leaf { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 6px; aspect-ratio: 2 / 3; max-width: 100%; padding: 14px 10px; display: flex; flex-direction: row-reverse; justify-content: space-between; text-decoration: none; overflow: hidden; }
.leaf-name { writing-mode: vertical-rl; font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: .08em; line-height: 1.2; max-height: 100%; }
.leaf-date { writing-mode: vertical-rl; font-size: 12px; color: var(--muted); letter-spacing: .1em; align-self: flex-end; }
.leaf-stamp { position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%) rotate(-8deg); width: 64px; height: 64px; border: 2px solid var(--shu); border-radius: 50%; color: var(--shu); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 13px; text-align: center; line-height: 1.2; opacity: .85; }
.leaf-stamp.manual { border-style: dashed; color: var(--muted); border-color: var(--muted); }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.timeline time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.timeline .how { font-size: 12px; color: var(--muted); }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; max-width: 30em; display: grid; gap: 12px; }
.me-tabs { display: flex; gap: 8px; margin-top: 28px; }

.foot { max-width: 1040px; margin: 0 auto; padding-inline: 16px; padding-block: 24px 40px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.foot p { margin: 0 0 6px; }

/* 地図のピン */
.pin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.pin-jinja { background: #c23b2a; }
.pin-tera { background: #4f6146; }
.pin-done { outline: 3px solid #a07a2c; }
.leaflet-popup-content { font-family: var(--font-body); }
.leaflet-popup-content a { font-weight: 700; }

@media (max-width: 760px) {
  .site-grid { grid-template-columns: minmax(0, 1fr); }
  .checkin { position: static; }
  .account { margin-left: 0; width: 100%; }
  .timeline li { grid-template-columns: 6.5em minmax(0, 1fr); }
  .timeline li .how { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* 参拝の案内(詳細情報) */
.h3 { font-size: 18px; margin: 28px 0 4px; }
.plain { margin: 0; padding-left: 1.2em; }
.plain li + li { margin-top: 2px; }
.site-text > .plain { margin-top: 4px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 0 8px; border-radius: 4px; line-height: 1.8; color: var(--muted); border: 1px solid var(--line); }
.badge.on { color: var(--moss); background: var(--moss-soft); border-color: transparent; }
.badge.off { color: var(--shu); background: var(--shu-soft); border-color: transparent; }
.fact-note { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }
.tag-go { color: var(--shu); border-color: var(--shu-soft); }
.tag-park { color: var(--moss); border-color: var(--moss-soft); }
.refs { margin-top: 20px; font-size: 13px; color: var(--muted); }
.refs summary { cursor: pointer; }
.refs ul { padding-left: 1.2em; }
.refs small { margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 0 10px; border-radius: 999px; background: var(--shu-soft); color: var(--shu); line-height: 1.9; }
.fact-note.warn { color: var(--gold); }

/* 参拝の種類(現地=GPS/手で記録)と進み具合 */
.me-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.me-tab { appearance: none; font: inherit; font-family: var(--font-display); font-weight: 700; font-size: 16px; border: 1px solid var(--line); background: var(--card); color: var(--muted); padding: 6px 16px; border-radius: 8px; cursor: pointer; }
.me-tab[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.stat.st-gps b { color: var(--shu); }
.stat.st-man b { color: var(--muted); }
.progs { display: grid; gap: 14px; margin: 4px 0 20px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.prog-label { font-weight: 700; }
.prog-num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.prog-num b { font-family: var(--font-display); font-size: 22px; color: var(--ink); }
.prog-bar { display: flex; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; margin-top: 4px; }
.prog-bar .seg-gps { background: var(--shu); }
.prog-bar .seg-man { background: repeating-linear-gradient(45deg, var(--muted) 0 3px, transparent 3px 6px); opacity: .7; }
.prog-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.prog-legend .lg-gps::before, .prog-legend .lg-man::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.prog-legend .lg-gps::before { background: var(--shu); }
.prog-legend .lg-man::before { background: repeating-linear-gradient(45deg, var(--muted) 0 2px, transparent 2px 4px); }
.prog-note { font-size: 12px; color: var(--muted); margin: 0; }
.progress .prog { font-weight: 400; max-width: 32em; margin-top: 8px; }
.row-done.manual { color: var(--muted); border-color: var(--muted); border-style: dashed; }
.kuni-sites a.done-manual { color: var(--muted); }
.kuni-sites a.done-manual::before { content: "○"; font-size: 10px; margin-right: 3px; vertical-align: 2px; }
.pin-manual { outline: 2px dashed #8a8f88; }
.leaf-name small { display: block; font-size: 11px; color: var(--muted); letter-spacing: 0; margin-bottom: 4px; }
.leaf-man { opacity: .85; }
.how-badge { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 4px; }
.hb-gps { color: var(--shu); background: var(--shu-soft); }
.hb-man { color: var(--muted); border: 1px dashed var(--muted); }
.henro-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; margin: 0 0 20px; }
.hg { display: grid; place-items: center; text-align: center; gap: 0; padding: 6px 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); text-decoration: none; min-width: 0; }
.hg b { font-family: var(--font-display); font-size: 17px; font-variant-numeric: tabular-nums; }
.hg span { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.hg-gps { background: var(--shu); border-color: var(--shu); }
.hg-gps b, .hg-gps span { color: #fff; }
.hg-man { border: 1.5px dashed var(--muted); }
.row-no { font-size: 12px; font-weight: 700; color: var(--shu); font-variant-numeric: tabular-nums; }
.sub-note { font-family: var(--font-body); font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 10px; }
/* 都道府県から探す */
.prefs { margin-top: 32px; }
.pref-group { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pref-group h3 { margin: 0; font-size: 14px; color: var(--muted); font-weight: 700; }
.pref-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.pref-group a { text-decoration: none; }
.pref-group a:hover { color: var(--shu); }
.pref-group small { font-size: 11px; color: var(--muted); margin-left: 3px; font-variant-numeric: tabular-nums; }
.more { margin-top: 12px; }
.small { font-size: 14px; }
.chip-plain { background: var(--moss-soft); color: var(--moss); }
@media (max-width: 520px) { .pref-group { grid-template-columns: minmax(0, 1fr); gap: 4px; } }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px !important; }
.doc { max-width: 40em; padding-block: 24px; }
.doc h1 { font-size: 30px; }
.doc h2 { font-size: 18px; margin-top: 24px; }
