:root {
  --ink: #5a4632;
  --accent: #bf4d1c;
  --bg: #fbf3e2;
  --surface: #fffaf0;
  --text: #3d2f22;
  --muted: #7a6650;
  --line: #ecdcc0;
  --header-h: 52px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.7;
}

a { color: var(--ink); }

.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--ink);
  color: #fff;
  z-index: 1000;
}

.app-title { margin: 0; font-size: 18px; letter-spacing: 0.04em; }

.tabs { display: flex; gap: 4px; }
.tabs a {
  color: #fff;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  opacity: 0.8;
}
.tabs a[aria-current] { background: rgba(255, 255, 255, 0.18); opacity: 1; font-weight: 600; }

main { padding-top: calc(var(--header-h) + env(safe-area-inset-top)); height: 100%; }

.view[hidden] { display: none; }

/* 地図 */
#view-map { position: relative; height: 100%; }
#map { position: absolute; inset: 0; }

.filter {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.filter button {
  border: 0;
  background: none;
  font: inherit;
  padding: 6px 18px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}
.filter button[aria-checked="true"] { background: var(--ink); color: #fff; font-weight: 600; }

.map-status {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 500;
  background: var(--surface);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.map-status[hidden] { display: none; }

.locate {
  position: absolute;
  right: 12px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 500;
  border: 0;
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

/* 地図のマーカー */
.pin {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 2px 2px rgba(80, 50, 20, 0.25));
}
.pin svg { width: 100%; height: 100%; display: block; }
.me {
  z-index: 2;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.maplibregl-ctrl.maplibregl-ctrl-attrib { font-size: 11px; background: rgba(255, 250, 240, 0.9); }
.maplibregl-ctrl-attrib a { color: var(--ink); }
.maplibregl-ctrl-top-left { top: 56px; }

/* 詳細・記録 */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}
.page h2 { margin: 8px 0 0; font-size: 22px; line-height: 1.4; }
.back { display: inline-block; margin-top: 4px; text-decoration: none; }
.address { margin: 4px 0 16px; color: var(--muted); }

.stamp-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px 16px;
  margin-bottom: 12px;
}
.stamp-block h3 { margin: 0 0 4px; font-size: 16px; }
.stamp-block p { margin: 0 0 12px; font-size: 14px; }

button.primary {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button.primary:disabled { background: #d6d3cb; color: #6b6760; cursor: default; }

.distance, .official, .source, .note, .empty { font-size: 14px; }
.source, .note { color: var(--muted); }
.official a { font-weight: 600; }

.records { list-style: none; margin: 16px 0; padding: 0; }
.records li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.records li a { font-weight: 600; text-decoration: none; }
.records .tag {
  justify-self: end;
  font-size: 12px;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
}
.records time { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }

/* 初回説明 */
dialog {
  border: 0;
  border-radius: 14px;
  padding: 20px;
  width: min(92vw, 480px);
  max-height: 88vh;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog p { margin: 0 0 12px; font-size: 15px; }
dialog .tip { font-size: 13px; color: var(--muted); background: var(--bg); padding: 10px 12px; border-radius: 8px; }
