:root {
  --blue: #74c8ff;
  --blue-2: #bceaff;
  --accent: #2f7dd8;
  --ink: #12304f;
  --muted: #6c87a0;
  --glass: rgba(255, 255, 255, .76);
  --glass-strong: rgba(255, 255, 255, .9);
  --line: rgba(255, 255, 255, .78);
  --shadow: 0 22px 60px rgba(57, 124, 174, .2);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #dff5ff 0, transparent 35%),
    linear-gradient(135deg, #f7fcff, #dff4ff);
}

button, input { font: inherit; }

button { cursor: pointer; }

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  width: 100vw;
  height: 100dvh;
  padding: 18px;
}

.map-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 32px;
  overflow: hidden;
  background: #dff4ff;
  box-shadow: 0 30px 80px rgba(48, 114, 162, .2);
  border: 1px solid rgba(255,255,255,.84);
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.map-tint {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(225,247,255,.18), rgba(255,255,255,.02)),
    radial-gradient(circle at 85% 10%, rgba(116,200,255,.12), transparent 30%);
  mix-blend-mode: soft-light;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  box-shadow: var(--shadow);
}

.topbar {
  position: absolute;
  z-index: 10;
  top: 22px;
  left: 22px;
  right: 22px;
  display: grid;
  grid-template-columns: auto minmax(280px, 560px) auto;
  align-items: center;
  gap: 18px;
  pointer-events: none;
}

.topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 10px;
  border-radius: 20px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: white;
  background: linear-gradient(145deg, #8fd9ff, #4caeef);
  box-shadow: 0 12px 24px rgba(47,125,216,.28);
}

.brand-mark svg { width: 25px; height: 25px; }

.brand-copy {
  display: grid;
  line-height: 1.12;
}

.brand-copy strong { font-size: 15px; letter-spacing: -.2px; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.search {
  height: 56px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 11px;
}

.search svg { color: #5f8fb6; min-width: 22px; }

.search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
}

.search input::placeholder { color: #7893aa; }

.search kbd {
  border: 1px solid rgba(81,128,163,.18);
  border-bottom-width: 2px;
  background: rgba(255,255,255,.65);
  color: #7490a6;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 20px;
  padding: 7px;
}

.icon-btn, .avatar {
  border: 0;
  background: transparent;
  color: #5e819e;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
}

.icon-btn:hover { background: rgba(116,200,255,.14); color: var(--accent); }

.avatar {
  color: white;
  font-weight: 800;
  background: linear-gradient(145deg, #74c8ff, #2f7dd8);
  box-shadow: 0 8px 16px rgba(47,125,216,.25);
}

.side-nav {
  position: absolute;
  z-index: 10;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 7px;
  border-radius: 24px;
  padding: 9px;
}

.nav-item {
  position: relative;
  width: 50px;
  height: 50px;
  border: 0;
  background: transparent;
  color: #65849d;
  border-radius: 16px;
  display: grid;
  place-items: center;
  transition: .2s ease;
}

.nav-item:hover, .nav-item.active {
  color: white;
  background: linear-gradient(145deg, #8fd9ff, #4caeef);
  box-shadow: 0 10px 20px rgba(47,125,216,.23);
}

.nav-item span {
  position: absolute;
  left: 62px;
  padding: 8px 11px;
  color: var(--ink);
  border-radius: 10px;
  background: var(--glass-strong);
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 12px 28px rgba(53,105,145,.16);
  transition: .18s ease;
}

.nav-item:hover span { opacity: 1; transform: translateX(0); }

.stats-card {
  position: absolute;
  z-index: 10;
  left: 22px;
  bottom: 22px;
  display: flex;
  gap: 3px;
  padding: 9px;
  border-radius: 20px;
}

.stats-card div {
  min-width: 74px;
  padding: 8px 12px;
  border-radius: 14px;
  text-align: center;
}

.stats-card div:not(:last-child) { border-right: 1px solid rgba(77,129,168,.12); }

.stats-card span { display: block; font-size: 18px; font-weight: 800; }
.stats-card small { color: var(--muted); font-size: 10px; }

.timeline {
  position: absolute;
  z-index: 10;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
}

.timeline span {
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, rgba(47,125,216,.16), rgba(47,125,216,.42));
}

.year {
  border: 0;
  background: transparent;
  color: #6f8ea7;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 12px;
}

.year.active {
  color: white;
  background: var(--accent);
  box-shadow: 0 8px 15px rgba(47,125,216,.24);
}

.add-memory {
  position: absolute;
  z-index: 10;
  right: 24px;
  bottom: 24px;
  border: 0;
  color: white;
  height: 60px;
  padding: 0 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 22px;
  background: linear-gradient(145deg, #82d3ff, #2f7dd8);
  box-shadow: 0 18px 34px rgba(47,125,216,.33);
  transition: transform .2s ease, box-shadow .2s ease;
}

.add-memory:hover { transform: translateY(-2px); box-shadow: 0 22px 42px rgba(47,125,216,.4); }

.add-memory span {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255,255,255,.18);
  font-size: 25px;
  font-weight: 300;
}

.add-memory b { font-size: 13px; }

.memory-pin {
  width: 52px;
  height: 52px;
  border: 4px solid white;
  border-radius: 50% 50% 50% 14px;
  transform: rotate(-45deg);
  overflow: hidden;
  box-shadow: 0 9px 24px rgba(31,95,143,.3);
  background: #fff;
  transition: .2s ease;
}

.memory-pin::after {
  content: "";
  position: absolute;
  inset: -11px;
  border-radius: 50%;
  border: 2px solid rgba(116,200,255,.5);
  animation: ripple 2.2s infinite;
}

.memory-pin img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: rotate(45deg) scale(1.22);
}

.memory-pin:hover { transform: rotate(-45deg) scale(1.08); }

@keyframes ripple {
  0% { opacity: .8; transform: scale(.76); }
  75%, 100% { opacity: 0; transform: scale(1.35); }
}

.leaflet-div-icon { background: transparent !important; border: 0 !important; }
.leaflet-control-attribution { font-size: 9px; opacity: .6; }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a { color: var(--accent) !important; border: 0 !important; }

.preview-card {
  position: absolute;
  z-index: 20;
  width: min(370px, calc(100vw - 44px));
  border-radius: 26px;
  padding: 10px;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(.97);
  transition: .22s ease;
}

.preview-card.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.preview-card > img {
  width: 130px;
  height: 150px;
  object-fit: cover;
  border-radius: 19px;
}

.preview-content { padding: 8px 8px 8px 0; }

.eyebrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .6px;
}

.eyebrow time { color: #7790a5; font-weight: 600; }

.preview-card h2, .sheet-copy h2 {
  margin: 10px 0 7px;
  font-size: 18px;
  letter-spacing: -.45px;
}

.preview-card p, .sheet-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 12px;
}

.open-memory {
  margin-top: 13px;
  border: 0;
  padding: 9px 12px;
  border-radius: 12px;
  color: white;
  background: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.open-memory span { margin-left: 8px; }

.close-preview, .sheet-close {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 3;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 0;
  background: rgba(255,255,255,.82);
  color: var(--ink);
  font-size: 20px;
}

.long-press-hint {
  position: absolute;
  z-index: 25;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 800;
  transform: translate(-50%, -120%);
}

.long-press-hint.show { display: flex; animation: pop .2s ease; }

.long-press-hint span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
}

@keyframes pop {
  from { opacity: 0; transform: translate(-50%, -95%) scale(.9); }
  to { opacity: 1; transform: translate(-50%, -120%) scale(1); }
}

.mobile-nav, .bottom-sheet { display: none; }

@media (max-width: 900px) {
  .app-shell { padding: 0; }
  .map-frame { border-radius: 0; border: 0; }

  .topbar {
    top: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    gap: 10px;
  }

  .brand { padding: 6px; border-radius: 16px; }
  .brand-copy { display: none; }
  .brand-mark { width: 42px; height: 42px; border-radius: 13px; }

  .search { height: 54px; flex: 1; border-radius: 18px; }
  .search kbd { display: none; }
  .search input { font-size: 13px; }

  .top-actions { padding: 6px; border-radius: 18px; }
  .top-actions .icon-btn { display: none; }
  .avatar { width: 40px; height: 40px; }

  .side-nav, .stats-card, .timeline, .add-memory, .preview-card {
    display: none !important;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    position: absolute;
    z-index: 30;
    left: 14px;
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    height: 72px;
    border-radius: 24px;
    padding: 7px 10px;
  }

  .mobile-nav button {
    border: 0;
    background: transparent;
    color: #7390a7;
    display: grid;
    justify-items: center;
    gap: 4px;
    font-size: 9px;
  }

  .mobile-nav button svg { width: 20px; height: 20px; }
  .mobile-nav button.active { color: var(--accent); }

  .mobile-nav .mobile-add {
    align-self: start;
    justify-self: center;
    width: 56px;
    height: 56px;
    margin-top: -28px;
    border-radius: 18px;
    color: white;
    font-size: 30px;
    background: linear-gradient(145deg, #83d4ff, #2f7dd8);
    box-shadow: 0 14px 27px rgba(47,125,216,.36);
    border: 5px solid rgba(255,255,255,.82);
  }

  .bottom-sheet {
    position: absolute;
    z-index: 40;
    left: 0;
    right: 0;
    bottom: 0;
    display: block;
    padding: 10px 16px calc(98px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
    background: rgba(248,252,255,.96);
    box-shadow: 0 -24px 70px rgba(36,92,134,.25);
    transform: translateY(110%);
    transition: transform .32s cubic-bezier(.2,.8,.2,1);
  }

  .bottom-sheet.open { transform: translateY(0); }

  .sheet-handle {
    width: 44px;
    height: 5px;
    background: #d0e4f1;
    border-radius: 999px;
    margin: 0 auto 12px;
  }

  .bottom-sheet > img {
    width: 100%;
    height: min(34vh, 270px);
    object-fit: cover;
    border-radius: 22px;
  }

  .sheet-copy { padding: 14px 4px 0; }
  .sheet-copy h2 { font-size: 22px; }
  .sheet-copy p { font-size: 13px; }
  .sheet-close { top: 24px; right: 26px; }

  .leaflet-control-zoom { display: none; }
}

@media (max-width: 520px) {
  .topbar { gap: 8px; }
  .search { padding: 0 12px; }
  .search input::placeholder { font-size: 12px; }
  .top-actions { background: transparent; border: 0; box-shadow: none; backdrop-filter: none; padding: 0; }
  .avatar { box-shadow: 0 10px 22px rgba(47,125,216,.3); }
}


/* Phase 2 — Add/Edit Memory */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 44, 70, .28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  transition: .22s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.memory-modal {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  border-radius: 30px;
  padding: 26px;
  background:
    radial-gradient(circle at 100% 0%, rgba(116,200,255,.18), transparent 30%),
    rgba(250,253,255,.97);
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 35px 90px rgba(28, 77, 112, .35);
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 13px;
  background: #edf7fd;
  color: var(--ink);
  font-size: 25px;
}

.modal-heading { padding-right: 50px; margin-bottom: 20px; }
.modal-kicker {
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.6px;
}
.modal-heading h2 {
  margin: 7px 0 6px;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -1.2px;
}
.modal-heading p { margin: 0; color: var(--muted); }

#memoryForm { display: grid; gap: 18px; }

#memoryForm label { display: grid; gap: 7px; }
#memoryForm label > span {
  font-size: 12px;
  font-weight: 800;
  color: #496b86;
}

#memoryForm input,
#memoryForm textarea {
  width: 100%;
  border: 1px solid #d8e9f4;
  outline: none;
  border-radius: 15px;
  padding: 13px 14px;
  color: var(--ink);
  background: rgba(255,255,255,.88);
  transition: .18s ease;
}

#memoryForm input:focus,
#memoryForm textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(116,200,255,.15);
}

#memoryForm textarea { resize: vertical; }

.upload-zone {
  min-height: 190px;
  place-items: center;
  border-radius: 22px;
  border: 1.5px dashed #a7d8f3;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(230,247,255,.8), rgba(255,255,255,.9));
  cursor: pointer;
}

.upload-zone input { display: none; }

#uploadPlaceholder {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: #5f819a;
  text-align: center;
}

.upload-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #8fd9ff, #4caeef);
  color: white;
  font-size: 28px;
  margin-bottom: 5px;
}

#uploadPlaceholder small { color: #8ba2b5; }

#uploadPreview {
  display: none;
  width: 100%;
  height: 260px;
  object-fit: cover;
}

.upload-zone.has-image #uploadPreview { display: block; }
.upload-zone.has-image #uploadPlaceholder { display: none; }

.form-grid {
  display: grid;
  grid-template-columns: 1.3fr 1.3fr .9fr .7fr;
  gap: 12px;
}

.coordinate-row {
  color: #6b8aa1;
  font-size: 11px;
  padding: 10px 13px;
  border-radius: 13px;
  background: #edf7fd;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

.modal-actions > div { display: flex; gap: 9px; }

.primary-btn,
.secondary-btn,
.danger-btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 850;
}

.primary-btn {
  color: white;
  background: linear-gradient(145deg, #74c8ff, #2f7dd8);
  box-shadow: 0 12px 24px rgba(47,125,216,.24);
}

.secondary-btn { color: #567690; background: #edf5fa; }
.danger-btn { color: #d14e5d; background: #fff0f2; }

#deleteMemory { display: none; }

.edit-memory-btn {
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-size: 11px;
  font-weight: 850;
}

@media (max-width: 760px) {
  .modal-backdrop {
    place-items: end center;
    padding: 0;
  }

  .memory-modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: 28px 28px 0 0;
    padding: 22px 16px calc(22px + env(safe-area-inset-bottom));
  }

  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .modal-actions {
    align-items: stretch;
  }

  .modal-actions > div {
    flex: 1;
  }

  .primary-btn { flex: 1; }
  #uploadPreview { height: 210px; }
}

@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions > div { width: 100%; }
  .secondary-btn, .primary-btn, .danger-btn { flex: 1; }
  .danger-btn { width: 100%; }
}


/* Phase 3.1 — Fullscreen map layout */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: #dbeef8;
}

.app-shell {
  width: 100vw;
  height: 100dvh;
  padding: 0;
}

.map-frame {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: #dceef6;
}

.map-tint {
  display: none;
}

.topbar {
  top: 16px;
  left: 16px;
  right: 16px;
  grid-template-columns: auto minmax(260px, 560px) auto;
}

.brand,
.search,
.top-actions,
.side-nav,
.stats-card,
.timeline {
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  box-shadow: 0 10px 30px rgba(44, 87, 120, .16);
}

.side-nav {
  left: 16px;
}

.stats-card {
  left: 16px;
  bottom: 16px;
}

.timeline {
  bottom: 16px;
}

.add-memory {
  right: 16px;
  bottom: 16px;
}

.leaflet-control-attribution {
  background: rgba(255,255,255,.76) !important;
  font-size: 9px !important;
}

.leaflet-control-zoom {
  margin-left: 16px !important;
  margin-bottom: 112px !important;
  border-radius: 14px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  font-size: 20px !important;
}

@media (max-width: 900px) {
  .topbar {
    top: 12px;
    left: 12px;
    right: 12px;
  }

  .mobile-nav {
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}


/* Phase 4 — Memory detail and multi-media gallery */
.detail-overlay {
  position: absolute;
  inset: 0;
  z-index: 120;
  background: rgba(12, 34, 54, .28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: .24s ease;
}

.detail-overlay.open {
  opacity: 1;
  visibility: visible;
}

.detail-shell {
  position: absolute;
  inset: 18px;
  overflow: hidden;
  border-radius: 30px;
  background: #f7fbfe;
  box-shadow: 0 40px 110px rgba(18, 59, 91, .36);
  transform: translateY(22px) scale(.985);
  transition: .28s cubic-bezier(.2,.8,.2,1);
}

.detail-overlay.open .detail-shell {
  transform: translateY(0) scale(1);
}

.detail-header {
  height: 76px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid #dfedf5;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(15px);
  position: relative;
  z-index: 4;
}

.detail-back,
.detail-edit {
  border: 0;
  border-radius: 14px;
  height: 42px;
  padding: 0 15px;
  font-weight: 850;
}

.detail-back {
  width: 42px;
  padding: 0;
  color: var(--ink);
  background: #edf6fb;
  font-size: 24px;
}

.detail-edit {
  color: white;
  background: var(--accent);
}

.detail-header-copy {
  display: grid;
  gap: 2px;
}

.detail-header-copy span {
  font-size: 10px;
  color: var(--accent);
  font-weight: 900;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.detail-header-copy strong {
  font-size: 14px;
}

.detail-body {
  height: calc(100% - 76px);
  overflow: auto;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(290px, .75fr);
  gap: 22px;
  align-items: start;
}

.detail-hero {
  position: relative;
  min-height: 520px;
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(116,200,255,.22), transparent 34%),
    #dfeff7;
  box-shadow: 0 20px 50px rgba(42, 92, 128, .16);
}

.detail-main-media {
  width: 100%;
  height: 100%;
  min-height: 520px;
  display: grid;
  place-items: center;
}

.detail-main-media img,
.detail-main-media video {
  width: 100%;
  height: 100%;
  min-height: 520px;
  object-fit: contain;
  background: #dcecf4;
}

.media-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 15px;
  border: 0;
  color: var(--ink);
  background: rgba(255,255,255,.88);
  box-shadow: 0 10px 24px rgba(26,66,97,.18);
  font-size: 28px;
}

.media-prev { left: 16px; }
.media-next { right: 16px; }

.detail-info {
  position: sticky;
  top: 0;
  padding: 24px;
  border-radius: 26px;
  background: white;
  box-shadow: 0 20px 50px rgba(42, 92, 128, .12);
}

.detail-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .7px;
}

.detail-meta-row time {
  color: #7e97aa;
}

.detail-info h1 {
  margin: 14px 0 9px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.02;
  letter-spacing: -1.7px;
}

.detail-info p {
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}

.detail-counts {
  display: flex;
  gap: 9px;
  margin: 20px 0;
}

.detail-counts span {
  padding: 8px 11px;
  border-radius: 11px;
  color: #58778f;
  background: #edf7fc;
  font-size: 11px;
  font-weight: 800;
}

.detail-upload {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 108px;
  padding: 15px;
  border-radius: 18px;
  border: 1.5px dashed #9fd2ee;
  background: linear-gradient(145deg, #f5fbff, #e9f7ff);
  color: var(--accent);
  cursor: pointer;
  text-align: center;
}

.detail-upload input { display: none; }
.detail-upload span { font-weight: 900; }
.detail-upload small { color: #829aab; }

.detail-upload-status {
  margin-top: 10px;
  min-height: 18px;
  color: #67879e;
  font-size: 12px;
}

.detail-gallery-wrap {
  grid-column: 1 / -1;
  padding: 6px 0 24px;
}

.detail-gallery-heading span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
}

.detail-gallery-heading h2 {
  margin: 5px 0 16px;
  font-size: 24px;
  letter-spacing: -.8px;
}

.detail-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: #dcecf4;
  box-shadow: 0 12px 28px rgba(44, 91, 126, .12);
  cursor: pointer;
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item.active {
  outline: 4px solid rgba(47,125,216,.26);
}

.gallery-type {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 6px 8px;
  border-radius: 9px;
  color: white;
  background: rgba(13,36,56,.6);
  backdrop-filter: blur(8px);
  font-size: 9px;
  font-weight: 900;
}

.delete-media {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 10px;
  color: white;
  background: rgba(197,65,82,.85);
  font-size: 16px;
  opacity: 0;
  transition: .18s ease;
}

.gallery-item:hover .delete-media {
  opacity: 1;
}

.gallery-empty {
  grid-column: 1 / -1;
  padding: 38px;
  border-radius: 20px;
  text-align: center;
  color: var(--muted);
  background: #edf7fc;
}

@media (max-width: 980px) {
  .detail-body {
    grid-template-columns: 1fr;
  }

  .detail-info {
    position: static;
  }

  .detail-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .detail-shell {
    inset: 0;
    border-radius: 0;
  }

  .detail-header {
    height: 68px;
    padding: 0 14px;
  }

  .detail-body {
    height: calc(100% - 68px);
    padding: 12px;
    gap: 12px;
  }

  .detail-hero,
  .detail-main-media,
  .detail-main-media img,
  .detail-main-media video {
    min-height: 42vh;
  }

  .detail-info {
    padding: 18px;
    border-radius: 20px;
  }

  .detail-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .media-nav {
    width: 40px;
    height: 40px;
  }

  .delete-media {
    opacity: 1;
  }
}


/* Phase 4.1 — center pick mode for accurate adding */
.center-picker {
  position: absolute;
  inset: 0;
  z-index: 85;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: .18s ease;
}

.center-picker.active {
  opacity: 1;
  visibility: visible;
}

.center-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.center-crosshair::before,
.center-crosshair::after {
  content: "";
  position: absolute;
  background: rgba(47, 125, 216, .35);
  border-radius: 999px;
}

.center-crosshair::before {
  width: 2px;
  height: 54px;
}

.center-crosshair::after {
  width: 54px;
  height: 2px;
}

.crosshair-plus {
  position: relative;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(145deg, #82d3ff, #2f7dd8);
  box-shadow: 0 16px 28px rgba(47,125,216,.28);
}

.crosshair-dot {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2f7dd8;
  box-shadow: 0 0 0 4px rgba(255,255,255,.92);
}

.center-picker-top {
  position: absolute;
  left: 50%;
  top: 96px;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 18px;
  text-align: center;
}

.center-picker-top strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.center-picker-top small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.center-picker-actions {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.center-picker-cancel,
.center-picker-confirm {
  height: 54px;
  border: 0;
  border-radius: 18px;
  padding: 0 18px;
  font-weight: 850;
  box-shadow: 0 12px 28px rgba(42, 92, 128, .16);
}

.center-picker-cancel {
  color: var(--ink);
  background: rgba(255,255,255,.96);
}

.center-picker-confirm {
  color: white;
  background: linear-gradient(145deg, #82d3ff, #2f7dd8);
}

body.center-pick-mode .side-nav,
body.center-pick-mode .stats-card,
body.center-pick-mode .timeline,
body.center-pick-mode .add-memory,
body.center-pick-mode .mobile-nav,
body.center-pick-mode .preview-card,
body.center-pick-mode .bottom-sheet {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 900px) {
  .center-picker-top {
    top: 90px;
    width: calc(100vw - 24px);
    padding: 13px 14px;
  }

  .center-picker-actions {
    width: calc(100vw - 24px);
    bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .center-picker-cancel,
  .center-picker-confirm {
    flex: 1;
  }

  .crosshair-plus {
    width: 36px;
    height: 36px;
    font-size: 28px;
  }
}
