/* ------------------------------------------------------------------
   CafeList — 落ち着いた実務向けの見た目。スマホでは表をカードに畳む。
   ------------------------------------------------------------------ */

:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --border: #e0dfda;
  --border-strong: #c9c7c0;
  --text: #23231f;
  --text-muted: #77746c;
  --text-faint: #a8a49b;
  --accent: #3f6b52;
  --accent-weak: #eaf1ec;
  --danger: #9a3f36;
  --warn: #8a6410;
  --warn-weak: #f6efdc;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(35, 35, 31, .06);
}

* { box-sizing: border-box; }

/* display を指定した要素にも hidden 属性を効かせる */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
               "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
a:hover { text-decoration: none; }

/* ---------- 部品 ---------- */

.btn {
  font: inherit;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #f0efec; }
.btn:disabled { opacity: .4; cursor: default; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #355a45; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: #e8e7e3; color: var(--text); }
.btn-danger { color: var(--danger); }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.field > span small { color: var(--text-faint); font-weight: normal; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin: 10px 0 0;
}

/* ---------- ログイン ---------- */

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.login-title { margin: 0; font-size: 20px; letter-spacing: .04em; }
.login-lead { margin: 2px 0 22px; color: var(--text-muted); font-size: 13px; }

/* ---------- ヘッダー ---------- */

.app-view { padding-bottom: 40px; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-title { margin: 0; font-size: 16px; letter-spacing: .04em; }
.app-header-right { display: flex; align-items: center; gap: 10px; }
.user-email { color: var(--text-faint); font-size: 12px; }

/* ---------- タブ ---------- */

.tabbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tabbar-status { background: transparent; border-bottom: 1px solid var(--border); }

.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tabs-empty { color: var(--text-faint); font-size: 13px; padding: 4px 2px; }
.tabbar-actions { display: flex; gap: 2px; flex-shrink: 0; }

.tab {
  font: inherit;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: #eeede9; color: var(--text); }
.tab.is-active {
  background: var(--accent-weak);
  border-color: #cadbd0;
  color: var(--accent);
  font-weight: 600;
}
/* ターゲット外のタブ。選んでいないときは沈ませる */
.tab-quiet:not(.is-active) { color: var(--text-faint); }

.tab-count {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: normal;
}
.tab.is-active .tab-count { color: var(--accent); }

/* ---------- ツールバー ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}
.search-input { max-width: 280px; }
.result-count { color: var(--text-faint); font-size: 12px; flex: 1; }

/* 検索の結果（追加◯件 / 更新◯件） */
.places-result {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-weak);
  border: 1px solid #cadbd0;
  border-radius: var(--radius);
  padding: 3px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- リスト ---------- */

.list-wrap { margin: 0 16px; }

.is-blank { color: var(--text-faint); }

/* 期限切れの案内 */
.stale-banner {
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid #e6d5a6;
  border-radius: var(--radius);
  background: var(--warn-weak);
  color: var(--warn);
  font-size: 13px;
}

.lead-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  align-items: start;
}

.lead-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
}

/* ---- 見出し（クチコミ件数と店名が主役） ---- */

.lead-head { display: flex; align-items: flex-start; gap: 12px; }
.lead-headings { flex: 1; min-width: 0; }

.lead-name {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.lead-name.is-expired-name {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-faint);
}
.lead-sub {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

/* クチコミ件数。少ないほど狙い目なので、少ないものほど目立つ色にする */
.review-chip {
  flex: 0 0 auto;
  min-width: 60px;
  padding: 6px 8px 5px;
  border: 1px solid;
  border-radius: 8px;
  text-align: center;
  line-height: 1.1;
}
.review-num {
  display: block;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.review-cap { display: block; margin-top: 2px; font-size: 10px; opacity: .75; }

.review-hot   { background: #fbdccf; border-color: #e29873; color: #99320f; }  /* 0-15   開業直後 */
.review-warm  { background: #fbf0d4; border-color: #e5cd8f; color: #85600e; }  /* 16-50  1〜3年 */
.review-cool  { background: #e9eff3; border-color: #ccd9e1; color: #4c6577; }  /* 51-300 定着 */
.review-faint { background: #f3f3f0; border-color: #e2e1dc; color: #8b8880; }  /* 301-   人気店 */
.review-none  { background: #f6f6f4; border-color: #e6e5e0; color: #b0aca3; }

/* ---- 連絡先・地図 ---- */

.lead-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
}
.lead-link { text-decoration: none; border-bottom: 1px solid transparent; }
a.lead-link:hover { border-bottom-color: currentColor; }
.lead-link-ig::before { content: 'IG '; color: var(--text-faint); font-size: 11px; }
.lead-link-map { color: var(--text-muted); }

/* ---- 1通目・メモ ---- */

.lead-detail { border-top: 1px solid #f1f0ec; padding-top: 9px; }
.lead-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.lead-summary::-webkit-details-marker { display: none; }
.lead-summary::before { content: '▸'; font-size: 10px; color: var(--text-faint); }
.lead-detail[open] .lead-summary::before { content: '▾'; }
.lead-summary-dot { font-size: 9px; color: var(--accent); }

.lead-field { display: block; margin-top: 9px; }
.lead-field-label {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
  color: var(--text-faint);
}
.lead-input {
  font-size: 13px;
  padding: 7px 9px;
  background: #fafaf8;
  border-color: var(--border);
  resize: vertical;
}
.lead-input.is-saving { opacity: .5; }
.lead-input.is-saved { border-color: var(--accent); background: var(--accent-weak); }

/* ---- 次の一手 ---- */

.lead-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.btn-next { font-weight: 600; }
.lead-actions-gap { flex: 1; }
.btn-back { color: var(--text-muted); }
.btn-quiet { font-size: 12px; color: var(--text-faint); }
.btn-quiet:hover:not(:disabled) { background: transparent; color: var(--danger); }
.lead-done { font-size: 13px; font-weight: 600; color: var(--accent); }

/* ターゲット外はグレーアウト。戻すボタンも目立たせない */
.lead-card.status-excluded { background: #f6f6f4; box-shadow: none; }
.lead-card.status-excluded .lead-head,
.lead-card.status-excluded .lead-links { opacity: .5; }
.lead-card.status-excluded .lead-name { font-weight: 400; }
.lead-card.status-excluded .btn-next {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
  font-weight: 400;
}

/* 期限切れの行 */
.lead-card.is-expired { border-style: dashed; }

.empty-message {
  margin: 0;
  padding: 40px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ---------- ダイアログ ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(35, 35, 31, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 8px 30px rgba(35, 35, 31, .2);
}
.modal-wide { max-width: 460px; }
.modal-title { margin: 0 0 18px; font-size: 15px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.modal-lead { margin: -8px 0 18px; color: var(--text-muted); font-size: 13px; }
.modal-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--warn);
  background: var(--warn-weak);
  border-radius: var(--radius);
  padding: 8px 10px;
}

/* 地名のチェックボックス */
.ward-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 2px 8px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.ward-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  cursor: pointer;
  user-select: none;
}
.ward-item input { accent-color: var(--accent); cursor: pointer; }
.ward-item:has(input:disabled) { color: var(--text-faint); cursor: default; }
.ward-item:has(input:disabled) input { cursor: default; }
.ward-empty { margin: 0; grid-column: 1 / -1; color: var(--text-faint); font-size: 13px; }

/* キーワードは数が少ないので横並びにする */
.ward-list-flat {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  max-height: none;
}

/* 押す前に見せる Text Search の回数 */
.modal-cost {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.modal-cost.is-warn { color: var(--warn); font-weight: 600; }

/* ---------- 地名のプリセット ---------- */

.preset-row,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.is-on {
  border-color: var(--accent);
  background: var(--accent-weak);
  color: var(--text-faint);
  cursor: default;
}

/* ---------- トースト ---------- */

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #23231f;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
.toast-error { background: var(--danger); }

/* ---------- スマホ ---------- */

@media (max-width: 720px) {
  .app-header, .tabbar, .toolbar { padding-left: 12px; padding-right: 12px; }
  .tabbar { flex-wrap: wrap; }
  .tabbar-actions { width: 100%; justify-content: flex-end; }
  .toolbar { flex-wrap: wrap; }
  .search-input { max-width: none; flex: 1 1 100%; }
  .places-result { flex: 1 1 100%; white-space: normal; }

  /* 段階タブは指で押せる大きさにして、横スクロールで全部並べる */
  .tabbar-status { position: sticky; top: 0; z-index: 10; background: var(--bg); }
  .tab-status { padding: 8px 12px; }

  .list-wrap { margin: 0 12px; }
  .lead-list { grid-template-columns: 1fr; gap: 10px; }
  .lead-card { padding: 14px; gap: 12px; }

  .lead-name { font-size: 18px; }
  .review-chip { min-width: 66px; padding: 8px 10px 6px; }
  .review-num { font-size: 22px; }
  .lead-links { font-size: 14px; gap: 6px 16px; }

  /* 次の一手は指1本で押せるよう1行占有させる */
  .lead-actions { flex-wrap: wrap; }
  .btn-next { flex: 1 1 100%; padding: 12px 14px; font-size: 15px; }
  .btn-back, .btn-quiet { padding: 8px 10px; }
  .lead-input { font-size: 16px; }   /* iOS で拡大されないように */
}
