/* Layout: full-bleed map with one floating sheet — left column on desktop, bottom sheet on phones */
:root {
  --paper: #f5f6f3;
  --paper-2: #e9ece7;
  --ink: #15212a;
  --ink-2: #55626a;
  --line: #d3d9d4;
  --ok: #0f8a68;
  --maybe: #d18700;
  --car: #3460c8;
  --free: #8b959b;
  --plate-yellow: #f3c432;
  --plate-red: #d2322a;
  --full: #c8372d;
  --report: #b03a86;
  --shadow: 0 6px 24px rgb(21 33 42 / 0.16);
  --font-ui: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-num: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --tile-filter: none;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151a1d; --paper-2: #1e2529; --ink: #e7ece8; --ink-2: #9aa6ab; --line: #2c353a;
    --ok: #2fbf8f; --maybe: #f0a52a; --car: #7096f0; --free: #6f7a80;
    --full: #f0625a; --report: #e070b8;
    --shadow: 0 6px 24px rgb(0 0 0 / 0.45);
    --tile-filter: invert(1) hue-rotate(180deg) brightness(0.82) contrast(0.9) saturate(0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #151a1d; --paper-2: #1e2529; --ink: #e7ece8; --ink-2: #9aa6ab; --line: #2c353a;
  --ok: #2fbf8f; --maybe: #f0a52a; --car: #7096f0; --free: #6f7a80;
  --full: #f0625a; --report: #e070b8;
  --shadow: 0 6px 24px rgb(0 0 0 / 0.45);
  --tile-filter: invert(1) hue-rotate(180deg) brightness(0.82) contrast(0.9) saturate(0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

.app { position: relative; height: 100%; }
.map-wrap { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; background: var(--paper-2); }

/* ---------------------------------------------------------------- sheet */
.sheet {
  position: absolute; z-index: 1000;
  top: max(16px, env(safe-area-inset-top, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  width: 340px;
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 18px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.sheet__body { display: flex; flex-direction: column; gap: 14px; flex: 1 0 auto; min-width: 0; }
.sheet__handle { display: none; }

.brand { display: flex; align-items: center; gap: 12px; }
.plates { display: flex; gap: 3px; flex: none; }
.plate {
  display: grid; place-items: center;
  width: 26px; height: 34px; border-radius: 4px;
  font: 900 15px/1 var(--font-ui);
  border: 1.5px solid rgb(0 0 0 / 0.55);
}
.plate--yellow { background: var(--plate-yellow); color: #1b1b1b; }
.plate--red { background: var(--plate-red); color: #fff; }
.brand h1 { margin: 0; font: 900 21px/1.2 var(--font-ui); letter-spacing: 0.02em; text-wrap: balance; }
.brand p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }

.eyebrow {
  margin: 0 0 6px; padding: 0;
  font-size: 12px; font-weight: 500; letter-spacing: 0.08em; color: var(--ink-2);
}

/* ---------------------------------------------------------------- legend */
.legend { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 2px; }
.legend__row {
  display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.legend__row:hover { background: var(--paper-2); }
.legend__row input { margin: 0; width: 16px; height: 16px; accent-color: var(--ink); }
.legend__row input:focus-visible { outline: 2px solid var(--car); outline-offset: 2px; }
.legend__label { display: flex; flex-direction: column; font-weight: 500; line-height: 1.3; min-width: 0; }
.legend__label small { font-weight: 400; font-size: 12px; color: var(--ink-2); }
.legend__n { font: 500 12.5px/1 var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.legend__row:has(input:not(:checked)) .swatch,
.legend__row:has(input:not(:checked)) .legend__label { opacity: 0.4; }

.swatch { width: 22px; height: 12px; border-radius: 3px; }
.swatch--ok { background: var(--ok); }
.swatch--maybe { background: var(--maybe); }
.swatch--car { background: transparent; border: 2px solid var(--car); }
.swatch--free { background: transparent; border: 2px dashed var(--free); }
.swatch--lot {
  height: 20px; display: grid; place-items: center; border-radius: 5px;
  background: var(--ink); color: var(--paper); font: 700 12px/1 var(--font-ui);
}

/* ---------------------------------------------------------------- info card */
.card {
  padding: 14px; border-radius: 10px;
  background: var(--paper-2);
  display: grid; gap: 8px;
}
.card .eyebrow { margin: 0; }
.rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; }
.rules b { font-weight: 700; margin-right: 6px; }
.hint { margin: 0; font-size: 13px; color: var(--ink-2); }

.badge {
  justify-self: start;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; color: #fff;
}
.badge--0 { background: var(--ok); }
.badge--1 { background: var(--maybe); color: #1d1500; }
.badge--2 { background: var(--free); }
.badge--3 { background: var(--car); }
.badge--lot { background: var(--ink); color: var(--paper); }
.card h2 { margin: 0; font: 700 18px/1.3 var(--font-ui); text-wrap: balance; }
.card .verdict { margin: 0; font-size: 14px; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mono { font-family: var(--font-num); font-size: 12.5px; }
.card a.nav {
  justify-self: start; margin-top: 2px;
  padding: 7px 12px; border-radius: 8px;
  background: var(--ink); color: var(--paper);
  font-size: 13.5px; font-weight: 500; text-decoration: none;
}
.card a.nav:focus-visible { outline: 2px solid var(--car); outline-offset: 2px; }

.sources { margin-top: auto; font-size: 11.5px; line-height: 1.6; color: var(--ink-2); }

/* ---------------------------------------------------------------- map chrome */
.zoom-hint {
  position: absolute; z-index: 900; left: 50%; transform: translateX(-50%);
  top: max(16px, env(safe-area-inset-top, 0px));
  padding: 8px 14px; border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow);
  pointer-events: none;
}
@media (min-width: 761px) { .zoom-hint { left: calc(50% + 186px); } }

.locate {
  position: absolute; z-index: 900;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 28px));
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer;
}
.locate:focus-visible { outline: 2px solid var(--car); outline-offset: 2px; }

.lot-pin {
  display: grid; place-items: center;
  min-width: 30px; height: 24px; padding: 0 6px; border-radius: 6px;
  background: var(--ink); color: var(--paper);
  font: 700 12px/1 var(--font-num); white-space: nowrap;
  border: 2px solid var(--paper); box-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
}

.leaflet-tile-pane { filter: var(--tile-filter); }
.leaflet-container { font-family: var(--font-ui); background: var(--paper-2); }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--paper); color: var(--ink); border-color: var(--line); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--paper) 85%, transparent) !important; color: var(--ink-2); }
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-control-zoom { margin-top: max(16px, env(safe-area-inset-top, 0px)) !important; margin-right: max(16px, env(safe-area-inset-right, 0px)) !important; }

/* ---------------------------------------------------------------- phone */
@media (max-width: 760px) {
  /* bottom sheet: 46% open, or just the handle + title when collapsed */
  .app { --sheet-h: 46%; }
  .app.sheet-collapsed { --sheet-h: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .map-wrap { bottom: var(--sheet-h); transition: bottom 0.25s ease; }
  .sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-h);
    border-radius: 16px 16px 0 0; border-width: 1px 0 0;
    padding: 0 max(16px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    gap: 12px;
    transition: height 0.25s ease;
  }
  .app.sheet-collapsed .sheet { overflow: hidden; }
  .sheet__body { gap: 12px; }
  .sheet__handle {
    position: sticky; top: 0; z-index: 2;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 0 5px; border: 0; background: var(--paper); color: var(--ink-2);
    font: 500 12px/1 var(--font-ui); cursor: pointer; touch-action: none;
  }
  .sheet__handle:focus-visible { outline: 2px solid var(--car); outline-offset: -2px; border-radius: 8px; }
  .sheet__grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
  #info { scroll-margin-top: 40px; }   /* keep the card clear of the sticky handle */
  .brand h1 { font-size: 18px; }
  .plate { width: 22px; height: 29px; font-size: 13px; }
  .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 4px; }
  .legend .eyebrow { grid-column: 1 / -1; }
  .legend__row { grid-template-columns: auto auto minmax(0, 1fr); gap: 8px; padding: 6px 4px; min-width: 0; }
  .legend__label small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .legend__n { display: none; }
  .locate { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .map-wrap, .sheet { transition: none !important; }
  .leaflet-fade-anim .leaflet-popup, .leaflet-zoom-anim .leaflet-zoom-animated { transition: none !important; }
}

/* ---------------------------------------------------------------- account */
.account { min-height: 36px; display: flex; align-items: center; }
.account__me { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.account__name { font-weight: 500; }
/* Google's button lives in a light-scheme iframe; matching it avoids an opaque white box in dark mode */
.sheet iframe { color-scheme: light; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar--initial { display: grid; place-items: center; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 13px; }
.devlogin { display: flex; gap: 6px; flex-wrap: wrap; }
.devlogin input { flex: 1 1 120px; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- buttons & inputs */
.btn {
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font: 500 13.5px/1.3 var(--font-ui);
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn:focus-visible, .linkbtn:focus-visible, .report-fab:focus-visible, .pick-chip button:focus-visible { outline: 2px solid var(--car); outline-offset: 2px; }
.linkbtn {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--ink-2); font: 400 12.5px/1.3 var(--font-ui); text-decoration: underline; text-underline-offset: 2px;
}
.sheet input:not([type=checkbox]):not([type=radio]), .sheet select {
  width: 100%; padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font: 400 14px/1.3 var(--font-ui);
}
.sheet input:focus-visible, .sheet select:focus-visible { outline: 2px solid var(--car); outline-offset: 1px; }

/* ---------------------------------------------------------------- community section */
.community { display: grid; gap: 10px; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); min-width: 0; }
.community:empty { display: none; }
.community__title { margin: 0; font: 700 15px/1.3 var(--font-ui); }
.rgroup { display: grid; gap: 4px; }
.rgroup h3 { margin: 0; font-size: 12px; font-weight: 500; letter-spacing: 0.06em; color: var(--ink-2); }
.rgroup .hint { font-size: 12.5px; }
.rlist { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.rlist li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 13.5px; }
.rlist__what { font-weight: 500; }
.rlist__meta { color: var(--ink-2); font-size: 12px; display: inline-flex; gap: 8px; align-items: baseline; }
.rlist__note { flex-basis: 100%; color: var(--ink); font-size: 13px; overflow-wrap: anywhere; }
.lvl { padding: 1px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: #fff; }
.lvl--easy { background: var(--ok); }
.lvl--tight { background: var(--maybe); color: #1d1500; }
.lvl--full { background: var(--full); }
.ractions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ractions__label { font-size: 12px; color: var(--ink-2); margin-right: 2px; }
.rflash { margin: 0; font-size: 13px; font-weight: 500; color: var(--ok); }
.rlogin { display: grid; gap: 8px; justify-items: start; }
.rlogin p { margin: 0; font-size: 13.5px; }

.rform { display: grid; gap: 10px; min-width: 0; }
.choice { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.choice legend { width: 100%; padding: 0; margin-bottom: 6px; font-size: 13.5px; font-weight: 500; }
.choice__opt { position: relative; cursor: pointer; }
.choice__opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice__opt span {
  display: inline-block; padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); font-size: 13.5px;
}
.choice__opt input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.choice__opt input:focus-visible + span { outline: 2px solid var(--car); outline-offset: 2px; }
.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--ink-2); min-width: 0; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rform__actions { display: flex; gap: 8px; }
.rform__who { margin: 0; font-size: 12px; color: var(--ink-2); }
.rform__error { margin: 0; font-size: 13px; font-weight: 500; color: var(--full); }

.badge--report { background: var(--report); }
.swatch--report { display: flex; align-items: center; justify-content: center; gap: 2px; }
.swatch--report i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.swatch--report i:nth-child(2) { background: var(--maybe); }
.swatch--report i:nth-child(3) { background: var(--full); }

/* ---------------------------------------------------------------- report pins & picking */
.rpin {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--report); color: #fff; border: 2px solid var(--paper);
  font: 700 14px/1 var(--font-num); box-shadow: 0 2px 6px rgb(0 0 0 / 0.3);
}
.rpin--mislabel { border-radius: 5px; background: var(--full); }
.rpin--draft { animation: pin-pulse 1.4s ease-in-out infinite; }
@keyframes pin-pulse { 50% { transform: scale(1.18); } }

.report-fab {
  position: absolute; z-index: 900;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(84px, calc(env(safe-area-inset-bottom, 0px) + 84px));
  display: inline-flex; align-items: center; gap: 6px;
  height: 44px; padding: 0 14px; border-radius: 12px; cursor: pointer;
  background: var(--report); color: #fff; border: 0; box-shadow: var(--shadow);
  font: 700 14px/1 var(--font-ui);
}
.pick-chip {
  position: absolute; z-index: 950; left: 50%; transform: translateX(-50%);
  top: max(16px, env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px 14px; border-radius: 999px;
  background: var(--report); color: #fff; box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 500; max-width: calc(100% - 32px);
}
.pick-chip button {
  padding: 4px 10px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgb(255 255 255 / 0.22); color: #fff; font: 500 13px/1.2 var(--font-ui);
}
@media (min-width: 761px) { .pick-chip { left: calc(50% + 186px); } }
.is-picking, .is-picking .leaflet-interactive { cursor: crosshair !important; }

@media (max-width: 760px) {
  .report-fab { bottom: 70px; height: 40px; padding: 0 12px; font-size: 13px; }
  .pick-chip { font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) { .rpin--draft { animation: none; } }

/* ---------------------------------------------------------------- place search */
.search {
  position: absolute; z-index: 960;
  top: max(16px, env(safe-area-inset-top, 0px));
  left: calc(max(16px, env(safe-area-inset-left, 0px)) + 356px);
  width: min(420px, calc(100% - 356px - 112px));
}
.search input {
  width: 100%; height: 46px; padding: 0 48px 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font: 400 16px/1 var(--font-ui); box-shadow: var(--shadow);
  -webkit-appearance: none; appearance: none;
}
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search input:focus-visible { outline: 2px solid var(--car); outline-offset: 1px; }
.search button[type=submit] {
  position: absolute; top: 3px; right: 3px; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
}
.search button[type=submit]:focus-visible { outline: 2px solid var(--car); }
.search__results {
  margin: 6px 0 0; padding: 4px; list-style: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  max-height: min(50vh, 360px); overflow-y: auto;
}
.search__results button {
  width: 100%; display: grid; gap: 2px; text-align: left; cursor: pointer;
  padding: 9px 12px; border: 0; border-radius: 8px; background: none; color: var(--ink);
  font: 500 15px/1.35 var(--font-ui);
}
.search__results button:hover, .search__results button:focus-visible { background: var(--paper-2); outline: none; }
.search__results small { font-weight: 400; font-size: 12.5px; color: var(--ink-2); }
.search__msg { padding: 10px 12px; font-size: 13.5px; color: var(--ink-2); }
.search-pin {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--paper);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--ink) 25%, transparent), 0 2px 6px rgb(0 0 0 / 0.35);
}

/* hints sit under the search bar */
.zoom-hint, .pick-chip { top: calc(max(16px, env(safe-area-inset-top, 0px)) + 58px); }

@media (max-width: 760px) {
  .search { left: max(12px, env(safe-area-inset-left, 0px)); right: calc(max(12px, env(safe-area-inset-right, 0px)) + 50px); width: auto; top: max(12px, env(safe-area-inset-top, 0px)); }
  .zoom-hint, .pick-chip { top: calc(max(12px, env(safe-area-inset-top, 0px)) + 56px); }
  .leaflet-control-zoom { margin-top: max(12px, env(safe-area-inset-top, 0px)) !important; margin-right: max(12px, env(safe-area-inset-right, 0px)) !important; }
}

/* ---------------------------------------------------------------- 申請試用 */
.account { flex-direction: column; align-items: stretch; gap: 8px; }
.account > div:first-child, .account > .devlogin { align-self: flex-start; }
.trial summary {
  cursor: pointer; font-size: 13px; color: var(--ink-2);
  text-decoration: underline; text-underline-offset: 2px; list-style: none;
}
.trial summary::-webkit-details-marker { display: none; }
.trial summary:focus-visible { outline: 2px solid var(--car); outline-offset: 2px; border-radius: 4px; }
.trial[open] summary { margin-bottom: 8px; }
.trial__form { display: grid; gap: 10px; padding: 12px; border-radius: 10px; background: var(--paper-2); }
.trial__form .hint { font-size: 12.5px; }
.trial__hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* iOS zooms into inputs smaller than 16px */
@media (max-width: 760px) {
  .sheet input:not([type=checkbox]):not([type=radio]), .sheet select { font-size: 16px; }
}
