/*
 * デジタル庁デザインシステム（DADS）のトークン・コンポーネント仕様を踏襲したスタイル
 * 外部フォントは読み込まない（第三者への通信を発生させないため）
 */
:root {
  color-scheme: light;
  /* Primitive */
  --blue-50: #e8f1fe;
  --blue-100: #d9e6ff;
  --blue-200: #c5d7fb;
  --blue-900: #0017c1;
  --blue-1000: #00118f;
  --blue-1100: #000082;
  --blue-1200: #000060;
  --gray-50: #f2f2f2;
  --gray-100: #e6e6e6;
  --gray-200: #cccccc;
  --gray-420: #949494;
  --gray-536: #767676;
  --gray-600: #666666;
  --gray-700: #4d4d4d;
  --gray-800: #333333;
  --gray-900: #1a1a1a;
  --red-50: #fdeeee;
  --red-800: #ec0000;
  --red-900: #ce0000;
  --green-50: #e6f5ec;
  --green-800: #197a4b;
  --yellow-50: #fbf5e0;
  --yellow-300: #ffd43d;
  --yellow-900: #927200;
  --white: #ffffff;
  --black: #000000;

  /* Semantic */
  --color-text: var(--gray-900);
  --color-text-sub: var(--gray-700);
  --color-text-desc: var(--gray-600);
  --color-link: var(--blue-1000);
  --color-link-visited: #5c10be;
  --color-primary: var(--blue-900);
  --color-primary-hover: var(--blue-1100);
  --color-primary-active: var(--blue-1200);
  --color-border: var(--gray-420);
  --color-border-field: var(--gray-536);
  --color-divider: var(--gray-200);
  --color-bg: var(--white);
  --color-bg-sub: var(--gray-50);
  --color-error: var(--red-800);
  --color-success: var(--green-800);

  --radius-s: 4px;
  --radius-m: 8px;
  --radius-l: 12px;
  --gutter: 16px;
  --font-sans: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", Meiryo, system-ui, sans-serif;
  --font-mono: "Noto Sans Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

img { max-width: 100%; }
.leaflet-container img { max-width: none; }

/* フォーカスリング（DADS: 黒のアウトライン＋黄色のリング） */
:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--yellow-300);
}

a { color: var(--color-link); text-decoration: underline; text-underline-offset: 3px; }
a:visited { color: var(--color-link-visited); }
a:hover { color: var(--blue-1100); text-decoration-thickness: 3px; }
a:active { color: var(--blue-1200); }
a:focus-visible { background: var(--yellow-300); color: var(--blue-1200); border-radius: var(--radius-s); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 10000;
  background: var(--white); padding: 8px 16px;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ===== ヘッダー / フッター ===== */
.site-header {
  border-bottom: 1px solid var(--color-divider);
  background: var(--white);
}
.site-header__inner {
  max-width: 1080px; margin: 0 auto; padding: 12px var(--gutter);
  display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap;
}
.site-header__logo {
  font-weight: 700; font-size: 18px; color: var(--color-text); text-decoration: none; line-height: 1.4;
}
.site-header__logo:visited { color: var(--color-text); }
.site-header__nav { margin-left: auto; display: flex; gap: 4px 20px; flex-wrap: wrap; font-size: 16px; }

.site-footer {
  margin-top: 64px;
  background: var(--color-bg-sub);
  border-top: 1px solid var(--color-divider);
  font-size: 14px;
  color: var(--color-text-sub);
}
.site-footer__inner { max-width: 1080px; margin: 0 auto; padding: 32px var(--gutter) 40px; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0 0 16px; padding: 0; list-style: none; }
.site-footer p { margin: 0 0 8px; }

/* ===== レイアウト ===== */
.container { max-width: 1080px; margin: 0 auto; padding: 0 var(--gutter); }
.container--narrow { max-width: 760px; }
main { display: block; padding-top: 32px; }

h1, h2, h3, h4 { line-height: 1.5; letter-spacing: 0.02em; margin: 0; }
.heading-l { font-size: 28px; font-weight: 700; margin-bottom: 16px; }
.heading-m { font-size: 22px; font-weight: 700; margin: 48px 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--color-divider); }
.heading-s { font-size: 18px; font-weight: 700; margin: 32px 0 8px; }
@media (min-width: 768px) {
  .heading-l { font-size: 36px; }
  .heading-m { font-size: 26px; }
  .heading-s { font-size: 20px; }
}
.lead { font-size: 17px; color: var(--color-text-sub); margin: 0 0 24px; }
p { margin: 0 0 16px; }
.text-desc { color: var(--color-text-desc); font-size: 14px; }
.text-mono { font-family: var(--font-mono); }
ul.list, ol.list { padding-left: 1.5em; margin: 0 0 16px; }
ul.list li, ol.list li { margin-bottom: 4px; }

/* ===== カード ===== */
.card-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin: 24px 0; }
@media (min-width: 768px) { .card-grid { grid-template-columns: 1fr 1fr; gap: 24px; } }
.card {
  border: 1px solid var(--color-border); border-radius: var(--radius-l);
  padding: 24px; background: var(--white); display: flex; flex-direction: column; gap: 12px;
}
.card h2 { font-size: 20px; }
.card p { margin: 0; color: var(--color-text-sub); }
.card .button { align-self: flex-start; margin-top: auto; }

/* ===== ボタン ===== */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; min-width: 96px; padding: 10px 24px;
  border-radius: var(--radius-m); border: 1px solid transparent;
  font: inherit; font-size: 16px; font-weight: 700; line-height: 1.4; letter-spacing: 0.02em;
  text-decoration: none; cursor: pointer; text-align: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.button--l { min-height: 56px; padding: 14px 28px; }
.button--s { min-height: 40px; min-width: 72px; padding: 6px 16px; font-size: 14px; }
.button--block { display: flex; width: 100%; }
.button--primary, .button--primary:visited { background: var(--color-primary); color: var(--white); }
.button--primary:hover { background: var(--color-primary-hover); color: var(--white); text-decoration: underline; }
.button--primary:active { background: var(--color-primary-active); }
.button--secondary, .button--secondary:visited { background: var(--white); color: var(--color-primary); border-color: var(--color-primary); }
.button--secondary:hover { background: var(--blue-50); color: var(--blue-1100); border-color: var(--blue-1100); text-decoration: underline; }
.button--secondary:active { background: var(--blue-100); }
.button--tertiary, .button--tertiary:visited { background: transparent; color: var(--color-primary); text-decoration: underline; text-underline-offset: 3px; }
.button--tertiary:hover { background: var(--blue-50); color: var(--blue-1100); }
.button:disabled, .button[aria-disabled="true"] {
  background: var(--gray-200); color: var(--gray-600); border-color: var(--gray-200); cursor: not-allowed; text-decoration: none;
}
.button-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0; }
@media (max-width: 479px) {
  .button-row--stack-sp { flex-direction: column; }
  .button-row--stack-sp .button { width: 100%; }
}

/* ===== フォーム ===== */
.form-section {
  border: 1px solid var(--color-divider); border-radius: var(--radius-l);
  padding: 20px var(--gutter); margin: 0 0 24px; background: var(--white);
}
@media (min-width: 768px) { .form-section { padding: 24px 32px; } }
.form-section > legend, .form-section__title {
  font-size: 18px; font-weight: 700; padding: 0 8px; margin-left: -8px;
}
.form-control { margin: 0 0 24px; }
.form-control:last-child { margin-bottom: 0; }
.form-label { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 700; font-size: 16px; margin-bottom: 8px; line-height: 1.5; }
.form-label .req { font-size: 14px; font-weight: 400; color: var(--color-error); }
.form-label .opt { font-size: 14px; font-weight: 400; color: var(--color-text-desc); }
.form-support { display: block; font-size: 14px; color: var(--color-text-desc); margin: -4px 0 8px; line-height: 1.6; }
.form-error { display: none; color: var(--color-error); font-size: 14px; margin-top: 6px; font-weight: 700; }
.form-error::before { content: "＊ "; }
.form-control.is-error .form-error { display: block; }
.form-control.is-error .input, .form-control.is-error .select, .form-control.is-error .textarea { border-color: var(--color-error); border-width: 2px; }

.input, .select, .textarea {
  display: block; width: 100%;
  min-height: 56px; padding: 14px 16px;
  border: 1px solid var(--color-border-field); border-radius: var(--radius-m);
  background: var(--white); color: var(--color-text);
  font: inherit; font-size: 16px; /* iOSのズーム防止のため16px以上 */
  line-height: 1.5;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--black); }
.input[readonly], .textarea[readonly] { background: var(--color-bg-sub); }
.textarea { min-height: 120px; resize: vertical; }
.textarea--code { font-family: var(--font-mono); font-size: 13px; line-height: 1.6; min-height: 280px; white-space: pre; overflow: auto; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 48px;
  background-image: linear-gradient(45deg, transparent 50%, var(--gray-900) 50%), linear-gradient(135deg, var(--gray-900) 50%, transparent 50%);
  background-position: calc(100% - 24px) 50%, calc(100% - 18px) 50%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
.input--short { max-width: 240px; }
.input-group { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .input-group--2 { grid-template-columns: 1fr 1fr; } .input-group--3 { grid-template-columns: 1fr 1fr 1fr; } }
.input-suffix { display: flex; align-items: center; gap: 8px; }
.input-suffix .input { max-width: 180px; }

/* ラジオ・チェックボックス（タップ領域 44px 以上） */
.choice-group { display: flex; flex-direction: column; gap: 4px; border: 0; padding: 0; margin: 0; min-width: 0; }
.choice-group--row { flex-direction: row; flex-wrap: wrap; gap: 4px 24px; }
.choice-group > legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.choice { display: inline-flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 10px 0; cursor: pointer; line-height: 1.5; }
.choice input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--color-primary); cursor: pointer; }
.choice small { display: block; color: var(--color-text-desc); font-size: 14px; }

/* ===== 通知バナー ===== */
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  border: 3px solid var(--blue-900); border-radius: var(--radius-l);
  padding: 16px; margin: 0 0 24px; background: var(--white);
}
.notice__icon { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--blue-900); color: var(--white); font-weight: 700; display: grid; place-items: center; font-size: 15px; line-height: 1; margin-top: 2px; }
.notice__body { min-width: 0; }
.notice__title { font-weight: 700; margin: 0 0 4px; font-size: 17px; }
.notice__body p:last-child, .notice__body ul:last-child { margin-bottom: 0; }
.notice--warning { border-color: var(--yellow-900); background: var(--yellow-50); }
.notice--warning .notice__icon { background: var(--yellow-900); }
.notice--error { border-color: var(--red-800); background: var(--red-50); }
.notice--error .notice__icon { background: var(--red-800); }
.notice--success { border-color: var(--green-800); background: var(--green-50); }
.notice--success .notice__icon { background: var(--green-800); }

/* ===== アコーディオン ===== */
.accordion { border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); margin: 0 0 24px; }
.accordion + .accordion { margin-top: -25px; }
.accordion > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 12px 4px; font-weight: 700; font-size: 17px;
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::after {
  content: ""; margin-left: auto; flex: none; width: 10px; height: 10px;
  border-right: 2px solid var(--gray-900); border-bottom: 2px solid var(--gray-900);
  transform: rotate(45deg); transition: transform .15s; margin-right: 8px;
}
.accordion[open] > summary::after { transform: rotate(-135deg); }
.accordion > summary:hover { background: var(--blue-50); text-decoration: underline; }
.accordion__body { padding: 4px 4px 20px; }
.accordion__body--pre { white-space: pre-wrap; }

/* ===== ステップ（手順書） ===== */
.steps { list-style: none; margin: 0 0 24px; padding: 0; counter-reset: step; }
.steps > li {
  position: relative; padding: 0 0 28px 56px; counter-increment: step;
}
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 36px; height: 36px; border-radius: 50%; background: var(--blue-900); color: var(--white);
  font-weight: 700; display: grid; place-items: center; line-height: 1;
}
.steps > li::after {
  content: ""; position: absolute; left: 17px; top: 40px; bottom: 4px; width: 2px; background: var(--blue-200);
}
.steps > li:last-child::after { display: none; }
.steps h3 { font-size: 18px; margin: 2px 0 8px; }

.code-inline { font-family: var(--font-mono); background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius-s); padding: 1px 6px; font-size: 0.92em; }
.code-block { font-family: var(--font-mono); font-size: 13px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius-m); padding: 12px 16px; overflow-x: auto; white-space: pre; margin: 0 0 16px; }

/* ===== テーブル ===== */
.table-wrap { overflow-x: auto; margin: 0 0 24px; }
.table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: 15px; }
.table th, .table td { border: 1px solid var(--color-divider); padding: 10px 12px; text-align: left; vertical-align: top; }
.table th { background: var(--color-bg-sub); font-weight: 700; }

/* ===== 地図（設定画面のプレビュー） ===== */
.map-preview { width: 100%; height: 320px; border: 1px solid var(--color-border); border-radius: var(--radius-m); overflow: hidden; background: var(--gray-100); }
@media (min-width: 768px) { .map-preview { height: 400px; } }
.coord-readout { font-family: var(--font-mono); font-size: 14px; color: var(--color-text-sub); margin-top: 8px; }

/* 現在地ボタン（Leaflet コントロール） */
.fbm-locate {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--white); border: 0; border-radius: var(--radius-s); cursor: pointer; padding: 0;
}
.fbm-locate:hover { background: var(--blue-50); }
.fbm-locate svg { width: 24px; height: 24px; }
.fbm-locate[aria-busy="true"] svg { animation: fbm-spin 1s linear infinite; }
@keyframes fbm-spin { to { transform: rotate(360deg); } }
.leaflet-control-zoom a { width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 22px !important; }
.fbm-here { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(26, 115, 232, .35); }

/* ===== 出力 ===== */
.output-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 0; }
.status-msg { min-height: 1.7em; font-size: 14px; color: var(--color-success); font-weight: 700; margin-top: 8px; }

.mt-16 { margin-top: 16px; }
#geoMsg:not(:empty) { display: block; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ===== 遷移ページ（go.html） ===== */
.go-body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.go-body main { flex: 1 0 auto; padding-top: 20px; }
.go-body .site-footer { margin-top: 32px; }
.go-title { font-size: 24px; font-weight: 700; margin: 0 0 12px; line-height: 1.5; }
@media (min-width: 768px) { .go-title { font-size: 30px; } }
.go-host { font-size: 14px; color: var(--color-text-sub); margin: 0 0 16px; }
.go-host strong { font-family: var(--font-mono); color: var(--color-text); word-break: break-all; }
.go-map-wrap { position: relative; margin: 0 calc(var(--gutter) * -1); }
@media (min-width: 768px) { .go-map-wrap { margin: 0; } }
.go-map {
  width: 100%; height: 60vh; height: 60svh; min-height: 320px; max-height: 640px;
  background: var(--gray-100); border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
}
@media (min-width: 768px) { .go-map { border: 1px solid var(--color-border); border-radius: var(--radius-m); } }
.go-map__placeholder { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--color-text-sub); }
.go-instruction { font-weight: 700; margin: 0 0 12px; }

/* 画面下部に固定するアクションバー（スマホで親指の届く位置） */
.go-actionbar {
  position: sticky; bottom: 0; z-index: 1000;
  background: var(--white); border-top: 1px solid var(--color-border);
  margin: 16px calc(var(--gutter) * -1) 0; padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 8px rgba(0, 0, 0, .08);
}
@media (min-width: 768px) {
  .go-actionbar { margin: 16px 0 0; border: 1px solid var(--color-border); border-radius: var(--radius-m); }
}
.go-actionbar__coords { font-size: 14px; color: var(--color-text-sub); margin: 0 0 8px; font-family: var(--font-mono); }

/* ===== モーダル（dialog） ===== */
.modal {
  border: 0; padding: 0; border-radius: var(--radius-l);
  width: calc(100% - 32px); max-width: 600px; max-height: calc(100dvh - 32px);
  color: var(--color-text); background: var(--white);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .3);
}
.modal::backdrop { background: rgba(0, 0, 0, .6); }
.modal__inner { padding: 24px var(--gutter); overflow-y: auto; max-height: calc(100dvh - 32px); }
@media (min-width: 600px) { .modal__inner { padding: 32px; } }
.modal__title { font-size: 22px; font-weight: 700; margin: 0 0 16px; }
.modal .list li { margin-bottom: 8px; }
.modal__dest { background: var(--color-bg-sub); border-radius: var(--radius-m); padding: 12px 16px; margin: 0 0 16px; }
.modal__dest strong { font-family: var(--font-mono); word-break: break-all; font-size: 15px; }

@media print {
  .site-header__nav, .button-row, .go-actionbar { display: none; }
}
