/* Avenir ships with Apple devices; elsewhere the bundled Nunito Sans stands in. */
@font-face {
  font-family: "Nunito Sans";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("/vendor/nunito-sans/nunito-sans-latin-wght-normal.woff2") format("woff2");
}

:root {
  --font: "Avenir Next", Avenir, "Nunito Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --bg: #ffffff;
  --canvas: #f7f6f3;
  --fg: #3d3c3a;
  --fg-strong: #1f1e1c;
  --muted: #8a8782;
  --line: #ebe8e2;
  --line-strong: #dad6ce;
  --hover: #f3f1ec;
  --accent: #dd4c4f;
  --accent-dark: #c33b3e;
  --accent-soft: #fcebea;
  --danger: #c62828;
  --ok: #2f9e5b;
  --focus-ring: 0 0 0 3px rgba(221, 76, 79, 0.25);
  --panel-w: 380px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(40, 32, 20, 0.06);
  --shadow: 0 4px 14px rgba(40, 32, 20, 0.08), 0 1px 3px rgba(40, 32, 20, 0.06);
  --shadow-lg: 0 20px 50px rgba(40, 32, 20, 0.16), 0 4px 12px rgba(40, 32, 20, 0.08);
  --glass: rgba(255, 255, 255, 0.86);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: var(--font);
  font-size: 15px;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--canvas); line-height: 1.5; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--fg-strong); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* ---------- shared bits ---------- */
.icon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon svg { display: block; }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--hover); color: var(--fg-strong); }
.icon-btn:active { background: var(--line); }
.icon-btn.danger:hover { background: #fdeceb; color: var(--danger); }

.toast {
  /* Undo the user-agent popover box (inset, margin, border, canvas colors). */
  position: fixed; inset: auto; margin: 0; border: 0; width: max-content; height: auto; overflow: visible;
  left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: #2b2a28; color: #fff; padding: 10px 16px; border-radius: 12px;
  max-width: 90vw; text-align: center; box-shadow: var(--shadow-lg); font-size: 0.93rem;
  animation: toast-in 0.2s var(--ease);
}
.toast-action {
  background: none; border: 0; color: #ff9b9d; font: inherit; font-weight: 600; cursor: pointer;
  padding: 4px 8px; margin: -4px -8px -4px 0; border-radius: 7px;
}
.toast-action:hover { background: rgba(255, 255, 255, 0.1); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--bg); border-radius: 9px;
  padding: 7px 14px; min-height: 36px; cursor: pointer; font-weight: 500; color: var(--fg-strong);
  box-shadow: var(--shadow-sm); transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: #f3c3c1; }
.btn.danger:hover { background: #fdeceb; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.danger-solid:hover { background: #a91f1f; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary:disabled { background: var(--accent); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.btn-row.end { justify-content: flex-end; }

.hint { color: var(--muted); font-size: 0.86rem; margin: 6px 0; }
.muted { color: var(--muted); }
.error-msg { color: var(--danger); font-size: 0.9rem; margin: 6px 0; }

/* ---------- map chrome ---------- */
.leaflet-container { font-family: var(--font); background: #eceae5; }
.leaflet-bar { border: 0 !important; border-radius: var(--radius) !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.leaflet-bar a, .leaflet-bar a:hover {
  width: 36px !important; height: 36px !important; line-height: 34px !important;
  color: var(--fg); border-bottom-color: var(--line) !important; font-weight: 400;
}
.leaflet-bar a:hover { background: var(--hover); }
.leaflet-right .leaflet-control { margin-right: 12px; }
.leaflet-bottom .leaflet-control { margin-bottom: 12px; }
.leaflet-control-attribution {
  font-size: 10.5px; color: var(--muted);
  background: rgba(255, 255, 255, 0.72) !important; border-radius: 6px 0 0 0;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.leaflet-bottom.leaflet-right .leaflet-control-attribution { margin: 0 !important; }
.leaflet-control-attribution a { color: var(--fg); }

.map-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius); background: var(--bg); color: var(--fg);
  box-shadow: var(--shadow); cursor: pointer;
}
.map-btn:hover { background: var(--hover); color: var(--fg-strong); }
.map-btn[aria-expanded="true"] { color: var(--accent); }

.basemap-control { position: relative; }
.basemap-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px);
  display: grid; grid-template-columns: repeat(2, 96px); gap: 8px;
  padding: 10px; border-radius: 14px; background: var(--bg); box-shadow: var(--shadow-lg);
}
.basemap-option {
  display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none;
  cursor: pointer; text-align: left; font-size: 0.8rem; font-weight: 500; color: var(--fg);
}
.basemap-thumb {
  position: relative; display: block; width: 96px; height: 64px; border-radius: 9px; overflow: hidden;
  background: var(--hover); box-shadow: inset 0 0 0 1px var(--line);
  outline: 2px solid transparent; outline-offset: 1px; transition: outline-color 0.12s;
}
.basemap-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.basemap-option:hover .basemap-thumb { outline-color: var(--line-strong); }
.basemap-option[aria-checked="true"] .basemap-thumb { outline-color: var(--accent); }
.basemap-option[aria-checked="true"] span { color: var(--accent); font-weight: 600; }

/* ---------- map markers ---------- */
.pin-wrap { background: none; border: 0; }
.pin {
  position: relative;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--c, #3d3c3a);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(20, 15, 10, 0.3);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px;
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
}
.pin-count {
  position: absolute; top: -7px; right: -8px;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px;
  background: #fff; color: var(--fg-strong);
  box-shadow: 0 1px 3px rgba(20, 15, 10, 0.3);
  font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center;
}
.pin-hover .pin { transform: scale(1.15); }
.pin-selected .pin { transform: scale(1.22); box-shadow: 0 0 0 4px rgba(221, 76, 79, 0.45), 0 3px 10px rgba(20, 15, 10, 0.35); }

.marker-cluster { background: rgba(61, 60, 58, 0.18); border-radius: 50%; }
.marker-cluster div {
  width: 30px; height: 30px; margin: 5px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #3d3c3a; color: #fff; border: 2px solid #fff;
  font: 700 12.5px var(--font); box-shadow: 0 2px 6px rgba(20, 15, 10, 0.3);
}

/* ---------- public page ---------- */
body.public #map { position: fixed; inset: 0; }

.overlay {
  position: fixed; z-index: 800;
  top: 12px; left: 12px;
  width: min(290px, calc(100vw - 24px));
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.overlay summary {
  cursor: pointer; list-style: none; min-height: 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-weight: 600; font-size: 1.05rem; color: var(--fg-strong); letter-spacing: -0.01em;
}
.overlay summary::-webkit-details-marker { display: none; }
.overlay summary::after {
  content: ""; width: 8px; height: 8px; flex: none; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-3px); transition: transform 0.15s var(--ease);
}
.overlay[open] summary::after { transform: rotate(-135deg) translate(-2px, -1px); }
.legend-help { margin: 6px 0 8px; font-size: 0.85rem; color: var(--muted); line-height: 1.45; }
#legend-items { display: flex; flex-direction: column; gap: 2px; }
.legend-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin: 0 -8px;
  border-radius: 9px; cursor: pointer; font-size: 0.93rem;
}
.legend-row:hover { background: rgba(0, 0, 0, 0.04); }
.legend-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.legend-row:has(input:not(:checked)) { color: var(--muted); }
.legend-row:has(input:not(:checked)) .swatch { opacity: 0.4; }
.swatch {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--c); color: #fff; font-size: 10.5px; font-weight: 700;
}

.card {
  position: fixed; z-index: 900;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  overflow-y: auto; overscroll-behavior: contain;
  top: 12px; right: 12px; bottom: 12px;
  width: var(--panel-w); max-width: calc(100vw - 24px);
  border-radius: var(--radius-lg);
  /* desktop: a floating panel that slides in from the right */
  transform: translateX(calc(100% + 24px));
  visibility: hidden;
  transition: transform 0.3s var(--ease), visibility 0s linear 0.3s;
}
.card.open { transform: none; visibility: visible; transition-delay: 0s; }
.card.dragging { transition: none; }
.card:focus { outline: none; }

.card-bar {
  position: sticky; top: 0; z-index: 1;
  display: flex; justify-content: flex-end; gap: 2px;
  padding: 10px 10px 0;
  background: linear-gradient(#fff 70%, rgba(255, 255, 255, 0));
}
#card-body { padding: 0 22px 28px; margin-top: -8px; }
.sheet-handle { display: none; }

.loc-card h2 { margin: 0 0 4px; font-size: 1.4rem; }
.address, .loc-notes { margin: 2px 0 8px; color: var(--muted); font-size: 0.92rem; }
.loc-notes { font-style: italic; }

.resource { border-top: 1px solid var(--line); padding: 16px 0 4px; margin-top: 16px; }
.resource:first-of-type { margin-top: 12px; }
.resource h3 { margin: 8px 0 2px; font-size: 1.12rem; }
.resource-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 12%, #fff); color: color-mix(in srgb, var(--c) 85%, #000);
  font-size: 0.76rem; font-weight: 600; letter-spacing: 0.01em;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.category { color: var(--muted); font-size: 0.86rem; }
.years { margin: 2px 0; font-weight: 600; font-size: 0.92rem; color: var(--fg); }
.year-notes { margin: 0 0 6px; color: var(--muted); font-size: 0.85rem; }
.description { margin: 10px 0; white-space: pre-line; line-height: 1.6; }
.resource-fig { margin: 10px 0 12px; }
.resource-img { display: block; width: 100%; height: auto; border-radius: 12px; background: var(--hover); }
.resource-fig figcaption { margin-top: 6px; font-size: 0.82rem; color: var(--muted); }
.resource-fig .credit { font-style: italic; }
.more-links { list-style: none; margin: 4px 0 8px; padding: 0; }
.more-link {
  display: inline-flex; align-items: center; min-height: 36px;
  color: var(--accent); font-weight: 600; text-decoration: none;
}
.more-link:hover { text-decoration: underline; }

.status {
  position: fixed; z-index: 950; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #2b2a28; color: #fff; padding: 10px 18px; border-radius: 999px;
  max-width: 90vw; text-align: center; box-shadow: var(--shadow-lg); font-size: 0.93rem;
}

/* mobile: bottom sheet */
@media (max-width: 720px) {
  .card {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; max-width: none; max-height: 58vh; max-height: 58dvh;
    border-radius: 20px 20px 0 0;
    transform: translateY(105%);
  }
  .card.open { transform: none; }
  .card-bar { z-index: 3; touch-action: none; padding-top: 0; margin-top: -30px; background: none; pointer-events: none; }
  .loc-card h2 { padding-right: 84px; }
  .card-bar .icon-btn { pointer-events: auto; background: rgba(243, 241, 236, 0.92); }
  .sheet-handle {
    display: flex; justify-content: center; padding: 8px 0 26px; touch-action: none; cursor: grab;
    position: sticky; top: 0; z-index: 2; background: #fff;
  }
  .sheet-handle span { width: 36px; height: 5px; border-radius: 3px; background: var(--line-strong); }
  #card-body { padding: 0 18px calc(28px + env(safe-area-inset-bottom)); margin-top: 0; }
  .overlay { top: 10px; left: 10px; width: auto; max-width: calc(100vw - 20px); padding: 10px 14px; }
}

/* ---------- inputs ---------- */
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea, .input-wrap input {
  width: 100%; padding: 8px 11px; min-height: 38px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input::placeholder, .field textarea::placeholder, .input-wrap input::placeholder { color: #b3afa8; }
.field input:focus, .field select:focus, .field textarea:focus, .input-wrap input:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus-ring);
}
.field textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.field.internal textarea { background: #fffaf0; border-color: #f1dca8; }
.field.internal > span { color: #9a6b12; }
.links-list { list-style: none; margin: 0 0 6px; padding: 0; }
.links-list li { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.link-inputs { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.links-list .icon-btn:disabled, .image-list .icon-btn:disabled { opacity: 0.3; cursor: default; }
.image-list { list-style: none; margin: 0 0 6px; padding: 0; }
.image-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.image-list li.uploading { align-items: center; color: var(--muted); font-size: 0.88rem; }
.img-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 9px; background: var(--hover); flex: none; }
.img-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.img-actions { display: flex; flex-direction: column; }
.img-actions .icon-btn { width: 32px; height: 28px; border-radius: 7px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite;
}
.dropzone {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px;
  border: 1.5px dashed var(--line-strong); border-radius: 12px; color: var(--muted); font-size: 0.88rem;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.library-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px;
  max-height: 60vh; overflow-y: auto; margin-bottom: 8px;
}
.library-item {
  display: flex; flex-direction: column; gap: 4px; padding: 6px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.library-item:hover { border-color: var(--accent); }
.library-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--hover); }
.library-item span { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-item small { color: var(--muted); font-size: 0.75rem; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }

.input-wrap { position: relative; display: block; }
.input-wrap > input { padding-right: 42px; }
.input-wrap > .icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-btn {
  position: absolute; right: 2px; top: 2px; bottom: 2px; width: 38px;
  border: 0; background: transparent; border-radius: 7px; color: var(--accent); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.input-btn:hover { background: var(--accent-soft); }
.input-btn:disabled { cursor: default; }
.busy .icon svg, .input-btn.busy svg, .busy > .icon svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.match { margin-top: 6px; font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.match .ok, .match .warn { display: inline-flex; align-items: center; gap: 4px; }
.match .ok { color: var(--ok); }
.match .warn { color: #b26b00; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 0; text-decoration: underline; }
.alts { list-style: none; margin: 0; padding: 4px; width: 100%; border: 1px solid var(--line); border-radius: 10px; }
.alts button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.alts button:hover { background: var(--hover); }

/* ---------- admin ---------- */
body.admin { overflow: hidden; }
#app { display: grid; grid-template-columns: minmax(0, 1fr) 6px var(--panel-w, 420px); height: 100vh; height: 100dvh; }
#panel-resizer { position: relative; z-index: 2; cursor: col-resize; touch-action: none; }
#panel-resizer::before { content: ""; position: absolute; top: 0; bottom: 0; left: -6px; right: -6px; }
#panel-resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 2px; width: 2px; background: var(--line); }
#panel-resizer:hover::after, #panel-resizer:focus-visible::after, body.panel-resizing #panel-resizer::after { background: var(--accent); }
body.panel-resizing { cursor: col-resize; user-select: none; }
#map-wrap { position: relative; min-height: 0; }
#map { height: 100%; }
body.previewing #map-wrap::after {
  content: ""; position: absolute; inset: 0; z-index: 1000; pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--accent);
}
#panel {
  display: flex; flex-direction: column; min-height: 0; background: var(--bg);
  border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(40, 32, 20, 0.04); z-index: 1;
}
.panel-head {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line);
}
.brand { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.brand-eyebrow { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.panel-head h1 { font-size: 1.08rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.mode-switch {
  position: absolute; z-index: 1000; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 2px; padding: 3px; border-radius: 12px;
  background: rgba(236, 233, 227, 0.88);
  -webkit-backdrop-filter: blur(12px) saturate(1.4); backdrop-filter: blur(12px) saturate(1.4);
  box-shadow: var(--shadow);
}
.mode-switch button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: none; border-radius: 9px; padding: 6px 14px; min-height: 32px;
  font-weight: 600; font-size: 0.88rem; color: var(--muted); cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.mode-switch button:hover { color: var(--fg-strong); }
.mode-switch button[aria-checked="true"] { background: var(--bg); color: var(--fg-strong); box-shadow: var(--shadow-sm), 0 0 0 0.5px rgba(0, 0, 0, 0.06); }
body.previewing .mode-switch #mode-preview { color: var(--accent); }

/* list view */
.list-view { flex: 1; overflow-y: auto; padding: 14px 12px 40px; }
.list-top { display: flex; gap: 8px; align-items: stretch; padding: 0 4px; }
.list-top .input-wrap { flex: 1; }
.list-top .input-wrap input { background: var(--hover); border-color: transparent; }
.list-top .input-wrap input:focus { background: var(--bg); }
.list-view > .hint { padding: 0 6px; margin: 10px 0 6px; font-size: 0.82rem; }
.loc-list { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.row-btn {
  position: relative;
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; border-radius: var(--radius);
  padding: 10px 10px 10px 12px; min-height: 54px; cursor: pointer; color: inherit;
  transition: background 0.12s;
}
.row-btn:hover { background: var(--hover); }
.row-btn:hover::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--accent);
}
.row-btn > .icon:last-child { color: #c4c0b8; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { font-weight: 600; color: var(--fg-strong); display: flex; align-items: center; gap: 6px; }
.row-btn .sub { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-btn.add {
  color: var(--accent); border: 1px dashed #f0b6b5; margin: 8px 0; padding: 10px 12px; background: var(--accent-soft);
}
.row-btn.add:hover { background: #f9dedd; }
.row-btn.add:hover::before { display: none; }
.row-btn.add .row-title { color: var(--accent-dark); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.empty { color: var(--muted); padding: 14px 6px; font-size: 0.92rem; }

.hidden-tag {
  display: inline-flex; align-items: center; gap: 3px; flex: none;
  padding: 1px 7px; border-radius: 999px; background: var(--hover); color: var(--muted);
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
}
.row-btn.is-hidden .row-main { opacity: 0.65; }
details.res-form.is-hidden { background: #faf9f6; border-style: dashed; }
details.res-form.is-hidden .entry-name { color: var(--muted); }
.pin-hidden .pin { opacity: 0.5; border-style: dashed; }

.switch { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; cursor: pointer; user-select: none; min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; flex: none; width: 38px; height: 22px; border-radius: 11px;
  background: var(--line-strong); transition: background 0.15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s var(--ease);
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text { font-size: 0.92rem; font-weight: 500; }

/* preview pane */
.preview-view { flex: 1; overflow-y: auto; padding: 14px 16px 40px; }
.preview-note {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-dark);
  font-size: 0.86rem;
}
.preview-note p { margin: 0; }
.preview-note .icon { margin-top: 1px; }
.preview-card { margin-top: 14px; padding: 18px 18px 8px; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.preview-card .loc-card h2 { padding-right: 0; }

/* editor view */
.editor { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-head { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.editor-head h2 { flex: 1; margin: 0 4px; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-scroll { flex: 1; overflow-y: auto; padding: 6px 18px 28px; overscroll-behavior: contain; }
.editor-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.92);
}
.save-status { color: var(--muted); font-size: 0.86rem; }
.save-status.dirty { color: #b26b00; font-weight: 600; }

details.coords { margin: 6px 0 0; }
details.coords > summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; padding: 4px 0; }
details.coords code { color: var(--fg); font-size: 0.82rem; }

.entries { margin-top: 22px; }
.entries-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.entries-head h3 { margin: 0; font-size: 1rem; }
details.res-form { border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; background: var(--bg); transition: box-shadow 0.15s; }
details.res-form[open] { box-shadow: var(--shadow); border-color: var(--line-strong); }
details.res-form > summary {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; min-height: 48px;
  list-style: none; border-radius: 12px;
}
details.res-form > summary:hover { background: #fbfaf8; }
details.res-form > summary::-webkit-details-marker { display: none; }
details.res-form > summary > .icon:first-child svg { transition: transform 0.15s; color: #b8b3aa; }
details.res-form[open] > summary > .icon:first-child svg { transform: rotate(90deg); }
details.res-form[open] > summary { border-bottom: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.entry-name { flex: 1; min-width: 0; font-weight: 600; color: var(--fg-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-years { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.unsaved-dot { width: 8px; height: 8px; border-radius: 50%; background: #f0a020; flex: none; }
.res-body { padding: 2px 14px 8px; }

dialog.dlg {
  border: 0; border-radius: 18px; padding: 22px; width: min(92vw, 400px); color: var(--fg);
  box-shadow: var(--shadow-lg);
}
dialog.dlg::backdrop { background: rgba(30, 26, 20, 0.35); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
dialog.dlg h2 { margin: 0 0 8px; font-size: 1.15rem; }
dialog.dlg p { margin: 0 0 12px; color: var(--muted); }
dialog.dlg form { margin: 0; }

#login, #invite {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #fff 0%, var(--canvas) 60%);
  z-index: 3000; padding: 16px;
}
#login form, #invite form {
  background: var(--bg); padding: 30px 28px 24px; border-radius: 20px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow-lg);
}
.login-mark {
  display: flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: 13px; background: var(--accent); color: #fff; margin-bottom: 16px;
  box-shadow: 0 6px 16px rgba(221, 76, 79, 0.35);
}
#login h1, #invite h1 { margin: 0 0 4px; font-size: 1.35rem; }
#login .btn-row .btn, #invite .btn-row .btn { width: 100%; min-height: 40px; }

details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--hover); color: var(--fg); cursor: pointer; box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.12s;
}
.avatar:hover, details.menu[open] .avatar { background: var(--line); color: var(--fg-strong); }
.menu-items {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 2000; width: 250px;
  background: var(--bg); border-radius: 14px; padding: 6px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.04);
  animation: menu-in 0.14s var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.menu-avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.menu-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.menu-who b { color: var(--fg-strong); font-weight: 600; }
#user-email { color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.menu-items button {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 0.93rem; color: inherit; cursor: pointer;
}
.menu-items button:hover { background: var(--hover); }
#logout { color: var(--danger); }

dialog.dlg.wide { width: min(94vw, 560px); }
dialog.types-dlg { width: min(94vw, 640px); }
.loc-modal {
  position: fixed; z-index: 2500; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0;
  display: flex; flex-direction: column; overflow: hidden;
  border: 0; padding: 0; background: var(--bg); color: var(--fg);
  width: min(92vw, 460px); max-height: min(88dvh, 760px); border-radius: 18px; box-shadow: var(--shadow-lg);
}
.loc-modal .editor { min-height: 0; max-height: min(88dvh, 760px); }
.type-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 46vh; overflow: auto; }
.type-card { padding: 12px 0; border-bottom: 1px solid var(--line); }
.type-card-top, .type-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.type-card .field, .type-add .field { margin: 0; }
.type-card .field.label, .type-add .field.label { flex: 1; min-width: 140px; }
.type-card .field.icon { width: 4.5rem; flex: none; }
.type-card input[type="color"], .type-add input[type="color"] {
  width: 38px; height: 38px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); cursor: pointer;
}
.type-actions { display: flex; gap: 2px; }
.type-actions .icon-btn:disabled { opacity: 0.3; cursor: default; }
.type-key { margin: 6px 0 0; color: var(--muted); font-size: 0.78rem; }
.team-list { list-style: none; margin: 0 0 14px; padding: 0; }
.team-list li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.team-list .who { flex: 1; min-width: 160px; }
.team-list .who .sub { color: var(--muted); font-size: 0.85rem; }
.team-list li.is-disabled .who { opacity: 0.55; }
.team-list select { padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 8px; font: inherit; background: var(--bg); }
.invite-link { display: flex; gap: 6px; margin: 8px 0; }
.invite-link input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; font: inherit; font-size: 0.85rem; }
dialog.dlg h3 { margin: 16px 0 6px; font-size: 0.95rem; }

.history-list, .trash-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 60vh; overflow-y: auto; }
.history-list li, .trash-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.history-head, .trash-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.history-head .who, .trash-row .who { flex: 1; min-width: 160px; }
.history-head .sub, .trash-row .sub { color: var(--muted); font-size: 0.85rem; }
.history-changes { margin: 6px 0 0; padding: 0 0 0 16px; font-size: 0.88rem; }
.history-changes li { border: 0; padding: 2px 0; }
.history-changes del { color: var(--danger); text-decoration: line-through; }
.history-changes ins { color: var(--ok); text-decoration: none; }
.current-tag { font-size: 0.72rem; font-weight: 600; color: var(--ok); text-transform: uppercase; letter-spacing: 0.03em; }

@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; grid-template-rows: 42dvh 1fr; }
  #panel-resizer { display: none; }
  #panel { border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(40, 32, 20, 0.05); }
  .loc-modal {
    top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 72dvh; border-radius: 18px 18px 0 0;
  }
  .loc-modal .editor { max-height: 72dvh; }
  .mode-switch { top: 10px; }
  /* 16px+ inputs stop iOS Safari from zooming the page on focus */
  .field input, .field select, .field textarea, .input-wrap input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
