/* Layout: phone-first single column; bottom tab bar on phones, top tabs on wide screens. Warm paper + guide red, same as the PDF. */
:root {
  --bg: #f6f3ee; --surface: #fffdf9; --ink: #1d1a17; --muted: #6f675f; --line: #e4ddd3; --accent: #b3122e; --accent-ink: #fff;
  --chip: #efe9e1; --ok: #2f7a4f; --warn: #9a5b00; --fav: #b3122e; --no: #6f675f; --shadow: 0 1px 2px rgb(40 25 10 / .08), 0 2px 8px rgb(40 25 10 / .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --radius: 12px; --tabbar: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15120f; --surface: #1f1b17; --ink: #f1ebe3; --muted: #a59c91; --line: #352f29; --accent: #e0455f; --accent-ink: #fff;
    --chip: #2a2520; --ok: #5fbf86; --warn: #e0a24a; --fav: #e0455f; --no: #a59c91; --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); }
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header + tabs */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; background: var(--bg);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; font-weight: 700; font-size: 17px; }
.brand-zh { color: var(--accent); font-size: 20px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a { text-decoration: none; padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 15px; }
.tabs a.on { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 720px) {
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; justify-content: space-around; background: var(--surface);
    border-top: 1px solid var(--line); padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
  .tabs a { padding: 8px 10px; font-size: 14px; }
  main { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 16px) !important; }
}

main { max-width: 860px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); outline: none; }
.loading { color: var(--muted); }
h1 { font-size: 26px; line-height: 1.2; margin: 6px 0 4px; text-wrap: balance; }
h2 { font-size: 19px; margin: 26px 0 10px; text-wrap: balance; }
.lead { color: var(--muted); margin: 0 0 14px; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { text-decoration: none; color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

/* search + chips */
.search { display: flex; gap: 8px; margin: 12px 0; }
.search input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
select.chip { padding-right: 28px; }

/* home: geo sections and category tiles */
.geo-block { margin-top: 22px; }
.geo-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--accent); padding-bottom: 4px; margin-bottom: 10px; }
.geo-head h2 { margin: 0; color: var(--accent); }
.geo-head span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 104px; border-radius: var(--radius); overflow: hidden;
  text-decoration: none; color: #fff; background: #3a3129; box-shadow: var(--shadow); }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgb(0 0 0 / .72), rgb(0 0 0 / .05) 70%); }
.tile b, .tile small { position: relative; z-index: 1; padding: 0 10px; text-shadow: 0 1px 2px rgb(0 0 0 / .5); }
.tile b { font-size: clamp(13px, 3.5vw, 15px); line-height: 1.2; hyphens: auto; overflow-wrap: anywhere; }
.tile small { padding-bottom: 9px; opacity: .9; font-size: 13px; }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 4px; }
.quick a { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-decoration: none; }
.quick b { display: block; font-size: 15px; }
.quick small { color: var(--muted); font-size: 13px; }

/* place list */
.list { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; background: var(--surface); border-radius: var(--radius); overflow: hidden;
  text-decoration: none; box-shadow: var(--shadow); min-height: 96px; }
.row .ph { position: relative; background: var(--chip); }
.row .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.row .num { position: absolute; left: 6px; top: 6px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.row .txt { padding: 9px 10px 9px 0; min-width: 0; }
.row h3 { font-size: 16px; line-height: 1.25; margin: 0 0 2px; }
.row .meta { font-size: 13px; color: var(--muted); }
.row p { margin: 4px 0 0; font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sub { font-weight: 700; margin: 16px 0 2px; color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 0 7px; border-radius: 999px; margin-left: 4px; vertical-align: 1px; }
.badge.kid { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.check { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.st-fav { background: var(--fav); color: #fff; } .badge.st-been { background: var(--ok); color: #fff; } .badge.st-no { background: var(--no); color: #fff; }
.empty { color: var(--muted); padding: 24px 0; }

/* place page */
.hero { margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))) 14px; max-height: 62vh; overflow: hidden; background: var(--chip); }
.hero img { width: 100%; max-height: 62vh; object-fit: cover; }
@media (min-width: 720px) { .hero { margin: 0 0 14px; border-radius: var(--radius); } }
.zh { font-size: 18px; color: var(--muted); margin: 0 0 6px; }
.desc { font-size: 17px; margin: 12px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 14px;
  text-decoration: none; font-weight: 600; font-size: 15px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
dl.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; margin: 14px 0; background: var(--surface); padding: 14px; border-radius: var(--radius); }
dl.facts dt { color: var(--muted); font-size: 14px; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.addr-zh { font-size: 18px; }
.note { font-size: 14px; color: var(--muted); }

/* my status panel */
.mine { background: var(--surface); border-radius: var(--radius); padding: 14px; margin: 16px 0; border: 1px solid var(--line); }
.mine h2 { margin: 0 0 10px; font-size: 17px; }
.status { display: flex; flex-wrap: wrap; gap: 6px; }
.rating { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0; }
.rating button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 600; }
.rating button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.mine textarea { width: 100%; min-height: 80px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 10px; resize: vertical; }

/* taxi card */
.taxi { position: fixed; inset: 0; z-index: 60; background: #fff; color: #000; display: flex; flex-direction: column; justify-content: center; gap: 18px;
  padding: max(24px, env(safe-area-inset-top, 0px)) 24px max(24px, env(safe-area-inset-bottom, 0px)); text-align: center; }
.taxi .big { font-size: clamp(30px, 9vw, 56px); line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
.taxi .small { font-size: 22px; color: #333; }
.taxi button { align-self: center; }

/* routes + hacks */
.card { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; text-decoration: none; display: block; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.card .meta { color: var(--muted); font-size: 14px; }
ol.stops { padding-left: 0; list-style: none; counter-reset: s; margin: 12px 0; display: grid; gap: 8px; }
ol.stops li { counter-increment: s; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: start; }
ol.stops li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; }
ol.stops a { text-decoration: none; font-weight: 600; }
ol.stops small { display: block; color: var(--muted); font-weight: 400; }
details.hack { background: var(--surface); border-radius: var(--radius); margin-bottom: 8px; border: 1px solid var(--line); }
details.hack summary { padding: 12px 14px; cursor: pointer; font-weight: 600; }
details.hack div { padding: 0 14px 14px; white-space: pre-line; }
.mini-map { height: 260px; border-radius: var(--radius); overflow: hidden; margin: 12px 0; }

/* full-screen map */
#map-wrap { position: fixed; z-index: 10; left: 0; right: 0; top: var(--top-h, 58px); bottom: 0; }
@media (max-width: 720px) { #map-wrap { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); } }
#map { position: absolute; inset: 0; }
.map-bar { position: absolute; z-index: 5; left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); top: 10px;
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.map-bar .chip { box-shadow: var(--shadow); }
.pop { width: min(260px, 70vw); color: #1d1a17; }
.pop img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: 6px; }
.pop b { display: block; font-size: 15px; line-height: 1.25; }
.pop small { color: #6f675f; }
.pop a { display: inline-block; margin-top: 6px; color: #b3122e; font-weight: 700; text-decoration: none; }
.maplibregl-popup-content { border-radius: 12px; padding: 10px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgb(26 115 232 / .25); }
.legend-note { font-size: 13px; color: var(--muted); }

#toast { position: fixed; z-index: 70; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); }
@media (prefers-reduced-motion: no-preference) { .row, .tile, .card { transition: transform .12s ease; } .row:active, .tile:active, .card:active { transform: scale(.99); } }
