:root {
  --bg: #f6f2ea;
  --card: #fffdf8;
  --text: #2b2620;
  --muted: #7a6f62;
  --line: #e4dccd;
  --accent: #b5452b;
  --accent-text: #fff;
  --accent-soft: #f6e3dc;
  --ok: #2e7d4f;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --card: #25221e;
    --text: #eee7dc;
    --muted: #a99d8e;
    --line: #3a352e;
    --accent: #e0775a;
    --accent-text: #1b1916;
    --accent-soft: #3d2a23;
    --ok: #6fc794;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
[hidden] { display: none !important; }

.site-header, main, .site-footer { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.site-header { padding-top: 24px; padding-bottom: 8px; }
.site-header h1 { margin: 0; font-size: 1.5rem; letter-spacing: .02em; }
.lead { margin: 4px 0 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.step {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  font-size: .8rem; font-weight: 700;
}

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 220px; }
input[type=search] {
  flex: 1; min-width: 0;
  font: inherit; font-size: 16px; /* iOS のズーム防止 */
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
input[type=search]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  font: inherit; font-weight: 600;
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 4px 0; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; }

.status { color: var(--muted); font-size: .9rem; margin-top: 8px; min-height: 1em; }
.status.error { color: var(--accent); }
.hint { color: var(--muted); font-size: .85rem; margin: -4px 0 12px; }
.meta { color: var(--muted); font-size: .85rem; }
.mono { font-family: ui-monospace, "Consolas", monospace; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font: inherit; font-size: .8rem; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 検索結果 */
.results { list-style: none; margin: 8px 0 0; padding: 0; }
.results li { border-top: 1px solid var(--line); }
.results button {
  all: unset; box-sizing: border-box; width: 100%; cursor: pointer;
  display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding: 10px 4px;
}
.results button:hover, .results button:focus-visible { background: var(--accent-soft); }
.results .title { font-weight: 600; line-height: 1.4; }
.cover {
  width: 48px; height: 68px; object-fit: cover; border-radius: 3px;
  background: var(--line); display: block;
}
.cover.lg { width: 84px; height: 120px; }

.selected { display: flex; gap: 14px; margin-top: 4px; }
.sel-title { font-weight: 700; font-size: 1.05rem; line-height: 1.4; }

/* チェーン一覧 */
.chain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.chain-list li {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  border-left: 5px solid var(--chain-color, var(--line));
}
.chain-list .name { font-weight: 600; }
.chain-list .howto { grid-column: 1; font-size: .8rem; color: var(--muted); }
.chain-list .btn { grid-row: 1 / span 2; grid-column: 2; }
.near-badge {
  font-size: .72rem; font-weight: 600; color: var(--ok);
  border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; margin-left: 6px;
  display: inline-block; white-space: nowrap; vertical-align: 2px; line-height: 1.5;
}

/* 近くの本屋 */
.radius { margin-top: 10px; gap: 14px; flex-wrap: wrap; }
.radius label { cursor: pointer; }
#map { height: 280px; border-radius: 10px; margin-top: 12px; border: 1px solid var(--line); z-index: 0; }
.filter { display: block; margin-top: 10px; font-size: .9rem; cursor: pointer; }
.stores { list-style: none; margin: 8px 0 0; padding: 0; }
.stores li { border-top: 1px solid var(--line); padding: 12px 0; }
.stores li.active { background: var(--accent-soft); }
.store-head { display: flex; align-items: baseline; gap: 8px; }
.store-name { font-weight: 600; cursor: pointer; }
.dist { margin-left: auto; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.chain-tag {
  display: inline-block; font-size: .72rem; padding: 0 8px; border-radius: 999px;
  color: #fff; background: var(--chain-color, #888); margin-top: 2px;
}
.store-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.store-note { font-size: .8rem; color: var(--muted); margin-top: 4px; }

.site-footer { color: var(--muted); font-size: .75rem; padding-bottom: 32px; }

@media (max-width: 420px) {
  .site-header h1 { font-size: 1.3rem; }
  .card { padding: 14px; }
}
