:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e0e0e0;
  --text: #1c1c1e;
  --muted: #6b7280;
  --accent: #0a84ff;
  --danger: #e53935;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Segoe UI', sans-serif;
  color: var(--text); background: var(--bg);
  font-size: 16px;
}

/* ── ヘッダー / タブ ── */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; line-height: 1; flex: 0 0 auto; }
.tabs { display: flex; gap: 4px; margin-left: auto; flex: 0 0 auto; }
.tabs a { white-space: nowrap; }

/* ロゴ横の都市切替（都市が増えても横スクロールでタブを押し出さない） */
.city-switch {
  display: flex; gap: 2px; padding: 2px;
  background: var(--bg); border-radius: 9px;
  flex: 0 1 auto; min-width: 0; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.city-switch::-webkit-scrollbar { display: none; }
.city-switch button {
  flex: 0 0 auto;
  border: none; background: transparent; cursor: pointer;
  padding: 6px 9px; border-radius: 7px;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--muted);
  white-space: nowrap;
}
.city-switch button.active { background: var(--accent); color: #fff; }
.tabs a {
  text-decoration: none; color: var(--muted);
  padding: 7px 12px; border-radius: 8px; font-size: 14px; font-weight: 600;
}
.tabs a.active { background: var(--accent); color: #fff; }

/* ── 集計バー ── */
.stats {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px;
  background: var(--card); border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.stat {
  flex: 0 0 auto; min-width: 62px; text-align: center;
  padding: 5px 10px; border-radius: 8px; background: var(--bg);
  border: none; border-left: 4px solid var(--line);
  font: inherit; color: inherit; cursor: pointer;
}
.stat b { display: block; font-size: 18px; line-height: 1.1; }
.stat span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.stat.active { background: var(--text); }
.stat.active b { color: #fff; }
.stat.active span { color: #cfd3d8; }

/* ── 地図 ── */
#map { position: absolute; inset: 0; }
.map-wrap { position: relative; flex: 1; min-height: 0; }
.page-map { display: flex; flex-direction: column; height: 100%; }

.map-controls {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 10;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.map-controls input[type="search"] {
  flex: 1; min-width: 140px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px 0; }
.chip {
  flex: 0 0 auto; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600;
  color: var(--muted); box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }

.locate-btn {
  position: absolute; right: 14px; bottom: calc(24px + var(--safe-b)); z-index: 10;
  width: 52px; height: 52px; border-radius: 50%; border: none;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.25);
  font-size: 24px; cursor: pointer;
}

/* ── ボトムシート ── */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 30;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--card); border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,.2);
  transform: translateY(100%); transition: transform .22s ease;
  max-height: 88vh; overflow-y: auto;
  padding: 8px 16px calc(20px + var(--safe-b));
}
.sheet.open { transform: translateY(0); }

/* スクロールしても上部に固定されるヘッダー（つまみ＋閉じるボタン） */
.sheet-head {
  position: sticky; top: 0; z-index: 3;
  background: var(--card);
  margin: 0 -16px 6px; padding: 4px 16px 6px;
}
.sheet .grabber { width: 40px; height: 5px; background: #d1d5db; border-radius: 3px; margin: 4px auto 0; }
.sheet-close {
  position: absolute; top: 6px; right: 10px;
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: #eceef1; color: #1c1c1e;
  font-size: 22px; font-weight: 700; line-height: 44px; text-align: center;
  padding: 0; cursor: pointer;
}
.sheet-close:active { background: #d7dbe0; }

.sheet h2 { font-size: 20px; margin: 0 0 4px; padding-right: 48px; }
.sheet .addr { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  color: #fff; font-size: 12px; font-weight: 700;
}
.meta { font-size: 14px; color: var(--muted); margin: 10px 0; line-height: 1.6; }
.meta b { color: var(--text); }

textarea, input[type="text"], input[type="password"] {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; font-family: inherit; background: #fff;
}
textarea { min-height: 74px; resize: vertical; }
label.fld { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0; }
.status-grid button {
  padding: 13px 8px; border-radius: 10px; border: 2px solid var(--line);
  background: #fff; font-size: 15px; font-weight: 700; color: var(--text);
}
.status-grid button.sel { color: #fff; border-color: transparent; }

.btn {
  display: block; width: 100%; padding: 15px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 700;
  margin-top: 12px; cursor: pointer;
}
.btn.secondary { background: #eceef1; color: var(--text); }
.btn:active { opacity: .85; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { margin-top: 12px; }

/* ── 求人（訪問ステータスとは独立した軸） ── */
.jobs-toggle {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 14px; font-weight: 700;
  white-space: nowrap; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.jobs-toggle.active { background: #7b1fa2; color: #fff; border-color: transparent; }

.jobs { margin-top: 4px; }
.job-item {
  padding: 10px 12px; border: 1px solid #e2d3ec; border-radius: 12px;
  background: #f6effa; margin-bottom: 8px;
}
.job-title { font-size: 14px; font-weight: 800; color: #6a1b9a; }
.job-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.job-item a { font-size: 13px; font-weight: 600; display: inline-block; margin-top: 4px; }
.job-add { display: grid; gap: 8px; margin-top: 8px; }
.job-add input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 15px; background: #fff;
}
.job-add .btn { margin-top: 0; }
.jobs-chip {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  padding: 1px 8px; border-radius: 999px;
  background: #f3e8fb; color: #6a1b9a; font-size: 11.5px; font-weight: 700;
}

/* ── 連絡先ボタン ── */
.contacts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ct-btn {
  flex: 1 1 auto; min-width: 44%; text-align: center; text-decoration: none;
  padding: 12px 10px; border-radius: 11px; font-size: 15px; font-weight: 700;
  border: 1px solid var(--line); background: #fff; color: var(--text);
}
.ct-btn.ig {
  background: linear-gradient(45deg, #f09433, #dc2743, #bc1888);
  color: #fff; border-color: transparent;
}
.ct-btn.mail { background: #eef4ff; color: #1552b0; border-color: #d5e3fb; }
.ct-btn.tel { background: #eafaef; color: #14703a; border-color: #cceedb; }
.ct-btn.web { background: #f3f0fa; color: #5b3fa6; border-color: #e0d8f2; }
.ct-sub { flex: 1 1 100%; font-size: 12.5px; color: var(--muted); margin-top: -2px; }

/* ── 業種表示 ── */
.industry-badge {
  background: #eef2ff; color: #3b4fa0; margin-left: 6px;
}
.industry-chip {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  padding: 1px 8px; border-radius: 999px;
  background: #eef2ff; color: #3b4fa0; font-size: 11.5px; font-weight: 700;
}

/* ── アクティビティ・タイムライン ── */
.tl-add textarea { min-height: 60px; }
.tl-add .btn { margin-top: 8px; }
.tl-filters { display: flex; gap: 6px; overflow-x: auto; margin: 14px -16px 8px; padding: 0 16px 2px; scrollbar-width: none; }
.tl-filters::-webkit-scrollbar { display: none; }
.tl-chip {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tl-chip.active { background: var(--text); color: #fff; border-color: var(--text); }

.timeline { margin-top: 4px; }
.tl-empty { color: var(--muted); font-size: 14px; padding: 10px 0; }
.tl-item { border-top: 1px solid var(--line); padding: 11px 0; }
.tl-head { display: flex; gap: 7px; align-items: baseline; font-size: 15px; }
.tl-icon { flex: 0 0 auto; }
.tl-body {
  margin-top: 4px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.tl-body.clamp {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tl-body.clamp.expanded { -webkit-line-clamp: unset; overflow: visible; }
.tl-more { border: none; background: none; padding: 2px 0; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.tl-meta { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.tl-link { display: inline-block; margin-top: 5px; font-size: 13px; font-weight: 600; }
.tl-acts { display: flex; gap: 8px; margin-top: 7px; }
.tl-acts button {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 5px 11px; border-radius: 8px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}

.history-list { margin: 6px 0 0; padding: 0; list-style: none; }
.history-list li {
  border-top: 1px solid var(--line); padding: 10px 0; font-size: 14px;
}
.history-list .when { color: var(--muted); font-size: 13px; }
.history-list .note { margin-top: 3px; white-space: pre-wrap; }

/* ── リスト / 履歴ページ ── */
.page { padding: 12px; max-width: 760px; margin: 0 auto; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input, .toolbar select {
  padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; background:#fff;
}
.toolbar input[type="search"] { flex: 1; min-width: 150px; }
.rcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; margin-bottom: 10px;
}
.rcard .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.rcard h3 { margin: 0 0 3px; font-size: 16px; }
.rcard .sub { color: var(--muted); font-size: 13px; }
.rcard .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.rcard .acts a, .rcard .acts button {
  font-size: 13px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--accent); text-decoration: none; font-weight: 600; cursor: pointer;
}
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

.rcard.selectable { cursor: pointer; }
.rcard.selected { outline: 2px solid var(--accent); background: #eef5ff; }
.rcard .selbox { position: absolute; top: 10px; left: 10px; width: 22px; height: 22px; }
.rcard.selmode { position: relative; padding-left: 42px; }

.bulkbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: none; align-items: center; gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0,0,0,.12);
}
.bulkbar.open { display: flex; }
.bulkbar #bulkCount { font-weight: 700; font-size: 15px; }
.bulkbar-actions { margin-left: auto; display: flex; gap: 8px; }
.bulkbar-actions button {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.bulkbar-actions button.danger { background: var(--danger); color: #fff; border-color: transparent; }
.bulkbar-actions button:disabled { opacity: .5; }

/* ── ログイン ── */
.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 22px; width: 100%; max-width: 360px; box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

/* ── トースト ── */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translate(-50%, 20px);
  background: #1c1c1e; color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 15px; font-weight: 600; opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 420px;
  max-height: 88vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 12px; font-size: 18px; }
