: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;
  }
}


/* Phase 4.4 — Dynamic year and month timeline */
.timeline.timeline-dynamic {
  width: min(760px, calc(100vw - 380px));
  min-width: 520px;
  display: grid;
  gap: 8px;
  padding: 9px 12px 10px;
  overflow: hidden;
}

.timeline-years,
.timeline-months {
  display: flex;
  align-items: center;
}

.timeline-years {
  justify-content: center;
  gap: 7px;
}

.timeline-months {
  gap: 4px;
  overflow-x: auto;
  padding: 2px 2px 1px;
  scrollbar-width: none;
}

.timeline-months::-webkit-scrollbar,
.timeline-years::-webkit-scrollbar {
  display: none;
}

.timeline-year,
.timeline-month {
  border: 0;
  background: transparent;
  color: #718da4;
  white-space: nowrap;
  transition: .18s ease;
}

.timeline-year {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
}

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

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

.timeline-month {
  position: relative;
  min-width: 42px;
  padding: 7px 9px 9px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 750;
}

.timeline-month:hover {
  color: var(--accent);
  background: rgba(116,200,255,.12);
}

.timeline-month.active {
  color: var(--accent);
  background: rgba(116,200,255,.2);
}

.timeline-month.empty-month {
  opacity: .46;
}

.timeline-month.empty-month:hover {
  opacity: .78;
}

.month-dot {
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 4px;
  height: 4px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--accent);
}

@media (max-width: 1100px) {
  .timeline.timeline-dynamic {
    width: min(650px, calc(100vw - 320px));
    min-width: 460px;
  }

  .timeline-connector {
    width: 20px;
  }
}

@media (max-width: 900px) {
  .timeline.timeline-dynamic {
    left: 12px;
    right: 12px;
    bottom: 98px;
    width: auto;
    min-width: 0;
    transform: none;
    padding: 8px 9px 9px;
  }

  .timeline-years,
  .timeline-months {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .timeline-year {
    padding: 7px 10px;
  }

  .timeline-month {
    min-width: 40px;
    padding-inline: 8px;
  }

  body.center-pick-mode .timeline.timeline-dynamic {
    opacity: 0;
    pointer-events: none;
  }
}


/* Phase 4.4.1 — Mobile timeline panel */
.timeline-mobile-header {
  display: none;
}

@media (max-width: 900px) {
  .timeline.timeline-dynamic {
    display: none !important;
    z-index: 42;
  }

  .timeline.timeline-dynamic.mobile-visible {
    display: grid !important;
    left: 12px;
    right: 12px;
    bottom: 98px;
    width: auto;
    min-width: 0;
    max-height: 240px;
    transform: none;
    padding: 10px;
    gap: 8px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 20px 55px rgba(25, 68, 100, .24);
    animation: timelineSlideUp .22s ease;
  }

  .timeline-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1px 2px 4px;
  }

  .timeline-mobile-header strong {
    font-size: 13px;
    color: var(--ink);
  }

  .timeline-mobile-header button {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 10px;
    color: var(--ink);
    background: #edf6fb;
    font-size: 20px;
    line-height: 1;
  }

  .mobile-nav button.mobile-active {
    color: var(--accent);
  }

  @keyframes timelineSlideUp {
    from {
      opacity: 0;
      transform: translateY(12px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

.gallery-overlay{position:absolute;inset:0;z-index:130;background:rgba(10,28,43,.34);backdrop-filter:blur(10px);opacity:0;visibility:hidden;transition:.22s}
.gallery-overlay.open{opacity:1;visibility:visible}
.gallery-shell{position:absolute;inset:18px;display:grid;grid-template-rows:auto 1fr;overflow:hidden;border-radius:28px;background:#f7fbfe;box-shadow:0 36px 100px rgba(18,57,86,.34)}
.gallery-header{min-height:76px;display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:16px;padding:14px 20px;border-bottom:1px solid #deebf3;background:rgba(255,255,255,.94)}
.gallery-back{width:42px;height:42px;border:0;border-radius:14px;background:#edf6fb;font-size:24px}
.gallery-header span{color:var(--accent);font-size:10px;font-weight:900;letter-spacing:1.2px}.gallery-header h1{margin:3px 0 0;font-size:22px}
.gallery-filters{display:flex;gap:7px}.gallery-filter{border:0;border-radius:12px;padding:9px 13px;background:#edf6fb;color:#67859b;font-size:11px;font-weight:850}.gallery-filter.active{color:white;background:var(--accent)}
.gallery-content{overflow-y:auto;padding:18px}.instagram-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:3px;width:min(1100px,100%);margin:0 auto}
.instagram-item{position:relative;aspect-ratio:1/1;border:0;padding:0;overflow:hidden;background:#dfeef6}.instagram-item img,.instagram-item video{width:100%;height:100%;object-fit:cover}
.instagram-overlay{position:absolute;inset:auto 0 0;display:grid;gap:3px;padding:34px 12px 11px;color:white;background:linear-gradient(transparent,rgba(7,22,34,.72));text-align:left;opacity:0}.instagram-item:hover .instagram-overlay{opacity:1}
.instagram-overlay strong{font-size:12px}.instagram-overlay small{font-size:10px;color:rgba(255,255,255,.82)}
.instagram-video-badge{position:absolute;top:10px;right:10px;width:28px;height:28px;display:grid;place-items:center;border-radius:9px;color:white;background:rgba(12,31,46,.62);font-size:10px}
.gallery-page-empty{min-height:50vh;display:none;place-items:center;color:var(--muted);font-weight:700}
@media(max-width:700px){.gallery-shell{inset:0;border-radius:0}.gallery-header{grid-template-columns:auto 1fr;min-height:68px;padding:10px 12px}.gallery-filters{grid-column:1/-1;justify-content:center}.gallery-content{padding:0}.instagram-grid{width:100%;gap:2px;grid-template-columns:repeat(3,minmax(0,1fr))}.instagram-overlay{display:none}}


/* Phase 4.7 — All years button */
.timeline-year[data-year=""] {
  min-width: 58px;
}

.memory-pin-v2{position:relative;width:56px;height:64px;filter:drop-shadow(0 12px 16px rgba(28,73,107,.28))}.memory-pin-photo{position:relative;z-index:2;width:54px;height:54px;padding:4px;border-radius:20px;background:#fff;box-shadow:0 0 0 2px rgba(116,200,255,.34)}.memory-pin-photo img{width:100%;height:100%;object-fit:cover;border-radius:15px}.memory-pin-tail{position:absolute;z-index:1;left:50%;bottom:1px;width:18px;height:18px;transform:translateX(-50%) rotate(45deg);background:#fff}.memory-pin-count{position:absolute;z-index:4;top:-7px;right:-7px;min-width:25px;height:25px;padding:0 7px;display:grid;place-items:center;border:3px solid #fff;border-radius:999px;color:#fff;background:linear-gradient(145deg,#74c8ff,#2f7dd8);font-size:11px;font-weight:900}.memory-pin-grouped .memory-pin-photo:before,.memory-pin-grouped .memory-pin-photo:after{content:"";position:absolute;inset:4px;z-index:-1;border-radius:17px;background:#fff}.memory-pin-grouped .memory-pin-photo:before{transform:translate(-7px,5px) rotate(-5deg)}.memory-pin-grouped .memory-pin-photo:after{transform:translate(7px,5px) rotate(5deg)}
.memory-stack-overlay,.upload-progress-overlay{position:absolute;inset:0;z-index:150;display:grid;place-items:center;padding:18px;background:rgba(10,28,43,.34);backdrop-filter:blur(9px);opacity:0;visibility:hidden;transition:.2s}.memory-stack-overlay.open,.upload-progress-overlay.open{opacity:1;visibility:visible}.memory-stack-sheet{width:min(560px,100%);max-height:min(720px,calc(100dvh - 36px));display:grid;grid-template-rows:auto 1fr auto;overflow:hidden;border-radius:28px;background:#f8fcff}.memory-stack-header{display:flex;justify-content:space-between;align-items:center;padding:20px;background:#fff}.memory-stack-header button{width:38px;height:38px;border:0;border-radius:13px}.memory-stack-list{overflow:auto;padding:10px}.memory-stack-item{width:100%;display:grid;grid-template-columns:76px 1fr auto;gap:13px;align-items:center;border:0;padding:10px;border-radius:18px;background:transparent;text-align:left}.memory-stack-item img{width:76px;height:76px;object-fit:cover;border-radius:15px}.memory-stack-item span{min-width:0;display:grid;gap:4px}.memory-stack-item strong,.memory-stack-item em{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.memory-stack-item em{font-style:normal;color:var(--muted);font-size:11px}.memory-stack-add{margin:12px;border:0;border-radius:16px;padding:14px;color:#fff;background:linear-gradient(145deg,#74c8ff,#2f7dd8);font-weight:900}
.upload-progress-overlay{z-index:220}.upload-progress-card{width:min(480px,100%);display:grid;grid-template-columns:auto 1fr;gap:18px;align-items:center;padding:22px;border-radius:26px;background:#fff}.upload-progress-icon{width:78px;height:78px;display:grid;place-items:center;border-radius:24px;color:#fff;background:linear-gradient(145deg,#83d4ff,#2f7dd8)}.upload-progress-copy{display:grid;gap:7px}.upload-progress-track{height:9px;overflow:hidden;border-radius:999px;background:#dfedf5}.upload-progress-bar{width:0;height:100%;background:linear-gradient(90deg,#74c8ff,#2f7dd8);transition:width .16s linear}
@media(max-width:700px){.memory-stack-overlay{place-items:end center;padding:0}.memory-stack-sheet{width:100%;max-height:80dvh;border-radius:28px 28px 0 0}.upload-progress-card{grid-template-columns:1fr;justify-items:center;text-align:center}}


/* Phase 4.8.1 — pin frame clipping fix */
.memory-pin-v2 {
  position: relative;
  width: 60px !important;
  height: 68px !important;
  box-sizing: border-box;
  overflow: visible;
}

.memory-pin-v2.memory-pin-grouped::before,
.memory-pin-v2.memory-pin-grouped::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 4px;
  width: 48px;
  height: 48px;
  border: 4px solid #fff;
  border-radius: 18px;
  background: #dfeef6;
  box-shadow: 0 8px 18px rgba(28, 73, 107, .16);
  transform-origin: center;
}

.memory-pin-v2.memory-pin-grouped::before {
  transform: translateX(-58%) rotate(-7deg);
}

.memory-pin-v2.memory-pin-grouped::after {
  transform: translateX(-42%) rotate(7deg);
}

.memory-pin-photo {
  position: absolute !important;
  z-index: 2 !important;
  left: 50% !important;
  top: 0 !important;
  width: 54px !important;
  height: 54px !important;
  padding: 4px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  transform: translateX(-50%) !important;
  border: 0 !important;
  border-radius: 20px !important;
  background: #fff !important;
  box-shadow:
    0 0 0 2px rgba(116, 200, 255, .36),
    0 10px 22px rgba(28, 73, 107, .22) !important;
}

.memory-pin-photo::before,
.memory-pin-photo::after {
  display: none !important;
  content: none !important;
}

.memory-pin-photo img {
  position: static !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  object-fit: cover !important;
  object-position: center !important;
  border-radius: 15px !important;
  transform: none !important;
}

.memory-pin-tail {
  z-index: 1 !important;
  left: 50% !important;
  bottom: 2px !important;
  width: 19px !important;
  height: 19px !important;
  transform: translateX(-50%) rotate(45deg) !important;
  border-radius: 4px !important;
  background: #fff !important;
}

.memory-pin-count {
  z-index: 5 !important;
  top: -8px !important;
  right: -6px !important;
}

/* The detail page now uses the popup progress overlay only. */
.detail-upload-status {
  display: none !important;
}


/* Phase 4.8.2 — Detail memory layout flow fix */

/*
  Desktop:
  - Hero photo and information card remain side by side.
  - Information/upload card is no longer sticky.
  - Gallery always starts below both columns, so thumbnails never slide behind it.
*/
.detail-body {
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr) !important;
  grid-template-areas:
    "hero info"
    "gallery gallery" !important;
  align-items: start !important;
}

.detail-hero {
  grid-area: hero !important;
  position: relative !important;
  width: 100% !important;
  height: clamp(460px, 67vh, 760px) !important;
  min-height: 0 !important;
  align-self: start !important;
}

.detail-main-media {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.detail-main-media img,
.detail-main-media video {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
}

.detail-info {
  grid-area: info !important;
  position: static !important;
  top: auto !important;
  align-self: start !important;
  width: 100% !important;
  min-width: 0 !important;
  z-index: auto !important;
}

.detail-gallery-wrap {
  grid-area: gallery !important;
  grid-column: auto !important;
  position: relative !important;
  z-index: 1 !important;
  width: 100% !important;
  clear: both !important;
}

/*
  Prevent long portrait thumbnails or media from escaping their own cards.
*/
.gallery-item {
  contain: layout paint !important;
}

.gallery-item img,
.gallery-item video {
  display: block !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

/*
  Tablet/mobile:
  Everything becomes one normal vertical flow:
  photo -> information/upload card -> gallery.
  Portrait photos stay inside a fixed media viewport and can never sit behind
  the information card.
*/
@media (max-width: 980px) {
  .detail-body {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "hero"
      "info"
      "gallery" !important;
    align-items: start !important;
  }

  .detail-hero {
    width: 100% !important;
    height: clamp(390px, 58vh, 680px) !important;
    min-height: 0 !important;
  }

  .detail-info {
    position: relative !important;
    width: 100% !important;
    margin: 0 !important;
  }

  .detail-gallery-wrap {
    width: 100% !important;
    margin-top: 0 !important;
  }
}

@media (max-width: 700px) {
  .detail-body {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "hero"
      "info"
      "gallery" !important;
    gap: 12px !important;
    padding: 12px !important;
    overflow-x: hidden !important;
  }

  .detail-hero {
    position: relative !important;
    width: 100% !important;
    height: min(52vh, 520px) !important;
    min-height: 330px !important;
    max-height: 520px !important;
    margin: 0 !important;
    overflow: hidden !important;
    border-radius: 22px !important;
  }

  .detail-main-media {
    position: absolute !important;
    inset: 0 !important;
    min-height: 0 !important;
  }

  .detail-main-media img,
  .detail-main-media video {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
  }

  .detail-info {
    position: relative !important;
    inset: auto !important;
    z-index: 1 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    transform: none !important;
  }

  .detail-gallery-wrap {
    position: relative !important;
    z-index: 1 !important;
    width: 100% !important;
    margin: 0 !important;
    padding-top: 4px !important;
  }

  .detail-gallery {
    width: 100% !important;
  }
}


/* Phase 4.8.3 — custom delete confirmation and toast */
.custom-dialog-overlay {
  position: absolute;
  inset: 0;
  z-index: 240;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 28, 43, .46);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: .18s ease;
}

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

.custom-dialog-card {
  width: min(460px, 100%);
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: 28px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 100% 0%, rgba(116, 200, 255, .14), transparent 34%),
    rgba(255, 255, 255, .98);
  border: 1px solid rgba(255,255,255,.92);
  box-shadow: 0 38px 110px rgba(17, 55, 84, .38);
  text-align: center;
  transform: translateY(14px) scale(.97);
  transition: .22s cubic-bezier(.2,.8,.2,1);
}

.custom-dialog-overlay.open .custom-dialog-card {
  transform: translateY(0) scale(1);
}

.custom-dialog-icon {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border-radius: 25px;
  color: white;
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 16px 32px rgba(38, 84, 120, .24);
}

.custom-dialog-icon.danger {
  background: linear-gradient(145deg, #ff8b98, #d84b5d);
}

.custom-dialog-icon.success {
  background: linear-gradient(145deg, #76d9b0, #27a676);
}

.custom-dialog-icon.info {
  background: linear-gradient(145deg, #82d3ff, #2f7dd8);
}

.custom-dialog-copy {
  display: grid;
  gap: 7px;
}

.custom-dialog-copy > span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.2px;
}

.custom-dialog-copy h2 {
  margin: 0;
  color: var(--ink);
  font-size: 25px;
  letter-spacing: -.8px;
}

.custom-dialog-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 13px;
}

.custom-dialog-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
}

.custom-dialog-actions button {
  min-height: 50px;
  border: 0;
  border-radius: 16px;
  padding: 12px 15px;
  font-weight: 900;
}

.custom-dialog-cancel {
  color: #58778f;
  background: #edf6fb;
}

.custom-dialog-confirm.danger {
  color: white;
  background: linear-gradient(145deg, #ff7e8d, #d74659);
  box-shadow: 0 13px 26px rgba(210, 67, 85, .25);
}

.custom-dialog-confirm.success {
  color: white;
  background: linear-gradient(145deg, #6bd4a9, #2aab79);
}

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

.app-toast {
  position: absolute;
  z-index: 260;
  top: 22px;
  left: 50%;
  width: min(390px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-radius: 18px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 20px 55px rgba(24, 66, 98, .28);
  transform: translate(-50%, -140%);
  opacity: 0;
  pointer-events: none;
  transition: .25s cubic-bezier(.2,.8,.2,1);
}

.app-toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.app-toast-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: white;
  font-weight: 900;
  background: #2faf7c;
}

.app-toast.danger .app-toast-icon {
  background: #d84b5d;
}

.app-toast.info .app-toast-icon {
  background: #2f7dd8;
}

.app-toast div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.app-toast strong {
  color: var(--ink);
  font-size: 13px;
}

.app-toast small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .custom-dialog-card {
    padding: 24px 18px 20px;
    border-radius: 25px;
  }

  .custom-dialog-icon {
    width: 68px;
    height: 68px;
    border-radius: 22px;
  }

  .custom-dialog-actions {
    grid-template-columns: 1fr;
  }

  .custom-dialog-confirm {
    grid-row: 1;
  }

  .custom-dialog-cancel {
    grid-row: 2;
  }

  .app-toast {
    top: max(12px, env(safe-area-inset-top));
  }
}


/* Phase 4.8.6 — minimizable upload progress */
.upload-progress-card {
  position: relative;
}

.upload-progress-minimize {
  position: absolute;
  z-index: 3;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: #58778f;
  background: #edf6fb;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  transition: .18s ease;
}

.upload-progress-minimize:hover {
  color: var(--ink);
  background: #dceef8;
  transform: scale(1.04);
}

.upload-mini-card {
  position: absolute;
  z-index: 225;
  right: 18px;
  bottom: 18px;
  width: min(390px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 20px;
  color: inherit;
  background: rgba(255,255,255,.97);
  box-shadow: 0 22px 65px rgba(23, 66, 98, .3);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(22px) scale(.97);
  transition: .22s cubic-bezier(.2,.8,.2,1);
  text-align: left;
}

.upload-mini-card.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.upload-mini-cover-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(145deg, #dff4ff, #b9def3);
}

.upload-mini-cover {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-mini-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: white;
  background: linear-gradient(145deg, #82d3ff, #2f7dd8);
  font-size: 26px;
  font-weight: 900;
}

.upload-mini-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.upload-mini-copy > small {
  overflow: hidden;
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.upload-mini-copy > strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-mini-copy > span:not(.upload-mini-track) {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-mini-track {
  width: 100%;
  height: 6px;
  margin-top: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfedf5;
}

.upload-mini-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #74c8ff, #2f7dd8);
  transition: width .16s linear;
}

.upload-mini-card > b {
  min-width: 43px;
  color: var(--accent);
  font-size: 14px;
  text-align: right;
}

@media (max-width: 900px) {
  .upload-mini-card {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(94px + env(safe-area-inset-bottom));
    width: auto;
  }
}

@media (max-width: 520px) {
  .upload-mini-card {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 18px;
  }

  .upload-mini-cover-wrap {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .upload-progress-minimize {
    top: 8px;
    right: 8px;
  }
}
