:root {
  color-scheme: dark;
  --bg: #07111f;
  --card: rgba(13, 25, 44, 0.88);
  --card-2: rgba(16, 36, 60, 0.94);
  --text: #e5f3ff;
  --muted: #9fb3c8;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --danger: #fb7185;
  --warning: #facc15;
  --line: rgba(148, 163, 184, 0.22);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 10%, rgba(56, 189, 248, 0.24), transparent 28rem),
    radial-gradient(circle at 90% 0%, rgba(34, 197, 94, 0.18), transparent 26rem),
    linear-gradient(135deg, #020617 0%, var(--bg) 58%, #0f172a 100%);
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2000;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 12px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  color: var(--text);
  font-weight: 900;
  font-size: 1.18rem;
  text-decoration: none;
  letter-spacing: -0.03em;
}

.main-nav,
.auth-nav,
.nav-auth-form {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.main-nav a {
  padding: 8px 11px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--text);
  background: rgba(148, 163, 184, 0.16);
}

.auth-nav {
  justify-content: flex-end;
}

.nav-user {
  color: #bae6fd;
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.nav-auth-form input {
  width: 120px;
  margin: 0;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.topbar button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  color: #02111f;
  background: linear-gradient(135deg, var(--accent), #67e8f9);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(56, 189, 248, 0.22);
  text-decoration: none;
}

.topbar button { padding: 8px 12px; font-size: 0.9rem; }

button.secondary,
.button-link.secondary {
  color: var(--text);
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid var(--line);
  box-shadow: none;
}

.app-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 30px 0 46px;
}

.hero,
.upload-card,
.map-card,
.gallery-card,
.subscription-card,
.shared-card,
.info-card,
.page-heading,
.user-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 22px;
  align-items: stretch;
  padding: clamp(22px, 5vw, 48px);
  margin-bottom: 22px;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px;
  margin-bottom: 22px;
}

.page-heading h1 {
  margin: 0 0 8px;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
}

.summary-pill {
  min-width: 240px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(2, 6, 23, 0.34);
}

.summary-pill strong,
.summary-pill span {
  display: block;
}

.summary-pill span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.info-card {
  padding: 22px;
}

.hero-actions {
  margin-top: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 800;
  font-size: 0.78rem;
}

h1,
h2,
h3 { margin-top: 0; }

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.6rem, 8vw, 6rem);
  line-height: 0.92;
  letter-spacing: -0.06em;
}

.hero p,
.muted,
.user-card p,
.status,
.quota {
  color: var(--muted);
  line-height: 1.6;
}

.tier-grid,
.plan-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.tier-grid article,
.plan-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(2, 6, 23, 0.34);
}

.tier-grid strong,
.tier-grid span { display: block; }
.tier-grid span { color: var(--muted); margin-top: 6px; }

.user-card {
  padding: 22px;
  background: var(--card-2);
}

.content {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 22px;
}

.upload-card,
.map-card,
.gallery-card,
.subscription-card,
.shared-card { padding: 22px; }

.standalone-card {
  max-width: 900px;
  margin: 0 auto;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading-row h2 {
  margin: 0;
}

.map-card { min-height: 650px; }
.gallery-card,
.subscription-card,
.shared-card { grid-column: 1 / -1; }
.shared-card { margin-bottom: 22px; }

label {
  display: block;
  margin: 14px 0;
  color: #dbeafe;
  font-weight: 700;
}

input,
textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: rgba(2, 6, 23, 0.66);
  outline: none;
  font: inherit;
}

textarea { resize: vertical; }

.checkbox-label {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.08);
}

.checkbox-label input {
  display: inline-block;
  width: auto;
  margin: 0;
}

.checkbox-label .muted {
  font-size: 0.84rem;
  font-weight: 500;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.14);
}

input:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 19px;
  color: #02111f;
  background: linear-gradient(135deg, var(--accent), #67e8f9);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(56, 189, 248, 0.22);
}

button.secondary {
  color: var(--text);
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.danger {
  color: white;
  background: rgba(251, 113, 133, 0.2);
  border: 1px solid rgba(251, 113, 133, 0.42);
  box-shadow: none;
}

.button-row,
.coords,
.map-heading {
  display: flex;
  gap: 12px;
}

.button-row { flex-wrap: wrap; }
.coords > label { flex: 1; }
.map-heading {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.map-heading h2 { margin-bottom: 0; }

/* Critical Leaflet layout CSS. The CDN stylesheet is still linked, but these
   local rules make the map reliable even if the external CSS is blocked or slow. */
.leaflet-container {
  position: relative;
  overflow: hidden;
  outline-offset: 1px;
  font: 12px/1.5 Arial, Helvetica, sans-serif;
  touch-action: pan-x pan-y;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }

.leaflet-tile {
  filter: inherit;
  visibility: hidden;
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile-loaded { visibility: inherit; }
.leaflet-zoom-animated { transform-origin: 0 0; }
.leaflet-marker-icon,
.leaflet-marker-shadow { display: block; }

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-control { position: relative; z-index: 800; pointer-events: auto; float: left; clear: both; }
.leaflet-right .leaflet-control { float: right; }
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; }

.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  text-decoration: none;
  color: #0f172a;
  background: #fff;
  border-bottom: 1px solid #cbd5e1;
  font-size: 20px;
  font-weight: bold;
}

.leaflet-control-zoom a:first-child { border-radius: 4px 4px 0 0; }
.leaflet-control-zoom a:last-child { border-bottom: 0; border-radius: 0 0 4px 4px; }
.leaflet-control-attribution { padding: 2px 6px; color: #334155; background: rgba(255,255,255,0.82); }
.leaflet-control-attribution a { color: #0369a1; }
.leaflet-popup,
.leaflet-tooltip { position: absolute; text-align: center; }
.leaflet-popup-content-wrapper { padding: 1px; text-align: left; border-radius: 12px; background: #fff; color: #0f172a; box-shadow: 0 3px 14px rgba(0,0,0,0.28); }
.leaflet-popup-content { margin: 14px; line-height: 1.4; }
.leaflet-tooltip { pointer-events: none; white-space: nowrap; }

#map,
#sharedMap {
  height: 560px;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #0f172a;
  isolation: isolate;
}

#sharedMap { height: 440px; }

/* Keep Leaflet's tile grid untouched by site image/card styles. Without these
   safeguards, browser or theme CSS can resize tile images and create gaps or
   make unrelated map tiles appear next to each other. */
.leaflet-container img.leaflet-tile {
  display: block !important;
  width: 256px !important;
  height: 256px !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  object-fit: fill !important;
  box-shadow: none !important;
}

.leaflet-container .leaflet-marker-icon,
.leaflet-container .leaflet-marker-shadow {
  max-width: none !important;
}

#map.location-change-active {
  cursor: crosshair;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.28), inset 0 0 0 2px rgba(34, 197, 94, 0.62);
}

.preview-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 14px 0;
}

#preview {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
}

.status,
.quota {
  padding: 12px;
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid var(--line);
}

.status.good { color: #bbf7d0; border-color: rgba(34, 197, 94, 0.42); }
.status.bad { color: #fecdd3; border-color: rgba(251, 113, 133, 0.42); }
.status.neutral { color: var(--muted); }

.paid-only {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #0f172a;
  background: var(--warning);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.plan-card.featured {
  border-color: rgba(56, 189, 248, 0.7);
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.18), rgba(34, 197, 94, 0.08));
}

.plan-card p { color: var(--muted); }
.plan-card strong { display: block; margin: 10px 0 16px; font-size: 1.35rem; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.gallery-manager {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1.15fr);
  gap: 20px;
  align-items: start;
  margin-top: 18px;
}

.gallery-select-list {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.image-select-card {
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: rgba(2, 6, 23, 0.42);
  text-align: left;
  box-shadow: none;
}

.image-select-card:hover,
.image-select-card.selected {
  border-color: rgba(56, 189, 248, 0.75);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.16);
}

.image-select-card img {
  display: block;
  width: 100%;
  height: 112px;
  object-fit: cover;
}

.image-select-card span,
.image-select-card small {
  margin: 10px 11px;
}

.image-select-card span {
  display: block;
  font-weight: 900;
}

.selected-image-panel {
  position: sticky;
  top: 92px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(2, 6, 23, 0.42);
}

.selected-image-preview {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.selected-image-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.selected-image-header h3 { margin-bottom: 8px; }
.selected-image-form { margin-top: 12px; }
.selected-meta {
  margin: 12px 0;
  padding: 12px;
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
}
.selected-meta p { margin: 0 0 8px; }
.selected-meta p:last-child { margin-bottom: 0; }

.image-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(2, 6, 23, 0.42);
}

.image-card img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.image-card-body { padding: 14px; }
.image-card h3 { margin: 0 0 8px; }
.image-card p { margin: 0 0 10px; color: var(--muted); font-size: 0.92rem; }
.image-card .comment { color: #dbeafe; }
.visibility-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.visibility-badge.public {
  color: #052e16;
  background: #86efac;
}
.visibility-badge.private {
  color: #fef3c7;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.36);
}

.photo-marker {
  border: 3px solid #e0f2fe;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.92);
  box-shadow: 0 12px 26px rgba(2, 6, 23, 0.48), 0 0 0 4px rgba(56, 189, 248, 0.22);
  overflow: hidden;
  transition: filter 160ms ease;
}

.photo-marker img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: cover;
}

.photo-marker span {
  display: none;
}

.photo-marker-selected {
  z-index: 900 !important;
  border-color: #67e8f9;
  box-shadow: 0 18px 42px rgba(8, 47, 73, 0.55), 0 0 0 6px rgba(34, 211, 238, 0.32);
}

.photo-mini-tooltip {
  padding: 3px 8px;
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 999px;
  color: #082f49;
  background: rgba(224, 242, 254, 0.96);
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.24);
}

.photo-mini-tooltip::before { display: none; }

.popup-show-button,
.popup-location-button {
  margin-left: 6px;
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  color: #02111f;
  background: linear-gradient(135deg, #38bdf8, #67e8f9);
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1.1;
  box-shadow: none;
}

.popup-location-button {
  color: #052e16;
  background: linear-gradient(135deg, #86efac, #22c55e);
}

.popup-show-button,
.popup-location-button {
  display: inline-flex;
  margin: 0 6px 8px 0;
  padding: 8px 12px;
  font-size: 0.78rem;
}

.photo-popup-content img,
.leaflet-popup-content img {
  display: block;
  width: 260px;
  max-width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  margin: 8px 0;
}

.photo-popup-content p { margin: 8px 0; }
.photo-popup-content small { display: block; color: #475569; }

.full-image-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 34px);
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(10px);
}

.full-image-dialog {
  max-width: min(1180px, 96vw);
  max-height: 94vh;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.36);
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.58);
}

.full-image-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.full-image-header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.full-image-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text);
  background: rgba(148, 163, 184, 0.18);
  border: 1px solid var(--line);
  box-shadow: none;
  font-size: 1.5rem;
  line-height: 1;
}

.full-image-dialog img {
  display: block;
  width: auto;
  height: auto;
  max-width: 96vw;
  max-height: calc(94vh - 62px);
  object-fit: contain;
  background: #020617;
}

.hidden { display: none !important; }

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .main-nav,
  .auth-nav {
    justify-content: flex-start;
  }
  .hero,
  .content,
  .info-grid,
  .gallery-manager { grid-template-columns: 1fr; }
  .page-heading {
    display: block;
  }
  .summary-pill {
    min-width: 0;
    margin-top: 16px;
  }
  .map-card { min-height: auto; }
  .selected-image-panel { position: static; }
}

@media (max-width: 700px) {
  .tier-grid,
  .plan-row { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 18px, 1220px); padding-top: 14px; }
  .hero,
  .upload-card,
  .map-card,
  .gallery-card,
  .subscription-card,
  .shared-card,
  .info-card,
  .page-heading,
  .user-card { border-radius: 18px; padding: 18px; }
  .nav-auth-form input { width: 100%; }
  .nav-auth-form { width: 100%; }
  .section-heading-row,
  .coords,
  .map-heading,
  .preview-row { display: block; }
  #map { height: 430px; }
  #sharedMap { height: 360px; }
}
