:root {
  --bg: #f6f5ff;
  --ink: #2b2440;
  --muted: #6b6580;
  --brand: #7048e8;
  --card: #ffffff;
  --ring: rgba(112, 72, 232, .25);
  --shadow: 0 10px 30px rgba(43, 36, 64, .12);
  --radius: 18px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); }
.wrap { max-width: 760px; margin: 0 auto; padding: 22px 18px 60px; }

/* language switcher (fixed, top-inline-end) */
.lang-switch { position: fixed; top: 10px; inset-inline-end: 12px; z-index: 20; margin: 0; }
.lang-switch select {
  font: inherit; font-size: 13px; font-weight: 700; color: var(--ink);
  padding: 6px 10px; border: 2px solid #e7e1fb; border-radius: 999px;
  background: rgba(255,255,255,.9); cursor: pointer; -webkit-appearance: none; appearance: none;
}
.wrap { padding-top: 46px; }
.wrap-narrow { max-width: 460px; }

/* account nav (fixed, top-inline-start) */
.account-nav { position: fixed; top: 10px; inset-inline-start: 12px; z-index: 20;
  display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 700; }
.account-nav a { text-decoration: none; color: var(--brand); }
.account-nav .acct-hi { color: var(--muted); font-weight: 600; }
.account-nav .acct-cta { background: var(--brand); color: #fff;
  padding: 6px 12px; border-radius: 999px; }

.alert { background: #ffe3e3; color: #a61e1e; border-radius: 12px; padding: 12px 14px; margin: 8px 0; font-weight: 600; }

/* dashboard */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dash-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.dash-card { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink);
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; }
.dash-card:hover { transform: translateY(-1px); }
.dash-emoji { font-size: 30px; }
.dash-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.dash-info .muted { font-size: 13px; }
.dash-status { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.status-open { background: #e7f5ff; color: #1971c2; }
.status-sealed { background: #ebfbee; color: #2f9e44; }

/* invitations */
.invite-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.invite-row { padding: 14px 16px; margin: 0; }
.invite-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.inv-status { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.inv-invited { background: #f1f3f5; color: #868e96; }
.inv-opened  { background: #fff3bf; color: #b08900; }
.inv-signed  { background: #ebfbee; color: #2f9e44; }
.invite-actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.inv-qr summary { cursor: pointer; color: var(--brand); font-weight: 700; font-size: 13px; }
.inv-qr .qr-box { margin-top: 10px; }
.inv-del { margin: 0; }
.inv-del .link-clear { color: #e03131; }

/* admin */
.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 18px; }
.admin-tabs a { text-decoration: none; font-weight: 700; font-size: 14px; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); }
.admin-tabs a.active { color: #fff; background: var(--brand); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 18px;
  display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
.stat-n { font-size: 30px; font-weight: 800; color: var(--brand); }
.stat-l { color: var(--muted); font-weight: 700; font-size: 13px; }
.stat-link:hover { transform: translateY(-1px); }

.table-wrap { overflow-x: auto; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: start; padding: 12px 14px; border-bottom: 1px solid #eee; white-space: nowrap; }
.admin-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.admin-table tr:last-child td { border-bottom: 0; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.you { color: var(--muted); font-weight: 600; }
.uform { margin: 0; }
button.mini { font: inherit; font-weight: 700; font-size: 12px; cursor: pointer; border: 2px solid #e7e1fb;
  background: #f6f2ff; color: var(--brand); padding: 5px 10px; border-radius: 999px; }
button.mini.danger { border-color: #ffc9c9; background: #fff5f5; color: #e03131; }

.fb-list { display: flex; flex-direction: column; gap: 12px; }
.fb-item { margin: 0; }
.fb-item.fb-new { border-inline-start: 4px solid var(--brand); }
.fb-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; }
.fb-msg { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 10px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.checkline input { width: auto; }

/* RTL adjustments */
[dir="rtl"] .note .author,
[dir="rtl"] .note { text-align: right; }
[dir="rtl"] .btn.block { direction: rtl; }
[dir="rtl"] .create-arrow { transform: scaleX(-1); }
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 20px; text-decoration: none; color: var(--ink);
}
.brand-logo { display: block; width: 240px; max-width: 100%; height: auto; }
.hero { text-align: center; padding: 26px 0 8px; }
.hero h1 { font-size: clamp(28px, 6vw, 44px); line-height: 1.05; margin: 14px 0 8px; }
.hero p { color: var(--muted); font-size: 18px; margin: 0 auto; max-width: 46ch; }
.grad { color: var(--brand); }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin: 18px 0;
}
label { display: block; font-weight: 700; margin: 14px 0 6px; font-size: 15px; }
input[type=text], input[type=date], input[type=email], input[type=password], input[type=tel], textarea, select {
  width: 100%; padding: 13px 14px; font: inherit; color: var(--ink);
  border: 2px solid #eae7f5; border-radius: 12px; background: #fbfaff; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
textarea { min-height: 96px; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; margin-top: 5px; }

/* "Help me write" assist */
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.assist-btn {
  font: inherit; font-weight: 800; font-size: 13px; cursor: pointer;
  border: 2px solid #e7e1fb; background: #f6f2ff; color: var(--brand);
  padding: 6px 12px; border-radius: 999px; margin-top: 8px;
}
.assist-btn:hover { background: #efe8ff; }
.assist {
  background: #faf8ff; border: 2px solid #efeafc; border-radius: 12px;
  padding: 12px; margin: 8px 0 10px; display: flex; flex-wrap: wrap;
  align-items: center; gap: 10px;
}
.assist-label { font-weight: 700; font-size: 14px; }
.assist .chips { gap: 6px; }
.assist .chip span { padding: 7px 11px; font-size: 13px; }
.assist .btn.secondary { padding: 9px 15px; font-size: 14px; }
.assist-hint { color: var(--muted); font-size: 12px; flex-basis: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: 16px;
  padding: 14px 22px; border-radius: 999px; color: #fff;
  background: var(--brand);
  box-shadow: 0 8px 20px var(--ring); text-decoration: none; transition: transform .06s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.secondary { background: #fff; color: var(--brand); border: 2px solid #e7e1fb; box-shadow: none; }
.btn.block { width: 100%; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

/* occasion & color pickers */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px;
  border: 2px solid #eae7f5; border-radius: 999px; background: #fff; font-weight: 700; font-size: 14px;
}
.chip input:checked + span { border-color: var(--brand); background: #f3efff; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 40px; height: 40px; border-radius: 12px; cursor: pointer; position: relative;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.05); }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch.active { outline: 3px solid var(--brand); outline-offset: 2px; }

/* template cover gallery */
.tpl-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tpl { padding: 0; border: 3px solid transparent; border-radius: 12px; background: none; cursor: pointer;
  overflow: hidden; line-height: 0; box-shadow: 0 4px 12px rgba(43,36,64,.12); }
.tpl img { width: 100%; aspect-ratio: 564 / 400; object-fit: cover; display: block; }
.tpl:hover { transform: translateY(-2px); }
.tpl.sel { border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }

/* signing wall */
.wall-head { text-align: center; }
.wall-head .emoji { font-size: 46px; }
.cover-banner { margin: 0 auto 6px; max-width: 460px; }
.cover-banner img { width: 100%; border-radius: 14px; box-shadow: var(--shadow); display: block; }
.wall-head h1 { margin: 6px 0 2px; font-size: clamp(26px, 6vw, 40px); }
.count-pill { display: inline-block; background: #fff; border-radius: 999px; padding: 6px 14px;
  font-weight: 800; color: var(--brand); box-shadow: var(--shadow); }
.masonry { columns: 2 220px; column-gap: 14px; margin-top: 18px; }
.note {
  break-inside: avoid; margin: 0 0 14px; padding: 16px; border-radius: 14px;
  box-shadow: 0 6px 16px rgba(43,36,64,.10); transform: rotate(var(--r, -1deg));
}
.note .body { font-size: 17px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .sig { margin-top: 8px; }
.note .sig img { max-height: 70px; }
.note .photo img { width: 100%; border-radius: 10px; margin-bottom: 8px; }
.note .author { font-family: 'Caveat', cursive; font-size: 24px; font-weight: 700; margin-top: 6px; }

/* signature pad */
.pad-wrap { border: 2px dashed #d9d2f2; border-radius: 12px; background: #fff; }
canvas.pad { width: 100%; height: 150px; display: block; touch-action: none; border-radius: 12px; }
.pad-tools { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; }
.link-clear { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }

/* share box */
.share { display: flex; gap: 10px; align-items: center; }
.share input { font-size: 14px; }
.qr { text-align: center; margin: 10px 0; }
.qr img { width: 190px; height: 190px; border-radius: 14px; box-shadow: var(--shadow); background:#fff; padding:8px;}

.center { text-align: center; }
.muted { color: var(--muted); }
.mt { margin-top: 16px; }
.divider { height: 1px; background: #eae7f5; margin: 20px 0; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; opacity: 0;
  transition: opacity .3s; pointer-events: none; font-weight: 700; }
.toast.show { opacity: 1; }

/* reveal / envelope */
.stage { min-height: 82vh; display: grid; place-items: center; }
.envelope { text-align: center; cursor: pointer; }
.envelope .flap { font-size: 96px; filter: drop-shadow(0 12px 20px rgba(0,0,0,.18)); animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
.envelope h1 { font-size: clamp(28px, 7vw, 46px); margin: 8px 0; }
.reveal-note { opacity: 0; transform: translateY(16px) rotate(var(--r,-1deg)); animation: pop .6s forwards; }
@keyframes pop { to { opacity: 1; transform: translateY(0) rotate(var(--r,-1deg)); } }
@media (prefers-reduced-motion: reduce) {
  .envelope .flap { animation: none; } .reveal-note { animation: none; opacity: 1; transform: none; }
}
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }
footer.site { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 0; }

.verification-banner { margin: 64px auto 0; max-width: 724px; padding: 14px 18px; background: #eee8ff; color: var(--ink); border-radius: 12px; }
.verification-banner + .wrap { padding-top: 20px; }
.smtp-fields { display: grid; gap: 8px; }
