/* ===== RESET & CSS VARIABLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #18181f;
  --surface3: #22223a;
  --border: rgba(255,255,255,0.08);
  --accent: #4facfe;
  --accent2: #00f2fe;
  --red: #e53935;
  --text: #f0f0f8;
  --text2: #a0a0c0;
  --text3: #505070;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

html, body {
  height: 100%; width: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.hidden { display: none !important; }

body.screen-torch-on::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(255,255,255,0.34);
  pointer-events: none;
  mix-blend-mode: screen;
}

/* ===== SPLASH ===== */
.splash {
  position: fixed; top: 0; left: 0; right: 0;
  height: 100vh; height: 100dvh;
  z-index: 9999;
  background: linear-gradient(145deg, #060610 0%, #0b1a2e 60%, #060610 100%);
  display: flex; align-items: center; justify-content: center;
}
.splash::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 35%, rgba(79,172,254,0.18) 0%, transparent 65%);
}
.splash-inner {
  text-align: center; position: relative; z-index: 1;
  padding: 0 24px;
  width: min(520px, 100%);
  animation: splashIn 0.35s ease-out;
}
@keyframes splashIn {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.splash-icon { width: 118px; height: 118px; margin: 0 auto 28px; }
.splash-icon svg { width: 100%; height: 100%; filter: drop-shadow(0 0 24px rgba(79,172,254,0.55)); }
.splash-title {
  font-size: clamp(38px, 10vw, 54px); font-weight: 800; letter-spacing: 0;
  line-height: 1.05;
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.splash-brand { font-size: clamp(22px, 5.6vw, 31px); font-weight: 700; color: rgba(224,224,242,0.82); margin: 14px 0 18px; }
.splash-sub   { font-size: clamp(16px, 4.2vw, 23px); color: rgba(150,150,180,0.58); margin-bottom: 64px; }
.splash-loader { width: min(280px, 58vw); height: 5px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow: hidden; margin: 0 auto; }
.splash-bar   { height: 100%; background: linear-gradient(90deg,#4facfe,#00f2fe); border-radius: 2px; animation: loadBar 0.95s ease-in-out forwards; }
@keyframes loadBar { 0%{width:0} 55%{width:65%} 100%{width:100%} }

/* ===== APP SHELL ===== */
.app {
  position: fixed; top: 0; left: 0; right: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: #000;
  animation: fadeIn 0.35s ease-out;
  padding-top: var(--safe-top);
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

@media (orientation: portrait) {
  body.pwa-rotate-landscape {
    background: #000;
  }
  body.pwa-rotate-landscape .app,
  body.pwa-rotate-landscape .splash {
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    right: 0;
    bottom: 0;
    transform: none;
  }
  body.pwa-rotate-landscape .viewfinder-wrap {
    flex: 1 1 auto;
    min-height: 0;
  }
  body.pwa-rotate-landscape .controls-bar {
    inset: auto 0 0 0 !important;
    display: block !important;
    padding: 0 !important;
    height: calc(110px + env(safe-area-inset-bottom, 0px));
    min-height: 0;
    max-height: none;
    width: 100vw !important;
    width: 100dvw !important;
    transform: none !important;
  }
  body.pwa-rotate-landscape .ctrl-group {
    flex-direction: column;
  }
  body.pwa-rotate-landscape .gps-overlay-preview {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    left: auto;
    right: calc(env(safe-area-inset-right, 0px) + 12px);
    transform: none;
    max-width: min(284px, calc(55vw - 16px));
    padding: 7px;
    gap: 7px;
  }
  body.pwa-rotate-landscape .overlay-map-thumb {
    width: 58px;
    height: 58px;
  }
  body.pwa-rotate-landscape .shutter-btn {
    width: 62px;
    height: 62px;
  }
  body.pwa-rotate-landscape .shutter-inner {
    width: 48px;
    height: 48px;
  }
  body.pwa-rotate-landscape .vf-corner.bl,
  body.pwa-rotate-landscape .vf-corner.br {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 78px);
  }
}

/* ===== HEADER ===== */
.app-header {
  position: absolute; top: var(--safe-top); left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.88) 0%, transparent 100%);
}
.header-left  { display: flex; align-items: center; gap: 8px; min-width: 0; }
.app-logo {
  width: 30px; height: 30px; flex-shrink: 0;
  background: linear-gradient(135deg,rgba(79,172,254,.15),rgba(0,242,254,.1));
  border: 1px solid rgba(79,172,254,0.3);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.app-name     { font-size: 12.5px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
.header-right {
  display: flex;
  flex-flow: row nowrap;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  min-width: max-content;
}
.header-right .icon-btn { width: 34px; height: 34px; border-radius: 9px; }

@media (max-width: 380px) {
  .app-header { padding-left: 8px; padding-right: 8px; }
  .app-logo { width: 28px; height: 28px; }
  .app-name { max-width: 24vw; font-size: 12px; }
  .header-right { gap: 3px; }
  .header-right .icon-btn,
  .camera-tool-btn {
    width: 32px;
    height: 32px;
  }
}

/* ===== ICON BUTTON ===== */
.icon-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px; color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.18s, transform 0.12s; backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:active { transform: scale(0.92); background: rgba(79,172,254,0.25); }
.danger-btn:active { background: rgba(229,57,53,0.3); }

/* ===== VIEWFINDER ===== */
.viewfinder-wrap { flex: 1; position: relative; overflow: hidden; background: #000; }
.video-feed { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ===== GPS OVERLAY PREVIEW ===== */
.gps-overlay-preview {
  position: absolute;
  /* sits above controls bar */
  bottom: calc(120px + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 8px; align-items: flex-start;
  background: rgba(0,0,0,0.42); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 10px; padding: 8px;
  /* constrain width so overlay doesn't span full image width */
  max-width: min(340px, calc(100% - 18px));
  width: max-content;
  animation: slideUpCenter 0.4s ease-out;
  z-index: 12;
}

/* Animation portrait (default) */
@keyframes slideUpCenter {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
/* Animation landscape */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== LANDSCAPE ORIENTATION ADJUSTMENTS ===== */
@media (orientation: landscape) {
  /* Shrink map thumbnail in landscape to save space */
  .overlay-map-thumb { width: 58px; height: 58px; }

  /* Move overlay to bottom-right corner in landscape */
  .gps-overlay-preview {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    left: auto;
    right: calc(env(safe-area-inset-right, 0px) + 12px);
    transform: none;
    max-width: min(284px, calc(55vw - 16px));
    padding: 7px;
    gap: 7px;
    animation: slideInRight 0.4s ease-out;
  }

  /* Compact controls bar in landscape */
  .controls-bar {
    padding: 10px 36px calc(env(safe-area-inset-bottom, 0px) + 8px);
  }

  /* Smaller shutter button in landscape */
  .shutter-btn  { width: 62px; height: 62px; }
  .shutter-inner { width: 48px; height: 48px; }

  /* Viewfinder corners — reduce bottom offset in landscape */
  .vf-corner.bl,
  .vf-corner.br {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 78px);
  }

  /* Zoom bar — move to left side in landscape */
  .zoom-bar {
    display: none;
  }
  /* Toast adjust */
  .toast {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 90px);
  }
}

/* ===== ZOOM BAR ===== */
.zoom-bar {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: none !important;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.60);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 20px;
  padding: 8px 5px;
  z-index: 15;
  width: 38px;
  visibility: hidden;
  pointer-events: none;
}
.zoom-btn {
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 50%;
  color: white; font-size: 18px; font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; line-height: 1;
  transition: background 0.15s, transform 0.1s;
  padding: 0;
  font-family: inherit;
}
.zoom-btn:active { background: rgba(79,172,254,0.4); transform: scale(0.9); }
.zoom-btn:disabled { opacity: 0.3; pointer-events: none; }
.zoom-label {
  font-size: 10px; font-weight: 700;
  color: #4facfe; font-family: 'Roboto Mono', monospace;
  text-align: center; line-height: 1;
  padding: 2px 0;
}

.camera-tools {
  position: relative;
  display: flex;
  flex-direction: row;
  gap: 5px;
  align-items: center;
}
.camera-tool-btn {
  width: 34px;
  height: 34px;
}
.camera-tool-btn span {
  font-size: 15px;
  line-height: 1;
}
.camera-tool-btn.active {
  color: #ffd54f;
  border-color: rgba(255,213,79,0.7);
  background: rgba(255,213,79,0.22);
}
.camera-tool-btn:disabled { opacity: 0.35; }
.brightness-control {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}
.brightness-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  height: 128px;
  width: 42px;
  border-radius: 22px;
  background: rgba(0,0,0,0.72);
  border: 1px solid rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.brightness-panel input {
  width: 94px;
  transform: rotate(-90deg);
  transform-origin: center;
  accent-color: #4facfe;
}
.focus-reticle {
  position: absolute;
  width: 58px;
  height: 58px;
  margin-left: -29px;
  margin-top: -29px;
  border: 2px solid rgba(255,213,79,0.95);
  border-radius: 50%;
  z-index: 18;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
}
@keyframes focusPulse {
  from { transform: scale(1.35); opacity: 0; }
  25%  { opacity: 1; }
  to   { transform: scale(0.86); opacity: 0; }
}


.overlay-map-thumb {
  width: 74px; height: 74px; flex-shrink: 0;
  border-radius: 7px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.18);
  position: relative;
  background: transparent;
}
.overlay-map-thumb .leaflet-container,
#miniMap {
  background: transparent !important;
}
.mini-map-canvas,
#miniMap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 7px;
}
.mini-map-canvas {
  z-index: 2;
}
#miniMap {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}
.overlay-info   { flex: 1; min-width: 0; width: min(238px, calc(100vw - 116px)); }
.overlay-brand  {
  display: flex; align-items: center; gap: 3px;
  font-size: 8.5px; color: var(--accent2); font-weight: 600;
  letter-spacing: 0; margin-bottom: 2px;
}
.overlay-city   { font-size: 12.5px; font-weight: 700; color: white; line-height: 1.12; margin-bottom: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overlay-address{
  font-size: 9.8px; color: rgba(255,255,255,0.75); line-height: 1.14; margin-bottom: 2px;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.overlay-coords { font-size: 9.8px; color: var(--accent2); font-family: 'Roboto Mono', monospace; margin-bottom: 2px; }
.overlay-time   { font-size: 9.2px; color: rgba(255,255,255,0.58); margin-bottom: 1px; }
.overlay-note   { font-size: 8.8px; color: rgba(255,255,255,0.4); font-style: italic; }

/* ===== VIEWFINDER CORNERS ===== */
.vf-corners { position: absolute; inset: 0; pointer-events: none; }
.vf-corner { position: absolute; width: 22px; height: 22px; border-color: rgba(79,172,254,0.75); border-style: solid; }
.vf-corner.tl { top: 52px; left: 10px; border-width: 2px 0 0 2px; border-radius: 4px 0 0 0; }
.vf-corner.tr { top: 52px; right: 10px; border-width: 2px 2px 0 0; border-radius: 0 4px 0 0; }
/* corners stop above controls */
.vf-corner.bl { bottom: calc(120px + var(--safe-bottom) + 8px); left: 10px; border-width: 0 0 2px 2px; border-radius: 0 0 0 4px; }
.vf-corner.br { bottom: calc(120px + var(--safe-bottom) + 8px); right: 10px; border-width: 0 2px 2px 0; border-radius: 0 0 4px 0; }

/* ===== GPS STATUS BAR ===== */
.gps-status-bar {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.gps-indicator {
  display: flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 20px; padding: 4px 10px; font-size: 10.5px;
  border: 1px solid rgba(255,255,255,0.09);
}
.gps-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.gps-searching .gps-dot { background: #ffa500; animation: gpsPulse 1s infinite; }
.gps-found  .gps-dot { background: #4caf50; }
.gps-error  .gps-dot { background: var(--red); }
@keyframes gpsPulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.35;transform:scale(0.75)} }

.accuracy-badge {
  background: rgba(79,172,254,0.18); border: 1px solid rgba(79,172,254,0.35);
  border-radius: 12px; padding: 3px 8px; font-size: 9.5px; color: var(--accent);
}

/* ===== PERMISSION OVERLAY ===== */
.permission-overlay {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.permission-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 24px; text-align: center; max-width: 300px; width: 100%;
}
.permission-icon { font-size: 48px; margin-bottom: 14px; }
.permission-box h3 { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.permission-box p  { color: var(--text2); font-size: 13px; margin-bottom: 20px; line-height: 1.55; }
.btn-primary {
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  color: #000; font-weight: 700; font-size: 14px;
  border: none; border-radius: 10px; padding: 13px 28px;
  cursor: pointer; transition: opacity 0.2s; width: 100%;
}
.btn-primary:active { opacity: 0.82; }

/* ===== CONTROLS BAR (overlay inside viewfinder) ===== */
.controls-bar {
  position: fixed !important;
  inset: auto 0 0 0 !important;
  z-index: 99;
  /* gradient so controls are readable over any camera scene */
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.45) 60%, transparent 100%);
  display: block !important;
  padding: 0 !important;
  height: calc(116px + var(--safe-bottom));
  min-height: 0;
  max-height: none;
  width: 100vw !important;
  width: 100dvw !important;
  writing-mode: horizontal-tb;
  transform: none !important;
  pointer-events: auto;
}
.ctrl-group  {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  position: absolute !important;
  bottom: calc(var(--safe-bottom) + 12px);
  min-width: 64px;
  transform: translateX(-50%) !important;
  writing-mode: horizontal-tb;
}
.ctrl-gallery { left: 18% !important; }
.ctrl-capture { left: 50% !important; bottom: calc(var(--safe-bottom) + 13px); }
.ctrl-timer   { left: 82% !important; }

@media (max-width: 380px) {
  .ctrl-gallery { left: 17% !important; }
  .ctrl-timer   { left: 83% !important; }
}
.ctrl-label  { font-size: 9.5px; color: rgba(255,255,255,0.6); letter-spacing: 0.2px; }

.gallery-btn {
  width: 54px; height: 54px;
  background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.2);
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color 0.18s; overflow: hidden;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.gallery-btn:active { border-color: var(--accent); transform: scale(0.94); }
.last-photo-thumb { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.5); }
.last-photo-thumb svg { width: 22px; height: 22px; }
.last-photo-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Shutter */
.shutter-btn {
  width: 76px; height: 76px; border-radius: 50%;
  background: transparent; border: 3px solid rgba(255,255,255,0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.12s; position: relative;
}
.shutter-btn::before {
  content: ''; position: absolute; inset: -7px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,0.22);
  animation: shutterRing 2.2s infinite;
}
@keyframes shutterRing { 0%,100%{opacity:0.22;transform:scale(1)} 50%{opacity:0.55;transform:scale(1.06)} }
.shutter-inner {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.88) 100%);
  transition: transform 0.12s, background 0.15s;
}
.shutter-btn:active { transform: scale(0.93); }
.shutter-btn:active .shutter-inner { transform: scale(0.86); background: rgba(79,172,254,0.88); }

/* Timer */
.timer-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px; padding: 8px 14px; color: white; cursor: pointer;
  transition: background 0.18s; font-size: 10px; font-family: inherit; min-width: 52px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.timer-btn svg { width: 20px; height: 20px; }
.timer-btn:active, .timer-btn.active { background: rgba(79,172,254,0.28); border-color: rgba(79,172,254,0.6); }

/* ===== MODALS ===== */
.modal {
  position: fixed; top: 0; left: 0; right: 0;
  height: 100vh; height: 100dvh;
  z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: slideInUp 0.28s ease-out;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
@keyframes slideInUp { from{transform:translateY(100%)} to{transform:translateY(0)} }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.modal-header h2 { font-size: 17px; font-weight: 600; }

.viewer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface); gap: 8px;
}
.viewer-title  { font-size: 14px; font-weight: 500; color: var(--text2); flex: 1; text-align: center; }
.viewer-actions{ display: flex; gap: 6px; }

/* Gallery */
.gallery-grid {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 2px; padding: 2px; align-content: start;
}
.gallery-item { aspect-ratio: 1; position: relative; cursor: pointer; overflow: hidden; background: var(--surface2); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; display: block; }
.gallery-item:active img { transform: scale(1.04); }
.gallery-item-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.72));
  padding: 8px 5px 4px; font-size: 8.5px; color: rgba(255,255,255,0.75);
}
.gallery-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: var(--text3); text-align: center; line-height: 1.6;
}
.empty-icon { font-size: 56px; }

/* Photo Map */
.photo-map-modal { background: #000; }
.photo-map {
  flex: 1;
  min-height: 0;
  background: #071018;
}
.map-empty {
  position: absolute;
  inset: 58px 0 0;
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: rgba(0,0,0,0.72);
  color: var(--text2);
  text-align: center;
  line-height: 1.6;
  pointer-events: none;
}
.photo-thumb-marker {
  width: 92px !important;
  height: 92px !important;
  margin-left: -46px !important;
  margin-top: -46px !important;
  border-radius: 18px;
  border: 0;
  background: transparent;
  overflow: visible;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto !important;
}
.photo-marker-hit {
  position: absolute;
  inset: 7px;
  padding: 0;
  border: 3px solid rgba(255,255,255,0.96);
  border-radius: 18px;
  background: #111;
  box-shadow: 0 8px 22px rgba(0,0,0,0.52), 0 0 0 5px rgba(79,172,254,0.18);
  overflow: visible;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.photo-marker-hit::after {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 28px;
}
.photo-marker-hit img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  display: block;
  pointer-events: none;
}
.photo-marker-hit b {
  position: absolute;
  right: -12px;
  top: -12px;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e53935;
  border: 2px solid #fff;
  color: #fff;
  font-size: 14px;
  line-height: 26px;
  text-align: center;
  pointer-events: none;
}
.map-location-panel {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(var(--safe-bottom) + 10px);
  z-index: 120;
  background: rgba(10,10,15,0.92);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.45);
  overflow: hidden;
}
.map-location-panel.expanded {
  top: auto;
  max-height: min(58vh, 470px);
}
.map-location-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 8px;
}
.map-location-head strong {
  display: block;
  font-size: 14px;
  color: white;
  margin-bottom: 3px;
}
.map-location-head span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11px;
  color: var(--text2);
  line-height: 1.4;
}
.map-location-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  max-height: min(42vh, 340px);
  padding: 0 12px 12px;
  -webkit-overflow-scrolling: touch;
}
.map-photo-item {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0f1118;
  color: white;
  padding: 0;
  position: relative;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 18px rgba(0,0,0,0.24);
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.map-photo-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
  display: block;
}
.map-photo-item span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 6px 6px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(transparent, rgba(0,0,0,0.86));
}

@media (orientation: landscape) {
  .map-location-panel.expanded {
    left: auto;
    right: calc(env(safe-area-inset-right, 0px) + 10px);
    width: min(360px, 42vw);
    max-height: calc(100vh - 86px);
  }
  .map-location-photos {
    max-height: calc(100vh - 190px);
  }
}

/* Photo Viewer */
.photo-viewer { background: #000; }
.viewer-body  { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 8px; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.viewer-meta  { padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text2); line-height: 1.9; }

/* ===== SETTINGS SIDE PANEL ===== */
.side-panel {
  position: fixed; top: 0; left: 0; right: 0;
  height: 100vh; height: 100dvh;
  z-index: 200;
  display: flex; justify-content: flex-end;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.side-panel-backdrop { position: absolute; inset: 0; }
.side-panel-inner {
  position: relative; z-index: 1;
  width: min(340px, 92vw);
  background: var(--surface);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  animation: slideInRight 0.28s ease-out;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
@keyframes slideInRight { from{transform:translateX(100%)} to{transform:translateX(0)} }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; background: var(--surface2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.panel-header h2 { font-size: 17px; font-weight: 600; }
.panel-body      { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; }

.setting-group    { margin-bottom: 22px; }
.setting-group h3 {
  font-size: 10px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;
}
.toggle-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer; font-size: 13.5px;
}
.toggle-item input { display: none; }
.toggle-switch {
  width: 44px; height: 26px; background: var(--surface3);
  border-radius: 13px; position: relative; transition: background 0.2s; flex-shrink: 0;
}
.toggle-switch::after {
  content: ''; position: absolute;
  width: 20px; height: 20px; background: white;
  border-radius: 50%; top: 3px; left: 3px;
  transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-item input:checked + .toggle-switch { background: var(--accent); }
.toggle-item input:checked + .toggle-switch::after { transform: translateX(18px); }

.setting-input {
  width: 100%; padding: 11px 13px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: 13px;
  outline: none; transition: border-color 0.2s; font-family: inherit;
}
.setting-input:focus { border-color: var(--accent); }
.setting-select {
  width: 100%; padding: 11px 13px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: 13px; font-family: inherit;
  outline: none; cursor: pointer; -webkit-appearance: none;
}
.info-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px;
  font-size: 12px; color: var(--text2); line-height: 1.6;
}
.settings-info-group { display: none; }

/* ===== TIMER COUNTDOWN ===== */
.timer-countdown {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.countdown-number {
  font-size: 110px; font-weight: 800; color: white;
  text-shadow: 0 0 50px rgba(79,172,254,0.75);
  animation: countPulse 0.9s ease-out;
}
@keyframes countPulse { from{transform:scale(1.4);opacity:0} to{transform:scale(1);opacity:1} }

/* ===== FLASH ===== */
.flash-effect { position: fixed; inset: 0; z-index: 400; background: white; animation: flashAnim 0.3s ease-out forwards; }
@keyframes flashAnim { 0%{opacity:1} 100%{opacity:0} }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: calc(150px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: rgba(20,20,35,0.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1); color: white;
  padding: 10px 22px; border-radius: 22px; font-size: 13px;
  z-index: 500; white-space: nowrap; max-width: calc(100vw - 32px);
  animation: toastIn 0.28s ease-out;
}
@keyframes toastIn { from{opacity:0;transform:translateX(-50%) translateY(10px)} to{opacity:1;transform:translateX(-50%) translateY(0)} }

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-control-attribution,
.leaflet-control-zoom { display: none !important; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ===== IN-APP BROWSER WARNING ===== */
.in-app-warning {
  background: linear-gradient(135deg, #ff9800, #f57c00);
  color: #000;
  font-size: 11.5px;
  font-weight: 700;
  padding: 10px 14px;
  text-align: center;
  z-index: 1000;
  position: relative;
  line-height: 1.45;
  border-bottom: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

/* ===== SETTINGS: FIELD LABEL ===== */
.setting-field {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 10px;
}
.setting-field:last-child { margin-bottom: 0; }
.setting-field label {
  font-size: 11.5px; font-weight: 500;
  color: var(--text2); letter-spacing: 0.1px;
}

/* ===== SETTINGS: SAVED BADGE ===== */
.settings-saved-badge {
  font-size: 11.5px; font-weight: 600;
  color: #4caf50;
  background: rgba(76,175,80,0.12);
  border: 1px solid rgba(76,175,80,0.3);
  border-radius: 12px; padding: 3px 10px;
  animation: fadeInBadge 0.2s ease;
}
@keyframes fadeInBadge { from{opacity:0;transform:scale(0.9)} to{opacity:1;transform:scale(1)} }

/* ===== SETTINGS: RESET BUTTON ===== */
.btn-reset-settings {
  margin-top: 12px;
  width: 100%; padding: 11px;
  background: rgba(229,57,53,0.1);
  border: 1px solid rgba(229,57,53,0.3);
  border-radius: 10px;
  color: #ef5350; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.18s;
  font-family: inherit;
}
.btn-reset-settings:active { background: rgba(229,57,53,0.22); }
