:root {
  color-scheme: light;
  --rose: #b88c8f;
  --ink: #231f20;
  --muted: #6f6767;
  --glass: rgba(255, 248, 244, .72);
  --glass-strong: rgba(255, 250, 247, .9);
  --line: rgba(255, 255, 255, .62);
  --shadow: 0 14px 40px rgba(55, 30, 32, .22);
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-right: max(20px, env(safe-area-inset-right));
  --safe-bottom: max(24px, env(safe-area-inset-bottom));
  --safe-left: max(20px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--rose);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, #map-stage:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
[hidden] { display: none !important; }

#app { position: relative; width: 100%; height: 100dvh; overflow: hidden; background: var(--rose); }
#map-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background: radial-gradient(circle at 50% 38%, #caa5a5, var(--rose) 70%);
}
#map-stage.is-panning { cursor: grabbing; }
#map-stage.placement-mode { cursor: crosshair; }
#map-scene {
  position: absolute;
  left: 0;
  top: 0;
  width: 4724px;
  height: 2362px;
  transform-origin: 0 0;
  will-change: transform;
}
#map-image { display: block; width: 100%; height: 100%; pointer-events: none; }
#placements { position: absolute; inset: 0; pointer-events: none; }
.placed-project {
  position: absolute;
  width: 76px;
  height: 76px;
  transform: translate(-50%, -50%);
  border: 4px solid rgba(255,255,255,.92);
  border-radius: 16px;
  overflow: hidden;
  background: #eee;
  box-shadow: 0 8px 22px rgba(33,20,20,.34);
  animation: place-pop .28s cubic-bezier(.2,.9,.2,1.2);
}
.placed-project img { width: 100%; height: 100%; object-fit: cover; }
@keyframes place-pop { from { opacity: 0; transform: translate(-50%,-50%) scale(.45); } }

.top-bar, .bottom-bar {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}
.top-bar { top: 0; padding: var(--safe-top) var(--safe-right) 0 var(--safe-left); }
.bottom-bar { bottom: 0; align-items: flex-end; padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left); }
.top-bar > *, .bottom-bar > * { pointer-events: auto; }

.glass-button, .glass-panel {
  border: 1px solid var(--line);
  background: rgba(255, 248, 244, .9);
  box-shadow: 0 8px 26px rgba(56,34,36,.19), inset 0 1px 0 rgba(255,255,255,.55);
}
.glass-button {
  min-height: 48px;
  border-radius: 999px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.glass-button:active { transform: scale(.97); background: var(--glass-strong); }
.glass-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.glass-button svg .fill, .glass-button .fill { fill: currentColor; stroke: none; }
.icon-only { width: 48px; padding: 0; }

.project-control { position: relative; width: min(340px, calc(100vw - 40px)); pointer-events: auto; }
.project-toggle { position: relative; z-index: 2; }
.project-toggle .chevron { width: 15px; transition: transform .2s ease; }
.project-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.project-drawer {
  position: absolute;
  top: 58px;
  left: 0;
  width: 340px;
  max-width: calc(100vw - var(--safe-left) - var(--safe-right));
  max-height: min(70dvh, 620px);
  padding: 18px 14px 14px;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: drawer-in .2s ease-out;
}
@keyframes drawer-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
.drawer-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 0 5px 14px; }
.drawer-heading h1, .sheet-header h2 { margin: 2px 0 0; font-size: 20px; line-height: 1.1; }
.eyebrow { display: block; color: #795e60; font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.icon-button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(45,35,35,.08); font-size: 26px; line-height: 1; cursor: pointer; }
.search-box { height: 44px; margin: 0 2px 10px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border-radius: 13px; background: rgba(255,255,255,.58); }
.search-box svg { width: 18px; height: 18px; fill: none; stroke: #665d5e; stroke-width: 2; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; }
.project-list { max-height: min(calc(70dvh - 148px), 470px); overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 2px 4px; }
.category-label { position: sticky; top: 0; z-index: 1; margin: 0; padding: 9px 8px 5px; background: rgba(243,230,226,.92); color: #7b6869; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.project-row {
  width: 100%; min-height: 64px; border: 0; border-radius: 15px; padding: 7px 7px 7px 8px; background: transparent;
  display: grid; grid-template-columns: 50px minmax(0,1fr) 42px; align-items: center; gap: 10px; text-align: left; cursor: pointer;
}
.project-row:hover, .project-row:focus-visible, .project-row[aria-selected="true"] { background: rgba(255,255,255,.58); }
.project-row[aria-selected="true"] { box-shadow: inset 0 0 0 1px rgba(116,83,85,.18); }
.project-thumb { width: 50px; height: 50px; border-radius: 12px; object-fit: cover; background: #e8dcda; }
.project-copy { min-width: 0; }
.project-copy strong, .project-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-copy strong { font-size: 14px; line-height: 1.25; }
.project-copy span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.drag-handle { width: 42px; height: 42px; border: 0; border-radius: 12px; background: rgba(52,39,39,.08); display: grid; place-items: center; touch-action: none; cursor: grab; }
.drag-handle svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.drag-ghost { position: fixed; z-index: 100; width: 68px; height: 68px; border: 3px solid #fff; border-radius: 15px; object-fit: cover; box-shadow: var(--shadow); pointer-events: none; transform: translate(-50%,-50%) scale(1.04); }
body.dragging #map-stage { box-shadow: inset 0 0 0 6px rgba(255,255,255,.9); }

.placement-banner {
  position: absolute; z-index: 18; left: 50%; top: var(--safe-top); transform: translateX(-50%);
  min-width: min(440px, calc(100vw - 280px)); max-width: calc(100vw - 330px); min-height: 56px;
  border-radius: 18px; padding: 7px 8px; display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 10px; align-items: center;
}
.placement-banner img { width: 42px; height: 42px; border-radius: 11px; object-fit: cover; }
.placement-banner strong, .placement-banner span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.placement-banner strong { font-size: 13px; }
.placement-banner span { font-size: 11px; color: var(--muted); margin-top: 2px; }
.placement-banner button { min-height: 40px; padding: 0 12px; border: 0; border-radius: 12px; background: #241f20; color: #fff; font-weight: 700; }
.drop-hint { position: absolute; z-index: 30; left: 50%; bottom: 92px; transform: translateX(-50%); padding: 12px 18px; border-radius: 999px; color: #fff; background: rgba(30,25,25,.86); font-weight: 700; pointer-events: none; }

.bottom-actions { display: flex; align-items: center; gap: 10px; }
.zoom-control { height: 50px; display: flex; border-radius: 999px; overflow: hidden; background: rgba(29,25,25,.89); box-shadow: 0 10px 28px rgba(40,25,25,.3); }
.zoom-control button { width: 54px; border: 0; background: transparent; color: #fff; cursor: pointer; }
.zoom-control button + button { border-left: 1px solid rgba(255,255,255,.2); }
.zoom-control button:active { background: rgba(255,255,255,.15); }
.zoom-control svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.toast { position: absolute; z-index: 60; left: 50%; bottom: 96px; transform: translateX(-50%); max-width: min(80vw, 520px); padding: 12px 17px; border-radius: 999px; background: rgba(31,27,27,.91); color: #fff; font-size: 14px; font-weight: 650; box-shadow: var(--shadow); text-align: center; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%,8px); } }

dialog { border: 0; color: var(--ink); }
dialog::backdrop { background: rgba(27,18,19,.42); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sheet { width: min(980px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; border-radius: 28px; padding: 0; background: #f8f1ed; box-shadow: 0 30px 90px rgba(35,20,21,.4); }
.sheet-header { min-height: 74px; padding: 15px 18px 14px 24px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 1px solid rgba(75,56,57,.1); }
.close-button { min-height: 42px; padding: 0 16px; border: 0; border-radius: 999px; background: #241f20; color: #fff; font-weight: 750; cursor: pointer; }
.video-sheet { width: min(1100px, calc(100vw - 32px)); background: #171516; color: #fff; }
.video-sheet .eyebrow { color: #d9bfc1; }
.video-sheet .sheet-header { border-color: rgba(255,255,255,.12); }
.video-wrap { height: min(72dvh, 680px); display: grid; place-items: center; padding: 18px; }
.video-wrap video { display: block; max-width: 100%; max-height: 100%; width: 100%; border-radius: 18px; background: #000; box-shadow: 0 18px 45px rgba(0,0,0,.35); }
.help-sheet { width: min(660px, calc(100vw - 32px)); padding-bottom: 20px; }
.help-steps { list-style: none; margin: 0; padding: 20px 24px 12px; display: grid; gap: 16px; }
.help-steps li { display: grid; grid-template-columns: 42px 1fr; gap: 14px; align-items: start; }
.help-steps li > span { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: #e7d0cd; color: #704f52; font-weight: 850; }
.help-steps strong { font-size: 16px; }
.help-steps p, .help-note p { margin: 4px 0 0; color: var(--muted); line-height: 1.4; font-size: 14px; }
.help-note { margin: 0 24px 18px; padding: 15px 17px; border-radius: 16px; background: rgba(184,140,143,.14); }
.primary-button { min-height: 48px; border: 0; border-radius: 999px; padding: 0 24px; background: #241f20; color: #fff; font-weight: 800; cursor: pointer; }
.help-sheet > .primary-button { display: block; width: calc(100% - 48px); margin: 0 24px; }
.alert-dialog { width: min(360px, calc(100vw - 40px)); border-radius: 26px; padding: 28px; text-align: center; background: rgba(255,250,247,.96); box-shadow: var(--shadow); }
.alert-dialog .alert-mark { width: 52px; height: 52px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 17px; background: #ead6d4; color: #77575a; font-size: 25px; font-weight: 900; }
.alert-dialog h2 { margin: 0; font-size: 21px; }
.alert-dialog p { margin: 8px 0 20px; color: var(--muted); line-height: 1.4; }
.alert-dialog .primary-button { width: 100%; }

@media (orientation: portrait) {
  .placement-banner { top: 76px; min-width: calc(100vw - 40px); max-width: calc(100vw - 40px); }
  .project-drawer { max-height: min(66dvh, 620px); }
  .project-list { max-height: min(calc(66dvh - 148px), 470px); }
}
@media (max-width: 700px) {
  .glass-button { min-height: 46px; }
  .top-bar { gap: 8px; }
  .project-control { width: auto; }
  .project-toggle span { display: none; }
  .project-drawer { width: calc(100vw - var(--safe-left) - var(--safe-right)); }
  #video-button span { display: none; }
  #video-button { width: 46px; padding: 0; }
  .help-steps { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
}
