:root {
  --ivory: #f8f1e6;
  --paper: #fffaf2;
  --maroon: #7a1f2b;
  --maroon-deep: #5a1420;
  --gold: #b8893b;
  --gold-soft: #d9b878;
  --marigold: #e9a23b;
  --ink: #3b2a25;
  --muted: #8a7468;
  --line: rgba(184, 137, 59, 0.35);
  --radius: 22px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --script: "Great Vibes", "Cormorant Garamond", cursive;
  --sans: "Jost", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(233, 162, 59, 0.18), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(122, 31, 43, 0.08), transparent 60%),
    radial-gradient(circle at 1px 1px, rgba(184, 137, 59, 0.12) 1px, transparent 1.5px) 0 0 / 22px 22px,
    var(--ivory);
  overflow-x: hidden;
}

/* ───────── Petals ───────── */
.petals { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.petals i {
  position: absolute; top: -40px;
  border-radius: 80% 0 80% 0;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translate3d(var(--drift), 110vh, 0) rotate(calc(var(--spin) * 540deg)); }
}
i.burst {
  position: fixed; top: 35vh; z-index: 50; pointer-events: none;
  border-radius: 80% 0 80% 0;
  animation: burst 3.2s cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes burst {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(720deg); opacity: 0; }
}

/* ───────── Layout ───────── */
.shell {
  position: relative; z-index: 1;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 18px 40px;
}
.shell.wide { width: min(1120px, 100%); }

/* Arch (mehrab) hero */
.arch {
  text-align: center;
  padding: 56px 28px 34px;
  margin: 8px 6px 22px;
  border-radius: 999px 999px 26px 26px / 260px 260px 26px 26px;
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.92), rgba(255, 250, 242, 0.65));
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 7px var(--paper), inset 0 0 0 8px var(--line), 0 20px 50px -30px rgba(90, 20, 32, 0.45);
  animation: rise .9s ease both;
}
.ornament { width: 170px; height: 30px; display: block; margin: 0 auto 10px; }
.ornament path, .ornament circle { fill: none; stroke: var(--gold); stroke-width: 1.3; }
.ornament .fill { fill: var(--gold); }

.eyebrow {
  font-family: var(--sans); font-size: 12px; letter-spacing: .28em; text-transform: uppercase;
  color: var(--gold); margin: 6px 0 4px;
}
.names {
  font-family: var(--script); font-weight: 400;
  font-size: clamp(52px, 15vw, 78px); line-height: 1.05;
  color: var(--maroon); margin: 6px 0 8px;
  display: flex; flex-direction: column; align-items: center;
}
.names .amp { font-family: var(--serif); font-style: italic; font-size: .45em; color: var(--gold); margin: -4px 0; }
.date {
  font-family: var(--sans); font-size: 13px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--maroon-deep); margin: 4px 0 14px;
}
.intro { font-size: 19px; font-style: italic; color: var(--muted); max-width: 400px; margin: 0 auto; line-height: 1.45; }

/* ───────── Card ───────── */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 26px 22px 24px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px -36px rgba(90, 20, 32, 0.5), 0 2px 0 rgba(255, 255, 255, .8) inset;
  animation: rise .9s .15s ease both;
}
.card-title { font-weight: 500; font-size: 24px; text-align: center; margin: 0 0 18px; color: var(--maroon-deep); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Mode tabs */
.modes {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 5px; border-radius: 16px; background: #f3e8d6; margin-bottom: 20px;
}
.mode {
  font: 500 14px var(--sans); letter-spacing: .04em; color: var(--muted);
  border: 0; background: transparent; border-radius: 12px; padding: 11px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer;
  transition: background .25s, color .25s, box-shadow .25s;
}
.mode svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mode[aria-selected="true"] { background: var(--paper); color: var(--maroon); box-shadow: 0 6px 16px -10px rgba(90, 20, 32, .6); }

/* Recorder */
.recorder { margin-bottom: 18px; }
.stage {
  position: relative; border-radius: 16px; overflow: hidden;
  background: linear-gradient(180deg, #fbf3e6, #f4e7d2);
  border: 1px solid var(--line);
}
.stage-audio { padding: 18px 14px; display: grid; place-items: center; min-height: 120px; }
.stage-audio canvas { width: 100%; height: 84px; display: block; }
.stage-audio audio { width: 100%; }
.stage-video { aspect-ratio: 4 / 5; background: #2a1a17; }
.stage-video video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage-video .live { transform: scaleX(-1); }
.placeholder {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  color: var(--gold-soft); font: 15px var(--sans); text-align: center; padding: 20px;
  background: radial-gradient(circle at 50% 40%, #4a2a24, #2a1a17);
}
.placeholder svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.2; }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 400 110px var(--serif); color: #fff; text-shadow: 0 4px 30px rgba(0, 0, 0, .5);
}
.countdown.pop { animation: pop .9s ease; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } 40% { opacity: 1; } to { transform: scale(.9); opacity: .2; } }

.rec-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.rec-btn {
  flex: none; width: 64px; height: 64px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--gold); background: var(--paper); display: grid; place-items: center;
  box-shadow: 0 8px 20px -10px rgba(122, 31, 43, .7);
  transition: transform .15s;
}
.rec-btn:active { transform: scale(.94); }
.rec-btn span { width: 26px; height: 26px; border-radius: 50%; background: var(--maroon); transition: border-radius .25s, width .25s, height .25s; }
[data-state="recording"] .rec-btn { animation: pulse 1.6s infinite; }
[data-state="recording"] .rec-btn span { width: 22px; height: 22px; border-radius: 5px; }
[data-state="recorded"] .rec-btn { display: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(122, 31, 43, .45); } 70% { box-shadow: 0 0 0 16px rgba(122, 31, 43, 0); } 100% { box-shadow: 0 0 0 0 rgba(122, 31, 43, 0); } }

.rec-meta { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 2px; }
.rec-time { font: 500 22px var(--sans); color: var(--maroon); font-variant-numeric: tabular-nums; }
.rec-max { font: 14px var(--sans); color: var(--muted); }
.rec-hint { flex-basis: 100%; font-size: 16px; font-style: italic; color: var(--muted); }

.link-btn {
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
  font: 500 14px var(--sans); color: var(--maroon); text-decoration: underline; text-underline-offset: 3px;
}

/* Fields */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font: 500 13px var(--sans); letter-spacing: .06em; color: var(--maroon-deep); margin-bottom: 6px; }
.field em { color: var(--marigold); font-style: normal; }
.field small { color: var(--muted); font-weight: 400; letter-spacing: 0; }
input, textarea {
  width: 100%; font: 19px var(--serif); color: var(--ink);
  background: #fffdf8; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #b7a495; font-style: italic; }
input:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(184, 137, 59, .18); }

.status { min-height: 1.4em; margin: 4px 0 10px; font-size: 16px; color: var(--muted); text-align: center; }
.status.err { color: #a3302a; }
.progress { height: 4px; border-radius: 4px; background: #f0e2cb; overflow: hidden; margin-bottom: 14px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--maroon)); transition: width .2s; }

/* Buttons */
.primary {
  width: 100%; border: 0; cursor: pointer; border-radius: 14px; padding: 16px 20px;
  font: 500 16px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: #fff8ec;
  background: linear-gradient(135deg, var(--maroon), var(--maroon-deep));
  box-shadow: 0 14px 30px -14px rgba(90, 20, 32, .8), inset 0 1px 0 rgba(255, 255, 255, .15);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .15s, opacity .2s;
}
.primary svg { width: 18px; height: 18px; fill: var(--marigold); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .6; cursor: progress; }
.ghost {
  border: 1px solid var(--gold); background: transparent; color: var(--maroon); cursor: pointer;
  border-radius: 12px; padding: 12px 18px; font: 500 14px var(--sans); letter-spacing: .06em;
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* Thanks */
.thanks { text-align: center; padding: 36px 24px; }
.script { font-family: var(--script); font-weight: 400; font-size: 64px; color: var(--maroon); margin: 0 0 6px; }
.thanks-line { font-size: 20px; font-style: italic; color: var(--muted); margin: 0 auto 24px; max-width: 380px; line-height: 1.45; }

.foot { text-align: center; margin-top: 26px; display: grid; gap: 10px; justify-items: center; }
.foot a { font: 500 14px var(--sans); letter-spacing: .06em; color: var(--maroon); text-underline-offset: 4px; }
.demo-badge { font: 12px var(--sans); color: var(--muted); background: #f3e8d6; padding: 6px 12px; border-radius: 99px; }

/* ───────── Wall ───────── */
.wall-head { text-align: center; padding: 34px 10px 10px; }
.wall-head .names { flex-direction: row; justify-content: center; gap: .25em; flex-wrap: wrap; font-size: clamp(44px, 9vw, 72px); }
.wall-head .names .amp { margin: 0; align-self: center; }
.wall-count { font: 13px var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.filters { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 22px 0 26px; }
.filters button {
  border: 1px solid var(--line); background: var(--paper); color: var(--muted); cursor: pointer;
  border-radius: 99px; padding: 8px 16px; font: 500 13px var(--sans); letter-spacing: .06em;
}
.filters button[aria-pressed="true"] { background: var(--maroon); border-color: var(--maroon); color: #fff8ec; }
.grid { columns: 3 300px; column-gap: 18px; }
.blessing {
  break-inside: avoid; margin: 0 0 18px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px 20px 16px; box-shadow: 0 18px 40px -32px rgba(90, 20, 32, .6);
  animation: rise .6s ease both;
}
.blessing video { width: 100%; border-radius: 12px; background: #2a1a17; margin-bottom: 12px; display: block; max-height: 420px; }
.blessing audio { width: 100%; margin-bottom: 12px; }
.blessing .msg { font-size: 20px; line-height: 1.5; margin: 0 0 14px; white-space: pre-wrap; }
.blessing .msg::before { content: "“"; font-size: 1.6em; color: var(--gold); line-height: 0; vertical-align: -.35em; margin-right: 2px; }
.blessing footer { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.blessing .who { font-weight: 600; font-size: 19px; color: var(--maroon-deep); }
.blessing .rel { font-size: 15px; font-style: italic; color: var(--muted); }
.blessing .meta { font: 12px var(--sans); color: var(--muted); text-align: right; white-space: nowrap; }
.blessing .meta a { color: var(--gold); display: block; margin-top: 3px; }
.tag { display: inline-block; font: 500 11px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: 10px; }
.empty { text-align: center; font-style: italic; color: var(--muted); font-size: 20px; padding: 40px 0; }

.gate { max-width: 380px; margin: 40px auto; text-align: center; }
.gate input { text-align: center; margin: 14px 0; }

/* ───────── QR page ───────── */
.qr-tools { display: grid; gap: 10px; margin-bottom: 22px; }
.qr-tools .row { display: flex; gap: 10px; }
.qr-tools .row > * { flex: 1; }
.qr-card {
  background: var(--paper); text-align: center; padding: 40px 30px 34px; margin: 0 auto;
  width: min(420px, 100%); border-radius: 200px 200px 22px 22px / 160px 160px 22px 22px;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 8px var(--paper), inset 0 0 0 9px var(--line), 0 24px 60px -36px rgba(90, 20, 32, .5);
}
.qr-card .names { font-size: 56px; }
.qr-box { display: inline-block; padding: 14px; background: #fff; border-radius: 14px; border: 1px solid var(--line); margin: 14px 0 12px; }
.qr-box img, .qr-box canvas { display: block; width: 220px !important; height: 220px !important; }
.qr-card .cta { font-size: 21px; font-style: italic; color: var(--maroon-deep); margin: 4px 0 0; }
.qr-card .sub { font: 12px var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); margin-top: 8px; }

@media print {
  body { background: #fff; }
  .petals, .no-print { display: none !important; }
  .qr-card { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ───────── Admin ───────── */
.login { max-width: 420px; margin: 10px auto; }
.admin-top { margin-bottom: 20px; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 24px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font: 500 13px var(--sans); color: var(--maroon-deep); margin-bottom: 7px; }
.meter-head b { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 8px; border-radius: 8px; background: #f0e2cb; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 8px; background: linear-gradient(90deg, var(--gold), var(--marigold)); transition: width .4s; }
.meter.warn .bar i { background: linear-gradient(90deg, var(--marigold), #d9644f); }
.meter.full .bar i { background: #a3302a; }
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line); }
.box-state { display: flex; align-items: center; gap: 8px; font: 500 14px var(--sans); color: #2f6b3a; margin-right: auto; }
.box-state .dot { width: 9px; height: 9px; border-radius: 50%; background: #3f9b50; box-shadow: 0 0 0 4px rgba(63, 155, 80, .15); }
.box-state.off { color: #a3302a; }
.box-state.off .dot { background: #a3302a; box-shadow: 0 0 0 4px rgba(163, 48, 42, .15); }
.foot.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 26px; }
.limits-line { font: 13px var(--sans); color: var(--muted); margin: 12px 0 0; }
.admin-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 0 0 18px; }
.admin-tools input { flex: 1 1 260px; max-width: 420px; font-size: 17px; }
.admin-tools .filters { margin: 0; }
.danger {
  width: 100%; margin-top: 12px; padding: 10px; border-radius: 10px; cursor: pointer;
  font: 500 13px var(--sans); letter-spacing: .04em; color: #a3302a; background: transparent; border: 1px solid rgba(163, 48, 42, .35);
}
.danger.armed { background: #a3302a; color: #fff; border-color: #a3302a; }
.danger:disabled { opacity: .6; }
.notice {
  text-align: center; padding: 30px 22px; font-size: 20px; font-style: italic; color: var(--maroon-deep); line-height: 1.45;
}
.mode:disabled { opacity: .4; cursor: not-allowed; }
.mode-note { font: 14px var(--sans); color: var(--muted); text-align: center; margin: -10px 0 16px; }
