/* Vellum — product UI (sign in, admin panel, couple dashboard, memories upload).
   Brand tokens: plum ink, lilac-grey vellum, wax-seal red, gilt hairlines. */
:root {
  --plum: #2B2130; --plum-2: #3A2E40; --vellum: #E9E4EC; --vellum-2: #F4F1F6; --sheet: #FFFFFF;
  --seal: #9E2F3A; --seal-2: #7F2530; --gilt: #C8A96A; --graphite: #5C5560; --line: #D9D2DE; --line-2: #EAE5EE;
  --ok: #2F6B4F; --ok-bg: #E4F1EA; --warn: #8A5A12; --warn-bg: #FBF0DB; --bad: #B3261E; --bad-bg: #FDECEA;
  --serif: 'Instrument Serif', Georgia, serif; --sans: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--sans); color: var(--plum); background: var(--vellum); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-weight: 400; }
h1, h2 { font-family: var(--serif); letter-spacing: -.01em; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 26px; line-height: 1.15; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
a { color: var(--seal); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--graphite); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent; background: var(--seal); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { background: var(--seal-2); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.sec { background: var(--sheet); color: var(--plum); border-color: var(--line); }
.btn.sec:hover { border-color: var(--plum); }
.btn.ghost { background: transparent; color: var(--plum); border-color: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { background: var(--sheet); color: var(--bad); border-color: #EBC3C0; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.wa { background: #1F7A4D; }
.btn.wa:hover { background: #17603C; }
.btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--line); background: var(--sheet); cursor: pointer; color: var(--plum); }
.icon-btn:hover { border-color: var(--plum); }
.icon-btn svg { width: 16px; height: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ---------- form fields ---------- */
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--plum); }
.field small, .hint { font-size: 13px; color: var(--graphite); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--sheet); font-size: 16px; }
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 3px rgba(43,33,48,.1); }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stack { display: grid; gap: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--seal); flex: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; padding: 12px 0; }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(18px); }
.switch b { display: block; font-weight: 600; }
.switch .hint { display: block; }

/* ---------- notices ---------- */
.notice { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; background: var(--vellum-2); border: 1px solid var(--line); }
.notice.warn { background: var(--warn-bg); border-color: #EED7A8; color: var(--warn); }
.notice.bad { background: var(--bad-bg); border-color: #F2C4C0; color: var(--bad); }
.notice.ok { background: var(--ok-bg); border-color: #BFDCCB; color: var(--ok); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--line-2); color: var(--graphite); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.plum { background: var(--plum); color: #fff; }

#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(420px, calc(100% - 24px)); pointer-events: none; }
.toast { background: var(--plum); color: #fff; padding: 12px 16px; border-radius: var(--r); font-size: 14px; box-shadow: 0 12px 32px -12px rgba(0,0,0,.45); animation: toast-in .25s ease-out; }
.toast.bad { background: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (min-width: 900px) { #toast { bottom: 24px; } }

/* ---------- auth pages (login / setup) ---------- */
.auth { min-height: 100svh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .auth { grid-template-columns: 1.1fr 1fr; } }
.auth-art { background: var(--plum); color: var(--vellum); padding: 32px; display: none; position: relative; overflow: hidden; }
@media (min-width: 900px) { .auth-art { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-art .quote { font-family: var(--serif); font-size: 44px; line-height: 1.05; max-width: 11em; }
.auth-art .cards { position: absolute; right: -40px; bottom: -60px; width: 420px; height: 520px; }
.auth-main { display: flex; flex-direction: column; justify-content: center; padding: 32px 22px; }
.auth-box { width: 100%; max-width: 380px; margin: 0 auto; display: grid; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 26px; color: inherit; text-decoration: none; }
.brand svg { width: 30px; height: 30px; }

/* ---------- app shell (admin + dashboard) ---------- */
.shell { min-height: 100svh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .shell { grid-template-columns: 236px 1fr; } }
.side { background: var(--plum); color: var(--vellum); padding: 20px 14px; display: none; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100svh; }
@media (min-width: 900px) { .side { display: flex; } }
.side .brand { color: #fff; padding: 0 8px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #D8CFDD; text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--plum-2); color: #fff; }
.nav a[aria-current="page"] { background: var(--vellum); color: var(--plum); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; font-size: 13px; color: #BDB2C3; padding: 0 8px; display: grid; gap: 8px; }
.side-foot button { background: none; border: 0; color: #fff; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--plum); padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 900px) { .tabbar { display: none; } }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px 8px; color: #BDB2C3; text-decoration: none; font-size: 11px; font-weight: 500; }
.tabbar a[aria-current="page"] { color: #fff; }
.tabbar a[aria-current="page"] svg { color: var(--gilt); }
.tabbar svg { width: 21px; height: 21px; }

.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; background: rgba(233,228,236,.92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 26px; }
.save-state { font-size: 13px; color: var(--graphite); display: inline-flex; align-items: center; gap: 6px; }
.save-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.save-state.saving::before { background: var(--gilt); }
.save-state.error::before { background: var(--bad); }

.main { min-width: 0; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .main { padding-bottom: 40px; } }
.page { padding: 20px 18px; max-width: 980px; display: grid; gap: 18px; }
@media (min-width: 900px) { .page { padding: 28px 32px; } }
.page.with-preview { max-width: none; }
@media (min-width: 1200px) { .page.with-preview { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; } }

.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; display: grid; gap: 16px; }
@media (min-width: 700px) { .sheet { padding: 24px; } }
.sheet > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.sheet > header p { color: var(--graphite); font-size: 14px; margin-top: 4px; }
.sheet.tight { gap: 10px; }
details.sheet > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
details.sheet > summary::-webkit-details-marker { display: none; }
details.sheet > summary::after { content: "+"; font-size: 22px; font-weight: 400; color: var(--graphite); }
details.sheet[open] > summary::after { content: "–"; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat { background: var(--sheet); padding: 16px 18px; }
.stat b { display: block; font-family: var(--serif); font-size: 34px; font-weight: 400; line-height: 1; }
.stat span { font-size: 13px; color: var(--graphite); }

.linkbox { display: flex; gap: 8px; align-items: center; background: var(--vellum-2); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 6px 6px 14px; min-width: 0; }
.linkbox code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 14px var(--sans); }

/* repeaters (events, schedule, story…) */
.rep { display: grid; gap: 12px; }
.rep-item { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 12px; background: var(--vellum-2); }
.rep-item .rep-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rep-item .rep-bar b { font-size: 13px; color: var(--graphite); font-weight: 600; }

/* design picker */
.designs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.dcard { display: grid; gap: 8px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.dcard .thumb { position: relative; aspect-ratio: 390 / 760; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.dcard .thumb > div { position: absolute; top: 0; left: 0; width: 390px; height: 760px; transform-origin: 0 0; pointer-events: none; }
.dcard[aria-pressed="true"] .thumb { outline: 3px solid var(--seal); outline-offset: 3px; }
.dcard b { font-weight: 600; }
.dcard .lockt { position: absolute; inset: 0; background: rgba(43,33,48,.55); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; text-align: center; padding: 10px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--sheet); border-radius: 999px; padding: 5px 14px 5px 5px; cursor: pointer; font-size: 14px; }
.swatch i { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.swatch[aria-pressed="true"] { border-color: var(--plum); box-shadow: 0 0 0 1px var(--plum); }

/* uploads */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.slot { position: relative; aspect-ratio: 3 / 4; border: 1.5px dashed #BFB4C6; border-radius: var(--r); background: var(--vellum-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 10px; cursor: pointer; overflow: hidden; font-size: 13px; color: var(--graphite); }
.slot:hover, .slot.drag { border-color: var(--seal); background: #fff; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot b { color: var(--plum); font-size: 14px; }
.slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.slot .slot-x { position: absolute; top: 8px; right: 8px; z-index: 2; }
.slot.busy::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='14' fill='none' stroke='%239E2F3A' stroke-width='3' stroke-dasharray='60 30'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 20 20' to='360 20 20' dur='.9s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center / 40px no-repeat; }
.drop { border: 1.5px dashed #BFB4C6; border-radius: var(--r-lg); padding: 28px 18px; text-align: center; background: var(--vellum-2); display: grid; gap: 8px; justify-items: center; position: relative; }
.drop.drag { border-color: var(--seal); background: #fff; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.th { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line-2); }
.th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.th .th-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 6px; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.th .th-bar button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--plum); }
.th .th-bar button svg { width: 14px; height: 14px; }
.th.hidden-item img { opacity: .35; }
.th .th-flag { position: absolute; top: 6px; left: 6px; }
.th .prog { position: absolute; left: 8px; right: 8px; bottom: 8px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.7); overflow: hidden; }
.th .prog i { display: block; height: 100%; background: var(--seal); width: 0; transition: width .2s; }

/* lists (guests, couples, wishes) */
.list { display: grid; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--sheet); }
.li { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; padding: 14px 16px; border-top: 1px solid var(--line-2); align-items: center; }
.li:first-child { border-top: 0; }
.li .li-main { min-width: 0; display: grid; gap: 4px; }
.li .li-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.li .li-meta { font-size: 13px; color: var(--graphite); display: flex; gap: 6px 12px; flex-wrap: wrap; }
.li .li-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) { .li { grid-template-columns: 1fr; } .li .li-actions { justify-content: flex-start; } }
.empty { padding: 36px 20px; text-align: center; color: var(--graphite); display: grid; gap: 10px; justify-items: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--line-2); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--graphite); }
.seg button[aria-pressed="true"] { background: var(--sheet); color: var(--plum); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* preview pane */
.preview-pane { display: none; }
@media (min-width: 1200px) { .preview-pane { display: grid; gap: 10px; position: sticky; top: 84px; } }
.phone { width: 390px; height: 780px; border-radius: 44px; border: 10px solid var(--plum); overflow: hidden; background: #fff; transform: scale(.94); transform-origin: top center; box-shadow: 0 30px 60px -30px rgba(43,33,48,.5); }
.phone iframe { width: 100%; height: 100%; border: 0; display: block; }
.fab-preview { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 45; }
@media (min-width: 1200px) { .fab-preview { display: none; } }

/* dialogs */
dialog { border: 0; border-radius: var(--r-lg); padding: 0; width: min(560px, calc(100% - 24px)); max-height: calc(100svh - 32px); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); color: var(--plum); }
dialog::backdrop { background: rgba(43,33,48,.55); }
dialog form, dialog .dlg { padding: 22px; display: grid; gap: 16px; }
dialog.full { width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0; margin: 0; }
dialog.full iframe { width: 100%; height: calc(100% - 56px); border: 0; display: block; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.creds { background: var(--vellum-2); border: 1px dashed var(--gilt); border-radius: var(--r); padding: 16px; display: grid; gap: 6px; font-size: 15px; }
.creds b { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 16px; }
.tpl-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tpl-checks label { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 14px; }
.tpl-checks input { accent-color: var(--seal); width: 16px; height: 16px; }
.qr { width: 220px; height: 220px; background: #fff; padding: 12px; border-radius: 12px; border: 1px solid var(--line); }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }

.boot { min-height: 100svh; display: flex; align-items: center; justify-content: center; }
.boot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--seal); animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .2; transform: scale(.6); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- small-screen polish ---------- */
@media (max-width: 600px) {
  .topbar h1 { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .save-state { font-size: 0; gap: 0; }
  .topbar .save-state.saving, .topbar .save-state.error { font-size: 12px; gap: 6px; }
  .stats .stat:last-child:nth-child(odd) { grid-column: span 2; }
}
.slots { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.mp-album a { text-decoration: none; }
