:root {
  --ink: #000000;
  --paper: #f7f7f5;
  --accent: #f47d54;
  --accent-light: #fce0d5;
  --green: #324e3f;
  --green-light: #d4e4d9;
  --blue: #009b9e;
  --blue-light: #c8eced;
  --gold: #faca39;
  --shadow: rgba(0,0,0,0.10);
  --radius: 10px;
  --teal: #009b9e;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Source Sans 3', 'Open Sans', sans-serif;
  background: var(--paper); color: var(--ink);
  height: 100vh; overflow: hidden;
}

/* ── HEADER ── */
#app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: #000; color: #fff;
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.header-brand {
  display: flex; align-items: center; gap: 16px;
}
.header-brand img {
  height: 30px; width: auto;
}
.header-brand .divider {
  width: 1px; height: 28px;
  background: rgba(255,255,255,0.25);
}
#app-header h1 {
  font-family: 'Staatliches', sans-serif;
  font-size: 22px; font-weight: 400;
  letter-spacing: 2px; text-transform: uppercase;
}
#app-header h1 span { color: var(--teal); }
.header-controls { display: flex; gap: 8px; align-items: center; }
.header-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--paper); padding: 6px 14px;
  border-radius: 6px; font-size: 13px;
  cursor: pointer; font-family: inherit; font-weight: 500;
  transition: all 0.2s;
}
.header-btn:hover { background: rgba(255,255,255,0.2); }
.header-btn.active { background: var(--teal); border-color: var(--teal); }
.header-btn.admin-btn.active { background: var(--gold); border-color: var(--gold); color: #000; }

/* ── MAP ── */
#map { position: fixed; top: 56px; left: 0; right: 0; bottom: 0; z-index: 1; }

/* ── SIDEBAR ── */
#sidebar {
  position: fixed; top: 56px; right: 0; bottom: 0;
  width: 400px; z-index: 900;
  background: var(--paper);
  border-left: 1px solid rgba(0,0,0,0.08);
  box-shadow: -4px 0 24px var(--shadow);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
#sidebar.open { transform: translateX(0); }
.sidebar-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.sidebar-header h2 {
  font-family: 'Staatliches', sans-serif;
  font-size: 22px; font-weight: 400; flex: 1; padding-right: 12px;
  letter-spacing: 0.5px;
}
.sidebar-header .close-btn {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--ink); opacity: 0.5;
  padding: 4px; line-height: 1; flex-shrink: 0;
}
.sidebar-header .close-btn:hover { opacity: 1; }
.sidebar-body { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: rgba(26,26,26,0.5); margin-bottom: 6px;
}
.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: 8px; font-family: inherit;
  font-size: 14px; background: #fff;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: var(--teal);
}
.form-group textarea { resize: vertical; min-height: 100px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-btn {
  padding: 5px 12px; border-radius: 20px;
  border: 1.5px solid rgba(0,0,0,0.12);
  background: #fff; font-size: 12px;
  cursor: pointer; font-family: inherit;
  font-weight: 500; transition: all 0.2s;
}
.tag-btn:hover { border-color: var(--teal); }
.tag-btn.selected { background: var(--teal); color: #fff; border-color: var(--teal); }

.file-drop {
  border: 2px dashed rgba(0,0,0,0.12);
  border-radius: 8px; padding: 24px;
  text-align: center; cursor: pointer;
  transition: all 0.2s; background: #fff;
}
.file-drop:hover { border-color: var(--teal); background: rgba(0,155,158,0.03); }
.file-drop.has-file { border-color: var(--green); background: var(--green-light); }
.file-drop p { font-size: 13px; color: rgba(26,26,26,0.5); }
.file-drop p strong { color: var(--teal); }
.file-drop input { display: none; }
.preview-thumb {
  max-width: 100%; max-height: 160px;
  border-radius: 6px; margin-top: 10px; object-fit: cover;
}

.submit-btn {
  width: 100%; padding: 13px;
  background: var(--teal); color: #fff;
  border: none; border-radius: 8px;
  font-family: inherit; font-size: 15px;
  font-weight: 600; cursor: pointer;
  transition: all 0.2s; margin-top: 8px;
}
.submit-btn:hover { background: #007d80; transform: translateY(-1px); }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.submit-btn.admin-submit { background: var(--gold); color: #000; }
.submit-btn.admin-submit:hover { background: #e0b520; }

.coord-display {
  background: rgba(0,0,0,0.04); padding: 8px 12px;
  border-radius: 6px; font-size: 12px;
  font-family: monospace; color: rgba(26,26,26,0.6);
  display: flex; align-items: center; justify-content: space-between;
}

/* ── GPS BUTTON ── */
.gps-btn {
  background: var(--teal); color: #fff;
  border: none; border-radius: 6px;
  padding: 6px 12px; font-size: 12px;
  font-family: inherit; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
}
.gps-btn:hover { background: #007d80; }
.gps-btn:disabled { opacity: 0.5; cursor: wait; }
.gps-msg {
  font-size: 12px; margin-top: 6px;
  color: rgba(26,26,26,0.5);
}
.gps-msg.error { color: var(--accent); }
.gps-msg.success { color: var(--green); }

/* ── LINK FIELDS ── */
.link-input-group { margin-bottom: 8px; }
.link-input-group input {
  font-size: 13px; padding: 8px 10px;
}
.link-input-group .link-row {
  display: flex; gap: 8px; margin-bottom: 6px;
}
.link-input-group .link-row input:first-child { flex: 1; }
.link-input-group .link-row input:last-child { flex: 2; }

/* ── LINKS IN DETAIL VIEW ── */
.detail-links {
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.detail-links h4 {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: rgba(26,26,26,0.4); margin-bottom: 8px;
}
.detail-links a {
  display: block; padding: 6px 0;
  color: var(--teal); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: color 0.2s;
}
.detail-links a:hover { color: #007d80; text-decoration: underline; }

/* ── MEMORY DETAIL ── */
.memory-detail .category-badge,
.official-detail .type-badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 12px; font-size: 11px;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 12px;
}
.category-badge.personal, .type-badge.memorial { background: var(--accent-light); color: var(--accent); }
.category-badge.academic, .type-badge.building { background: var(--blue-light); color: var(--blue); }
.category-badge.social { background: #f0e0f5; color: #8b4d9e; }
.category-badge.nature, .type-badge.nature { background: var(--green-light); color: var(--green); }
.category-badge.art, .type-badge.art { background: #fce8d5; color: #b8763e; }
.type-badge.cultural { background: #fce8d5; color: #b8763e; }
.type-badge.housing { background: #e8e4f0; color: #5a4d7e; }

.description { font-size: 15px; line-height: 1.65; margin-bottom: 16px; }
.memory-image {
  width: 100%; border-radius: 8px; margin-bottom: 16px;
  object-fit: cover; max-height: 260px;
}
.author { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.meta { font-size: 12px; color: rgba(26,26,26,0.45); }

/* ── LOADING ── */
.loading-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── LEGEND ── */
#legend {
  position: fixed; bottom: 24px; left: 24px; z-index: 800;
  background: var(--paper); border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: 0 4px 20px var(--shadow);
  font-size: 12px; border: 1px solid rgba(0,0,0,0.06);
}
#legend h3 {
  font-family: 'Staatliches', sans-serif;
  font-size: 14px; margin-bottom: 10px; font-weight: 400;
  letter-spacing: 0.5px;
}
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); flex-shrink: 0;
}

/* ── PROMPTS & TOASTS ── */
#click-prompt {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 800; background: var(--ink); color: var(--paper);
  padding: 10px 24px; border-radius: 24px; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  pointer-events: none; opacity: 0; transition: opacity 0.4s;
}
#click-prompt.visible { opacity: 1; }
#toast {
  position: fixed; top: 72px; left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 1100; background: var(--green); color: #fff;
  padding: 10px 24px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  opacity: 0; transition: all 0.3s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--accent); }

/* ── CONFIG BANNER ── */
#config-banner {
  position: fixed; top: 56px; left: 0; right: 0;
  z-index: 999; background: #fef3cd; color: #856404;
  padding: 10px 24px; font-size: 13px;
  border-bottom: 1px solid #ffc107;
  text-align: center; display: none;
}
#config-banner code {
  background: rgba(0,0,0,0.08); padding: 2px 6px;
  border-radius: 3px; font-size: 12px;
}
#config-banner.visible { display: block; }

/* ── MARKERS ── */
.marker-official {
  background: var(--blue); width: 28px; height: 28px;
  border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; cursor: pointer; transition: transform 0.2s;
}
.marker-official:hover { transform: scale(1.2); }
.marker-official.cultural { background: var(--gold); }
.marker-official.art { background: #8b4d9e; }
.marker-official.nature { background: var(--green); }
.marker-official.memorial { background: var(--accent); }
.marker-official.housing { background: #6a5d8e; }

.marker-memory {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  cursor: pointer; transition: transform 0.2s;
}
.marker-memory:hover { transform: scale(1.25); }
.marker-memory.personal { background: var(--accent); }
.marker-memory.academic { background: var(--blue); }
.marker-memory.social { background: #8b4d9e; }
.marker-memory.nature { background: var(--green); }
.marker-memory.art { background: #b8763e; }

.marker-new {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--teal); border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(0,155,158,0.3), 0 2px 8px rgba(0,0,0,0.3);
  animation: pulse-ring 1.5s infinite;
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 4px rgba(0,155,158,0.3), 0 2px 8px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 0 10px rgba(0,155,158,0.1), 0 2px 8px rgba(0,0,0,0.3); }
  100% { box-shadow: 0 0 0 4px rgba(0,155,158,0.3), 0 2px 8px rgba(0,0,0,0.3); }
}

/* ── LANDMARK LABELS ── */
.landmark-label {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #1a1a1a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  text-shadow:
    -1px -1px 0 rgba(255,255,255,0.9),
     1px -1px 0 rgba(255,255,255,0.9),
    -1px  1px 0 rgba(255,255,255,0.9),
     1px  1px 0 rgba(255,255,255,0.9),
     0    2px 4px rgba(0,0,0,0.15);
  pointer-events: none;
}

/* ── AUTH MODAL ── */
#auth-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
#auth-overlay.visible { display: flex; }
#auth-modal {
  background: var(--paper); border-radius: 12px;
  padding: 32px; width: 380px; max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  position: relative;
}
#auth-modal h2 {
  font-family: 'Staatliches', sans-serif;
  font-size: 24px; letter-spacing: 1px;
  margin-bottom: 20px;
}
#auth-modal .close-btn {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; font-size: 20px;
  cursor: pointer; opacity: 0.5; color: var(--ink);
}
#auth-modal .close-btn:hover { opacity: 1; }
#auth-modal .form-group { margin-bottom: 16px; }
#auth-modal .auth-error {
  color: var(--accent); font-size: 13px;
  margin-bottom: 12px; display: none;
}
#auth-modal .auth-error.visible { display: block; }
#auth-modal .auth-toggle {
  text-align: center; margin-top: 16px;
  font-size: 13px; color: rgba(0,0,0,0.5);
}
#auth-modal .auth-toggle a {
  color: var(--teal); cursor: pointer;
  text-decoration: none; font-weight: 600;
}
#auth-modal .auth-toggle a:hover { text-decoration: underline; }

/* ── USER BADGE (header) ── */
.user-badge {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; padding: 4px 12px;
  font-size: 13px; color: var(--paper);
}
.user-badge .user-email {
  max-width: 120px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500;
}
.user-badge .signout-btn {
  background: none; border: none;
  color: rgba(255,255,255,0.6); cursor: pointer;
  font-size: 11px; font-family: inherit;
  padding: 2px 4px;
}
.user-badge .signout-btn:hover { color: #fff; }

/* ── EDIT/DELETE BUTTONS ── */
.detail-actions {
  display: flex; gap: 8px; margin-top: 16px;
  padding-top: 16px; border-top: 1px solid rgba(0,0,0,0.06);
}
.detail-actions button {
  flex: 1; padding: 8px; border-radius: 6px;
  font-family: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-edit {
  background: var(--teal); color: #fff; border: none;
}
.btn-edit:hover { background: #007d80; }
.btn-delete {
  background: none; color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-delete:hover { background: var(--accent-light); }

/* ── POST LIMIT NOTICE ── */
.limit-notice {
  background: #fef3cd; color: #856404;
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px;
  text-align: center;
}

@media (max-width: 640px) {
  #sidebar { width: 100%; }
  #legend { bottom: 12px; left: 12px; right: 12px; }
  .header-btn span.label { display: none; }
  .header-brand img { height: 22px; }
  .header-brand .divider { height: 20px; }
  #app-header h1 { font-size: 18px; }
}
