/* SG Park Where — Soft Civic theme (locked, from design-handoff/README.md).
   Reference-fidelity port of design-handoff/*.dc.html: same tokens, same markup shapes,
   same interactions. Do not invent a new direction here — this is the shipped design. */

:root {
  --bg: #fbfaf7;
  --surface: #f1efe9;
  --card: #ffffff;
  --ink: #1e2421;
  --muted: #66706b;
  --body2: #3d4541;
  --hairline: #ebe8e1;
  --rule: #e6e3dc;
  --hover: #f3f1ec;
  --handle: #d3cfc6;

  --accent: #0e7c66;
  --accent-hover: #0b6654;
  --accent-tint: #e2f0ec;
  --accent-tint-fg: #0b6654;
  --on-accent: #ffffff;

  --sec: #1e2421;
  --sec-hover: #343c38;
  --on-sec: #ffffff;

  --lvl-plenty-bar: #0e7c66;
  --lvl-plenty-num: #0e7c66;
  --lvl-filling-bar: #d9822b;
  --lvl-filling-num: #b86a1c;
  --lvl-full-bar: #c9c5bc;
  --lvl-full-fg: #4a514d;
  --lvl-full-num: #8a918d;
  --lvl-nodata-bar: #d8d5cc;
  --lvl-nodata-num: #9aa19d;

  --pin-plenty: #0e7c66;
  --pin-plenty-fg: #ffffff;
  --pin-filling: #d9822b;
  --pin-filling-fg: #ffffff;
  --pin-full: #c9c5bc;
  --pin-full-fg: #4a514d;
  --pin-ring: #ffffff;
  --pin-sel: #1e2421;
  --user-dot: #2563eb;

  --radius-sheet: 22px;
  --radius-btn: 14px;
  --radius-card-lg: 22px;
  --radius-card-md: 18px;
  --radius-card-sm: 16px;
  --radius-pill: 999px;
  --radius-bar: 4px;
  --radius-handle: 4px;

  --shadow-sheet: 0 -10px 30px rgba(30, 36, 33, 0.12);
  --shadow-chip: 0 4px 14px rgba(30, 36, 33, 0.12);
  --shadow-live-card: 0 8px 30px rgba(30, 36, 33, 0.08);
  --shadow-pin: 0 1px 3px rgba(0, 0, 0, 0.25);

  --font: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { font: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
summary::-webkit-details-marker { display: none; }
.tabular { font-variant-numeric: tabular-nums; }
.leaflet-control-attribution { font-size: 9px !important; }

/* ================= Site chrome (carpark page + directory) ================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(251, 250, 247, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.site-header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: none;
}
.site-brand:hover { color: var(--ink); }
.site-brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 6px; }
.pill-link {
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  flex: none;
}
.pill-link:hover { background: var(--surface); color: var(--ink); }
.pill-link--accent {
  padding: 10px 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.pill-link--accent:hover { background: var(--accent-hover); color: var(--on-accent); }

.site-main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 20px 72px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}
.site-footer { border-top: 1px solid var(--hairline); }
.site-footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

/* ================= Carpark page ================= */
.cp-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.cp-crumb .cur { color: var(--ink); }
.cp-head { display: flex; flex-direction: column; gap: 14px; }
.src-tag {
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent-tint-fg);
  white-space: nowrap;
}
.cp-h1 { margin: 0; font-size: clamp(32px, 6vw, 52px); line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; text-wrap: pretty; }
.cp-address { font-size: 17px; color: var(--muted); }

.cp-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 20px; }
.live-card {
  background: var(--card);
  border-radius: var(--radius-card-lg);
  box-shadow: var(--shadow-live-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.live-card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.live-card-title { font-size: 15px; font-weight: 700; white-space: nowrap; }
.live-dot-row { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.live-num-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.live-num { font-size: 72px; font-weight: 700; line-height: 0.9; letter-spacing: -0.03em; }
.live-of { font-size: 17px; color: var(--muted); white-space: nowrap; }
.bar-track { height: 8px; border-radius: var(--radius-bar); background: var(--hairline); overflow: hidden; }
.bar-fill { height: 8px; border-radius: var(--radius-bar); }
.live-status { font-size: 15px; font-weight: 500; }
.live-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
.big-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  border-radius: var(--radius-btn);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}
.big-btn--accent { background: var(--accent); }
.big-btn--accent:hover { background: var(--accent-hover); color: #fff; }
.big-btn--sec { background: var(--sec); }
.big-btn--sec:hover { background: var(--sec-hover); color: #fff; }

#cp-map { min-height: 320px; border-radius: var(--radius-card-lg); overflow: hidden; background: var(--surface); z-index: 1; }

.cp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 40px 20px; }
.h2 { margin: 0; font-size: 24px; font-weight: 700; }
.kv-card { background: var(--card); border-radius: var(--radius-card-sm); padding: 4px 20px; }
.kv-row { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--hairline); font-size: 16px; }
.kv-row:last-of-type { border-bottom: 0; }
.kv-label { color: var(--muted); }
.kv-value { font-weight: 700; text-align: right; }
.kv-value--reg { font-weight: 500; }
.kv-foot { padding: 12px 0; font-size: 13px; color: var(--muted); }

.nearby-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.nearby-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius-card-sm);
  background: var(--card);
  color: var(--ink);
}
.nearby-card:hover { background: var(--hover); color: var(--ink); }
.nearby-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nearby-sub { font-size: 14px; color: var(--muted); }
.nearby-num { font-size: 22px; font-weight: 700; }
.empty-note { font-size: 15px; color: var(--muted); }

.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item { background: var(--card); border-radius: var(--radius-card-sm); padding: 0 20px; }
.faq-item summary { list-style: none; cursor: pointer; padding: 18px 0; font-size: 17px; font-weight: 700; }
.faq-answer { padding: 0 0 18px; font-size: 16px; line-height: 1.55; color: var(--body2); text-wrap: pretty; }

/* ================= Directory ================= */
.dir-head { display: flex; flex-direction: column; gap: 10px; }
.dir-h1 { margin: 0; font-size: clamp(32px, 6vw, 52px); line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; }
.dir-sub { font-size: 17px; color: var(--muted); text-wrap: pretty; }

.dir-controls {
  position: sticky;
  top: 65px;
  z-index: 5;
  background: var(--bg);
  padding: 8px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dir-search {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 18px;
  border-radius: var(--radius-btn);
  background: var(--surface);
  border: 1px solid transparent;
}
.dir-search:focus-within { border-color: var(--accent); }
.dir-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
}
.dir-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dir-chip {
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.dir-chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

.dir-groups { display: flex; flex-direction: column; gap: 32px; }
.dir-group { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 200px; }
.dir-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px; }
.dir-group-title { margin: 0; font-size: 22px; font-weight: 700; }
.dir-group-count { font-size: 14px; color: var(--muted); }
.dir-list { background: var(--card); border-radius: var(--radius-card-sm); overflow: hidden; }
.dir-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink);
}
.dir-list a.dir-row:last-child { border-bottom: 0; }
.dir-row:hover { background: var(--hover); color: var(--ink); }
.dir-row-name { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dir-row-sub { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dir-row-num { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.dir-row-num-val { font-size: 22px; font-weight: 700; line-height: 1; }
.dir-row-num-cap { font-size: 12px; color: var(--muted); }
.dir-empty { padding: 32px 4px; font-size: 17px; color: var(--muted); display: none; }
.dir-empty.is-visible { display: block; }
.dir-group.is-hidden { display: none; }
.dir-row.is-hidden { display: none; }

/* ================= Map app ================= */
html.app-html, body.app-body { height: 100%; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
.app-shell {
  position: fixed;
  inset: 0;
  background: var(--bg);
  overflow: hidden;
}
.app-shell, .app-shell * { box-sizing: border-box; }
#app-map {
  position: absolute;
  inset: 0;
  z-index: 1;
  font-family: var(--font);
  background: var(--surface);
}
#app-map .leaflet-tile-pane { filter: saturate(0.62) brightness(1.05) contrast(0.96); }

.app-topbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-chip);
  padding: 8px 12px;
  pointer-events: auto;
}
.chip-brand-dot { width: 12px; height: 12px; background: var(--accent); border-radius: 50%; }
.chip-brand-name { font-weight: 700; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.chip-live { gap: 6px; font-size: 12px; font-weight: 600; }
.chip-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.recenter-btn {
  position: absolute;
  right: 12px;
  bottom: calc(100% + 12px);
  width: 48px;
  height: 48px;
  background: var(--bg);
  border: 0;
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-chip);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.app-sheet-wrap { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1000; }
.app-sheet {
  background: var(--bg);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: var(--shadow-sheet);
  padding-bottom: env(safe-area-inset-bottom);
}

/* idle */
.sheet-idle { padding: 16px 16px 28px; display: flex; flex-direction: column; gap: 12px; }
.sheet-idle-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sheet-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.search-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 17px;
  color: var(--muted);
  width: 100%;
}
.primary-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  color: var(--on-accent);
  width: 100%;
}
.primary-btn:hover { background: var(--accent-hover); }

/* search */
.sheet-search-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px; }
.text-btn { background: none; border: 0; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; padding: 6px 0; color: var(--ink); }
.sheet-search-list { max-height: 360px; overflow-y: auto; border-top: 1px solid var(--rule); }
.sheet-search-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 10px 16px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--ink);
}
.sheet-search-row:hover { background: var(--hover); }
.ssr-title { font-size: 16px; font-weight: 600; }
.ssr-sub { font-size: 13px; color: var(--muted); }
.sheet-search-empty { padding: 16px; font-size: 15px; color: var(--muted); }
.sheet-search-inputwrap { padding: 12px 16px 28px; border-top: 1px solid var(--rule); }
.search-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
}
.search-input-row.is-focused { border-color: var(--accent); }
.search-input-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 17px;
  background: transparent;
  color: var(--ink);
}

/* results */
.drag-handle-row { height: 22px; display: flex; align-items: center; justify-content: center; cursor: ns-resize; touch-action: none; }
.drag-handle { width: 44px; height: 5px; border-radius: var(--radius-handle); background: var(--handle); }
.results-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 0 16px 12px; }
.results-head-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.results-title { font-size: 22px; font-weight: 700; line-height: 1.15; text-wrap: pretty; }
.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  background: none;
  border: 0;
  border-radius: var(--radius-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: var(--hover); }
.results-list { overflow-y: auto; border-top: 1px solid var(--rule); }
.result-row {
  width: 100%;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 10px 16px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--ink);
}
.result-row:hover { background: var(--hover); }
.rr-lots { display: flex; flex-direction: column; gap: 4px; }
.rr-lots-num { font-size: 24px; font-weight: 700; line-height: 1; }
.rr-bar-track { height: 4px; background: var(--hairline); border-radius: var(--radius-handle); overflow: hidden; }
.rr-bar-fill { height: 4px; }
.rr-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr-sub { font-size: 13px; color: var(--muted); }
.rr-rate { font-size: 14px; font-weight: 600; text-align: right; white-space: nowrap; }
.results-footer { padding: 12px 16px 28px; border-top: 1px solid var(--rule); }

/* detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 14px; }
.detail-head-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.detail-name { font-size: 26px; font-weight: 700; line-height: 1.1; text-wrap: pretty; }
.detail-stats { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.detail-stat-cell { padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.detail-stat-cell--left { border-right: 1px solid var(--rule); }
.detail-stat-big-row { display: flex; align-items: baseline; gap: 6px; }
.detail-stat-big { font-size: 40px; font-weight: 700; line-height: 1; }
.detail-stat-of { font-size: 14px; color: var(--muted); }
.detail-stat-big2 { font-size: 40px; font-weight: 700; line-height: 1; }
.detail-stat-walk { font-size: 13px; color: var(--muted); }
.detail-rates { padding: 12px 16px 4px; display: flex; flex-direction: column; }
.detail-rate-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--hairline); font-size: 15px; }
.detail-meta-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0 4px; font-size: 12px; color: var(--muted); }
.detail-fulllink { flex: none; font-size: 13px; font-weight: 700; color: var(--accent); padding: 6px 0; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 16px 28px; }
.detail-action-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 14px;
  border-radius: var(--radius-btn);
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
}
.detail-action-btn--accent { background: var(--accent); color: var(--on-accent); }
.detail-action-btn--accent:hover { background: var(--accent-hover); color: var(--on-accent); }
.detail-action-btn--sec { background: var(--sec); color: var(--on-sec); }
.detail-action-btn--sec:hover { background: var(--sec-hover); color: var(--on-sec); }

/* leaflet pin (custom divIcon content, styled inline for portability; class hooks here for hover states) */
.spw-pin { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.spw-pin-chip { white-space: nowrap; font-weight: 700; font-family: var(--font); border: 2px solid #fff; box-shadow: var(--shadow-pin); font-variant-numeric: tabular-nums; }
.spw-pin-stem { width: 2px; background: currentColor; }
.spw-dest-pin { background: var(--bg); border: 4px solid var(--ink); transform: rotate(45deg); }
.spw-user-dot { border-radius: 50%; background: var(--user-dot); border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35); }

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 2000;
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  max-width: 90vw;
  text-align: center;
}
.hidden { display: none !important; }
