:root {
  --cream: #fbf7ef;
  --ink: #2f2a24;
  --muted: #7a6f62;
  --line: #ddd2bd;
  --sage: #6f8f6a;
  --sage-dark: #4f6d4b;
  --sage-soft: #eef3ea;
  --gold: #e8b45a;
  --glass: rgba(251, 247, 239, 0.88);
  --shadow: 0 8px 30px rgba(40, 30, 20, 0.18);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe3c9; color: var(--ink); font-family: Inter, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 999px; padding: 10px 16px; background: var(--glass); color: var(--ink); box-shadow: var(--shadow); touch-action: manipulation; }
button:hover { filter: brightness(0.97); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--sage); color: #fff; font-weight: 600; }
button.ghost { background: transparent; box-shadow: none; color: var(--muted); }
h1, h2 { font-family: Fraunces, Georgia, serif; font-weight: 600; margin: 0 0 8px; }
[hidden] { display: none !important; }

/* ---- top ---- */
.topbar { position: fixed; top: 12px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; z-index: 5; }
.brand, .online { pointer-events: auto; background: var(--glass); padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 600; }
.brand { font-family: Fraunces, Georgia, serif; font-size: 18px; }
.brand-mark { color: var(--gold); }
.top-right { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.icon { padding: 8px 11px; font-size: 16px; }
.online { font-size: 13px; display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5cb85c; box-shadow: 0 0 0 3px rgba(92,184,92,.25); }

.ceremony { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: var(--glass); padding: 7px 14px; border-radius: 999px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; z-index: 4; }
.ceremony.live { background: #2f2a24; color: #ffe7b0; font-size: 13px; padding: 9px 16px; cursor: pointer; }

/* ---- intro ---- */
.intro { position: fixed; left: 50%; top: 28%; transform: translateX(-50%); text-align: center; color: #fff; text-shadow: 0 2px 20px rgba(0,0,0,.35); pointer-events: none; width: min(560px, calc(100% - 32px)); transition: opacity 1.2s; z-index: 3; }
.intro h1 { font-size: clamp(26px, 5vw, 40px); }
.intro p { margin: 0; font-size: 16px; }
.intro.gone { opacity: 0; }

/* ---- activity ---- */
.activity { position: fixed; left: 16px; bottom: calc(110px + var(--safe-b)); width: 300px; max-width: calc(100% - 32px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 3; }
.activity div { background: rgba(251,247,239,.75); padding: 6px 12px; border-radius: 12px; font-size: 13px; animation: fade 8s forwards; }
@keyframes fade { 0%{opacity:0;transform:translateY(6px)} 8%{opacity:1;transform:none} 80%{opacity:1} 100%{opacity:0} }

/* ---- dock ---- */
.dock { position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 6px; align-items: flex-end; background: var(--glass); padding: 6px; border-radius: 26px; box-shadow: var(--shadow); z-index: 5; }
.dock-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: none; background: transparent; border-radius: 20px; padding: 8px 16px; font-size: 12px; font-weight: 600; min-width: 74px; }
.dock-btn span { font-size: 20px; line-height: 1; }
.dock-btn.primary { background: var(--sage); color: #fff; }
.dock-btn.on { background: #efe6d4; }
.emote-tray { position: absolute; bottom: calc(100% + 10px); right: 0; display: flex; gap: 4px; background: var(--cream); padding: 6px; border-radius: 20px; box-shadow: var(--shadow); }
.emote-tray button { display: flex; flex-direction: column; align-items: center; font-size: 22px; box-shadow: none; background: transparent; padding: 6px 8px; border-radius: 14px; min-width: 58px; }
.emote-tray small { font-size: 10px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.hint { position: fixed; bottom: calc(6px + var(--safe-b)); left: 0; right: 0; text-align: center; font-size: 11px; color: var(--ink); opacity: .65; margin: 0; transition: opacity 1s; pointer-events: none; }
.hint.gone { opacity: 0; }

/* ---- thumb pad (touch screens only) ---- */
.joy { position: fixed; left: 18px; bottom: calc(108px + var(--safe-b)); width: 104px; height: 104px; border-radius: 50%; background: rgba(251,247,239,.32); border: 2px solid rgba(251,247,239,.7); box-shadow: 0 4px 18px rgba(40,30,20,.15); z-index: 4; touch-action: none; display: grid; place-items: center; transition: background .2s; }
.joy.on { background: rgba(251,247,239,.5); }
.joy-knob { width: 46px; height: 46px; border-radius: 50%; background: var(--cream); box-shadow: var(--shadow); pointer-events: none; transition: transform .08s; }
.joy.on .joy-knob { transition: none; }

/* ---- memorial sheet ---- */
.panel { position: fixed; right: 16px; top: 64px; bottom: 16px; width: 360px; max-width: calc(100% - 32px); overflow-y: auto; background: var(--cream); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; z-index: 6; }
.grabber { display: none; }
.panel .close { position: sticky; top: 0; float: right; margin: -8px -8px 0 0; z-index: 1; }
.close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; padding: 0; font-size: 20px; box-shadow: var(--shadow); background: #efe6d4; }
.panel .photo { width: 100%; aspect-ratio: 1; border-radius: 14px; background: #e9e1d1 center/cover no-repeat; display: grid; place-items: center; font-size: 72px; margin-bottom: 14px; }
.thumbs { display: flex; gap: 6px; margin: -6px 0 12px; flex-wrap: wrap; }
.thumbs button { width: 44px; height: 44px; padding: 0; border-radius: 10px; background: #e9e1d1 center/cover no-repeat; box-shadow: none; outline: 2px solid transparent; }
.thumbs button.on { outline-color: var(--sage); }
.zone-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--sage-soft); color: var(--sage-dark); margin-bottom: 6px; }
.panel h2 { font-size: 28px; margin: 0; }
.years { color: var(--muted); margin: 2px 0 10px; }
blockquote { margin: 0 0 8px; font-family: Fraunces, Georgia, serif; font-style: italic; font-size: 17px; }
.by { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.stats { display: flex; gap: 14px; font-size: 14px; margin-bottom: 12px; color: var(--sage-dark); font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.actions button { flex: 1; box-shadow: none; background: #efe6d4; }
.actions button.big { flex: 2; background: var(--ink); color: #ffe7b0; font-weight: 600; }
.actions.secondary button { background: transparent; border: 1px solid var(--line); }
.actions.secondary button.primary { background: var(--sage); color: #fff; border: 0; }
.notes summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.notes ul { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
.notes li { background: #fff; border-radius: 12px; padding: 8px 10px; font-size: 14px; }
.notes li b { display: block; font-size: 12px; color: var(--muted); }
.notes textarea { width: 100%; min-height: 70px; border-radius: 12px; border: 1px solid var(--line); padding: 8px; font: inherit; resize: vertical; margin-bottom: 6px; }

/* ---- decorate ---- */
.decor h2 { font-size: 22px; padding-right: 30px; }
.decor h3 { font-size: 13px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--sage-dark); }
.decor h3 small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; }
.sub { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.decor input#d-epitaph { width: 100%; font: inherit; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid .ph { position: relative; aspect-ratio: 1; border-radius: 10px; background: #e9e1d1 center/cover no-repeat; }
.photo-grid .ph.cover::after { content: 'Cover'; position: absolute; left: 4px; bottom: 4px; font-size: 10px; background: var(--sage); color: #fff; padding: 2px 6px; border-radius: 6px; }
.photo-grid .ph button { position: absolute; padding: 2px 7px; font-size: 11px; box-shadow: none; }
.photo-grid .ph .rm { top: 4px; right: 4px; }
.photo-grid .ph .cv { top: 4px; left: 4px; }
.add-photo { display: block; margin-top: 8px; text-align: center; padding: 10px; border: 2px dashed var(--line); border-radius: 12px; cursor: pointer; font-weight: 600; color: var(--sage-dark); }
.add-photo input { display: none; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 38px; height: 38px; padding: 0; box-shadow: none; border: 3px solid #fff; outline: 2px solid transparent; }
.swatches button.on { outline-color: var(--ink); }
.chips, .items { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button, .items button { box-shadow: none; background: #efe6d4; padding: 8px 12px; font-size: 13px; }
.chips button.on { background: var(--sage); color: #fff; }
.placed { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.placed button { box-shadow: none; background: #fff; border: 1px solid var(--line); font-size: 12px; padding: 6px 10px; }
#d-undo { margin-top: 6px; padding: 6px 10px; }
.owner-link { margin-top: 18px; padding: 12px; background: #fff; border-radius: 12px; }
.owner-link p { margin: 4px 0 8px; }

/* ---- modals ---- */
.modal { position: fixed; inset: 0; background: rgba(40, 32, 24, .35); display: grid; place-items: center; padding: 16px; z-index: 10; }
.card { position: relative; background: var(--cream); border-radius: var(--radius); padding: 24px; width: min(440px, calc(100vw - 32px)); max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; overflow-x: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.card > * { flex-shrink: 0; }
.card p { margin: 0; color: var(--muted); }
.card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
.card input:not([type=radio]):not([type=file]), .card select { font: inherit; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); width: 100%; min-width: 0; }
.err { color: #b24a3a !important; min-height: 1em; font-size: 13px; }

.wizard h1 { font-size: 24px; padding-right: 30px; }
.steps { display: flex; gap: 6px; }
.steps i { width: 26px; height: 5px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--sage); }
.step { display: flex; flex-direction: column; gap: 12px; }
.wizard-nav { display: flex; gap: 8px; justify-content: space-between; }
.wizard-nav .primary { flex: 1; }
.photo-pick { align-items: center; justify-content: center; border: 2px dashed var(--line); border-radius: 14px; height: 170px; cursor: pointer; background: #fff center/cover no-repeat; font-size: 15px !important; color: var(--sage-dark) !important; font-weight: 600 !important; }
.photo-pick input { display: none; }
.species { display: flex; gap: 6px; flex-wrap: wrap; }
.species button { box-shadow: none; background: #fff; border: 1px solid var(--line); padding: 7px 12px; font-size: 14px; }
.species button.on { background: var(--sage); border-color: var(--sage); color: #fff; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.marker-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.marker-cards label { cursor: pointer; }
.marker-cards input { display: none; }
.marker-cards span { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; border: 1px solid var(--line); border-radius: 14px; background: #fff; font-size: 28px; color: var(--ink); }
.marker-cards b { font-size: 14px; }
.marker-cards small { font-size: 11px; color: var(--muted); font-weight: 400; }
.marker-cards input:checked + span { border-color: var(--sage); box-shadow: 0 0 0 2px rgba(111,143,106,.3); }
.free-note { background: var(--sage-soft); color: var(--ink) !important; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.supporter summary { cursor: pointer; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; list-style: none; }
.supporter summary::-webkit-details-marker { display: none; }
.supporter[open] summary { margin-bottom: 8px; }
.zones { border: 0; padding: 0; margin: 0 0 6px; display: flex; flex-direction: column; gap: 6px; }
.zones label { flex-direction: row !important; align-items: center; gap: 10px !important; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--ink) !important; cursor: pointer; }
.zones label:has(input:checked) { border-color: var(--sage); box-shadow: 0 0 0 2px rgba(111,143,106,.25); }
.zones label span { display: flex; flex-direction: column; flex: 1; font-size: 14px; }
.zones label small { color: var(--muted); font-weight: 400; font-size: 12px; }
.zones label em { font-style: normal; font-weight: 700; color: var(--sage-dark); }
.zones .left { font-style: normal; font-size: 11px; color: var(--muted); min-width: 52px; text-align: right; }

.find-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.find-list button { width: 100%; text-align: left; box-shadow: none; background: #fff; border-radius: 12px; display: flex; gap: 10px; align-items: center; }
.find-list .thumb { width: 36px; height: 36px; border-radius: 9px; background: #efe6d4 center/cover no-repeat; display: grid; place-items: center; flex-shrink: 0; }

/* ---- quiet view ---- */
.quiet { position: fixed; inset: 0; background: var(--cream); overflow-y: auto; z-index: 8; padding: 72px 16px 40px; }
.quiet-head { max-width: 960px; margin: 0 auto 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.quiet-head h1 { margin: 0; flex: 1; }
.quiet-head input { font: inherit; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); min-width: 0; flex: 1 1 180px; }
.quiet-list { list-style: none; padding: 0; margin: 0 auto; max-width: 960px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.quiet-list li { background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(40,30,20,.06); display: flex; flex-direction: column; }
.quiet-list .qp { aspect-ratio: 1; background: #efe6d4 center/cover no-repeat; display: grid; place-items: center; font-size: 56px; }
.quiet-list .qb { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.quiet-list h2 { font-size: 19px; margin: 0; }
.quiet-list small { color: var(--muted); }
.quiet-list .qa { display: flex; gap: 6px; margin-top: 6px; }
.quiet-list .qa button { flex: 1; box-shadow: none; padding: 7px 8px; font-size: 13px; background: #efe6d4; }

/* ---- overlays ---- */
.recording { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #2f2a24; color: #ffe7b0; padding: 14px 22px; border-radius: 999px; z-index: 20; }
.toast { position: fixed; top: 110px; left: 50%; transform: translateX(-50%); background: #2f2a24; color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 20; font-size: 14px; max-width: calc(100% - 32px); text-align: center; }
.portal-fade { position: fixed; inset: 0; background: radial-gradient(circle, #fff7e0, #f6d6a8 60%, #c9b2e6); opacity: 0; pointer-events: none; transition: opacity .35s ease; z-index: 30; }
.portal-fade.on { opacity: 1; }
.zone-toast { position: fixed; top: 38%; left: 50%; transform: translate(-50%, -50%); font-family: Fraunces, Georgia, serif; font-size: 34px; color: #fff; text-shadow: 0 2px 18px rgba(0,0,0,.35); opacity: 0; transition: opacity .6s; pointer-events: none; z-index: 31; text-align: center; white-space: nowrap; }
.zone-toast small { display: block; font-family: Inter, sans-serif; font-size: 14px; }
.zone-toast.on { opacity: 1; }

/* ---- phones: bottom sheets ---- */
@media (max-width: 640px) {
  .brand { font-size: 15px; padding: 7px 12px; }
  .brand-text, .online-label { display: none; }
  .top-right { gap: 6px; }
  .icon { padding: 7px 9px; font-size: 15px; }
  .online { font-size: 12px; padding: 7px 10px; }
  .ceremony { top: 60px; font-size: 11px; }
  .intro { top: 22%; }
  .panel { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-width: 100%; max-height: 72vh; border-radius: 22px 22px 0 0; padding: 12px 18px calc(18px + var(--safe-b)); }
  /* a tall invisible strip around the handle, so it's easy to catch with a thumb and drag down */
  .grabber { display: block; position: relative; height: 26px; margin: -12px -18px 4px; touch-action: none; }
  .grabber::before { content: ''; position: absolute; left: 50%; top: 10px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--line); }
  .panel { transition: transform .2s ease; }
  .hint { bottom: calc(96px + var(--safe-b)); padding: 0 16px; }
  .activity { top: 64px; bottom: auto; left: 16px; right: 16px; width: auto; align-items: flex-start; }
  .panel .photo { aspect-ratio: 4 / 3; }
  .dock { bottom: calc(18px + var(--safe-b)); }
  .dock-btn { min-width: 68px; padding: 8px 10px; }
  .emote-tray { right: 50%; transform: translateX(50%); }
  .emote-tray button { min-width: 48px; padding: 6px 4px; }
  .card { padding: 20px; }
}

/* ---- choosing a spot ---- */
.pickbar { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); background: var(--cream); border-radius: 20px; box-shadow: var(--shadow); padding: 14px 16px; width: min(520px, calc(100% - 32px)); z-index: 7; display: flex; flex-direction: column; gap: 10px; }
.pickbar p { margin: 0; font-size: 14px; text-align: center; }
.pick-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pick-actions button { box-shadow: none; background: #efe6d4; }
.pick-actions button.primary { background: var(--sage); }
.pick-actions button.ghost { background: transparent; }

/* ---- how you look ---- */
.me-panel h3 { font-size: 13px; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--sage-dark); }
.me-panel .swatches button { width: 34px; height: 34px; }

/* ---- ☰ menu ---- */
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 8px); right: 0; background: var(--cream); border-radius: 16px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; min-width: 200px; z-index: 6; }
.menu-item { display: flex; align-items: center; gap: 10px; box-shadow: none; background: transparent; border-radius: 12px; padding: 10px 12px; text-align: left; font-size: 14px; white-space: nowrap; }
.menu-item:hover { background: #efe6d4; filter: none; }
.menu-item i { font-style: normal; font-size: 18px; width: 22px; text-align: center; }

/* ---- reporting ---- */
.report-link { display: block; margin: 4px auto 0; background: transparent; box-shadow: none; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.notes li { position: relative; }
.note-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.note-tools button { box-shadow: none; background: transparent; color: var(--muted); font-size: 11px; padding: 2px 6px; }
a.menu-item { color: var(--ink); text-decoration: none; }

/* ---- sign in ---- */
.g-btn { display: flex; justify-content: center; min-height: 44px; }

.qp-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
