/* 内見ナビ — デモアプリ群と同じライトテーマ（白基調・青系グラデ） */
:root {
  --bg: #f2f6fb;
  --card: #ffffff;
  --text: #1c2b3a;
  --sub: #5b6b80;
  --line: #dbe4ef;
  --accent: #2563eb;
  --accent2: #0e7490;
  --grad: linear-gradient(135deg, #2563eb, #0e7490);
  --danger: #dc2626;
  --ok: #16a34a;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  padding-bottom: 40px;
}

/* ヘッダー */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
}
.brand {
  font-weight: 800; font-size: 18px;
  color: var(--accent);
}
.tabs { display: flex; gap: 6px; }
.tab {
  border: 1px solid var(--line); background: var(--card); color: var(--sub);
  padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
}
.tab.active { background: var(--grad); color: #fff; border-color: transparent; }

.view { max-width: 560px; margin: 0 auto; padding: 14px; }

/* ルート画面 */
.route-summary { display: flex; align-items: center; gap: 10px; padding: 4px 2px 12px; flex-wrap: wrap; }
.route-summary .count { font-size: 13px; color: var(--sub); font-weight: 600; }
.route-summary .next-label { font-size: 13px; font-weight: 700; }
.route-list { display: flex; flex-direction: column; gap: 10px; }
.route-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  display: flex; align-items: center; gap: 12px; padding: 14px;
  box-shadow: 0 1px 3px rgba(28, 43, 58, 0.05);
}
.route-card.next { border: 2px solid var(--accent); }
.route-card.done { opacity: 0.55; }
.route-order {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.route-card.done .route-order { background: var(--ok); }
.route-main { flex: 1; min-width: 0; cursor: pointer; }
.route-name { font-weight: 700; font-size: 16px; }
.badge-next {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px;
  background: var(--grad); color: #fff; font-size: 13px; font-weight: 700; vertical-align: 2px;
}
.route-addr { color: var(--sub); font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.map-btn {
  flex-shrink: 0; text-align: center; text-decoration: none;
  background: var(--card); border: 1.5px solid var(--accent); color: var(--accent);
  border-radius: 12px; padding: 8px 12px; font-size: 14px; font-weight: 700; line-height: 1.2;
}
.map-btn span { font-size: 14px; font-weight: 600; }

/* 物件カード */
.back-btn { background: none; border: none; color: var(--accent); font-size: 15px; font-weight: 600; padding: 4px 0 12px; }
.d-name { font-size: 22px; font-weight: 800; }
.d-addr { color: var(--sub); font-size: 13px; margin: 4px 0 12px; }
.d-sec {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-top: 12px;
}
.d-sec h2 { font-size: 15px; margin-bottom: 8px; }
.d-line { font-size: 15px; line-height: 1.6; }
.d-line.dim { color: var(--sub); }
.d-line.pre { white-space: pre-wrap; }
.d-photo { width: 100%; border-radius: 10px; margin-bottom: 8px; border: 1px solid var(--line); }
.reveal-btn {
  display: block; width: 100%; margin-top: 10px; padding: 14px;
  border: 1.5px dashed var(--accent); border-radius: 12px;
  background: #eef4ff; color: var(--accent); font-size: 15px; font-weight: 700;
}
.key-num {
  margin-top: 10px; padding: 16px; text-align: center;
  background: var(--grad); color: #fff; border-radius: 12px;
  font-size: 40px; font-weight: 800; letter-spacing: 8px;
}
.tel-btn {
  display: block; text-align: center; padding: 12px; border-radius: 12px;
  border: 1.5px solid var(--accent); color: var(--accent);
  font-weight: 700; text-decoration: none;
}

/* 退出チェック */
.checkout .check-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px;
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.checkout .check-item input { width: 22px; height: 22px; accent-color: var(--accent); }
.checkout .primary-btn { margin-top: 14px; }

/* ボタン共通 */
.primary-btn {
  display: block; border: none; border-radius: 12px; padding: 13px 18px;
  background: var(--grad); color: #fff; font-size: 15px; font-weight: 700;
  text-align: center; text-decoration: none; cursor: pointer;
}
.primary-btn:disabled { opacity: 0.55; cursor: default; }
.primary-btn.wide { width: 100%; margin-top: 10px; }
.primary-btn.small { padding: 9px 14px; font-size: 14px; display: inline-block; }
.ghost-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--sub);
  border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.ghost-btn.small { padding: 8px 12px; font-size: 14px; }
.ghost-btn.danger { color: var(--danger); border-color: #f3c4c4; }
main > .ghost-btn { margin-top: 16px; width: 100%; }

/* 物件管理 */
.edit-head { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.edit-list { display: flex; flex-direction: column; gap: 10px; }
.edit-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
}
.edit-order { display: flex; flex-direction: column; gap: 4px; }
.order-btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  width: 28px; height: 22px; font-size: 14px; color: var(--sub); cursor: pointer;
}
.order-btn:disabled { opacity: 0.3; }
.edit-main { flex: 1; min-width: 0; }
.edit-name { font-weight: 700; font-size: 14px; }
.edit-sub { color: var(--sub); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }

/* 取り込み */
.import-area {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.import-area .hint { font-size: 13px; color: var(--sub); margin-bottom: 8px; }
.import-area textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  font-size: 13px; font-family: inherit;
}
.row-btns { display: flex; gap: 8px; margin-top: 10px; }

/* フォーム（モーダル） */
.modal {
  position: fixed; inset: 0; z-index: 20; background: rgba(28, 43, 58, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px 14px; overflow-y: auto;
}
.modal-card {
  background: var(--card); border-radius: 16px; padding: 18px;
  width: 100%; max-width: 520px;
}
.modal-card h2 { font-size: 18px; margin-bottom: 12px; }
.modal-card label { display: block; font-size: 13px; font-weight: 600; color: var(--sub); margin-top: 10px; }
.modal-card input[type="text"], .modal-card input[type="tel"], .modal-card textarea {
  width: 100%; margin-top: 4px; padding: 11px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; font-family: inherit;
}
.modal-card fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px 12px; margin-top: 14px; }
.modal-card legend { font-size: 13px; font-weight: 700; padding: 0 6px; }
.photo-label input[type="file"] { display: block; margin-top: 6px; font-size: 13px; }
.photo-state { display: block; font-size: 12px; color: var(--ok); margin-top: 4px; font-weight: 600; }
.modal-card .row-btns { margin-top: 16px; }
.modal-card .row-btns .primary-btn { flex: 1; }

/* 物件資料 */
.doc-btn {
  display: block; width: 100%; margin-top: 10px; padding: 13px;
  border: 1.5px solid var(--accent); border-radius: 12px;
  background: var(--card); color: var(--accent); font-size: 15px; font-weight: 700; cursor: pointer;
}
.ad-badge {
  display: inline-block; margin-left: 8px; padding: 2px 10px; border-radius: 999px;
  background: #fff4e0; color: #b45309; border: 1px solid #f3d9a4;
  font-size: 13px; font-weight: 700; vertical-align: 1px;
}
.doc-viewer {
  position: fixed; inset: 0; z-index: 40; background: rgba(28, 43, 58, 0.92);
  display: flex; flex-direction: column;
}
.doc-close {
  align-self: flex-end; margin: 10px 14px; padding: 9px 16px;
  border: none; border-radius: 999px; background: #fff; color: var(--text);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.doc-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 0 8px 12px; }
.doc-img { display: block; width: 100%; border-radius: 8px; background: #fff; }
.doc-frame { display: block; width: 100%; height: 100%; border: none; border-radius: 8px; background: #fff; }

/* その他 */
.empty {
  text-align: center; color: var(--sub); font-size: 14px; line-height: 1.8;
  padding: 40px 0;
}
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; z-index: 30;
  max-width: 90vw;
}

/* ---- 公開版のみ：ログイン画面 ---- */
.login-wrap {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; width: 100%; max-width: 380px; text-align: center;
}
.login-card h1 {
  font-size: 22px; font-weight: 800; margin-bottom: 6px;
  color: var(--accent);
}
.login-card p { font-size: 13px; color: var(--sub); margin-bottom: 16px; }
.login-card input {
  width: 100%; padding: 13px; font-size: 16px; text-align: center;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px;
}
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.sync-info { text-align: center; color: var(--sub); font-size: 13px; padding: 14px 0 4px; }

/* ---- 案件・内見日 ---- */
.ctx-line { font-size: 13px; font-weight: 700; color: var(--sub); padding: 2px 2px 10px; }
.case-card { cursor: pointer; }
.chev { font-size: 18px; color: var(--sub); padding: 0 4px; }
.today-btn { margin-bottom: 12px; }
.link-btn {
  display: block; text-align: center; padding: 12px; border-radius: 12px;
  border: 1.5px solid var(--accent); color: var(--accent); font-size: 15px;
  font-weight: 700; text-decoration: none; margin-bottom: 8px;
}
.link-btn:last-child { margin-bottom: 0; }
.edit-prop-btn { display: block; width: 100%; margin-top: 10px; }

/* ---- 周辺マップビューア（ローカル・公開版共通） ---- */
.map-viewer { position: fixed; inset: 0; z-index: 45; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.map-wrap { max-width: 560px; margin: 0 auto; padding: 12px 14px 24px; }
.map-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.map-title { font-size: 17px; font-weight: 800; }
.map-sub { font-size: 12px; color: var(--sub); overflow-wrap: anywhere; }
.mode-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.mode-tab { flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--sub); padding: 10px; border-radius: 12px; font-size: 14px; font-weight: 700; cursor: pointer; }
.mode-tab.active { background: var(--grad); color: #fff; border-color: transparent; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--sub); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer; }
.chip.on { color: #fff; border-color: transparent; }
.chip.on.c-super { background: #16a34a; }
.chip.on.c-conv { background: #2563eb; }
.chip.on.c-shop { background: #9333ea; }
.chip.on.c-hosp { background: #dc2626; }
.school-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.school-tab { flex: 1; border: 1.5px solid var(--line); background: var(--card); color: var(--sub); padding: 9px; border-radius: 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.school-tab.on.s-elem { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.school-tab.on.s-jr { border-color: #16a34a; color: #16a34a; background: #f0fdf4; }
#mvMap { width: 100%; height: 400px; border-radius: 14px; border: 1px solid var(--line); }
.map-tiles { filter: grayscale(0.92) brightness(1.06) contrast(0.92); }
.legend-note { font-size: 11px; color: var(--sub); margin-top: 6px; text-align: right; }
.school-badge { margin-bottom: 10px; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 14px; line-height: 1.7; }
.school-badge b { font-size: 16px; }
.school-badge .warn { display: block; font-size: 11px; color: #b45309; }
.near-list { margin-top: 12px; }
.near-item { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.near-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.near-name { flex: 1; font-size: 14px; font-weight: 700; min-width: 0; }
.near-name span { display: block; font-size: 11px; font-weight: 600; color: var(--sub); }
.near-walk { font-size: 13px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.pin { display: flex; flex-direction: column; align-items: center; }
.pin-bubble { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 3px solid; display: flex; align-items: center; justify-content: center; font-size: 17px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.pin-tail { width: 0; height: 0; border: 6px solid transparent; border-top-width: 9px; border-bottom: none; margin-top: -1px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.pin-home .pin-bubble { width: 42px; height: 42px; font-size: 21px; background: var(--grad); border-color: #fff; }
.pin-tip { background: #fff !important; border: 1.5px solid var(--line) !important; border-radius: 999px !important; padding: 3px 10px !important; font-weight: 800; font-size: 11px; color: var(--text); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); white-space: nowrap; }
.pin-tip::before { display: none !important; }
.pin-tip .walk { color: var(--accent); }
.leaflet-popup-content-wrapper { border-radius: 12px !important; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important; }
.leaflet-popup-content { margin: 10px 14px !important; font-family: inherit !important; }
.pop-name { font-weight: 800; font-size: 14px; }
.pop-walk { color: var(--accent); font-weight: 800; font-size: 13px; margin-top: 2px; }

/* ---- セクション単位のその場編集 ---- */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sec-head h2 { margin-bottom: 0; }
.sec-edit { border: none; background: none; font-size: 15px; cursor: pointer; opacity: 0.5; padding: 2px 6px; }
.sec-edit:hover { opacity: 1; }
.sec-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.d-sec.editing { border: 1.5px solid var(--accent); }
.il-label { display: block; font-size: 12px; font-weight: 600; color: var(--sub); margin-top: 8px; }
.il-label input[type="text"], .il-label textarea { width: 100%; margin-top: 4px; padding: 10px; font-size: 15px; border: 1px solid var(--line); border-radius: 10px; font-family: inherit; }
.il-label input[type="file"] { display: block; margin-top: 6px; font-size: 13px; }
.d-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.d-line .dim, .dim { color: var(--sub); }
.row-edit { border: none; background: none; font-size: 15px; opacity: 0.45; cursor: pointer; padding: 4px; flex-shrink: 0; }
.row-edit:hover { opacity: 1; }
.doc-pdf-bar { text-align: right; padding: 0 0 8px; }
.doc-img { user-select: none; -webkit-user-select: none; }
.chip.on.c-drug { background: #ea8a00; }

/* ---- 周辺マップのヘッダー整え（2026-08-27） ---- */
.map-head > div:first-child { min-width: 0; flex: 1; }
.map-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: flex-start; }
.map-actions .ghost-btn.small { padding: 7px 10px; font-size: 12px; white-space: nowrap; }
.mv-name { color: var(--text); font-size: 14px; }

/* 注意メモの箇条書き（改行区切り・2026-08-27） */
.notes-list { margin: 0; padding: 0; list-style: none; }
.notes-list li { font-size: 15px; line-height: 1.7; padding-left: 1em; text-indent: -1em; }
.notes-list li::before { content: "・"; }

/* キーボックス番号のマス目入力（4マス標準・最大8マスまで自動拡張・2026-08-30） */
.kb-hidden { display: none !important; }
.kb-wrap { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.kb-cells { display: flex; gap: 6px; }
.kb-cell {
  width: clamp(30px, 9vw, 42px); height: 48px; padding: 0; text-align: center;
  font-size: 22px; font-weight: 700; color: var(--text);
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
.kb-cell:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15); }
.kb-alpha {
  flex: none; padding: 6px 8px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--sub);
}
/* 桁数が多い番号は表示を少し縮めてはみ出しを防ぐ */
.key-num.kb-long { font-size: 32px; letter-spacing: 5px; }
.key-num.kb-long2 { font-size: 25px; letter-spacing: 3px; }

/* ---- 長押しドラッグ並べ替え ---- */
.route-card {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.drag-lift {
  opacity: 0.96;
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(20, 50, 90, 0.28);
  position: relative;
  z-index: 20;
  cursor: grabbing;
}
body.drag-lock { overflow: hidden; overscroll-behavior: none; }
