/* ---------- Theme ---------- */
:root {
  --bg: #f5f2ea; --surface: #fffdf9; --sunken: #efebe0; --text: #1b2620; --muted: #647067; --line: #e4dfd2;
  --accent: #2b6a43; --accent-2: #1e5132; --on-accent: #fff; --tint: #e3efe2;
  --earth: #c2643a; --warn: #fdf0d9; --warn-line: #e0ad58; --danger: #b3412f;
  --sun: #c8463a; --sat: #3a6cc0;
  --forest-1: #173d26; --forest-2: #2b6a43;
  --shadow: 0 1px 2px rgba(27, 38, 32, .05), 0 6px 20px rgba(27, 38, 32, .06);
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101411; --surface: #191f1a; --sunken: #141915; --text: #e7ece5; --muted: #97a399; --line: #2a332c;
    --accent: #6fc487; --accent-2: #8ad79f; --on-accent: #0d1a11; --tint: #1e3326;
    --earth: #e39063; --warn: #37301e; --warn-line: #8c6c33; --danger: #ef8674;
    --sun: #ef8478; --sat: #7fa8ee;
    --forest-1: #0c2416; --forest-2: #1c4a2e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; }
a.plain { color: inherit; text-decoration: none; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
main { flex: 1; padding-top: 32px; padding-bottom: 64px; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2rem); line-height: 1.2; letter-spacing: -.02em; margin: 0 0 20px; font-weight: 800; }
h2 { font-size: 1.2rem; letter-spacing: -.01em; margin: 44px 0 14px; font-weight: 750; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-line; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header ---------- */
header.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 8px 16px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; text-decoration: none; color: var(--text); }
.logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-size: 1.15rem;
  background: linear-gradient(145deg, var(--forest-2), var(--forest-1)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
nav { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
nav > a:not(.btn), nav .linkbtn { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .93rem; padding: 6px 10px; border-radius: 8px; }
nav > a:not(.btn):hover, nav .linkbtn:hover { color: var(--text); background: var(--sunken); }
.langs { display: inline-flex; gap: 2px; background: var(--sunken); border-radius: 99px; padding: 3px; margin-left: 6px; }
.lang { padding: 3px 10px; border-radius: 99px; font-size: .82rem; font-weight: 600; color: var(--muted); white-space: nowrap; text-decoration: none; }
.lang.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--on-accent); border: 0;
  border-radius: 10px; padding: 11px 20px; font: inherit; font-weight: 700; line-height: 1.2; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .05s, box-shadow .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.btn:hover { background: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 7px 14px; font-size: .88rem; border-radius: 8px; }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent); }
.btn.ghost:hover { background: var(--tint); }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
nav .linkbtn { text-decoration: none; }
form.inline { display: inline; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; color: #f3f7f1; padding: 64px 0 150px;
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(255, 214, 140, .22), transparent 60%),
    radial-gradient(700px 400px at 0% 100%, rgba(111, 196, 135, .18), transparent 60%),
    linear-gradient(160deg, var(--forest-1), var(--forest-2)); }
.hero .wrap { position: relative; z-index: 1; }
.eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); padding: 4px 12px; border-radius: 99px; margin-bottom: 18px; }
.hero h1 { font-size: clamp(2.2rem, 6.5vw, 3.8rem); line-height: 1.08; letter-spacing: -.03em; margin: 0 0 16px; max-width: 14em; text-wrap: balance; }
.hero .lead { font-size: clamp(1rem, 2vw, 1.15rem); max-width: 36em; color: rgba(243, 247, 241, .86); margin-bottom: 28px; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 0; }
.hero .btn { background: #fdf6e3; color: #173d26; padding: 13px 24px; }
.hero .btn:hover { background: #fff; }
.hero .btn.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .55); }
.hero .btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.ridge { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 150px; display: block; }
.ridge .r1 { fill: rgba(255, 255, 255, .07); }
.ridge .r2 { fill: rgba(6, 22, 12, .32); }
.ridge .r3 { fill: var(--bg); }
.hero + main { padding-top: 8px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card.day { display: flex; gap: 14px; align-items: stretch; padding: 14px; transition: transform .15s, box-shadow .15s, border-color .15s; }
.card.day:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card.mine { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.datebadge { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 62px; min-height: 76px; border-radius: 12px;
  background: var(--tint); color: var(--accent); line-height: 1.1; }
.datebadge .mon { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.datebadge .dd { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; color: var(--text); }
.datebadge .wd { font-size: .72rem; font-weight: 600; color: var(--muted); }
.datebadge.big { width: 84px; min-height: 100px; border-radius: 16px; }
.datebadge.big .dd { font-size: 2.3rem; }
.card.mine .datebadge { background: var(--accent); color: var(--on-accent); }
.card.mine .datebadge .dd, .card.mine .datebadge .wd { color: var(--on-accent); }
.daybody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.daytitle { font-weight: 750; font-size: 1.05rem; letter-spacing: -.01em; }
.daytitle:hover { color: var(--accent); }
.clamp { margin: 0; font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dayfoot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dayfoot form, .eventfoot form { display: flex; align-items: center; gap: 10px; margin: 0; }
.date { color: var(--accent); font-weight: 700; font-size: .9rem; }
.card.event { max-width: 680px; padding: 24px; }
.eventhead { display: flex; gap: 18px; align-items: center; }
.eventhead h1 { margin: 2px 0 4px; }
.eventhead p { margin: 0; }
.desc { margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.eventfoot { margin-top: 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.eventfoot .btn.small { padding: 11px 22px; font-size: 1rem; border-radius: 10px; }
.card.add { margin-bottom: 20px; }
.card summary { cursor: pointer; }

.tag { display: inline-flex; align-items: center; background: var(--tint); color: var(--accent); border-radius: 99px; padding: 2px 10px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.tag.grey { background: var(--sunken); color: var(--muted); }
.tag.warn { background: var(--warn); color: var(--text); box-shadow: inset 0 0 0 1px var(--warn-line); }

/* ---------- Calendar ---------- */
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-head h2 { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.cal-head span { display: inline-flex; gap: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cal-wd { background: var(--sunken); text-align: center; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 0; }
.cal-cell { background: var(--surface); min-height: 104px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-cell.empty { background: var(--sunken); }
.cal-cell.has { background: color-mix(in srgb, var(--tint) 35%, var(--surface)); }
.sun .dnum, .cal-wd.sun { color: var(--sun); }
.sat .dnum, .cal-wd.sat { color: var(--sat); }
.dnum { font-size: .85rem; font-weight: 700; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell.today .dnum { background: var(--accent); color: var(--on-accent); }
.ev { display: block; font-size: .78rem; line-height: 1.3; font-weight: 700; background: var(--tint); color: var(--accent); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 4px 7px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: transform .1s; }
.ev:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }
.ev.mine { background: var(--accent); color: var(--on-accent); border-left-color: var(--earth); }
.ev.past { opacity: .5; }
.cal > p { margin: 12px 2px 0; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 16px 22px;
  color: var(--muted); font-size: .88rem; font-weight: 600; box-shadow: var(--shadow); overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(var(--accent), var(--earth)); }
.stat span { display: block; color: var(--text); font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.25; }

/* ---------- Forms ---------- */
.narrow { max-width: 480px; margin: 8px auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.form { display: flex; flex-direction: column; gap: 16px; }
.form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; margin-top: 14px; }
.form .wide { grid-column: 1 / -1; }
.form > .btn { align-self: flex-start; }
.narrow .form > .btn { align-self: stretch; padding: 13px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 650; font-size: .9rem; }
label .muted { font-weight: 400; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%; min-height: 44px;
  transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); padding: 0; }
input[type=search] { width: auto; }
label.check { flex-direction: row; align-items: flex-start; gap: 12px; font-weight: 400; background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; padding: 14px; line-height: 1.5; }
label.check input { flex: none; margin-top: 2px; }

.notice { background: var(--tint); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-weight: 600; }
.notice.warn { background: var(--warn); border-color: var(--warn-line); }

/* ---------- Tables ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 28px 0 14px; }
.toolbar form { display: flex; gap: 8px; align-items: center; }
.toolbar input { min-width: 240px; background: var(--surface); }
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; }
main > table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--sunken); font-weight: 700; }
tbody tr:hover td { background: color-mix(in srgb, var(--tint) 30%, transparent); }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 650; text-decoration: none; }
td a:hover { text-decoration: underline; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0 0 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); max-width: 680px; }
.details dt { color: var(--muted); font-size: .9rem; }
.details dd { margin: 0; font-weight: 600; }
.danger { margin-top: 36px; }
.danger .linkbtn { color: var(--danger); }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 22px 0; }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  main { padding-top: 22px; }
  .hero { padding: 40px 0 110px; }
  .ridge { height: 100px; }
  .cal { padding: 12px; border-radius: 14px; }
  .cal-head h2 { order: -1; width: 100%; text-align: center; font-size: 1.3rem; }
  .cal-cell { min-height: 56px; padding: 4px 2px; align-items: center; }
  .ev { font-size: 0; padding: 0; width: 8px; height: 8px; border-left: 0; border-radius: 50%; background: var(--accent); }
  .ev.mine { background: var(--earth); }
  .cards { grid-template-columns: 1fr; }
  .narrow { padding: 20px; border-radius: 14px; }
  .langs { margin-left: 0; }
  .lang { padding: 3px 8px; }
  .details { grid-template-columns: 1fr; gap: 2px; }
  .details dd { margin-bottom: 10px; }
  .eventhead { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* On phones the whole calendar square is tappable, not just the dot */
@media (max-width: 640px) {
  .cal-cell { position: relative; }
  .ev::after { content: ""; position: absolute; inset: 0; }
}

/* ---------- Information pages ---------- */
.hero.sub { padding: 44px 0 120px; }
.hero.sub h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 10px; }
.hero.sub .lead { margin: 0; }
.hero.sub .ridge { height: 110px; }
.prose { max-width: 820px; }
.prose > p, .prose li { font-size: 1.03rem; }
.prose h2 { font-size: 1.35rem; margin-top: 40px; }
.prose h2:first-child { margin-top: 8px; }
.prose h3 { margin: 0 0 6px; font-size: 1.05rem; font-weight: 750; }
.prose ul { padding-left: 1.2em; display: grid; gap: 6px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.feature p, .steps p, .contact p { margin: 0; color: var(--muted); font-size: .95rem; }
.ficon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--tint); font-size: 1.3rem; margin-bottom: 12px; flex: none; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; display: grid; gap: 12px; }
.steps li { counter-increment: step; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 16px 68px; box-shadow: var(--shadow); }
.steps li::before { content: counter(step); position: absolute; left: 18px; top: 16px; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-weight: 800; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 32px; }
.faq { display: grid; gap: 10px; margin-bottom: 24px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.faq summary { cursor: pointer; padding: 15px 18px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-weight: 800; font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0; padding: 0 18px 16px; color: var(--muted); }
.card.contact { display: flex; gap: 16px; align-items: flex-start; max-width: 480px; margin-bottom: 20px; }
.card.contact .ficon { margin: 0; }
.card.contact p a { font-weight: 700; font-size: 1.05rem; }
footer .wrap { display: flex; justify-content: space-between; align-items: center; gap: 10px 24px; flex-wrap: wrap; }
.footlinks { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.footlinks a { color: var(--muted); text-decoration: none; font-weight: 600; }
.footlinks a:hover { color: var(--text); text-decoration: underline; }

/* Flag-only language switch */
.langs { gap: 4px; padding: 4px; }
.lang, .lang.on { display: grid; place-items: center; padding: 4px 7px; }
.lang svg { display: block; width: 27px; height: 18px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); }
.lang:not(.on) svg { opacity: .45; filter: saturate(.6); transition: opacity .15s, filter .15s; }
.lang:not(.on):hover svg { opacity: 1; filter: none; }

/* ---------- Event types ---------- */
:root { --ride: #2a66c4; --meet: #b3582f; --race: #7c45bd; }
@media (prefers-color-scheme: dark) { :root { --ride: #7fa8ee; --meet: #e39063; --race: #b892ea; } }
.t-trail { --tc: var(--accent); } .t-ride { --tc: var(--ride); } .t-meeting { --tc: var(--meet); } .t-race { --tc: var(--race); }
.etype { display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--tc); white-space: nowrap; }
.etype::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tc); }
.ev { background: color-mix(in srgb, var(--tc) 15%, var(--surface)); color: var(--tc); border-left-color: var(--tc); }
.ev.mine { background: var(--tc); color: var(--on-accent); border-left-color: var(--text); }
.legend { display: flex; gap: 8px 18px; flex-wrap: wrap; margin: 12px 2px 0; }
td .etype { margin-right: 6px; }
@media (max-width: 640px) { .ev, .ev.mine { background: var(--tc); } }

/* ---------- Trail map ---------- */
.mapwrap { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 10px 10px 12px; margin-bottom: 24px; }
.map { height: min(62vh, 560px); min-height: 340px; border-radius: 12px; background: var(--sunken); z-index: 0; }
.mapfail { display: none; padding: 24px; color: var(--muted); }
.map.failed .mapfail { display: block; }
.mapwrap .legend { margin: 12px 6px 0; }
.leaflet-container { font: inherit; }
.leaflet-popup-content { margin: 12px 14px; font-size: .9rem; line-height: 1.45; }
.leaflet-popup-content strong { font-size: 1rem; }
.leaflet-popup-content a { font-weight: 700; }
.popimg { display: block; width: 100%; height: 96px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
.diff { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.diff::before { content: ""; width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.diff.green::before { background: #2e9e4f; } .diff.blue::before { background: #2f6fd0; }
.diff.red::before { background: #d0392f; } .diff.black::before { background: #1c1c1c; border-radius: 2px; transform: rotate(45deg) scale(.85); }
.tag.bad { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); }
.tags { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.cards.trails { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card.trail { padding: 0; overflow: hidden; display: flex; flex-direction: column; text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
.card.trail:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card.trail img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
.trailbody { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 2px; }
.lead-text { font-size: 1.08rem; max-width: 46em; margin-bottom: 22px; }
.gap { height: 22px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.gallery a { display: block; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.gallery img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; transition: transform .25s; }
.gallery a:hover img { transform: scale(1.04); }
@media (max-width: 640px) { .map { height: 58vh; } .gallery { grid-template-columns: 1fr 1fr; } }
/* Keep the site's form styling off the map's own controls */
.leaflet-container input { width: auto; min-height: 0; padding: 0; margin: 0 6px 0 0; box-shadow: none; }
.leaflet-container label { display: block; font-weight: 600; font-size: .85rem; color: #222; }
.leaflet-control-layers-expanded { padding: 8px 12px; border-radius: 10px; }
.diff.black::before { box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px var(--line); }

/* ---------- Trail admin ---------- */
.adminbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.formcard { max-width: 820px; padding: 24px; }
.formcard .form.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; margin-top: 0; }
.formfoot { display: flex; gap: 12px; flex-wrap: wrap; margin: 22px 0 0; }
textarea { resize: vertical; min-height: 84px; }
input[type=file] { padding: 9px; background: var(--sunken); border-style: dashed; cursor: pointer; }
input[type=file]::file-selector-button { font: inherit; font-weight: 700; font-size: .88rem; margin-right: 12px; padding: 6px 12px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); cursor: pointer; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.danger { background: var(--danger); color: #fff; }
.gallery.manage { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.mphoto { position: relative; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.mphoto img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
.mphoto form { position: absolute; right: 8px; bottom: 8px; margin: 0; }
.nophoto { aspect-ratio: 3 / 2; display: grid; place-items: center; font-size: 2.4rem; background: linear-gradient(160deg, var(--forest-1), var(--forest-2)); }
.tags .btn { margin-left: auto; }
@media (max-width: 640px) { .formcard { padding: 16px; } .formcard .form.grid { grid-template-columns: 1fr; } }

/* ================= Kiryu MTB Park brand ================= */
:root { --brand: #ff7a0a; --brand-2: #e56800; --on-brand: #1a1206; --earth: #ff7a0a; --display: "Racing Sans One", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif; }
@media (prefers-color-scheme: dark) { :root { --earth: #ff8f2e; } }

/* Racing Sans One for headings and big numbers (Japanese text falls back to the normal font) */
h1, h2, .cal-head h2, .stat span, .datebadge .dd, .daytitle, .prose h3, .faq summary, .etype, .eyebrow, .btn, .datebadge .mon {
  font-family: var(--display); font-synthesis: none; letter-spacing: .01em; }
h1, h2, .cal-head h2, .stat span, .datebadge .dd { font-weight: 400; }
:lang(ja) :is(h1, h2, .stat span, .daytitle, .prose h3, .faq summary, .btn) { font-weight: 800; }
h1 { font-size: clamp(1.9rem, 4vw, 2.5rem); text-transform: uppercase; }
h2 { font-size: 1.45rem; text-transform: uppercase; }
.daytitle { font-size: 1.2rem; font-weight: 400; }
.btn { font-weight: 400; font-size: 1.02rem; letter-spacing: .03em; text-transform: uppercase; }
.btn.small { font-size: .9rem; }
.faq summary, .prose h3 { font-weight: 400; font-size: 1.15rem; }
/* The slanted orange bar from the logo, under page titles */
main > h1::after, .prose > h2::after, main > h2::after { content: ""; display: block; width: 64px; height: 6px; margin-top: 8px; background: var(--brand); transform: skewX(-24deg); transform-origin: left; }
main > h2::after, .prose > h2::after { width: 40px; height: 4px; margin-top: 6px; }

/* Dark header and footer so the white logo shows, in light and dark themes */
header.top { background: rgba(14, 38, 23, .94); border-bottom: 3px solid var(--brand); }
header.top .wrap { min-height: 68px; }
.brand img { display: block; height: 46px; width: auto; }
nav > a:not(.btn), nav .linkbtn { color: rgba(255, 255, 255, .78); }
nav > a:not(.btn):hover, nav .linkbtn:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.langs { background: rgba(255, 255, 255, .1); }
.lang.on { background: rgba(255, 255, 255, .22); box-shadow: none; }
nav .btn, .hero .btn:not(.ghost) { background: var(--brand); color: var(--on-brand); }
nav .btn:hover, .hero .btn:not(.ghost):hover { background: #ff9233; }
footer { background: #0e2617; color: rgba(255, 255, 255, .7); border-top: 3px solid var(--brand); padding: 26px 0; }
.footbrand { display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.footbrand img { height: 38px; width: auto; display: block; }
.footlinks a { color: rgba(255, 255, 255, .7); }
.footlinks a:hover { color: #fff; }

/* Front-page banner with the stacked logo */
.hero { background:
    radial-gradient(900px 420px at 85% -10%, rgba(255, 122, 10, .22), transparent 60%),
    radial-gradient(700px 400px at 0% 100%, rgba(111, 196, 135, .16), transparent 60%),
    linear-gradient(160deg, #0e2617, var(--forest-2)); }
.herogrid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; gap: 24px; }
.herologo { width: 100%; max-width: 440px; height: auto; justify-self: center; margin: -40px 0 -50px; filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .35)); }
.hero h1 { text-transform: uppercase; font-size: clamp(2.3rem, 6vw, 4rem); line-height: 1.02; }
.hero h1::after { content: ""; display: block; width: 110px; height: 9px; margin-top: 14px; background: var(--brand); transform: skewX(-24deg); transform-origin: left; }
.eyebrow { font-size: .85rem; letter-spacing: .1em; }
.cal-cell.today .dnum { background: var(--brand); color: var(--on-brand); }
.stat::before { background: var(--brand); }
@media (max-width: 760px) {
  .herogrid { grid-template-columns: 1fr; }
  .herologo { order: -1; max-width: 260px; margin: -50px auto -40px; justify-self: start; }
  .brand img { height: 38px; }
}

/* Clickable number tiles and the My events tabs */
a.stat.link { display: block; text-decoration: none; transition: transform .15s, border-color .15s; }
a.stat.link:hover { transform: translateY(-2px); border-color: var(--brand); }
a.stat.link b { color: var(--brand); font-weight: 800; }
.tabs { display: inline-flex; gap: 4px; background: var(--sunken); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 22px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 700; font-size: .92rem; }
.tab span { display: inline-block; min-width: 22px; text-align: center; margin-left: 4px; padding: 0 6px; border-radius: 99px; background: var(--line); font-size: .8rem; }
.tab.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.tab.on span { background: var(--brand); color: var(--on-brand); }

/* ---------- Sign-up confirm page and event questions ---------- */
.narrow.wide { max-width: 560px; }
.confirmbox { display: flex; gap: 14px; align-items: center; background: var(--sunken); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 14px 0 20px; }
.confirmbox > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.narrow h2 { margin: 6px 0 0; font-size: 1.15rem; }
.q { display: flex; flex-direction: column; gap: 6px; }
.qlabel { font-weight: 650; font-size: .95rem; }
.req { color: var(--brand); }
.radios { display: flex; gap: 10px; flex-wrap: wrap; }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.radios label.inline { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 18px; min-width: 96px; }
.radios label.inline:has(input:checked) { border-color: var(--accent); background: var(--tint); }
input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); }
.myanswers { margin-top: 20px; padding-top: 4px; border-top: 1px solid var(--line); }
.myanswers h2 { margin: 16px 0 10px; font-size: 1.1rem; }
.details.plain { background: none; border: 0; box-shadow: none; padding: 0; margin-bottom: 10px; }
.qlist { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; max-width: 820px; }
.qlist li { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.qlist li > div { display: flex; flex-direction: column; }
.qlist form { margin: 0; }
.linkbtn.del { color: var(--danger); }
.stats.sums { margin-bottom: 16px; }
.sumline { font-family: inherit !important; font-size: 1.05rem !important; font-weight: 600 !important; letter-spacing: 0 !important; }
.sumline b { font-family: var(--display); font-size: 1.5rem; font-weight: 400; color: var(--brand); margin-left: 2px; }

/* ---------- Social links ---------- */
.socials { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.social { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 40px; height: 40px; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .12);
  text-decoration: none; transition: background .15s, transform .15s; }
.social:hover { background: var(--brand); color: var(--on-brand); transform: translateY(-2px); }
.socials.big { gap: 10px; }
.socials.big .social { width: auto; height: auto; border-radius: 12px; padding: 12px 18px; background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 700; }
.socials.big .social svg { color: var(--brand); }
.socials.big .social:hover { border-color: var(--brand); background: var(--surface); color: var(--text); }
.radios label.inline { min-width: 84px; justify-content: center; }

/* ---------- Event photos, templates, news board ---------- */
.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card.day { flex-direction: column; gap: 0; padding: 0; overflow: hidden; }
.daybanner { position: relative; display: block; aspect-ratio: 16 / 9; background: #14261c; overflow: hidden; }
.daybanner > img:not(.bannerlogo) { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.card.day:hover .daybanner > img:not(.bannerlogo) { transform: scale(1.04); }
.daybanner.plainbanner { background: linear-gradient(135deg, #14261c 0%, #1f3a2a 55%, color-mix(in srgb, var(--tc) 55%, #14261c) 100%); display: grid; place-items: center; }
.bannerlogo { height: 72%; width: auto; opacity: .92; }
.daybanner .datebadge { position: absolute; left: 12px; top: 12px; width: 58px; min-height: 68px; background: var(--surface); color: var(--tc); box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.card.mine .daybanner .datebadge { background: var(--accent); }
.card.day .daybody { padding: 14px 16px 16px; }
.eventcover { display: block; width: calc(100% + 48px); max-width: none; margin: -24px -24px 20px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius) var(--radius) 0 0; }
.tplbox { max-width: 820px; margin-bottom: 18px; }
.tplbox p { margin: 4px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--bg); color: var(--text); font-weight: 700; font-size: .92rem; text-decoration: none; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.coverfield { display: flex; flex-direction: column; gap: 10px; }
.coverthumb { width: 240px; max-width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.news { margin-top: 44px; }
.newshead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.newshead h2 { margin: 0; }
.newshead span { display: flex; gap: 8px; flex-wrap: wrap; }
.newsgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(326px, 1fr)); gap: 18px; align-items: start; }
.newsgrid .instagram-media { margin: 0 !important; min-width: 0 !important; width: 100% !important; max-width: 540px !important; }
.newsgrid blockquote.instagram-media { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); word-break: break-all; }
.newsform { margin-bottom: 22px; }
@media (max-width: 640px) { .eventcover { width: calc(100% + 48px); } .newsgrid { grid-template-columns: 1fr; } }
.bannerlogo { position: absolute; top: 50%; left: 50%; height: 78%; width: auto; transform: translate(-50%, -50%); }

/* ---------- Home hero with photo carousel ---------- */
.hero.home { padding: 72px 0 160px; }
.hero .slides, .hero .slide { position: absolute; inset: 0; }
.hero .slide { background-size: cover; background-position: center; opacity: 0; transition: opacity 1.2s ease; }
.hero .slide.on { opacity: 1; }
.hero.photos .slides::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(8, 24, 14, .9) 0%, rgba(8, 24, 14, .68) 48%, rgba(8, 24, 14, .3) 100%), linear-gradient(0deg, rgba(8, 24, 14, .55), transparent 45%); }
.hero.photos h1, .hero.photos .lead, .hero.photos .eyebrow { text-shadow: 0 2px 14px rgba(0, 0, 0, .5); }
.hero.photos .lead { color: #f3f7f1; }
.hero .dots { position: absolute; z-index: 2; left: 0; right: 0; bottom: 112px; display: flex; justify-content: center; gap: 8px; }
.hero .dots button { width: 26px; height: 5px; padding: 0; border: 0; border-radius: 3px; background: rgba(255, 255, 255, .4); cursor: pointer; transform: skewX(-24deg); }
.hero .dots button.on { background: var(--brand); }
.photogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.photoitem { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.photoitem img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
@media (max-width: 640px) { .hero.home { padding: 44px 0 120px; } .hero .dots { bottom: 78px; } }
@media (prefers-reduced-motion: reduce) { .hero .slide { transition: none; } }
.hero.home h1 { font-size: clamp(2rem, 4.6vw, 3.3rem); max-width: none; }

/* ---------- Header stays on one line in both languages ---------- */
nav > a, nav .linkbtn { white-space: nowrap; }
html[lang="ja"] nav > a:not(.btn), html[lang="ja"] nav .linkbtn { font-size: .86rem; padding: 6px 7px; }
@media (min-width: 900px) {
  header.top .wrap, nav { flex-wrap: nowrap; }
  .brand { flex: none; }
  nav { gap: 2px; }
}
.resend { margin-top: 18px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .resend .linkbtn { color: var(--accent); text-decoration: underline; padding: 0; }

/* ---------- Loading feedback ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
.loading { pointer-events: none; opacity: .8; cursor: progress; }
.loading::before { content: ""; flex: none; display: inline-block; width: 1em; height: 1em; margin-right: .5em; vertical-align: -.15em;
  border: .16em solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.loading::before { margin-right: .2em; }
.loadbar { position: fixed; z-index: 100; top: 0; left: 0; height: 3px; width: 0; background: var(--brand); opacity: 0; pointer-events: none; }
.loadbar.on { opacity: 1; width: 90%; transition: width 8s cubic-bezier(.1, .7, .2, 1); }
@media (prefers-reduced-motion: reduce) { .loading::before { animation-duration: 2s; } }

/* ---------- Hero photos: show the picture as it is, with only a light shade behind the text ---------- */
.hero.photos .slides::after { background: linear-gradient(90deg, rgba(0, 0, 0, .4) 0%, rgba(0, 0, 0, .2) 40%, rgba(0, 0, 0, 0) 65%); }
.hero.photos .ridge { display: none; }
.hero.photos h1, .hero.photos .lead, .hero.photos .eyebrow { text-shadow: 0 1px 3px rgba(0, 0, 0, .7), 0 2px 18px rgba(0, 0, 0, .55); }
.hero.photos .herologo { filter: drop-shadow(0 2px 10px rgba(0, 0, 0, .6)); }
@media (max-width: 760px) { .hero.photos .slides::after { background: rgba(0, 0, 0, .3); } }

/* ---------- Hero photos: light even tint, and more room so the photo shows around the text ---------- */
.hero.photos .slides::after { background: linear-gradient(90deg, rgba(0, 0, 0, .22) 0%, rgba(0, 0, 0, 0) 60%), rgba(0, 0, 0, .26); }
.hero.home.photos { padding: 130px 0 170px; }
.hero.photos .dots { bottom: 30px; }
@media (max-width: 760px) {
  .hero.photos .slides::after { background: rgba(0, 0, 0, .34); }
  .hero.home.photos { padding: 64px 0 110px; }
  .hero.photos .dots { bottom: 22px; }
}

/* ---------- Hero photos: mountain shapes show while the first photo loads, then fade away ---------- */
.hero.photos .ridge { display: block; opacity: 1; transition: opacity .8s ease; }
.hero.photos.ready .ridge { opacity: 0; }
.hero.photos .slide.on { opacity: 0; }
.hero.photos.ready .slide.on { opacity: 1; }
.tpledit { margin: 10px 0 0; }

/* ---------- Trail form: is there a GPX line yet? ---------- */
.gpxstate { display: block; padding: 10px 14px; border-radius: 10px; font-weight: 700; margin-bottom: 8px; }
.gpxstate.ok { background: var(--tint); color: var(--accent); }
.gpxstate.none { background: var(--warn); color: var(--text); box-shadow: inset 0 0 0 1px var(--warn-line); }

/* ---------- Trail map: "hold Ctrl and scroll" hint ---------- */
.maphint { position: absolute; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; text-align: center; pointer-events: none;
  background: rgba(0, 0, 0, .45); color: #fff; font-weight: 700; font-size: 1.1rem; opacity: 0; transition: opacity .25s ease; }
.maphint.on { opacity: 1; }

/* ---------- Trail map: difficulty filter buttons ---------- */
.legend.filters { align-items: center; gap: 8px; }
.fbtn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 700; font-size: .9rem; padding: 6px 12px; min-height: 40px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.fbtn b { font-weight: 700; color: var(--muted); }
.fbtn:hover:not(:disabled) { border-color: var(--brand); }
.fbtn.on { border-color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand); background: var(--surface); }
.fbtn:disabled { opacity: .45; cursor: default; }
.card.trail[hidden] { display: none; }

/* ---------- Hero photos: make the words easier to read on bright photos ---------- */
.hero.photos .slides::after { background: linear-gradient(90deg, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .34) 45%, rgba(0, 0, 0, 0) 75%), rgba(0, 0, 0, .3); }
.hero.photos h1 { text-shadow: 0 2px 4px rgba(0, 0, 0, .85), 0 4px 26px rgba(0, 0, 0, .7); }
.hero.photos .lead { color: #fff; font-weight: 500; text-shadow: 0 1px 2px rgba(0, 0, 0, .95), 0 0 14px rgba(0, 0, 0, .85), 0 0 30px rgba(0, 0, 0, .6); }
.hero.photos .eyebrow { background: rgba(0, 0, 0, .5); border-color: rgba(255, 255, 255, .4); color: #fff; }
.hero.photos .btn.ghost { background: rgba(0, 0, 0, .4); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .8); }
.hero.photos .herologo { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .75)) drop-shadow(0 6px 26px rgba(0, 0, 0, .5)); }
@media (max-width: 760px) { .hero.photos .slides::after { background: rgba(0, 0, 0, .45); } }
.qacts { display: inline-flex; align-items: center; gap: 14px; white-space: nowrap; }

/* ---------- Question form: one box per option ---------- */
.optbox .optlabel { display: block; font-weight: 600; margin-bottom: 6px; }
.optlist { display: grid; gap: 8px; margin-bottom: 10px; }

/* ---------- Sign-up form: first and last name side by side ---------- */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .pair { grid-template-columns: 1fr; } }

/* ---------- Registration questions: follow-up box appears when the answer is Yes ---------- */
.q .qdetail { display: none; margin-top: 10px; }
.q:has(input[type="radio"][value="yes"]:checked) .qdetail { display: flex; }
[data-types][hidden] { display: none !important; }

/* ---------- Event QR code ---------- */
.qrcard { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qrcard img { background: #fff; border-radius: 10px; padding: 6px; width: 180px; height: 180px; }
.qrcard a { overflow-wrap: anywhere; }

/* ---------- Event page: "send to your friends" QR code on the right of the header ---------- */
.shareqr { margin-left: auto; flex: none; display: grid; justify-items: center; gap: 6px; width: 124px; text-align: center; text-decoration: none;
  color: var(--muted); font-size: .78rem; font-weight: 700; line-height: 1.25; }
.shareqr img { width: 104px; height: 104px; background: #fff; border-radius: 10px; padding: 5px; box-sizing: content-box; }
.shareqr:hover { color: var(--text); }
@media (max-width: 640px) { .eventhead { flex-wrap: wrap; } .shareqr { flex: 1 1 100%; display: flex; align-items: center; gap: 12px; margin: 8px 0 0; width: auto; min-width: 0; text-align: left; font-size: .9rem; } .shareqr img { width: 84px; height: 84px; flex: none; } }
