/* Journey Planner · Explore */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --line: #dfe4ec;
  --text: #17202e;
  --text-2: #5b6576;
  --accent: #2f80ed;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fd;
  --heart: #e8466c;
  --ok: #1f9d55;
  --warn: #c77700;
  --danger: #d23b3b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .12);
  --radius: 14px;
  --topbar-h: 60px;
  --panel-w: 400px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b;
    --surface: #171d26;
    --surface-2: #1f2732;
    --line: #2b3542;
    --text: #e8edf4;
    --text-2: #9aa6b6;
    --accent: #5aa0ff;
    --accent-ink: #0b1220;
    --accent-soft: #1b2b44;
    --heart: #ff5c82;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
svg { fill: currentColor; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { color: var(--text-2); font-size: 12px; letter-spacing: .02em; }

.search { position: relative; flex: 1 1 340px; max-width: 520px; }
.search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  outline: none;
}
.search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-icon { position: absolute; left: 12px; top: 10px; width: 20px; height: 20px; color: var(--text-2); pointer-events: none; }
.search-results {
  position: absolute; top: 46px; left: 0; right: 0;
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  max-height: 60vh; overflow: auto;
}
.search-results li { display: flex; align-items: center; gap: 8px; border-radius: 8px; }
.search-results li[aria-selected="true"], .search-results li:hover { background: var(--surface-2); }
.search-results .go { flex: 1; text-align: left; background: none; border: 0; padding: 8px 10px; cursor: pointer; min-width: 0; }
.search-results .go strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .go small { display: block; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .add { flex: none; margin-right: 6px; }
.search-results .none { padding: 10px; color: var(--text-2); }

.layers { display: flex; gap: 6px; flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  cursor: pointer; white-space: nowrap;
}
.chip svg { width: 17px; height: 17px; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip[data-layer="mine"][aria-pressed="true"] { color: var(--heart); background: color-mix(in srgb, var(--heart) 12%, transparent); }

.sync-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px; margin-left: auto;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer; flex: none;
}
.sync-btn svg { width: 18px; height: 18px; }
.sync-btn.linked { background: var(--ok); color: #fff; }
.sync-btn.live { background: var(--ok); color: #fff; }
.sync-btn.live > svg { display: none; }
.sync-btn.live .live-dot { background: #fff; }
.sync-btn.live.busy .live-dot { animation: pulse 1s ease-in-out infinite; }
.sync-btn.live.offline { background: var(--text-2); }
.sync-btn.live.readonly { background: var(--text-2); }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .sync-btn.live.busy .live-dot { animation: none; opacity: .6; } }

/* ---------- Layout ---------- */

.layout { position: absolute; top: var(--topbar-h); left: 0; right: 0; bottom: 0; display: flex; }
.map-wrap { position: relative; flex: 1; min-width: 0; }
.map { position: absolute; inset: 0; background: var(--surface-2); }

.panel {
  width: var(--panel-w);
  flex: none;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  min-height: 0;
}
.panel-handle { display: none; }

.tabs { display: flex; padding: 8px 8px 0; gap: 4px; border-bottom: 1px solid var(--line); flex: none; }
.tabs button {
  flex: 1; padding: 10px 8px 12px; border: 0; background: none; cursor: pointer;
  color: var(--text-2); font-weight: 600; border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 600; }
.count:empty { display: none; }

.pane { flex: 1; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.pane-empty { padding: 24px 20px; color: var(--text-2); text-align: center; }
.pane-empty p { margin: 0 0 8px; }
.credit { font-size: 12px; color: var(--text-2); padding: 4px 14px 16px; margin: 0; }

/* Photo grid (Panoramio-style mosaic) */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 4px; padding: 8px; }
.tile {
  position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 8px; overflow: hidden;
  background: var(--surface-2); cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.tile:hover img, .tile:focus-visible img { transform: scale(1.06); }
.tile .tile-title {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 6px 5px;
  font-size: 11.5px; line-height: 1.2; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
  opacity: 0; transition: opacity .2s;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile:hover .tile-title, .tile:focus-visible .tile-title { opacity: 1; }
.tile .saved { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; background: var(--heart); color: #fff; display: grid; place-items: center; font-size: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.photo-grid .more { grid-column: 1 / -1; margin: 6px 0; }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

/* ---------- Map markers ---------- */

.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-div-icon.pm { background: none; border: 0; }

.pm-photo {
  width: 44px; height: 44px; border: 2.5px solid #fff; border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
  background: #ccd;
  transition: transform .15s;
}
.pm-photo { position: relative; }
/* Leaflet sets width:auto on marker-pane images; keep thumbnails square. */
.leaflet-marker-pane .pm-photo img { width: 100% !important; height: 100% !important; object-fit: cover; display: block; border-radius: 1.5px; }
.pm-count {
  position: absolute; top: -9px; right: -9px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: #fff; border: 2px solid #fff;
  font: 700 10.5px/15px system-ui, sans-serif; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.pm-count:empty { display: none; }
.pm-photo.saved { border-color: var(--heart); }
.pm-photo.hot, .pm-photo:hover { transform: scale(1.65); z-index: 1000; }

.pm-wiki {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  background: #f4f4f2; color: #333;
  display: grid; place-items: center; font: 700 13px Georgia, "Times New Roman", serif;
  transition: transform .15s;
}
.pm-wiki.saved { border-color: var(--heart); }
.pm-wiki:hover, .pm-wiki.hot { transform: scale(1.4); }

.pm-place { width: 34px; height: 42px; position: relative; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); transition: transform .15s; transform-origin: 50% 100%; }
.pm-place svg { width: 34px; height: 42px; position: absolute; inset: 0; }
.pm-place .emoji { position: absolute; top: 6px; left: 0; right: 0; text-align: center; font-size: 15px; line-height: 20px; }
.pm-place.rejected { opacity: .55; }
.pm-place:hover, .pm-place.hot { transform: scale(1.25); }

.pm-pin-new { width: 22px; height: 22px; border-radius: 50%; background: var(--heart); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.5); }

.drop-popup .leaflet-popup-content { margin: 12px 14px; }
.drop-popup p { margin: 0 0 8px; color: var(--text-2); font-size: 13px; }

.map-status {
  position: absolute; z-index: 800; top: 12px; left: 50%; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 999px; background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow); font-size: 13px; font-weight: 500; white-space: nowrap; pointer-events: none;
}
.map-status.loading::before {
  content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Welcome card ---------- */

.welcome {
  position: absolute; z-index: 900; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 32px));
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 26px 26px 22px;
}
.welcome h1 { margin: 0 0 8px; font-size: 24px; line-height: 1.2; }
.welcome p { margin: 0 0 16px; color: var(--text-2); }
.welcome-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.welcome-chips button {
  border: 0; padding: 0; border-radius: 12px; overflow: hidden; cursor: pointer; position: relative;
  width: calc(33.33% - 6px); aspect-ratio: 4 / 3; background: var(--surface-2) center/cover;
}
.welcome-chips button span {
  position: absolute; inset: auto 0 0 0; padding: 14px 8px 6px; color: #fff; font-weight: 600; font-size: 13px; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
}
.welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons & forms ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-heart { background: var(--heart); border-color: var(--heart); color: #fff; }
.btn-heart:hover { background: color-mix(in srgb, var(--heart) 88%, black); }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-quiet { border-color: transparent; background: none; }
.btn:disabled { opacity: .55; cursor: default; }
.danger { color: var(--danger); }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface-2); cursor: pointer; flex: none; font-size: 15px; }
.icon-btn:hover { background: var(--line); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

input[type="text"], select, textarea {
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 7px 10px; outline: none;
}
input[type="text"]:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- My places list ---------- */

.list-head { padding: 14px 14px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.session-name { width: 100%; font-size: 18px; font-weight: 700; border-color: transparent !important; padding: 4px 6px !important; margin-left: -6px; background: none !important; }
.session-name:hover { border-color: var(--line) !important; }
.link-note { margin: 2px 0 6px; font-size: 13px; color: var(--ok); }
.stats { display: flex; gap: 6px; margin: 8px 0 10px; }
.stat { flex: 1; background: var(--surface-2); border-radius: 10px; padding: 7px 8px; text-align: center; }
.stat b { display: block; font-size: 16px; }
.stat span { font-size: 12px; color: var(--text-2); }
.list-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text-2); }
.select-label select { margin-left: 4px; padding: 4px 8px; font-size: 13px; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.place-list { list-style: none; margin: 0; padding: 8px; }
.place { border-radius: 12px; margin-bottom: 4px; border: 1px solid transparent; }
.place.open { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow); margin: 8px 0; }
.place.rejected .place-row { opacity: .55; }
.place.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.place-row { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 12px; }
.place-row:hover { background: var(--surface-2); }
.place.open .place-row:hover { background: none; }
.thumb { width: 52px; height: 52px; border-radius: 10px; flex: none; background: var(--surface-2) center/cover no-repeat; display: grid; place-items: center; font-size: 24px; }
.place-main { min-width: 0; flex: 1; }
.place-title { font-weight: 650; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.place-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--text-2); font-size: 12.5px; margin-top: 2px; align-items: center; }
.hearts { color: var(--heart); letter-spacing: 1px; }
.hearts .off { color: var(--line); }
.badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.badge.app { background: var(--surface-2); color: var(--text-2); }
.badge.new { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.edited { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

.editor { padding: 4px 12px 14px; display: grid; gap: 10px; }
.editor label { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.editor input[type="text"], .editor select, .editor textarea { width: 100%; color: var(--text); font-weight: 400; font-size: 14px; }
.editor textarea { min-height: 64px; resize: vertical; }
.editor .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.heart-picker { display: flex; gap: 2px; }
.heart-picker button { border: 0; background: none; font-size: 22px; line-height: 1; padding: 2px; cursor: pointer; color: var(--line); }
.heart-picker button.on { color: var(--heart); }
.segmented { display: flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { flex: 1; border: 0; background: none; padding: 5px 4px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.editor-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.editor-actions .danger { margin-left: auto; }
.editor .summary { font-size: 13px; color: var(--text-2); margin: 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Dialogs ---------- */

dialog { border: 0; padding: 0; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 14, 22, .55); backdrop-filter: blur(2px); }

.viewer {
  width: min(1180px, calc(100vw - 32px)); height: min(760px, calc(100vh - 32px));
  max-width: none; max-height: none; border-radius: 18px; overflow: hidden;
}
.viewer[open] { display: grid; grid-template-columns: 1fr 360px; }
.viewer-media { position: relative; background: #0b0d12; display: grid; place-items: center; min-height: 0; }
.viewer-media img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.viewer-media img[src=""] { display: none; }
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; z-index: 2;
}
.viewer-nav:hover { background: rgba(255, 255, 255, .28); }
.viewer-nav.prev { left: 14px; }
.viewer-nav.next { right: 14px; }
.viewer-media.no-image img { display: none; }
.viewer-media.no-image::after { content: "W"; font: 700 140px/1 Georgia, "Times New Roman", serif; color: #2a2f3a; }
.viewer-spinner { position: absolute; width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.viewer-info { position: relative; padding: 22px 22px 18px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.viewer-close { position: absolute; top: 14px; right: 14px; }
.viewer-kind { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 700; padding-right: 40px; }
.viewer-info h2 { margin: 0; font-size: 21px; line-height: 1.25; padding-right: 30px; overflow-wrap: anywhere; }
.viewer-text { color: var(--text); font-size: 14.5px; overflow-wrap: anywhere; }
.viewer-text p { margin: 0 0 8px; }
.viewer-meta { margin: 0; font-size: 12.5px; color: var(--text-2); }
.viewer-links { display: flex; gap: 8px; flex-wrap: wrap; }
.viewer-add { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.viewer-add .saved-note { color: var(--heart); font-weight: 650; margin: 0; }
.viewer-add .row { display: flex; gap: 8px; }
.viewer-add select { flex: 1; }

.sheet { width: min(560px, calc(100vw - 24px)); border-radius: 18px; padding: 0 22px 18px; max-height: calc(100vh - 32px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 6px; position: sticky; top: 0; background: var(--surface); }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sync-summary { margin: 0 0 6px; color: var(--text-2); font-size: 14px; }
.sync-block { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 12px 0; }
.sync-block h3 { margin: 0 0 6px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.sync-block p { margin: 0 0 12px; color: var(--text-2); font-size: 14px; }
.step { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 13px; }
.code-form { display: flex; gap: 8px; }
.code-input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  font: 600 20px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; outline: none;
}
.code-input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.code-out { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.code-big { font: 700 32px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .12em; padding: 12px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); user-select: all; }
.code-out .form-hint { flex-basis: 100%; }
.project-block { border: 1.5px solid var(--ok); }
.save-block { border: 1.5px solid var(--accent); }
.project-block h3 { display: flex; align-items: center; gap: 8px; }
.project-block .form-hint { margin-top: 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.form-msg { margin: 8px 0 0 !important; font-size: 13.5px; color: var(--danger) !important; }
.form-msg:empty { display: none; }
.form-msg.ok { color: var(--ok) !important; }
.form-hint { font-size: 12.5px; color: var(--text-2); margin: 0; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 4px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; z-index: 3000; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1c2430; color: #fff; padding: 10px 12px 10px 16px; border-radius: 12px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); font-size: 14px;
}
.toast button { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 8px; padding: 5px 10px; font-weight: 600; cursor: pointer; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .layers .chip span { display: none; }
  .layers .chip { padding: 0 10px; }
  :root { --panel-w: 360px; }
}

@media (max-width: 760px) {
  :root { --topbar-h: 100px; }
  .topbar { flex-wrap: wrap; height: auto; min-height: var(--topbar-h); padding: 8px 12px; gap: 8px; align-content: center; }
  .brand-text small { display: none; }
  .brand img { width: 28px; height: 28px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .search input { height: 38px; }
  .layers { margin-left: auto; }
  .sync-btn { margin-left: 0; height: 34px; padding: 0 12px; font-size: 14px; }
  #sync-label { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 480px) {
  .brand-text { display: none; }
  .layers .chip { padding: 0 9px; }
}
@media (max-width: 760px) {

  .layout { display: block; }
  .map-wrap { position: absolute; inset: 0; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; z-index: 1000;
    border-left: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.18);
    transition: height .25s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel[data-size="peek"] { height: 96px; }
  .panel[data-size="half"] { height: 46%; }
  .panel[data-size="full"] { height: calc(100% - 12px); }
  .panel-handle { display: block; width: 100%; height: 20px; border: 0; background: none; cursor: grab; flex: none; padding: 0; }
  .panel-handle span { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
  .tabs { padding-top: 0; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }

  .viewer { width: 100vw; height: 100dvh; border-radius: 0; }
  .viewer[open] { grid-template-columns: 1fr; grid-template-rows: 42% 1fr; }
  .viewer-nav { width: 40px; height: 40px; font-size: 26px; }
  .welcome { top: 38%; padding: 20px; }
  .welcome h1 { font-size: 20px; }
  .map-status { top: 8px; }
  .toast { bottom: calc(110px + env(safe-area-inset-bottom)); }
  .leaflet-control-layers { margin-bottom: 104px !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
