:root {
  color-scheme: dark;
  --bg: #0d1418;
  --panel: #121d21;
  --panel-alt: #17252a;
  --sidebar: #111b1e;
  --topbar: #10191c;
  --line: rgba(230, 247, 239, .12);
  --text: #f3f7f4;
  --muted: #9cacae;
  --accent: #a6d2ba;
  --accent-strong: #b9ddc9;
  --accent-ink: #183027;
  --spot: #bde0c8;
  --danger: #f0a29a;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #c8f9dd; outline-offset: 3px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); font-weight: 400; }
.overline { font-size: 10px; color: var(--accent); font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn.primary:hover { background: #cdeadb; }
.btn.danger { color: var(--danger); border-color: rgba(240, 162, 154, .35); background: transparent; }
.close-panel {
  border: none; background: #223333; color: #fff; border-radius: 9px;
  font-size: 20px; line-height: 1; width: 30px; height: 30px; flex: none;
}
.close-panel:hover { background: #2c4242; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 306px minmax(0, 1fr); height: 100dvh; min-height: 460px; }

.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--line);
  padding: 29px 22px 24px; display: flex; flex-direction: column;
  min-height: 0; overflow-y: auto; scrollbar-width: thin; z-index: 4;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 4px 30px; border-bottom: 1px solid var(--line); }
.mark { display: grid; place-items: center; width: 43px; height: 43px; border: 1px solid rgba(175, 221, 193, .5); border-radius: 13px; color: var(--accent); flex: none; }
.mark svg { width: 23px; height: 23px; }
.brand-name { font-weight: 750; letter-spacing: .19em; font-size: 13px; }
.brand-sub { font-size: 10px; letter-spacing: .2em; color: var(--muted); margin-top: 5px; }

.side-section { margin-top: 30px; }
.title { font-size: 29px; line-height: 1.12; font-weight: 600; letter-spacing: -.045em; margin: 12px 0 13px; }
.description { font-size: 13px; line-height: 1.65; color: var(--muted); margin: 0; }

.photo-card {
  margin-top: 24px; display: flex; gap: 14px; align-items: center; padding: 10px; width: 100%;
  background: #19282b; border: 1px solid rgba(193, 233, 207, .11); border-radius: 15px;
  color: var(--text); text-align: left; transition: border-color .2s, background .2s;
}
.photo-card:hover { border-color: rgba(165, 211, 185, .46); background: #1d2f31; }
.photo-thumb { width: 79px; height: 69px; flex-shrink: 0; object-fit: cover; border-radius: 10px; background: #0b1214; }
.photo-meta { min-width: 0; flex: 1; }
.photo-meta strong { display: block; font-weight: 650; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-meta span { display: block; color: var(--muted); font-size: 11px; margin-top: 7px; }

.scene-bar { display: flex; justify-content: space-between; align-items: baseline; margin: 29px 3px 13px; }
.scene-count { font-size: 11px; color: var(--muted); }

.location-list { display: flex; flex-direction: column; gap: 9px; }
.location {
  width: 100%; border: 1px solid rgba(165, 211, 185, .14); border-radius: 13px; background: transparent; color: var(--text);
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 13px 12px; transition: background .2s, border-color .2s;
}
.location:hover, .location.active { background: #22342f; border-color: rgba(165, 211, 185, .46); }
.location-index { display: grid; place-items: center; border-radius: 10px; background: #283b36; color: #baddc6; width: 31px; height: 31px; flex: none; font-size: 12px; font-weight: 750; }
.location-label { flex: 1; font-size: 12px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.location-arrow { font-size: 17px; color: var(--muted); }
.location-empty { font-size: 12px; line-height: 1.6; color: var(--muted); padding: 4px 3px; }

.help { margin-top: auto; padding-top: 26px; }
.help-card {
  padding: 16px; border-radius: 13px; border: 1px solid var(--line);
  background: linear-gradient(115deg, rgba(143, 185, 156, .095), rgba(0, 0, 0, 0));
  font-size: 12px; line-height: 1.55; color: var(--muted);
}
.help-card strong { display: block; color: #e1f0e6; font-weight: 650; margin-bottom: 5px; }

/* ---------- Top bar ---------- */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  height: 78px; flex-shrink: 0; padding: 0 30px; border-bottom: 1px solid var(--line); background: var(--topbar);
}
.top-left { display: flex; align-items: center; gap: 13px; min-width: 0; }
.top-crumb { font-size: 12px; color: var(--muted); display: flex; align-items: center; min-width: 0; }
.top-crumb strong { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-link { background: none; border: 0; padding: 0; color: var(--muted); font-size: inherit; }
.crumb-link:hover { color: var(--text); }
.crumb-sep { color: #556b6d; margin: 0 12px; }
.right-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.mode-pill {
  padding: 9px 12px; border-radius: 50px; border: 1px solid #36584b; background: #192c26;
  color: #c0e9d0; font-size: 11px; font-weight: 650; white-space: nowrap;
}
.status-dot { display: inline-block; width: 6px; height: 6px; background: #b5e2c4; border-radius: 50%; margin-right: 7px; box-shadow: 0 0 9px #c3edc6; }
.mode-pill.editing { border-color: #6b5a33; background: #2c2618; color: #f1dca6; }
.mode-pill.editing .status-dot { background: #f1d48a; box-shadow: 0 0 9px #f1d48a; }
.top-utility {
  background: none; border: 1px solid var(--line); color: #d6e3dc;
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; font-size: 16px;
}
.top-utility:hover:not(:disabled) { background: rgba(255, 255, 255, .06); }
.top-utility.on { background: var(--accent-strong); color: var(--accent-ink); border-color: var(--accent-strong); }

/* ---------- Viewer ---------- */
.viewer-frame { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #1a2728; }
.viewer-frame::after {
  content: ""; pointer-events: none; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to bottom, rgba(7, 15, 17, .34), transparent 19%, transparent 74%, rgba(7, 15, 17, .58));
}
.viewer { position: absolute; inset: 0; cursor: grab; }
.viewer:active { cursor: grabbing; }
body.editing .viewer { cursor: crosshair; }

.load-label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2;
  color: #d6e7df; font-size: 13px; letter-spacing: .04em; pointer-events: none;
}

.viewer-label { z-index: 2; position: absolute; top: 27px; left: 32px; display: flex; flex-direction: column; gap: 9px; pointer-events: none; max-width: calc(100% - 64px); }
.viewer-label .eyebrow { font-size: 10px; font-weight: 800; letter-spacing: .22em; color: #d8f5e3; text-shadow: 0 2px 10px #000; }
.viewer-label h2 { margin: 0; font-size: 25px; letter-spacing: -.04em; font-weight: 600; text-shadow: 0 2px 20px #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-label p { font-size: 12px; color: #e1e9e3; text-shadow: 0 1px 10px #000; margin: 0; }

.viewer-tip {
  z-index: 2; position: absolute; left: 50%; top: 23px; transform: translateX(-50%);
  padding: 9px 15px; border-radius: 30px; font-size: 11px; color: #fff;
  background: rgba(11, 20, 22, .48); border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  white-space: nowrap; pointer-events: none; transition: opacity .4s;
}
.viewer-tip.fade, .viewer-frame:has(.info-panel.open) .viewer-tip { opacity: 0; }
body.editing .viewer-tip { border-color: rgba(241, 212, 138, .45); }

.viewer-bottom { position: absolute; bottom: 23px; left: 26px; right: 26px; z-index: 3; display: flex; align-items: end; justify-content: space-between; gap: 12px; pointer-events: none; }
.controls {
  display: flex; gap: 5px; align-items: center; padding: 7px; border-radius: 14px; pointer-events: auto;
  background: rgba(10, 21, 23, .77); border: 1px solid rgba(255, 255, 255, .15);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.ctrl { width: 39px; height: 39px; border: 0; border-radius: 9px; background: transparent; color: #edf6ef; display: grid; place-items: center; font-size: 18px; }
.ctrl:hover, .ctrl.on { background: var(--accent-strong); color: var(--accent-ink); }
.control-div { width: 1px; height: 23px; margin: 0 3px; background: rgba(255, 255, 255, .23); }
.mini-help { font-size: 11px; color: #eef5ed; text-shadow: 0 1px 7px #000; padding-bottom: 7px; white-space: nowrap; }

/* ---------- Empty state ---------- */
.empty { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 16px; }
.empty-card {
  width: 100%; max-width: 380px; padding: 28px 24px; text-align: center;
  background: rgba(15, 27, 29, .94); border: 1px solid rgba(200, 232, 208, .27); border-radius: 18px;
  box-shadow: 0 24px 70px #0009;
}
.empty-card h2 { margin: 12px 0 8px; font-size: 22px; letter-spacing: -.035em; font-weight: 600; }
.empty-card p { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* ---------- Hotspots ---------- */
.hotspot { position: relative; width: 0; height: 0; }
.hotspot-inner {
  position: absolute; left: -19.5px; top: -19.5px;
  display: flex; align-items: center; gap: 8px; border: 0; background: transparent; color: #fff;
  white-space: nowrap; padding: 0; touch-action: none;
}
.spot-icon {
  width: 39px; height: 39px; flex: none; display: grid; place-items: center;
  border: 2px solid #fff; background: var(--spot); border-radius: 50%; color: #183629; font-size: 12px; font-weight: 800;
  box-shadow: 0 0 0 5px rgba(204, 240, 214, .26), 0 5px 20px #0008; transition: transform .18s;
}
.hotspot-inner:hover .spot-icon, .hotspot-inner:focus-visible .spot-icon { transform: scale(1.16); }
.spot-name {
  padding: 9px 11px; color: #f8fff8; background: rgba(12, 23, 26, .88); border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 9px; font-size: 11px; font-weight: 650; box-shadow: 0 8px 22px #0004;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.spot-name:empty { display: none; }
.hotspot.selected .spot-icon { background: #effeec; box-shadow: 0 0 0 7px rgba(204, 240, 214, .34), 0 5px 23px #0009; }
body.editing .hotspot-inner { cursor: grab; }
body.editing .spot-icon { box-shadow: 0 0 0 5px rgba(241, 212, 138, .3), 0 5px 20px #0008; }
.hotspot.dragging .hotspot-inner { cursor: grabbing; }
.hotspot.dragging .spot-icon { transform: scale(1.2); }
.hotspot.pending .spot-icon { background: #f1d48a; }

/* ---------- Info panel / editor ---------- */
.info-panel {
  position: absolute; z-index: 5; right: 22px; top: 91px; width: min(340px, calc(100% - 40px));
  max-height: calc(100% - 190px); overflow-y: auto;
  background: rgba(15, 27, 29, .94); border: 1px solid rgba(200, 232, 208, .27); border-radius: 18px;
  box-shadow: 0 24px 70px #0009; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  padding: 22px; opacity: 0; transform: translateX(15px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.info-panel.open { opacity: 1; transform: none; pointer-events: auto; }
.info-head { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.info-tag { font-size: 10px; letter-spacing: .15em; color: #aedfc1; font-weight: 800; padding-top: 8px; }
.info-panel h3 { margin: 14px 0 12px; font-size: 24px; letter-spacing: -.035em; font-weight: 600; overflow-wrap: anywhere; }
.info-panel p { color: #c6d7d3; line-height: 1.6; font-size: 13px; margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.info-panel p:empty { display: none; }

.editor { margin-top: 16px; }
.editor label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: #cfe0d8; margin-bottom: 14px; }
.editor input, .editor textarea {
  display: block; width: 100%; margin-top: 7px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(165, 211, 185, .2); background: rgba(0, 0, 0, .22); color: var(--text);
  font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */ resize: vertical;
}
.editor input:focus, .editor textarea:focus { outline: none; border-color: rgba(165, 211, 185, .6); }
.editor-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.editor-actions .spacer { flex: 1; }

/* ---------- Gallery modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgba(4, 9, 10, .62);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  width: 100%; max-width: 720px; max-height: 84vh; overflow-y: auto;
  background: var(--panel); border: 1px solid rgba(200, 232, 208, .2); border-radius: 18px;
  box-shadow: 0 24px 70px #000a; padding: 22px;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { margin: 8px 0 0; font-size: 24px; letter-spacing: -.035em; font-weight: 600; }
.modal-actions { display: flex; align-items: center; gap: 8px; }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.gallery-item {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 8px; text-align: left;
  background: #19282b; border: 1px solid rgba(193, 233, 207, .11); border-radius: 14px; color: var(--text);
}
.gallery-item:hover { border-color: rgba(165, 211, 185, .46); }
.gallery-item.active { border-color: var(--accent); background: #1e3330; }
.gallery-item img { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; border-radius: 9px; display: block; background: #0b1214; }
.gallery-item strong { font-size: 13px; font-weight: 650; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-item span { font-size: 11px; color: var(--muted); padding: 0 4px 4px; }
.gallery-item .remove {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 9px;
  border: 0; background: rgba(10, 21, 23, .8); color: #fff; display: grid; place-items: center;
}
.gallery-item .remove svg { width: 15px; height: 15px; }
.gallery-item .remove:hover { background: #7a3530; }

/* ---------- Toast ---------- */
.toast {
  position: absolute; z-index: 6; left: 50%; bottom: 92px; transform: translate(-50%, 8px);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  background: rgba(15, 27, 29, .96); border: 1px solid rgba(200, 232, 208, .27); border-radius: 12px;
  padding: 10px 14px; font-size: 12px; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 10px 30px #0008;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Add to home screen ---------- */
.install {
  position: fixed; z-index: 15; right: 24px; bottom: 24px; width: 370px;
  display: flex; gap: 14px; align-items: flex-start; padding: 18px;
  background: rgba(15, 27, 29, .97); border: 1px solid rgba(200, 232, 208, .27); border-radius: 18px;
  box-shadow: 0 24px 70px #000b; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  opacity: 0; transform: translateY(16px); transition: opacity .25s, transform .25s ease;
}
.install.show { opacity: 1; transform: none; }
.install-icon { width: 52px; height: 52px; border-radius: 13px; flex: none; }
.install-body { flex: 1; min-width: 0; }
.install-body strong { display: block; font-size: 15px; font-weight: 650; letter-spacing: -.01em; line-height: 1.3; }
.install-body p { margin: 6px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.install-steps { margin: 10px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: #c6d7d3; }
.install-steps li + li { margin-top: 8px; }
.install-steps b { color: var(--text); font-weight: 650; }
.install-glyph {
  display: inline-grid; place-items: center; width: 24px; height: 24px; margin: 0 2px; vertical-align: middle;
  border-radius: 7px; background: #223333; color: #8ec5ff;
}
.install-glyph svg { width: 15px; height: 15px; }
.install-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.install-cta {
  width: 100%; display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 12px;
  border: 1px solid rgba(165, 211, 185, .3); border-radius: 13px; background: #1a2d2a; color: var(--text); text-align: left;
  transition: background .2s, border-color .2s;
}
.install-cta:hover { background: #22342f; border-color: rgba(165, 211, 185, .55); }
.install-cta-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--accent-strong); color: var(--accent-ink); }
.install-cta-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.install-cta-text strong { font-size: 13px; font-weight: 650; }
.install-cta-text span { font-size: 11px; color: var(--muted); }

/* ---------- Phone menu (hidden on larger screens) ---------- */
.menu-btn, .drawer-close, .drawer-backdrop { display: none; }
.menu-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent-strong); color: var(--accent-ink); font-size: 10px; font-weight: 800; line-height: 18px; text-align: center;
}

/* ---------- Responsive ---------- */
@media (min-width: 1300px) {
  .viewer-label { left: 40px; top: 32px; }
  .info-panel { top: 105px; right: 30px; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 240px 1fr; }
  .sidebar { padding: 21px 14px; }
  .title { font-size: 24px; }
  .topbar { height: 64px; padding: 0 18px; }
  .viewer-label { left: 20px; }
  .viewer-bottom { left: 17px; right: 17px; }
  .mini-help, .mode-pill { display: none; }
}

/* Phones (portrait, and landscape where height is the constraint). */
@media (max-width: 660px), (max-height: 500px) and (max-width: 1000px) {
  .app { display: flex; flex-direction: column; min-height: 0; }
  .stage { flex: 1; }

  .topbar { height: calc(65px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 12px 0 10px; }
  .top-left { gap: 10px; }
  .top-crumb { font-size: 12px; }
  .top-crumb strong { font-size: 15px; }
  .crumb-sep { margin: 0 8px; }
  .top-utility { width: 38px; height: 38px; }
  .right-tools { gap: 8px; }
  .desktop-only { display: none; }

  /* Sidebar becomes a slide-in drawer. */
  .menu-btn { display: grid; position: relative; flex: none; }
  .drawer-close { display: block; margin-left: auto; }
  .sidebar {
    position: fixed; z-index: 25; top: 0; bottom: 0; left: 0; width: min(330px, 86vw);
    padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(18px + var(--safe-bottom));
    box-shadow: 24px 0 60px #0009; transform: translateX(-105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    overscroll-behavior: contain;
  }
  .brand { padding-bottom: 20px; }
  .side-section { margin-top: 22px; }
  .title { font-size: 25px; }
  .drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: 24; background: rgba(4, 9, 10, .6);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

  /* The title already sits in the top bar. */
  .viewer-label { display: none !important; }
  .viewer-tip { top: 14px; padding: 7px 12px; font-size: 11px; max-width: calc(100% - 24px); white-space: normal; text-align: center; }

  .viewer-bottom { bottom: calc(16px + var(--safe-bottom)); left: 50%; right: auto; transform: translateX(-50%); }
  .ctrl { width: 40px; height: 40px; }
  .controls { gap: 2px; padding: 5px; }
  .control-div { margin: 0 1px; }

  /* Point details / editor become a bottom sheet. */
  .info-panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 72%;
    border-radius: 20px 20px 0 0; border-width: 1px 0 0; padding: 10px 18px calc(18px + var(--safe-bottom));
    transform: translateY(100%); transition: opacity .2s, transform .25s ease;
  }
  .info-panel::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .22); margin: 0 auto 10px; }
  .info-panel h3 { font-size: 21px; margin: 10px 0 8px; }
  .viewer-frame:has(.info-panel.open) .viewer-bottom { opacity: 0; pointer-events: none; }
  .viewer-bottom { transition: opacity .2s; }
  .editor { margin-top: 12px; }
  .editor-actions .btn { padding: 11px 16px; }

  .spot-name { font-size: 10px; padding: 7px 8px; max-width: 140px; }
  .spot-icon { width: 34px; height: 34px; }
  .hotspot-inner { left: -17px; top: -17px; }
  .toast { bottom: calc(80px + var(--safe-bottom)); }

  .install { left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom)); width: auto; padding: 16px; }

  /* Gallery becomes a bottom sheet too. */
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal { max-width: none; max-height: 85dvh; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom)); }
  .modal-head h2 { font-size: 21px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}

/* Phone in landscape: give the photo all the height. */
@media (max-height: 500px) and (max-width: 1000px) {
  .topbar { height: 48px; }
  .intro { display: none; }
  .info-panel { left: auto; right: 12px; bottom: 12px; width: min(360px, calc(100% - 24px)); max-height: calc(100% - 24px); border-radius: 18px; border-width: 1px; transform: translateY(15px); }
  .info-panel::before { display: none; }
  .modal { max-height: 92dvh; }
}

@media (max-width: 380px) {
  .ctrl[data-action="left"], .ctrl[data-action="right"], .controls .control-div:first-of-type { display: none; }
}
