:root {
  --bg: #f6efe6;
  --campus: #efe4d4;
  --park: #d9e6c8;
  --pitch: #c9ddb4;
  --water: #b9d3e0;
  --road: #ffffff;
  --path: #d6c3ab;
  --bldg: #e2c9b0;
  --bldg-edge: #b8957a;
  --bldg-hover: #f2a7a0;
  --ink: #3d2b26;
  --muted: #8a7468;
  --heart: #d6455d;
  --line: #e3d3c2;
  --panel: rgba(255, 250, 244, 0.95);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, sans-serif; }
#map { position: absolute; inset: 0; background: var(--bg); }

button {
  font: 500 13px Inter, sans-serif; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; cursor: pointer;
}
button:hover { background: #fff; }
button.primary, button.on { background: var(--heart); color: #fff; border-color: var(--heart); }
button.primary:hover { background: #c23a51; }
button.wide { width: 100%; padding: 11px; font-size: 14px; }

.title {
  position: absolute; top: 16px; left: 16px; z-index: 500;
  background: var(--panel); padding: 12px 18px; border-radius: 14px;
  box-shadow: 0 4px 18px rgba(61, 43, 38, 0.12); max-width: calc(100% - 90px);
}
.title h1 { margin: 0; font-family: Fraunces, serif; font-size: 22px; font-weight: 700; }
.title p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.controls {
  position: absolute; bottom: 20px; left: 16px; z-index: 500;
  display: flex; gap: 8px; flex-wrap: wrap; max-width: calc(100% - 32px);
}
.controls button { box-shadow: 0 2px 10px rgba(61, 43, 38, 0.08); }

.admin-bar {
  position: absolute; top: 92px; left: 16px; z-index: 600;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  background: var(--panel); border: 1px dashed var(--heart); border-radius: 14px;
  padding: 8px; max-width: calc(100% - 32px);
}
.admin-tag { font: 600 11px Inter; text-transform: uppercase; letter-spacing: .08em; color: var(--heart); padding: 0 6px; }
#btn-save.dirty::after { content: " •"; }
#btn-add.on { cursor: crosshair; }

.toast {
  position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%); z-index: 2000;
  background: var(--ink); color: #fff; font-size: 13px; padding: 9px 14px; border-radius: 10px;
  max-width: calc(100% - 32px); text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* overlays & cards */
.overlay {
  position: fixed; inset: 0; z-index: 1500; display: grid; place-items: center; padding: 16px;
  background: rgba(246, 239, 230, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
}
#login { background: rgba(246, 239, 230, 0.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.card {
  background: #fffaf4; border-radius: 18px; padding: 24px; width: 100%;
  box-shadow: 0 12px 40px rgba(61, 43, 38, 0.18);
}
.card h2 { margin: 0 0 6px; font: 700 22px Fraunces, serif; }
.card p { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.login-card { max-width: 340px; text-align: center; }
.login-heart { font-size: 34px; color: var(--heart); line-height: 1; margin-bottom: 6px; animation: beat 2.4s ease-in-out infinite; }
.card input, .card textarea {
  width: 100%; font: 14px Inter, sans-serif; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; margin-bottom: 10px;
}
.card input:focus, .card textarea:focus { outline: 2px solid rgba(214, 69, 93, 0.35); border-color: var(--heart); }
.error { color: var(--heart); font-size: 13px; min-height: 18px; margin-top: 6px; }

.editor-card { max-width: 480px; }
.editor-card label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.editor-card label input, .editor-card label textarea { margin-top: 4px; font-weight: 400; }
.editor-card .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .editor-card .row { grid-template-columns: 1fr; } }
.photos-edit { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.photos-edit .ph { position: relative; width: 84px; height: 84px; }
.photos-edit img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.photos-edit .ph button { position: absolute; top: -6px; right: -6px; padding: 0; width: 22px; height: 22px; line-height: 20px; font-size: 14px; }
.photos-edit .ph .move { left: -6px; right: auto; }
.photos-edit .ph .rot { top: auto; bottom: -6px; left: -6px; right: auto; }
.photos-edit .ph .size { top: auto; bottom: -6px; font: 600 11px Inter, sans-serif; }
.file-btn {
  display: inline-block !important; cursor: pointer; border: 1px dashed var(--heart); color: var(--heart) !important;
  border-radius: 999px; padding: 8px 14px; font-size: 13px !important;
}
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.actions .left { margin-right: auto; }

/* story order */
.order-card { max-width: 440px; }
.order-list { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow-y: auto; }
.order-list li {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px; margin-bottom: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: grab; user-select: none;
}
.order-list li.dragging { opacity: .4; border-style: dashed; border-color: var(--heart); }
.order-list .grip { color: var(--muted); font-size: 16px; }
.order-list .n { font: 700 15px Fraunces, serif; color: var(--heart); min-width: 18px; text-align: center; }
.order-list .t { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-list .t small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.order-list button { padding: 0; width: 28px; height: 28px; font-size: 11px; flex: none; }
.order-list button:disabled { opacity: .3; cursor: default; }

/* building labels */
.bldg-label {
  background: none; border: none; box-shadow: none; padding: 0;
  font: 500 11px Inter, sans-serif; color: var(--ink); text-shadow: 0 0 3px #fff, 0 0 3px #fff;
  white-space: nowrap;
}
.bldg-label::before { display: none; }

/* heart markers */
.heart-pin { width: 34px; height: 34px; }
.heart-pin svg { width: 34px; height: 34px; filter: drop-shadow(0 3px 4px rgba(0,0,0,0.25)); transition: transform .15s; animation: beat 2.4s ease-in-out infinite; }
.heart-pin:hover svg { transform: scale(1.2); }
.admin .heart-pin { cursor: move; }
@keyframes beat { 0%, 100% { transform: scale(1); } 10% { transform: scale(1.12); } 20% { transform: scale(1); } }

.leaflet-popup-content-wrapper { border-radius: 14px; background: #fffaf4; }
.leaflet-popup-content { margin: 14px 16px; font-family: Inter, sans-serif; color: var(--ink); }
.memory h3 { margin: 0 0 2px; font: 700 17px Fraunces, serif; }
.memory .when { font-size: 12px; color: var(--heart); margin-bottom: 4px; }
.memory .where { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-style: italic; }
.memory p { margin: 0; font-size: 13px; line-height: 1.5; white-space: pre-wrap; max-height: 180px; overflow-y: auto; }
.memory .photos { display: flex; align-items: flex-start; gap: 6px; overflow-x: auto; margin-top: 10px; max-width: 100%; padding-bottom: 2px; }
.memory .photos img { width: 110px; height: 82px; object-fit: cover; border-radius: 8px; cursor: zoom-in; flex: none; }
/* medium / large keep the photo's shape (no crop) */
.memory .photos img.s2, .memory .photos img.s3 { width: auto; height: auto; object-fit: contain; }
.memory .photos img.s2 { max-width: 180px; max-height: 240px; }
.memory .photos img.s3 { max-width: min(340px, calc(100vw - 90px)); max-height: min(420px, 50vh); }
.memory .admin-actions { display: flex; gap: 6px; margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.memory .admin-actions button { padding: 5px 12px; font-size: 12px; }

.lightbox { position: fixed; inset: 0; z-index: 3000; background: rgba(20, 12, 10, 0.92); display: grid; place-items: center; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 6px; }
.lightbox button { position: absolute; background: rgba(255,255,255,0.12); color: #fff; border: none; font-size: 28px; width: 48px; height: 48px; padding: 0; }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }

.leaflet-control-attribution { font-size: 10px; background: rgba(255,250,244,0.8) !important; }
