/* 画面の作り: 上に小さな見出し、下に4つのタブ（探す・登録・人・その他）。1列で縦に流れる、片手で押せる大きさ */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --ink: #1d2a2d;
  --muted: #5b6b6e;
  --line: #d8dfdc;
  --accent: #2f6f62;
  --accent-ink: #ffffff;
  --accent-soft: #e2efeb;
  --visited: #3d4f8a;
  --visited-soft: #e6e9f5;
  --star: #c98a0c;
  --danger: #a33a2e;
  --danger-soft: #f7e4e1;
  --warn-bg: #fbf1d9;
  --warn-ink: #7a5200;
  --radius: 12px;
  --tap: 44px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131a1c; --surface: #1b2427; --surface-2: #222d30; --ink: #e5ecea; --muted: #9babaa; --line: #33413f;
    --accent: #7cc4b2; --accent-ink: #0f1d19; --accent-soft: #1e3530; --visited: #a8b6ee; --visited-soft: #252c47;
    --star: #f0bd4f; --danger: #f0a196; --danger-soft: #3a2320; --warn-bg: #3a2f17; --warn-ink: #f0c56a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131a1c; --surface: #1b2427; --surface-2: #222d30; --ink: #e5ecea; --muted: #9babaa; --line: #33413f;
  --accent: #7cc4b2; --accent-ink: #0f1d19; --accent-soft: #1e3530; --visited: #a8b6ee; --visited-soft: #252c47;
  --star: #f0bd4f; --danger: #f0a196; --danger-soft: #3a2320; --warn-bg: #3a2f17; --warn-ink: #f0c56a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.6;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.ic { width: 20px; height: 20px; flex: none; }
.ic.sm { width: 16px; height: 16px; }
.ic.lg { width: 26px; height: 26px; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ---- 全体の枠 ---- */
.shell { display: flex; flex-direction: column; min-height: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 8px;
  display: flex; align-items: center; gap: 8px; min-height: 52px;
}
.topbar h1 { font-size: 19px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn {
  width: var(--tap); height: var(--tap); border-radius: 50%; border: none; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink);
}
.iconbtn:active { background: var(--surface-2); }
main { flex: 1; padding: 4px 16px calc(env(safe-area-inset-bottom, 0px) + 92px); display: flex; flex-direction: column; gap: 14px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 58px; font-size: 12px; color: var(--muted); text-decoration: none;
}
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 700; }
.tabs a.add-tab .ic { width: 26px; height: 26px; }

/* ---- お知らせ帯 ---- */
.notices { padding: 0 16px 10px; display: flex; flex-direction: column; gap: 8px; }
.banner { border-radius: var(--radius); padding: 10px 12px; font-size: 14px; display: flex; gap: 8px; align-items: flex-start; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.info { background: var(--accent-soft); color: var(--ink); }
.banner.error { background: var(--danger-soft); color: var(--danger); }
.banner .ic { margin-top: 2px; }

/* ---- ボタン ---- */
.btn {
  min-height: var(--tap); border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.block { width: 100%; white-space: normal; text-align: center; padding-block: 8px; line-height: 1.4; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, .iconbtn:focus-visible, .chip:focus-visible, .tabs a:focus-visible, .item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---- 入力 ---- */
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
label.field > span.lab { display: flex; align-items: center; gap: 6px; }
input[type="text"], input[type="search"], input[type="url"], input[type="date"], select, textarea {
  width: 100%; min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  padding: 8px 12px; font-size: 16px; color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.err { color: var(--danger); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; }

/* ---- 選ぶ部品 ---- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { min-height: 40px; border: none; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 34px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px;
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font-size: 14px; color: var(--ink); text-decoration: none;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.chip .x { display: inline-flex; color: var(--muted); }
.stars { display: inline-flex; gap: 2px; }
.stars button { width: 40px; height: 40px; border: none; background: transparent; cursor: pointer; color: var(--line); display: inline-flex; align-items: center; justify-content: center; }
.stars button.on { color: var(--star); }
.stars button.on .ic { fill: currentColor; }
.stars-view { display: inline-flex; gap: 1px; color: var(--star); vertical-align: middle; }
.stars-view .ic { width: 14px; height: 14px; fill: currentColor; }
.stars-view .ic.off { color: var(--line); fill: none; }

/* ---- 一覧 ---- */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--ink); background: var(--surface); min-height: 56px; cursor: pointer;
}
.item:last-child { border-bottom: none; }
.item:active { background: var(--surface-2); }
.item .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .title { font-weight: 700; overflow-wrap: anywhere; }
.item .sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.item .dist { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.want { background: var(--accent-soft); color: var(--accent); }
.badge.visited { background: var(--visited-soft); color: var(--visited); }
.badge.plain { background: var(--surface-2); color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 7px; }
.dot.want { background: var(--accent); }
.dot.visited { background: var(--visited); }
.section-title { font-size: 14px; color: var(--muted); font-weight: 700; margin: 4px 2px -6px; display: flex; align-items: center; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ic { width: 32px; height: 32px; }

/* ---- カード（情報のまとまり） ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kv { display: grid; grid-template-columns: 7.5em 1fr; gap: 6px 10px; font-size: 15px; }
.kv dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
.kv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.big-name { font-size: 22px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; margin: 0; }
.attribution { font-size: 12px; color: var(--muted); }
.attribution b { font-family: Roboto, Arial, sans-serif; font-weight: 500; }

/* ---- 地図 ---- */
.map { width: 100%; height: 42vh; min-height: 240px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); overflow: hidden; }
.map.small { height: 30vh; min-height: 200px; }
.map-note { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* ---- 写真 ---- */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2); max-width: 100%; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph button { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: none; background: rgba(0,0,0,0.55); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.preview { max-width: 100%; max-height: 220px; border-radius: 10px; border: 1px solid var(--line); display: block; }

/* ---- 重ねる窓 ---- */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 640px; border-radius: 16px 16px 0 0; max-height: 90vh; overflow: auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 16px); display: flex; flex-direction: column; gap: 12px;
}
.sheet h2 { margin: 0; font-size: 18px; }
.viewer { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; }
.viewer .iconbtn { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 8px); right: 8px; color: #fff; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 72px); z-index: 70;
  background: var(--ink); color: var(--bg); border-radius: 10px; padding: 12px 14px; font-size: 15px;
  display: flex; gap: 8px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
.toast.error { background: var(--danger); color: #fff; }

/* ---- ログイン ---- */
.login { min-height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 32px 20px calc(env(safe-area-inset-bottom, 0px) + 32px); max-width: 480px; margin: 0 auto; }
.login .mark { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; }
.login .mark .ic { width: 30px; height: 30px; }
.login h1 { margin: 0; font-size: 26px; }
.login p { margin: 0; color: var(--muted); }
#gsi-btn { min-height: 44px; }

summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden-input { display: none; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
