:root {
  --bg: #fff; --text: #000; --card: #f3f3f3; --card2: #e8e8e8; --line: #e2e2e2; --muted: #6b6b6b;
  --good: #047a41; --warn: #9a4a00; --blue: #276ef1; --btn: #000; --btn-ink: #fff; --best-ink: #fff; --star: #8a5d00;
  --attr-bg: rgba(255,255,255,.88); --attr-ink: #333;
  --shadow: 0 -2px 20px rgba(0,0,0,.16); --float: 0 2px 12px rgba(0,0,0,.22);
  --tiles: none;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414; --text: #fff; --card: #262626; --card2: #333; --line: #2f2f2f; --muted: #a3a3a3;
    --good: #3ddc84; --warn: #f5a524; --blue: #5b9bff; --btn: #fff; --btn-ink: #000; --best-ink: #000; --star: #f5b301;
    --attr-bg: rgba(20,20,20,.85); --attr-ink: #ddd;
    --shadow: 0 -2px 20px rgba(0,0,0,.6); --float: 0 2px 12px rgba(0,0,0,.6);
    --tiles: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; letter-spacing: -.01em; background: var(--bg); color: var(--text); overscroll-behavior: none; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .875rem; }
main { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: var(--card); }
.leaflet-tile-pane { filter: var(--tiles); }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; line-height: 1.6; background: var(--attr-bg) !important; color: var(--attr-ink) !important; border-radius: 999px; padding: 0 8px; white-space: nowrap; }
.leaflet-control-attribution a { color: inherit !important; }
/* top-right, vertically centred on the 46px top bar so it never overlaps it, even at 320px */
.leaflet-top.leaflet-right .leaflet-control-attribution { margin: calc(12px + env(safe-area-inset-top) + 14px) 12px 0 0; }

/* ---- buttons ---- */
.btn { color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 6px 16px; line-height: 1.2; text-align: center; position: relative; border-radius: 12px; border: 0; background: var(--card); cursor: pointer; font-weight: 600; text-decoration: none; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--btn); color: var(--btn-ink); }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 36px; padding: 0 18px; font-size: .875rem; border-radius: 999px; }
.btn.small::after { content: ''; position: absolute; inset: -4px; } /* 44px hit area */
.btn.tip { background: #ffdd00; color: #111; margin: 4px 0 10px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: transparent; }

/* ---- floating UI ---- */
.topbar { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; gap: 10px; align-items: center; z-index: 800; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.avatar { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--btn); color: var(--btn-ink); font-weight: 700; font-size: 1.1rem; box-shadow: var(--float); cursor: pointer; }
.pill { height: 46px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--bg); box-shadow: var(--float); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.pill svg { opacity: .6; }
.hint { position: absolute; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: var(--btn); color: var(--btn-ink); padding: 10px 16px; border-radius: 999px; z-index: 800; font-weight: 600; font-size: .9rem; max-width: 90vw; text-align: center; box-shadow: var(--float); }
.fab { position: absolute; right: 12px; top: -62px; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--bg); box-shadow: var(--float); cursor: pointer; display: grid; place-items: center; }
.fab.on { background: var(--blue); color: #fff; }
.pin { position: absolute; left: 50%; top: 50%; z-index: 1200; pointer-events: none; transform: translate(-50%, -100%); }
.pin span { display: block; width: 22px; height: 22px; background: var(--btn); border: 4px solid var(--bg); border-radius: 50%; box-shadow: var(--float); }
.pin::after { content: ''; display: block; width: 3px; height: 20px; background: var(--btn); margin: -2px auto 0; border-radius: 2px; }

/* ---- sheets ---- */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; max-width: 640px; margin: 0 auto; background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: var(--shadow); z-index: 700; padding-bottom: env(safe-area-inset-bottom); }
.sheet.home { display: flex; flex-direction: column; max-height: 72%; transition: height .22s ease; }
.sheet.home.open { height: 72%; }
.handle { background: none; border: 0; padding: 0; width: 100%; height: 44px; display: grid; place-items: center; cursor: grab; touch-action: none; flex: none; }
.handle span { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--muted); opacity: .5; }
#homeBody { overflow-y: auto; flex: 1; padding: 0 16px 16px; overscroll-behavior: contain; }
.sheet.pad { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 70%; overflow-y: auto; }
@media (min-width: 700px) { .sheet { bottom: 12px; border-radius: 22px; } .sheet.pad { padding-bottom: 20px; } }

.hello { color: var(--muted); font-size: .875rem; }
.title { font-size: 1.6rem; font-weight: 700; line-height: 1.15; margin: 2px 0 10px; letter-spacing: -.03em; }
.seg { display: inline-flex; background: var(--card); border-radius: 999px; padding: 3px; gap: 2px; margin-bottom: 10px; }
.seg button { border: 0; background: none; border-radius: 999px; min-height: 40px; padding: 0 16px; font-weight: 600; font-size: .875rem; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.chips { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--card); cursor: pointer; font-weight: 600; font-size: .9rem; }
.chip[aria-pressed="true"] { background: var(--btn); color: var(--btn-ink); }

.hero { background: var(--card); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.hero .top { display: flex; align-items: center; gap: 12px; }
.hero .grow, .row .grow { flex: 1; min-width: 0; }
.hero .nm { font-weight: 700; font-size: 1.05rem; }
.hero .big { font-size: 2rem; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.hero .big.best { color: var(--good); }
.save { color: var(--good); font-weight: 600; font-size: .875rem; margin-top: 2px; }
.hero .btns { display: flex; gap: 8px; margin-top: 12px; }
.hero .btns > * { flex: 1; }
.hero p + .btn, .hero p + .btns { margin-top: 12px; }
.stoprow { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.label { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 4px; }

.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; min-height: 64px; }
.ico { width: 40px; height: 40px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.row .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.price.best { color: var(--good); }
.empty { padding: 14px 0; color: var(--muted); }
.addrow { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); cursor: pointer; font-weight: 600; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; }

/* ---- map markers ---- */
.mk { background: var(--btn); color: var(--btn-ink); border-radius: 999px; padding: 4px 9px; font-weight: 700; font-size: 12px; white-space: nowrap; text-align: center; box-shadow: var(--float); font-variant-numeric: tabular-nums; border: 2px solid var(--bg); }
.mk.none { background: var(--bg); color: var(--muted); font-weight: 600; }
.mk.best { background: var(--good); color: var(--best-ink); border-color: var(--best-ink); }
.mk.stale { opacity: .75; border-style: dashed; }
.mk.dim { opacity: .4; }
.mk.dot { width: 14px; height: 14px; padding: 0; border-radius: 50%; background: var(--btn); }
.mk.dot.dim { opacity: .35; }

/* ---- detail ---- */
.dhead { display: flex; align-items: flex-start; gap: 8px; }
.dhead h2 { font-size: 1.45rem; letter-spacing: -.03em; line-height: 1.15; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); cursor: pointer; font-size: 1.1rem; flex: none; display: grid; place-items: center; }
.iconbtn.on { color: var(--star); border: 2px solid currentColor; }
.pricecard { background: var(--card); border-radius: 16px; padding: 14px; margin: 14px 0 10px; }
.pricecard .lbl { font-weight: 600; }
.pricecard .big { font-size: 2.4rem; font-weight: 800; letter-spacing: -.04em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--card2); margin-left: 6px; }
.badge.warn { color: var(--warn); } .badge.ok { color: var(--good); }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.actions > .btn { flex: 1 1 auto; }
.others { margin-top: 6px; }
.others summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style: none; display: flex; justify-content: space-between; border-top: 1px solid var(--line); }
.others summary::after { content: '＋'; color: var(--muted); }
.others[open] summary::after { content: '－'; }
.ofuel { padding: 10px 0; border-top: 1px solid var(--line); }
.ofuel .head { display: flex; justify-content: space-between; align-items: baseline; }
.ofuel .actions { margin-top: 8px; }
.ofuel .btn { min-height: 44px; font-size: .875rem; }
.inline { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.inline .btn { flex: none; }
input[type=number], input[type=text] { width: 100%; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 2px solid transparent; background: var(--card); outline: none; font-size: 1.05rem; }
input:focus { border-color: var(--text); }
label { display: block; font-weight: 600; margin: 14px 0 6px; }

/* ---- modal sheet ---- */
.modal { position: fixed; inset: 0; z-index: 1500; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-sheet { z-index: 1; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; border-radius: 14px; border: 2px solid transparent; background: var(--card); cursor: pointer; text-align: left; margin-bottom: 8px; }
.opt[aria-checked="true"] { border-color: var(--text); }
.opt .grow { flex: 1; } .opt b { display: block; font-size: 1.05rem; }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.opt[aria-checked="true"] .radio { border: 7px solid var(--btn); }
.brandgrid { display: flex; flex-wrap: wrap; gap: 8px; }
.brandgrid .chip { min-height: 44px; padding: 0 18px; font-size: 1rem; }

/* ---- onboarding ---- */
.onboard { position: fixed; inset: 0; z-index: 3000; background: var(--bg); display: flex; flex-direction: column; padding: calc(16px + env(safe-area-inset-top)) 20px calc(12px + env(safe-area-inset-bottom)); overflow: hidden; }
.progress { display: flex; gap: 6px; margin-bottom: 20px; flex: none; }
.progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--card2); }
.progress i.on { background: var(--btn); }
.onboard h1 { font-size: 2rem; line-height: 1.1; letter-spacing: -.04em; margin-bottom: 8px; }
.onboard .sub { color: var(--muted); margin-bottom: 22px; }
.onboard .body { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 8px; }
.onboard .foot { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; flex: none; background: var(--bg); }
.onboard h1:focus { outline: none; }
.nick { display: flex; gap: 8px; }
.nick .btn { flex: none; width: 52px; padding: 0; }
.back { background: none; border: 0; font-size: 1.5rem; cursor: pointer; padding: 0; width: 44px; height: 44px; margin: -8px 0 8px -8px; flex: none; align-self: flex-start; }
.logo { width: 56px; height: 56px; border-radius: 14px; margin-bottom: 20px; }

dialog { max-width: min(92vw, 440px); max-height: 90vh; overflow-y: auto; border: 0; border-radius: 20px; background: var(--bg); color: var(--text); padding: 22px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2, dialog h3 { margin-bottom: 6px; } dialog p { margin-bottom: 10px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); pointer-events: none; transform: translateX(-50%); background: var(--btn); color: var(--btn-ink); padding: 12px 18px; border-radius: 12px; z-index: 4000; max-width: 90vw; text-align: center; font-weight: 600; box-shadow: var(--float); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.hero .btn:not(.primary), .hero .chip { background: var(--card2); }
.hero .chip[aria-pressed="true"] { background: var(--btn); }
.hero .btn.primary { background: var(--btn); }

/* ---- utility classes for dynamic content (no inline styles) ---- */
.chips.nomargin { margin: 0; }
.actions.nomargin { margin: 0 0 8px; }
.actions.gap { margin-top: 18px; }
.title.tight { margin-bottom: 4px; }
.nickhint { margin-top: 10px; }
.officialnote { margin: -4px 0 10px; }
.pin span { box-shadow: var(--float); }

@media (prefers-reduced-motion: reduce) {
  .sheet.home { transition: none; }
  .btn, .btn:active { transition: none; transform: none; }
}
.modal-sheet:focus, #detail:focus { outline: none; }
