:root {
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1c1f1d;
  --muted: #6b726d;
  --line: #e4e7e3;
  --danger: #b91c1c;
  --warn: #b45309;
  --note: #fef9c3;
  --radius: 16px;
  --martin: #2563eb;
  --nienke: #9333ea;
  --coen: #ea580c;
  --femke: #db2777;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #2dd4bf;
    --accent-soft: #123b37;
    --bg: #111312;
    --card: #1b1e1c;
    --text: #eef1ee;
    --muted: #9aa39d;
    --line: #2b302d;
    --danger: #f87171;
    --warn: #fbbf24;
    --note: #3b3720;
    --martin: #60a5fa;
    --nienke: #c084fc;
    --coen: #fb923c;
    --femke: #f472b6;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }

h1 { font-size: 1.6rem; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; margin: 0; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.85rem; }
.pad { padding: 0 16px; }
.over { color: var(--danger) !important; }
.warn { color: var(--warn); }
a { color: var(--accent); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.page { max-width: 640px; margin: 0 auto; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* --- Buttons and fields --- */
.button {
  display: block;
  border: 0;
  border-radius: 12px;
  padding: 13px 16px;
  background: var(--line);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--text);
}
.button.primary { background: var(--accent); color: #fff; }
.button.danger { background: transparent; color: var(--danger); }
.button.danger-fill { background: var(--danger); color: #fff; }
.button.wide { width: 100%; }
.button.wide + .button.wide { margin-top: 8px; }
.button:disabled { opacity: 0.45; }
.small-button { display: inline-block; padding: 8px 12px; font-size: 0.9rem; }
.link-button { border: 0; background: none; padding: 10px 0 0; color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.chip-button { border: 0; border-radius: 99px; padding: 7px 12px; background: var(--card); font-size: 0.85rem; font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

.icon-button {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--line);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}
.icon-button.small { width: 36px; height: 36px; background: transparent; }
.icon-button:disabled { opacity: 0.3; }
.icon-button svg { width: 22px; height: 22px; fill: currentColor; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.field > small { display: block; margin-top: 4px; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 17px; /* 16px or more keeps iOS from zooming in */
}
textarea.input { resize: vertical; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 18px center, right 13px center; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.actions .button { flex: 1; }
.spacer { flex: 1; }
.error { color: var(--danger); min-height: 1.4em; margin: 0 0 8px; }

/* --- Avatars --- */
.avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--muted);
}
.avatar[data-person="Martin"] { background: var(--martin); }
.avatar[data-person="Nienke"] { background: var(--nienke); }
.avatar[data-person="Coen"] { background: var(--coen); }
.avatar[data-person="Femke"] { background: var(--femke); }

/* --- Login --- */
.login { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 32px) 24px 32px; text-align: center; }
.login-icon { width: 84px; height: 84px; border-radius: 22px; margin: 10px auto 14px; display: block; }
.login form { text-align: left; margin-top: 24px; }
.members { border: 0; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.members legend { padding: 0; margin-bottom: 8px; font-weight: 600; }
.member {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-weight: 600;
  cursor: pointer;
}
.member input { position: absolute; opacity: 0; pointer-events: none; }
.member:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* --- Headers --- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.top.sub { justify-content: flex-start; }
.top.sub h1 { font-size: 1.3rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-button {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.1);
  display: grid;
  place-items: center;
  color: var(--text);
}
.home-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.member-chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  background: var(--card);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
  font-weight: 600;
}
.section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 18px 16px 8px; font-weight: 700; }

/* --- Home --- */
.hero {
  display: block;
  margin: 0 16px;
  height: 180px;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(160deg, #8fb3a8 0%, #5d8a7c 45%, #3f6b5e 100%);
  text-decoration: none;
}
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero.empty::before { content: "🏡"; position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 64px; }
.hero .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 32px 14px 10px; background: linear-gradient(transparent, rgb(0 0 0 / 0.6)); }
.hero .cap b { display: block; font-size: 1.05rem; }
.hero .cap span { font-size: 0.8rem; opacity: 0.92; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 16px; }
.tile {
  --t: var(--accent);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 112px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
  border-top: 4px solid var(--t);
}
.tile:active { transform: scale(0.98); }
.tile i { font-style: normal; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; background: color-mix(in srgb, var(--t) 14%, transparent); margin-bottom: auto; }
.tile b { font-size: 1rem; line-height: 1.2; margin-top: 8px; }
.tile span { font-size: 0.8rem; color: var(--muted); }
.tile .lock { position: absolute; right: 12px; top: 12px; font-size: 0.9rem; }
.tile .bar { margin-top: 6px; }
.tile.wide { grid-column: span 2; min-height: 0; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; }
.tile.wide i { grid-row: span 2; margin: 0; }
.tile.wide b { margin: 0; }

/* --- Budget bars --- */
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; display: flex; }
.bar.large { height: 12px; margin: 12px 0 8px; }
.bar > * { height: 100%; }
.bar .paid { background: var(--k, var(--accent)); }
.bar .plan { background: color-mix(in srgb, var(--k, var(--accent)) 40%, transparent); }
.bar.over .paid, .bar.over .plan { background: var(--danger); }

/* --- Filters --- */
.filters { display: flex; flex-direction: column; gap: 10px; padding: 0 0 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 0; padding: 8px 14px; border-radius: 99px; background: var(--card); font-size: 0.88rem; font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.chips button.on { background: var(--text); color: var(--bg); }
.chips.wrap { flex-wrap: wrap; padding: 0; overflow: visible; }
.chips.wrap button { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.chips.wrap button.on { background: var(--text); }
.segmented { display: flex; background: var(--line); border-radius: 12px; padding: 3px; }
.filters .segmented { margin: 0 16px; }
.segmented button { flex: 1; border: 0; background: none; text-align: center; padding: 9px 4px; font-size: 0.9rem; font-weight: 600; border-radius: 9px; color: var(--muted); }
.segmented button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }

/* --- Photos --- */
.day { padding: 14px 16px 6px; font-weight: 700; font-size: 0.95rem; display: flex; justify-content: space-between; gap: 8px; }
.day::first-letter { text-transform: uppercase; }
.day span { color: var(--muted); font-weight: 400; font-size: 0.85rem; text-align: right; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
@media (min-width: 560px) { .grid3 { grid-template-columns: repeat(4, 1fr); } }
.ph { aspect-ratio: 1; border: 0; padding: 0; background: var(--line); position: relative; overflow: hidden; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph.video::after { content: "▶"; position: absolute; right: 6px; bottom: 4px; color: #fff; font-size: 0.85rem; text-shadow: 0 1px 3px rgb(0 0 0 / 0.6); }
.pick-preview { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; }
.pick-preview img, .pick-video { flex: none; width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--line); display: grid; place-items: center; }

/* --- Floating button --- */
.fab-space { height: 90px; }
.fab {
  position: fixed;
  right: max(18px, calc(50vw - 302px));
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 6;
  height: 56px;
  padding: 0 22px;
  border: 0;
  border-radius: 28px;
  background: var(--fab, var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgb(0 0 0 / 0.25);
}
.fab span { font-size: 1.2rem; }

/* --- Cards and rows --- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgb(0 0 0 / 0.07); margin: 0 16px; }
.rows .row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; }
.rows .row:last-child { border-bottom: 0; }
.rows button.row:disabled { opacity: 1; cursor: default; }
.rows .row.selected { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.row-main { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: center; border: 0; background: none; padding: 0; text-align: left; }
.docs .row { padding: 10px 6px 10px 14px; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t span { font-size: 0.8rem; color: var(--muted); }
.thumb { width: 52px; height: 52px; border-radius: 10px; flex: none; display: grid; place-items: center; font-size: 0.7rem; font-weight: 800; color: #fff; background: #64748b; object-fit: cover; }
.thumb.pdf { background: #dc2626; }
.thumb.model { background: #7c3aed; }
.thumb.link { background: #0369a1; }
.badge { flex: none; font-size: 0.7rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge.old { background: var(--line); color: var(--muted); }
.chev { color: var(--muted); }
.older-toggle { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 8px 14px 10px 78px; text-align: left; color: var(--accent); font-size: 0.85rem; font-weight: 600; }
.older { background: color-mix(in srgb, var(--line) 35%, transparent); }
.price { font-weight: 700; white-space: nowrap; text-align: right; }
.price small { display: block; font-weight: 600; font-size: 0.72rem; }
.readonly { margin: 0 16px 12px; padding: 10px 12px; border-radius: 12px; background: var(--line); font-size: 0.88rem; color: var(--muted); }

.empty { text-align: center; padding: 40px 32px; color: var(--muted); }
.empty-icon { font-size: 44px; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }

/* --- Floor plans --- */
.plan-card { margin-bottom: 14px; overflow: hidden; }
.plan-image { display: block; width: 100%; border: 0; padding: 0; background: #fff; position: relative; }
.plan-image img { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
.plan-zoom { position: absolute; right: 10px; bottom: 10px; width: 40px; height: 40px; border-radius: 12px; background: var(--card); color: var(--text); display: grid; place-items: center; box-shadow: 0 1px 4px rgb(0 0 0 / 0.2); }
.plan-zoom svg, .model-full svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.plan-pdf { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 14px; font-weight: 600; }
.plan-meta { display: flex; align-items: center; justify-content: space-between; padding: 8px 6px 8px 14px; border-top: 1px solid var(--line); }

/* --- 3D --- */
.model-stage { position: relative; margin: 0 16px; height: min(62vh, 520px); border-radius: var(--radius); overflow: hidden; background: radial-gradient(circle at 50% 40%, #fff 0%, #e3e8e5 75%); box-shadow: 0 1px 3px rgb(0 0 0 / 0.07); }
.model-stage model-viewer { width: 100%; height: 100%; --poster-color: transparent; }
.model-stage.full { position: fixed; inset: 0; margin: 0; height: 100dvh; border-radius: 0; z-index: 30; padding-top: env(safe-area-inset-top); }
.model-full { position: absolute; right: 10px; top: calc(10px + env(safe-area-inset-top) * var(--full, 0)); width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--card); color: var(--text); display: grid; place-items: center; box-shadow: 0 1px 4px rgb(0 0 0 / 0.2); z-index: 2; }
.model-stage.full .model-full { --full: 1; }
.model-hint { position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; font-size: 0.78rem; color: #4b524d; pointer-events: none; }

/* --- Moodboard --- */
.masonry { columns: 2; column-gap: 10px; padding: 0 16px; }
@media (min-width: 560px) { .masonry { columns: 3; } }
.mb { break-inside: avoid; margin-bottom: 10px; border-radius: 14px; overflow: hidden; background: var(--card); box-shadow: 0 1px 3px rgb(0 0 0 / 0.07); cursor: pointer; }
.mb img { display: block; width: 100%; height: auto; background: var(--line); }
.mb-link { display: flex; align-items: center; gap: 8px; padding: 18px 12px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 0.85rem; word-break: break-all; }
.mb-link svg, .like svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; }
.mb-cap { display: flex; align-items: flex-start; gap: 4px; padding: 8px 4px 8px 10px; font-size: 0.78rem; color: var(--muted); }
.mb-cap > div { flex: 1; min-width: 0; }
.mb-cap b { display: block; font-size: 0.86rem; color: var(--text); }
.sw { display: flex; height: 70px; }
.sw div { flex: 1; }
.note { padding: 12px; font-size: 0.92rem; background: var(--note); white-space: pre-wrap; }
.like { flex: none; display: flex; align-items: center; gap: 3px; border: 0; background: none; padding: 4px 6px; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.like.on { color: #e11d48; }
.like.on svg { fill: currentColor; }
.kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kind { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); padding: 22px 10px; font-weight: 700; font-size: 1rem; }
.color-rows { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.color-row { display: flex; gap: 8px; align-items: center; width: 100%; }
.color-row input[type="color"] { flex: none; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: var(--bg); }
.swatches { display: grid; gap: 8px; margin-bottom: 14px; }
.swatch { display: grid; grid-template-columns: 48px 1fr; column-gap: 12px; align-items: center; }
.swatch i { grid-row: span 2; width: 48px; height: 48px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.1); }
.note-text { white-space: pre-wrap; }
.sheet-image { display: block; width: 100%; max-height: 50vh; object-fit: contain; border-radius: 12px; margin-bottom: 14px; background: var(--line); }

/* --- Link previews --- */
.linkprev { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 12px; margin: -6px 0 14px; font-size: 0.85rem; }
.linkprev img, .linkprev .img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--line); }

/* --- Kids' rooms --- */
.budget { padding: 16px; }
.budget .big { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.budget .big b { font-size: 2rem; letter-spacing: -0.02em; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.paid { background: var(--k); }
.legend i.plan { background: color-mix(in srgb, var(--k) 40%, transparent); }
.items .row { padding: 10px 14px; }
.item-img { width: 54px; height: 54px; border-radius: 10px; flex: none; object-fit: cover; background: var(--line); }
.empty-img { display: grid; place-items: center; font-size: 1.4rem; }
.item-picture { display: flex; align-items: center; gap: 10px; }
.item-picture img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--line); }
.st { font-size: 0.72rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.st.buy { background: #dcfce7; color: #15803d; }
.st.wish { background: #fef3c7; color: #92400e; }
.after { padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 0.9rem; font-weight: 600; margin-bottom: 14px; }
.after.over { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* --- PIN --- */
.pinpad { text-align: center; padding: 8px 24px 16px; max-width: 360px; margin: 0 auto; }
.pin-lock { font-size: 40px; margin-top: 8px; }
.pinpad h2 { margin-top: 6px; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 22px 0 6px; }
.dots i { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--text); }
.dots i.f { background: var(--text); }
.pinpad .error { text-align: center; }
.keys { display: grid; grid-template-columns: repeat(3, 72px); justify-content: center; gap: 14px 24px; margin-bottom: 20px; }
.keys button { width: 72px; height: 72px; border-radius: 50%; border: 0; background: var(--card); font-size: 1.7rem; box-shadow: 0 1px 2px rgb(0 0 0 / 0.1); }
.sheet .keys button { background: var(--bg); }
.keys button:active { background: var(--line); }

/* --- Renovation budget --- */
.sum { padding: 16px; }
.sum-total { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
.nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nums span { display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.nums b { font-size: 1.02rem; }
.sum-diff { margin: 12px 0 0; padding: 8px 10px; border-radius: 10px; font-weight: 600; font-size: 0.9rem; }
.sum-diff.ok { background: var(--accent-soft); color: var(--accent); }
.sum-diff.over { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.cat .row { flex-wrap: wrap; row-gap: 6px; }
.cat .row .bar { flex-basis: 100%; height: 6px; }
.cat .row.static { cursor: default; }
.pad.muted { margin-top: 10px; }
.attachments { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.attachment { display: flex; align-items: center; gap: 8px; width: 100%; }
.attachment a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

/* --- Rooms --- */
.room-emoji { width: 28px; text-align: center; font-size: 1.2rem; }
.add-room { display: flex; gap: 8px; padding: 12px; margin-top: 14px; }
.add-room.plain { padding: 0; margin: 0 0 14px; }
.emoji-input { flex: none; width: 64px; text-align: center; }

/* --- Sheets and menus --- */
dialog.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--card);
  color: var(--text);
  overflow: auto;
  overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgb(0 0 0 / 0.4); }
dialog.sheet[open] { animation: up 0.2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 14px 12px 8px 18px; background: var(--card); }
.sheet-head h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { padding: 4px 18px calc(22px + env(safe-area-inset-bottom)); }
.menu { display: flex; flex-direction: column; }
.menu-item { display: block; width: 100%; padding: 15px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-weight: 600; color: var(--text); text-decoration: none; }
.menu-item:last-child { border-bottom: 0; }
.menu-item.danger { color: var(--danger); }
.tips summary { cursor: pointer; list-style: none; }
.tips p { font-weight: 400; font-size: 0.9rem; color: var(--muted); margin: 8px 0 0; }

/* --- Viewer --- */
.viewer { position: fixed; inset: 0; z-index: 40; background: #000; color: #fff; display: flex; flex-direction: column; }
.viewer-top { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; }
.viewer-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgb(255 255 255 / 0.15); color: #fff; font-size: 1rem; }
.viewer-count { font-size: 0.9rem; opacity: 0.8; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.viewer-media { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; will-change: transform; }
video.viewer-media { width: 100%; }
.viewer-media.from-right { animation: from-right 0.2s ease-out; }
.viewer-media.from-left { animation: from-left 0.2s ease-out; }
@keyframes from-right { from { opacity: 0.3; translate: 40px 0; } }
@keyframes from-left { from { opacity: 0.3; translate: -40px 0; } }
.viewer-caption { padding: 10px 16px 0; min-height: 3em; }
.viewer-caption b { display: block; }
.viewer-caption span { font-size: 0.85rem; opacity: 0.75; }
.viewer-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
.viewer-bar:empty { padding-top: 0; }
.viewer-button { flex: none; border: 0; border-radius: 10px; padding: 10px 14px; background: rgb(255 255 255 / 0.14); color: #fff; font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.viewer-button.danger { color: #fca5a5; }

/* --- Messages --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: #1c1f1d;
  color: #fff;
  font-size: 0.95rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.3);
}
.toast button { border: 0; background: none; color: #5eead4; font-weight: 700; }
.update { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: var(--accent-soft); font-size: 0.9rem; font-weight: 600; }
.update span { flex: 1; }
.update .button { padding: 8px 14px; }
.progress { position: fixed; top: 0; left: 0; right: 0; z-index: 45; padding: calc(env(safe-area-inset-top) + 8px) 16px 10px; background: var(--card); box-shadow: 0 2px 10px rgb(0 0 0 / 0.15); font-size: 0.88rem; font-weight: 600; }
.progress-bar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* --- Pull to refresh --- */
.pull { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 8px); z-index: 10; width: 40px; height: 40px; border-radius: 50%; background: var(--card); box-shadow: 0 2px 8px rgb(0 0 0 / 0.15); display: grid; place-items: center; opacity: 0; transform: translate(-50%, -56px); pointer-events: none; }
.pull svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pull.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
.section-title.split { display: flex; justify-content: space-between; }
.sum-line { display: flex; justify-content: space-between; font-size: 0.92rem; color: var(--muted); margin-top: 4px; }
.sum-line b { color: var(--text); }
.sum-total.over { color: var(--danger); }
.links .row { color: var(--text); text-decoration: none; }
.links .row-main { color: var(--text); text-decoration: none; }
.link-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; flex: none; }
.link-button.inline { padding: 0; text-transform: none; letter-spacing: 0; font-size: 0.85rem; }
.features { margin-bottom: 4px; padding: 2px 14px; }
.feature { display: grid; grid-template-columns: minmax(110px, 42%) 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }
.feature:last-child { border-bottom: 0; }
.feature dt { color: var(--muted); }
.feature dd { margin: 0; font-weight: 600; }
.page > .muted.small.pad:first-of-type { margin-bottom: 4px; }

/* --- Who is around, and looking as someone else --- */
.sheet-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 6px 0 8px; }
.presence { list-style: none; margin: 0 0 18px; padding: 0; }
.presence-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.presence-row:last-child { border-bottom: 0; }
.presence-name { flex: 1; font-weight: 600; }
.presence-status { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.presence-row.online .presence-status { color: #16a34a; font-weight: 600; }
.presence-row.online .presence-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #16a34a; }
.members.switch { margin-bottom: 8px; }
.members.switch .member { font: inherit; font-weight: 600; text-align: left; }
.member.current { border-color: var(--accent); background: var(--accent-soft); }
.viewing { position: sticky; top: 0; z-index: 8; display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: #fef3c7; color: #78350f; font-size: 0.92rem; }
.viewing span { flex: 1; }
.viewing .button { padding: 8px 12px; font-size: 0.85rem; background: #fff; }
.viewing:not([hidden]) ~ .page .top { top: calc(env(safe-area-inset-top) + 52px); }
.hero-wrap { position: relative; padding-top: calc(env(safe-area-inset-top) + 12px); }
.member-chip.on-hero { position: absolute; top: calc(env(safe-area-inset-top) + 24px); right: 28px; box-shadow: 0 2px 8px rgb(0 0 0 / 0.25); }
.viewing:not([hidden]) ~ .page .hero-wrap { padding-top: 12px; }
.viewing:not([hidden]) ~ .page .member-chip.on-hero { top: 24px; }

/* --- Shared links --- */
.switch-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.switch-row > span { flex: 1; display: flex; flex-direction: column; }
input.switch { appearance: none; width: 52px; height: 32px; border-radius: 16px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background 0.15s; }
input.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); transition: transform 0.15s; }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(20px); }
.share-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.share-side .link-button { padding: 4px 0 0; }
.link-button.danger { color: var(--danger); }
.share-gate { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 40px) 24px; text-align: center; }
.share-gate form { text-align: left; margin-top: 20px; }
.shared-note { margin: -4px 16px 12px; font-size: 0.82rem; color: var(--muted); }
.shared .fab, .shared .fab-space, .shared .home-button, .shared .like, .shared .readonly, .shared .link-button { display: none !important; }
.shared .top.sub { padding-left: 20px; }

/* --- Loading a 3D model --- */
.model-loading { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; text-align: center; background: color-mix(in srgb, var(--card) 88%, transparent); }
.model-loading b { font-size: 1.05rem; margin-top: 8px; }
.model-bar { width: min(240px, 70%); height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.model-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.model-percent { font-size: 0.85rem; font-weight: 700; color: var(--accent); min-height: 1.2em; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.model-loading.failed .spinner, .model-loading.failed .model-bar { display: none; }
.model-loading.failed b { color: var(--danger); }
.share-url { font-size: 16px; }
.share-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.button.whatsapp { background: #25d366; color: #fff; }
