:root { --btn-bg: #fff; --btn-fg: #222; --muted: #888; --accent: #FF7326; --sheet-bg: #fff; --tile-bg: #f2f1ea; }
.dark { --btn-bg: #222; --btn-fg: #ddd; --muted: #777; --sheet-bg: #1b1b1b; --tile-bg: #2a2a2a; }
/* Full-screen map: the page never scrolls. The layers sheet is position: fixed, so while
   closed (moved below the viewport) it doesn't make the document scrollable. */
html, body { margin: 0; height: 100%; overflow: hidden; overflow: clip; background: #E3E1D2; font-family: system-ui, sans-serif; }
#map { position: absolute; inset: 0; }
.btn {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  border: 0; border-radius: 20px; padding: 8px 14px; font-size: 13px;
  background: var(--btn-bg); color: var(--btn-fg); box-shadow: 0 1px 4px rgba(0,0,0,.25); cursor: pointer;
}
#btnLayers { top: auto; bottom: 40px; right: 12px; left: auto; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; }
#btnLayers svg { width: 22px; height: 22px; }
#btnLayers.active { color: var(--accent); }
/* Location button above the layers button; OM's accent blue while following the position */
#btnLocate { top: auto; bottom: 96px; right: 12px; left: auto; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; }
#btnLocate svg { width: 22px; height: 22px; }
#btnLocate.follow { color: #249CF2; }
#btnLocate.pending svg { animation: locating 1s ease-in-out infinite alternate; }
#btnLocate.denied, #btnLocate.unavailable, #btnLocate.outside { color: var(--muted); }
/* A short message over the map, above the buttons (main.js: $store.map.say()) */
#toast { position: absolute; z-index: 5; left: 50%; bottom: 160px; transform: translateX(-50%); margin: 0;
  width: max-content; max-width: calc(100% - 48px); box-sizing: border-box; padding: 10px 14px; border-radius: 12px;
  background: rgba(34, 34, 34, .9); color: #fff; font-size: 14px; line-height: 1.4; text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.25); pointer-events: none; }
@keyframes locating { from { opacity: 1; } to { opacity: .3; } }

/* OM-style layers sheet */
#sheet {
  position: fixed; z-index: 3; left: 50%; bottom: 12px; transform: translate(-50%, 120%);
  width: min(420px, calc(100% - 32px)); box-sizing: border-box; padding: 14px 14px 16px;
  background: var(--sheet-bg); color: var(--btn-fg); border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.25);
  /* Closed: slide out, then hide (not focusable, not read out); open: show, then slide in. */
  visibility: hidden; transition: transform .2s ease-out, visibility 0s linear .2s;
}
#sheet.open { transform: translate(-50%, 0); visibility: visible; transition: transform .2s ease-out; }
/* Touch: the sheet is swiped down to close (main.js), the page itself never scrolls; a grab handle shows it */
#sheet { touch-action: none; }
#sheet .grab { display: none; width: 36px; height: 4px; margin: -4px auto 10px; border-radius: 2px; background: var(--muted); opacity: .5; }
@media (pointer: coarse) { #sheet .grab { display: block; } }
#sheet h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; }
#sheet h2 button { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.tile { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 11px; text-align: center; }
.tile .ico { aspect-ratio: 1; border-radius: 12px; background: var(--tile-bg); display: grid; place-items: center;
  margin-bottom: 6px; border: 2px solid transparent; color: var(--muted); }
.tile .ico svg { width: 26px; height: 26px; }
.tile.on .ico { border-color: var(--accent); color: var(--accent); }
#hint { margin: 10px 0 0; font-size: 11px; color: var(--muted); min-height: 1em; }
.row.link { color: inherit; text-decoration: none; }
.row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--tile-bg); font-size: 14px; cursor: pointer; }
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: var(--tile-bg); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* OM-style search */
#search { position: absolute; z-index: 4; top: 12px; left: 20px; width: min(380px, calc(100% - 88px));
  display: flex; flex-direction: column; max-height: calc(100% - 24px); color: var(--btn-fg); }
/* flex: none: a long result list scrolls in the panel instead of squeezing the bar */
.searchbar { display: flex; flex: none; align-items: center; gap: 8px; height: 44px; padding: 0 6px 0 14px; box-sizing: border-box;
  background: var(--btn-bg); border-radius: 22px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.searchbar svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.searchbar .brand { flex: none; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; color: var(--btn-fg);
  text-decoration: none; padding-right: 2px; }
.searchbar .brand span { color: var(--accent); }
.searchbar input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: inherit; font: inherit; font-size: 15px; }
.searchbar input::placeholder { color: var(--muted); }
.searchbar input::-webkit-search-cancel-button { display: none; }
.searchbar button { border: 0; background: none; color: var(--muted); width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; font-size: 16px; display: none; }
#search.has-text .searchbar button { display: block; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--tile-bg); border-top-color: #1E96F0; border-radius: 50%;
  animation: spin .7s linear infinite; display: none; flex: none; }
#search.htmx-request .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.panel { margin-top: 8px; background: var(--sheet-bg); border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,.2);
  overflow: auto; display: none; }
#search.open .panel { display: block; }
.panel h3 { margin: 14px 16px 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.history { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 4px; }
.history button { border: 0; background: var(--tile-bg); color: inherit; border-radius: 14px; padding: 5px 10px; font-size: 13px; cursor: pointer; }
.list { list-style: none; margin: 0; padding: 0 0 8px; }
.list li button { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; color: inherit;
  text-align: left; padding: 9px 16px; cursor: pointer; font: inherit; }
.list li button:hover, .list li button:focus-visible { background: var(--tile-bg); outline: 0; }
.list img { width: 28px; height: 28px; flex: none; }
.list img.cat-night, .dark .list img.cat-day { display: none; }
.dark .list img.cat-night { display: block; }
.list .txt { flex: 1; min-width: 0; }
.list .name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.list .dist { font-size: 12px; color: var(--muted); flex: none; }
.showall { display: block; margin: 4px 16px 12px; width: calc(100% - 32px); border: 0; border-radius: 10px; padding: 10px;
  background: #1E96F0; color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.msg { padding: 16px; font-size: 14px; color: var(--muted); }

/* place page (simplified OM bottom sheet) */
#place { position: absolute; z-index: 3; left: 12px; bottom: 40px; width: min(380px, calc(100% - 80px)); box-sizing: border-box;
  padding: 14px 16px; background: var(--sheet-bg); color: var(--btn-fg); border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.25); display: none; }
#place.open { display: block; }
#place h4 { margin: 0 28px 4px 0; font-size: 18px; }
#place .sub { font-size: 13px; color: var(--muted); }
#place .close { position: absolute; top: 10px; right: 10px; border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; }

@media (max-width: 600px) {
  /* The search bar across the screen, a little in from both sides; the zoom controls below it */
  #search { left: 12px; right: 12px; width: auto; }
  .maplibregl-ctrl-top-right { top: 56px; }
  .maplibregl-ctrl-top-right .maplibregl-ctrl { margin-right: 12px; } /* in line with the bar and the buttons */
  #place { width: calc(100% - 24px); bottom: 96px; }
}

[x-cloak] { display: none !important; }
button.row { width: 100%; border: 0; border-top: 1px solid var(--tile-bg); background: none; color: inherit; font: inherit; font-size: 14px; padding: 12px 0 0; text-align: left; }

/* Community places in the place card */
.community-note { margin-top: 6px; font-size: 12px; color: var(--accent); }
.community-note a { color: inherit; }

/* "Add Place": a pin over the map center while picking the location */
body.picking #search, body.picking #btnLayers, body.picking #btnLocate { display: none; }
#picker .bar { position: absolute; z-index: 4; top: 12px; left: 50%; transform: translateX(-50%);
  width: min(420px, calc(100% - 32px)); display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px; background: var(--btn-bg); color: var(--btn-fg); border-radius: 22px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
#picker .bar button { border: 0; background: none; color: inherit; font: inherit; padding: 6px 12px; border-radius: 16px; cursor: pointer; }
#picker .bar .go { background: var(--accent); color: #fff; }
#picker .pin { position: absolute; z-index: 2; left: 50%; top: 50%; width: 32px; height: 44px; margin: -44px 0 0 -16px;
  pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }

/* "Add Place" panel: same place and look as the search panel */
#editor { position: absolute; z-index: 5; top: 12px; left: 12px; width: min(380px, calc(100% - 24px));
  max-height: calc(100% - 24px); overflow: auto; box-sizing: border-box; background: var(--sheet-bg); color: var(--btn-fg);
  border-radius: 16px; box-shadow: 0 4px 24px rgba(0,0,0,.25); }
#editor h2 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 12px 16px; font-size: 15px; font-weight: 600;
  display: flex; justify-content: space-between; background: var(--sheet-bg); }
#editor h2 button { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; }
#editor .searchbar { margin: 0 12px 4px; box-shadow: none; background: var(--tile-bg); }
#editor .sprite { display: inline-block; flex: none; }
#editor .sprite.dot { width: 10px; height: 10px; margin: 6px; border-radius: 50%; background: var(--muted); }
#editor .list .empty { padding: 12px 16px; font-size: 13px; }
#editor-body { padding: 0 16px 16px; font-size: 14px; }
.editor-form label { display: block; margin: 0 0 10px; font-weight: 500; }
.editor-form input:not([type=checkbox]), .editor-form select, .editor-form textarea { display: block; width: 100%;
  box-sizing: border-box; margin-top: 3px; padding: 7px 9px; font: inherit; color: inherit; background: var(--tile-bg);
  border: 1px solid transparent; border-radius: 8px; }
.editor-form .hint { display: block; font-size: 12px; font-weight: normal; color: var(--muted); }
.editor-form .category { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.editor-form .category .link { margin-left: auto; }
.editor-form .error { color: #d33; }
.editor-form button.primary, #editor .saved button { width: 100%; border: 0; border-radius: 10px; padding: 10px;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.editor-form button.link { border: 0; background: none; color: #1E96F0; cursor: pointer; font: inherit; }
.dupes { background: #fff6e0; color: #5a4300; border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; font-size: 13px; }
.dupes ul { margin: 4px 0 0; padding-left: 18px; }
.dupes .muted { color: #8a7333; }

/* Search limited to an administrative area: chip in the search bar, area results */
.area-chip { display: flex; align-items: center; gap: 2px; flex: none; max-width: 45%; padding: 2px 2px 2px 10px;
  border-radius: 14px; background: #1E96F0; color: #fff; font-size: 13px; white-space: nowrap; }
.area-chip > span { overflow: hidden; text-overflow: ellipsis; }
.searchbar .area-chip button { display: block; width: 24px; height: 24px; color: #fff; font-size: 12px; }
.list.areas .area-ico { width: 18px; height: 18px; flex: none; margin: 0 3px; border: 2px solid #1E96F0;
  border-radius: 3px; background: rgba(30, 150, 240, .12); box-sizing: border-box; }
.list .name .th { color: var(--muted); font-weight: normal; margin-left: 4px; }
