:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-press: #0062c4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
  --topbar-h: 52px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; }
:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.45); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h);
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 3;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: 0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; color: var(--accent); }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- app layout ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "search" "map" "panel";
}
.app > .search { grid-area: search; margin: 12px 16px; z-index: 4; }
.map-wrap { grid-area: map; position: relative; height: 56svh; min-height: 320px; background: #e8e8ed; }
#map { position: absolute; inset: 0; }
.panel { grid-area: panel; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

@media (min-width: 900px) {
  .app {
    grid-template-columns: 380px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "search map" "panel map";
    height: calc(100svh - var(--topbar-h));
    min-height: 560px;
  }
  .app > .search { margin: 20px 20px 0; }
  .map-wrap { height: auto; min-height: 0; border-left: 1px solid var(--line); }
  .panel { overflow-y: auto; padding: 12px 20px 20px; }
}

/* ---------- map overlays ---------- */
.map-hint {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: calc(100% - 76px); /* 右上のズームボタンと重ねない */
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(29, 29, 31, 0.78);
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.3s ease;
}
.map-hint.is-hidden { opacity: 0; }

.map-tools {
  position: absolute;
  right: 12px;
  bottom: 36px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tool {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  transition: background-color 0.15s ease;
}
.tool + .tool { border-top: 1px solid var(--line); }
.tool svg { width: 22px; height: 22px; }
.tool:hover { background: rgba(0, 0, 0, 0.04); }
.tool:active { background: rgba(0, 0, 0, 0.08); }
.tool[aria-pressed="true"] { color: var(--accent); }
.tool:disabled { color: #c7c7cc; cursor: default; background: transparent; }
.tool.is-busy svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.center-pin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  cursor: grab;
}
.center-pin:active { cursor: grabbing; }
.maplibregl-ctrl-attrib { font-size: 11px; }

/* ---------- search ---------- */
.search {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.search:focus-within { box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.35), var(--shadow); }
.search-icon { width: 18px; height: 18px; margin-left: 12px; color: var(--muted); flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 13px 8px;
  font: inherit;
  font-size: 16px; /* iOS のズームを防ぐ */
  color: var(--text);
  outline: none;
}
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search-submit {
  margin: 5px;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}
.search-submit:active { background: var(--accent-press); }
.search-results {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  max-height: 50svh;
  overflow-y: auto;
}
.search-results li { padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.search-results li:hover, .search-results li[aria-selected="true"] { background: rgba(0, 113, 227, 0.08); }
.search-results .r-name { display: block; font-weight: 600; }
.search-results .r-detail { display: block; color: var(--muted); font-size: 12px; }
.search-results .r-empty { color: var(--muted); cursor: default; }
.search-results .r-empty:hover { background: none; }
.search-results .r-pending { font-size: 12px; animation: pulse 1.2s ease-in-out infinite; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.card h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 14px; padding: 4px 0; }
.center-name { margin: 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.center-coords { margin: 2px 0 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.radii { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.radius-row {
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr) auto 36px;
  align-items: center;
  gap: 10px;
  animation: row-in 0.25s ease;
}
@keyframes row-in { from { opacity: 0; transform: translateY(-4px); } }
.swatch { width: 6px; height: 36px; border-radius: 3px; }
.radius-field {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid transparent;
  transition: border-color 0.15s ease;
}
.radius-field:focus-within { border-color: var(--accent); background: #fff; }
.radius-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 8px 4px 8px 12px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.radius-field select {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: var(--muted);
  padding: 8px 10px 8px 2px;
  outline: none;
  cursor: pointer;
}
.radius-meta { min-width: 5.4em; font-size: 12px; color: var(--muted); text-align: right; line-height: 1.35; white-space: nowrap; font-variant-numeric: tabular-nums; }
.radius-meta b { color: var(--text); font-weight: 600; }
.row-del {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.row-del:hover { background: rgba(255, 59, 48, 0.08); color: #ff3b30; }
.row-del svg { width: 16px; height: 16px; }
.radius-row.is-invalid .radius-field { border-color: #ff3b30; }

.add-btn {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  border: 1px dashed rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}
.add-btn:hover { background: rgba(0, 113, 227, 0.05); }
.add-btn:disabled { color: var(--muted); cursor: not-allowed; }

.presets { margin-top: 12px; display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; }
.presets-label { margin: 0; font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: rgba(0, 113, 227, 0.4); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.share { display: flex; gap: 8px; }
.primary-btn, .secondary-btn {
  flex: 1;
  padding: 13px;
  border-radius: 12px;
  border: 0;
  font-weight: 600;
  font-size: 15px;
  transition: transform 0.1s ease, background-color 0.15s ease;
}
.primary-btn { background: var(--accent); color: #fff; }
.primary-btn:active { background: var(--accent-press); transform: scale(0.98); }
.secondary-btn { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.secondary-btn:active { transform: scale(0.98); }
.fineprint { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(29, 29, 31, 0.9);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
  max-width: calc(100% - 32px);
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------- guide (SEO content) ---------- */
.guide { max-width: 760px; margin: 0 auto; padding: 48px 20px 24px; }
.guide section + section { margin-top: 48px; }
.guide h2 { font-size: 22px; margin: 0 0 14px; letter-spacing: 0.01em; }
.guide p { margin: 0 0 12px; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 12px; }
.steps li {
  counter-increment: s;
  position: relative;
  padding: 14px 16px 14px 56px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 16px;
  top: 14px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
}
.steps strong { display: block; }
.steps span { color: var(--muted); font-size: 14px; }

.table-scroll { overflow-x: auto; margin-bottom: 12px; }
.walk-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
.walk-table th, .walk-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
.walk-table th { background: #fafafa; color: var(--muted); font-weight: 600; font-size: 12px; }
.walk-table td:nth-child(odd) { font-weight: 600; }
.walk-table tr:last-child td { border-bottom: 0; }
.walk-table a { font-size: 12px; margin-left: 6px; }

.uses { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.uses li { background: var(--surface); padding: 14px 16px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 14px; color: var(--muted); }
.uses strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 2px; }

.faq { margin: 0; }
.faq dt { font-weight: 700; margin-top: 18px; }
.faq dd { margin: 4px 0 0; color: #424245; }
.faq code { background: rgba(0, 0, 0, 0.05); padding: 1px 6px; border-radius: 4px; font-size: 13px; }

.footer { padding: 24px 20px calc(32px + env(safe-area-inset-bottom)); text-align: center; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 40px; }
.footer p { margin: 4px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
