/* ============== TOKENS ============== */
:root {
  --bg-0: #1f1b30;
  --bg-1: #2a2540;
  --bg-2: #362f4e;
  --line:  rgba(255, 240, 220, 0.13);
  --line-strong: rgba(255, 240, 220, 0.26);

  --ink:        #fbf3e3;
  --ink-soft:   #e5dcc7;
  --ink-mute:   #a59cb3;

  --accent:        #ff7a4d;   /* vivid sunset */
  --accent-soft:   #ffd166;   /* bright gold */
  --accent-deep:   #e85a2e;
  --sage:          #95d5b2;
  --plum:          #9a82d6;
  --rose:          #ff9eb5;

  --visited:    #ff7a4d;
  --has-cities: #ff9166;
  --pin-city:   #ffce5e;

  --radius:    14px;
  --radius-sm: 10px;
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);

  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
}

/* ============== LOADING ============== */
.loading-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: grid; place-items: center;
  background: var(--bg-0);
  transition: opacity 400ms ease;
}
.loading-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.loading-pin {
  color: var(--accent-soft);
  animation: loading-pulse 1.6s ease-in-out infinite;
}
@keyframes loading-pulse {
  0%, 100% { opacity: 0.5; transform: scale(0.9); }
  50%       { opacity: 1.0; transform: scale(1.1); }
}
.loading-inner p { color: var(--ink-mute); font-size: 14px; margin: 0; }

/* ============== RESET ============== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg-0);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
h1, h2, h3 { margin: 0; font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.01em; }

/* Aurora background */
.aurora {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(60% 50% at 8% 0%,    rgba(255, 122, 77, 0.36), transparent 60%),
    radial-gradient(55% 45% at 100% 100%, rgba(154, 130, 214, 0.38), transparent 65%),
    radial-gradient(45% 40% at 60% 30%,  rgba(255, 209, 102, 0.18), transparent 70%),
    radial-gradient(50% 45% at 92% 8%,   rgba(255, 158, 181, 0.22), transparent 65%),
    linear-gradient(180deg, #1f1b30 0%, #18152a 100%);
}

.pin {
  position: relative;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--pin-city);
  border: 2px solid #2a2540;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 0 18px rgba(255, 206, 94, 0.95), 0 6px 14px rgba(0, 0, 0, 0.45);
  z-index: 1;
}
.pin-wrap::before {
  content: ''; position: absolute; inset: -10px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 206, 94, 0.65), rgba(255, 206, 94, 0));
  pointer-events: none;
}

/* ============== TOPBAR ============== */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  background: rgba(20, 18, 26, 0.55);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(224, 122, 95, 0.30), rgba(242, 204, 143, 0.18));
  color: var(--accent-soft);
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.brand-text h1 {
  font-size: 22px; line-height: 1;
}
.brand-text .subtitle {
  margin: 4px 0 0;
  font-size: 13px; color: var(--ink-mute);
  font-family: var(--font-serif); font-style: italic;
}

.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,0.02); }
.tab {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13.5px; font-weight: 500;
  color: var(--ink-soft);
  transition: all 200ms ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  background: linear-gradient(180deg, rgba(224, 122, 95, 0.92), rgba(181, 78, 52, 0.92));
  color: #fff;
  box-shadow: 0 6px 20px rgba(224, 122, 95, 0.30);
}

.stats { display: flex; justify-content: flex-end; gap: 18px; }
.stat {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 6px 14px; border-left: 1px solid var(--line);
}
.stat:first-child { border-left: none; }
.stat-num { font-family: var(--font-serif); font-size: 24px; font-weight: 600; color: var(--accent-soft); line-height: 1; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-mute); margin-top: 4px; }

/* ============== LAYOUT ============== */
.layout {
  height: calc(100vh - 81px);
  position: relative;
}
.view {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  opacity: 0; pointer-events: none;
  transition: opacity 250ms ease;
}
.view.is-active { opacity: 1; pointer-events: auto; }

/* ============== PANEL ============== */
.panel {
  background: linear-gradient(180deg, rgba(27, 24, 34, 0.78), rgba(20, 18, 26, 0.78));
  border-right: 1px solid var(--line);
  padding: 24px 22px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 22px;
}
.panel-head h2 { font-size: 28px; }
.panel-head .hint { margin: 6px 0 0; color: var(--ink-mute); font-size: 13px; line-height: 1.5; }

.panel-section { display: flex; flex-direction: column; gap: 10px; }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--ink-mute); font-weight: 600;
}
.muted { color: var(--ink-mute); font-weight: 400; }

/* Search */
.search-row {
  position: relative;
  display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-mute); pointer-events: none;
}
.search-row input {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px 10px 34px;
  color: var(--ink);
  font-family: inherit; font-size: 13.5px;
  transition: border-color 160ms ease, background 160ms ease;
}
.search-row input::placeholder { color: var(--ink-mute); }
.search-row input:focus {
  outline: none;
  border-color: rgba(224, 122, 95, 0.55);
  background: rgba(255,255,255,0.05);
}

.btn-add {
  width: 100%;
  gap: 6px;
}

/* Country groups */
.country-groups { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.country-groups > li.empty {
  background: transparent; border: 1px dashed var(--line); border-radius: var(--radius-sm);
  color: var(--ink-mute); font-size: 13px; text-align: center; padding: 16px 12px;
}
.country-group {
  list-style: none;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 160ms ease;
}
.group-head:hover { background: rgba(255,255,255,0.04); }
.group-head .flag { font-size: 18px; line-height: 1; }
.group-head .name { font-weight: 500; color: var(--ink); flex: 1; }
.group-head .meta { font-size: 12px; color: var(--ink-mute); }
.group-head .chev {
  width: 14px; height: 14px; color: var(--ink-mute);
  transition: transform 180ms ease;
}
.group-head .trash-country {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 6px; color: var(--ink-mute);
  opacity: 0; transition: all 140ms ease;
  flex-shrink: 0;
}
.country-group:hover .group-head .trash-country { opacity: 1; }
.group-head .trash-country:hover { background: rgba(255, 90, 80, 0.12); color: #ef9b94; }
.country-group.is-collapsed .chev { transform: rotate(-90deg); }
.country-group.is-collapsed .city-sublist { display: none; }

.city-sublist {
  list-style: none; margin: 0; padding: 4px 8px 8px;
  display: flex; flex-direction: column; gap: 2px;
  border-top: 1px solid var(--line);
}
.city-sublist li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 140ms ease;
}
.city-sublist li:hover { background: rgba(255,255,255,0.04); }
.city-sublist .pin-mini {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--pin-city); flex-shrink: 0;
  box-shadow: 0 0 6px rgba(242,204,143,0.55);
}
.city-sublist .city-info { flex: 1; min-width: 0; }
.city-sublist .city-name {
  font-size: 13.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.city-sublist .city-date { font-size: 11.5px; color: var(--ink-mute); }
.city-sublist .edit-city,
.city-sublist .trash {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 6px; color: var(--ink-mute);
  opacity: 0; transition: all 140ms ease; flex-shrink: 0;
}
.city-sublist li:hover .edit-city,
.city-sublist li:hover .trash { opacity: 1; }
.city-sublist .edit-city:hover { background: rgba(154, 130, 214, 0.15); color: var(--plum); }
.city-sublist .trash:hover { background: rgba(255, 90, 80, 0.12); color: #ef9b94; }
.city-sublist li.no-coords .pin-mini { background: var(--ink-mute); box-shadow: none; opacity: 0.5; }

/* Buttons */
.btn-ghost, .btn-primary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 500; font-size: 13.5px;
  transition: all 180ms ease;
}
.btn-ghost { background: rgba(255,255,255,0.04); color: var(--ink-soft); border: 1px solid var(--line); }
.btn-ghost:hover { background: rgba(255,255,255,0.07); color: var(--ink); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #fff;
  box-shadow: 0 8px 20px rgba(224, 122, 95, 0.28);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(224, 122, 95, 0.36); }
.btn-danger { background: rgba(255, 90, 80, 0.08); color: #ef9b94; border: 1px solid rgba(255, 90, 80, 0.25); }
.btn-danger:hover { background: rgba(255, 90, 80, 0.15); }

/* ============== MAP ============== */
.map-wrap { position: relative; }
.map { width: 100%; height: 100%; background: #0d0b12; }

/* Leaflet overrides */
.leaflet-container { background: #0d0b12; font-family: var(--font-sans); }
.leaflet-control-zoom a {
  background: rgba(27, 24, 34, 0.85) !important;
  color: var(--ink-soft) !important;
  border: 1px solid var(--line-strong) !important;
  backdrop-filter: blur(8px);
}
.leaflet-control-zoom a:hover { background: rgba(35, 32, 48, 0.95) !important; color: var(--ink) !important; }
.leaflet-control-attribution {
  background: rgba(20, 18, 26, 0.7) !important;
  color: var(--ink-mute) !important;
  font-size: 10.5px !important;
  backdrop-filter: blur(6px);
}
.leaflet-control-attribution a { color: var(--accent-soft) !important; }

/* Custom city marker — prominent gold dot with halo */
.pin-wrap {
  position: relative;
  width: 18px; height: 18px;
  display: grid; place-items: center;
}
.pin-wrap::before {
  content: ''; position: absolute; inset: -8px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(242, 204, 143, 0.55), rgba(242, 204, 143, 0));
  pointer-events: none;
}
.pin {
  position: relative;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--pin-city);
  border: 2px solid #1b1822;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 0 14px rgba(242, 204, 143, 0.75), 0 6px 14px rgba(0, 0, 0, 0.45);
  z-index: 1;
}

/* Popup */
.leaflet-popup-content-wrapper {
  background: rgba(27, 24, 34, 0.96) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line-strong);
  border-radius: 12px !important;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}
.leaflet-popup-tip { background: rgba(27, 24, 34, 0.96) !important; }
.leaflet-popup-content { margin: 12px 14px !important; font-size: 13px; line-height: 1.4; }
.leaflet-popup-content .pop-title { font-family: var(--font-serif); font-size: 16px; margin-bottom: 4px; }
.leaflet-popup-content .pop-meta { color: var(--ink-mute); font-size: 11.5px; margin-bottom: 6px; }
.leaflet-popup-content .pop-actions { display: flex; gap: 6px; margin-top: 8px; }
.leaflet-popup-content .pop-actions button {
  font-size: 11.5px; padding: 4px 9px; border-radius: 6px;
  background: rgba(255,255,255,0.06); color: var(--ink-soft);
}
.leaflet-popup-content .pop-actions button:hover { background: rgba(255,255,255,0.12); color: var(--ink); }

/* Theme switcher */
.theme-switcher {
  position: absolute; top: 16px; right: 16px;
  display: flex; gap: 6px;
  z-index: 400;
}
.theme-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 11px;
  background: rgba(20, 18, 26, 0.82);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--ink-soft);
  backdrop-filter: blur(10px);
  transition: all 160ms ease;
  cursor: pointer;
}
.theme-btn:hover { background: rgba(40, 35, 60, 0.92); color: var(--ink); border-color: rgba(255,255,255,0.3); }
.theme-btn.is-active {
  background: linear-gradient(135deg, rgba(255,122,77,0.85), rgba(154,130,214,0.85));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(255, 122, 77, 0.35);
}
.theme-btn span { display: none; }
.theme-btn.is-active span { display: inline; }

/* Legend */
.legend {
  position: absolute; bottom: 16px; left: 16px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: rgba(20, 18, 26, 0.75);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  font-size: 11.5px; color: var(--ink-soft);
  z-index: 400;
}
.legend-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink-mute); margin-right: 2px;
}
.legend-dot.visited    { background: var(--visited); }
.legend-dot.has-cities { background: var(--has-cities); opacity: 0.45; }
.legend-dot.pin        { background: var(--pin-city); box-shadow: 0 0 6px rgba(242,204,143,0.7); }
.legend-hint { color: var(--ink-mute); margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--line); font-style: italic; }

/* ============== JOURNAL ============== */
#view-journal { display: block; overflow-y: auto; }
.journal-wrap { padding: 40px 56px; min-height: 100%; }
.journal-hdr { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 32px; }
.journal-hdr h2 { font-size: 36px; font-style: italic; font-weight: 400; }
.journal-hdr .hint { color: var(--ink-mute); margin: 6px 0 0; font-size: 13px; }
.btn-new-post { gap: 6px; }
.journal-empty { color: var(--ink-mute); font-size: 14px; padding: 40px 0; }
.journal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.journal-card { background: rgba(27,24,34,0.7); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease; }
.journal-card:hover { transform: translateY(-2px); box-shadow: 0 12px 36px rgba(0,0,0,0.4); border-color: var(--line-strong); }
.jcard-cover { height: 180px; background-color: rgba(255,255,255,0.04); background-size: cover; background-position: center; position: relative; }
.jcard-cover-ph { width: 100%; height: 100%; background: linear-gradient(135deg, rgba(255,122,77,0.12), rgba(154,130,214,0.12)); }
.jcard-count { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.55); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.jcard-info { padding: 14px 16px 16px; }
.jcard-date { font-size: 11.5px; color: var(--ink-mute); margin-bottom: 4px; }
.jcard-title { font-family: var(--font-serif); font-size: 17px; font-weight: 500; margin-bottom: 6px; }
.jcard-excerpt { font-size: 13px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 10px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.jcard-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.jcard-tag { font-size: 11.5px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,0.06); color: var(--ink-soft); }

/* ============== POST DETAIL ============== */
.post-detail { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; }
.post-detail[hidden] { display: none; }
.pd-backdrop { position: absolute; inset: 0; background: rgba(8,6,12,0.75); backdrop-filter: blur(8px); cursor: pointer; }
.pd-panel { position: relative; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: linear-gradient(180deg, rgba(35,32,48,0.99), rgba(27,24,34,0.99)); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: modal-in 220ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.pd-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.pd-scroll { overflow-y: auto; overflow-x: hidden; flex: 1; }
.pd-content { padding: 28px 32px 40px; }
.pd-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-bottom: 24px; }
.pd-img { width: 100%; height: 200px; object-fit: cover; border-radius: 10px; cursor: pointer; transition: opacity 140ms; }
.pd-img:hover { opacity: 0.88; }
.pd-video { width: 100%; border-radius: 10px; max-height: 380px; grid-column: 1 / -1; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.92); cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 92vh; object-fit: contain; border-radius: 6px; pointer-events: none; }
.lightbox-close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 32px; line-height: 1; cursor: pointer; opacity: 0.7; }
.lightbox-close:hover { opacity: 1; }
.pd-date { font-size: 12px; color: var(--ink-mute); margin-bottom: 6px; }
.pd-title { font-family: var(--font-serif); font-size: 32px; font-weight: 500; font-style: italic; margin-bottom: 14px; }
.pd-cities { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.pd-city-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 999px; background: rgba(255,255,255,0.06); border: 1px solid var(--line); font-size: 13px; color: var(--ink-soft); cursor: pointer; transition: all 140ms ease; }
.pd-city-chip:hover { background: rgba(255,122,77,0.12); border-color: rgba(255,122,77,0.3); color: var(--ink); }
.pd-body { font-size: 15px; line-height: 1.8; color: var(--ink-soft); margin-top: 20px; white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; }

/* ============== POST EDITOR ============== */
.post-editor { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; }
.post-editor[hidden] { display: none; }
.pe-backdrop { position: absolute; inset: 0; background: rgba(8,6,12,0.75); backdrop-filter: blur(8px); }
.pe-panel { position: relative; width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: linear-gradient(180deg, rgba(35,32,48,0.99), rgba(27,24,34,0.99)); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: modal-in 220ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.pe-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.pe-head h3 { font-size: 19px; font-style: italic; font-weight: 500; }
.pe-head-actions { display: flex; gap: 8px; align-items: center; }
.pe-body { display: grid; grid-template-columns: 1fr 240px; flex: 1; overflow: hidden; }
.pe-main { padding: 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; border-right: 1px solid var(--line); }
.pe-title-input { background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); font-family: var(--font-serif); font-size: 20px; width: 100%; transition: border-color 160ms; }
.pe-date-input { background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; color: var(--ink); font-family: inherit; font-size: 14px; width: 100%; transition: border-color 160ms; }
.pe-body-input { background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--ink); font-family: inherit; font-size: 14px; line-height: 1.6; resize: vertical; min-height: 130px; transition: border-color 160ms; width: 100%; }
.pe-title-input:focus, .pe-date-input:focus, .pe-body-input:focus { outline: none; border-color: rgba(224,122,95,0.55); background: rgba(255,255,255,0.05); }
.pe-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-mute); font-weight: 600; margin-bottom: 8px; }
.pe-media-section { display: flex; flex-direction: column; }
.pe-dropzone { border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 16px; text-align: center; color: var(--ink-mute); font-size: 13px; transition: border-color 160ms, background 160ms; }
.pe-dropzone input[type="file"] { display: none; }
.pe-dropzone.is-over { border-color: var(--accent); background: rgba(255,122,77,0.06); }
.pe-dropzone svg { display: block; margin: 0 auto 8px; opacity: 0.45; }
.pe-dropzone p { margin: 0; }
.pe-dropzone button { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.pe-media-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pe-media-item { position: relative; width: 80px; height: 80px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); flex-shrink: 0; }
.pe-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.pe-thumb-spin { width: 100%; height: 100%; display: grid; place-items: center; background: rgba(255,255,255,0.04); color: var(--ink-mute); }
.pe-pending-name { position: absolute; bottom: 0; left: 0; right: 0; font-size: 9px; padding: 2px 4px; background: rgba(0,0,0,0.7); color: #ccc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-media-del { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; background: rgba(0,0,0,0.75); color: #fff; border-radius: 50%; font-size: 14px; line-height: 1; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity 140ms; }
.pe-media-item:hover .pe-media-del { opacity: 1; }
.pe-sidebar { padding: 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; background: rgba(0,0,0,0.12); }
.pe-city-search { background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--ink); font-family: inherit; font-size: 13px; width: 100%; }
.pe-city-search:focus { outline: none; border-color: rgba(224,122,95,0.4); }
.pe-city-list { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.pe-city-group { margin-bottom: 8px; }
.pe-city-group-label { font-size: 11px; color: var(--ink-mute); font-weight: 600; padding: 2px 4px 4px; }
.pe-city-item { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; transition: background 140ms; }
.pe-city-item:hover { background: rgba(255,255,255,0.04); }
.pe-city-item input { width: 14px; height: 14px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.pe-city-date { font-size: 11px; color: var(--ink-mute); margin-left: 4px; }
.pe-no-cities { font-size: 13px; color: var(--ink-mute); padding: 6px 4px; }
.pe-status { padding: 10px 20px; font-size: 13px; color: var(--ink-mute); border-top: 1px solid var(--line); flex-shrink: 0; }
.pe-status.is-error { color: #ef9b94; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* ============== MODAL ============== */
.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 6, 12, 0.66); backdrop-filter: blur(6px); }
.modal-card {
  position: relative;
  width: min(480px, calc(100vw - 32px));
  background: linear-gradient(180deg, rgba(35, 32, 48, 0.98), rgba(27, 24, 34, 0.98));
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 19px; font-style: italic; font-weight: 500; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-mute); }
.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--ink); }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--ink-mute); font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field input, .field select, .field textarea {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  font-family: inherit; font-size: 14px;
  transition: border-color 160ms ease, background 160ms ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: rgba(224, 122, 95, 0.55);
  background: rgba(255,255,255,0.05);
}
.field textarea { resize: vertical; min-height: 70px; }

.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px;
}
.modal-actions .btn-danger { margin-right: auto; }

.modal-msg {
  margin: 0; font-size: 12.5px; color: var(--ink-mute);
  padding: 8px 12px; border-radius: 8px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--line);
}
.modal-msg.is-error { color: #ef9b94; background: rgba(255, 90, 80, 0.08); border-color: rgba(255, 90, 80, 0.25); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; transform: none; }

/* ============== SCROLLBARS ============== */
.panel::-webkit-scrollbar, .journal-wrap::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-track, .journal-wrap::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb, .journal-wrap::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06); border-radius: 4px;
}
.panel::-webkit-scrollbar-thumb:hover, .journal-wrap::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

/* ============== EDITOR LOCK ============== */

/* ============== PASSPHRASE DIALOG ============== */
.pass-dialog { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; }
.pass-backdrop { position: absolute; inset: 0; background: rgba(8,6,12,0.66); backdrop-filter: blur(6px); }
.pass-card {
  position: relative; background: var(--bg-1); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 24px; width: 280px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px;
}
.pass-label { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.pass-input {
  width: 100%; box-sizing: border-box; background: var(--bg-2); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 9px 12px; color: var(--ink); font-size: 15px; outline: none;
  letter-spacing: 0.1em;
}
.pass-input:focus { border-color: var(--plum); }
.pass-error { margin: -4px 0 0; font-size: 12px; color: #ef9b94; }
.pass-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Hide all edit controls when locked */
body:not(.editor-unlocked) #btn-add-city,
body:not(.editor-unlocked) #btn-new-post,
body:not(.editor-unlocked) #pd-edit,
body:not(.editor-unlocked) .trash,
body:not(.editor-unlocked) .trash-country,
body:not(.editor-unlocked) .edit-city,
body:not(.editor-unlocked) .pop-actions { display: none !important; }

/* ============== RESPONSIVE ============== */
@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr; gap: 12px; padding: 14px 18px; }
  .stats { justify-content: flex-start; }
  .view { grid-template-columns: 1fr; }
  .panel { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .layout { height: calc(100vh - 160px); }
}
