/* Editor (editor.html) — VowMotion brand chrome around the live invitation preview. */

:root {
  --bg: #F4EFE7;
  --card: #FFFDF9;
  --ink: #2F2A24;
  --muted: #7C7366;
  --line: #E4DACB;
  --line-strong: #CFC2AE;
  --gold: #A88A5A;
  --gold-dark: #8C7046;
  --danger: #A4483C;
  --radius: 14px;
  --top: 60px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* visually hidden but still focusable / readable by screen readers */
.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ───────────── buttons ───────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #FFFDF9; }
.btn.primary:hover { background: #4A4239; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 14px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.link-btn {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); }

/* ───────────── top bar ───────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--top);
  padding: 0 20px;
  background: rgb(255 253 249 / .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  flex: none;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink);
  text-decoration: none;
}
.brand img { width: 1.5em; height: 1.5em; flex: none; }
.save-state { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.save-state[data-state="saving"] { color: var(--muted); }
.save-state[data-state="saved"]::before { content: "✓ "; color: var(--gold); }
.save-state[data-state="error"] { color: var(--danger); }
.top-actions { display: flex; gap: 8px; }
.only-mobile { display: none; }

/* ───────────── layout ───────────── */
.layout {
  display: grid;
  grid-template-columns: minmax(380px, 600px) 1fr;
  min-height: calc(100vh - var(--top));
}
.panel { padding: 24px 24px 80px; }
.intro { margin: 0 4px 18px; color: var(--muted); font-size: 14px; }
/* Taken offline by VowMotion (Terms §7): the reason, above the form */
.offline-note { margin: 0 0 18px; padding: 14px 16px; border: 1px solid #DDB1A9; border-radius: 12px; background: #F8E8E4; color: #6B2E25; font-size: 14px; line-height: 1.5; }
.offline-note b { display: block; margin-bottom: 4px; }
.offline-note .why { display: block; margin: 6px 0; font-style: italic; }
.offline-note a { color: inherit; }
/* The names and date after the wedding day (fixed: one invitation, one event) */
.field input:disabled { color: var(--muted); background: #F4EFE7; cursor: not-allowed; }

.stage {
  position: sticky;
  top: var(--top);
  height: calc(100vh - var(--top));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 14px 24px 24px;
  border-left: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 40%, rgb(255 255 255 / .7), transparent 60%),
    #EAE3D8;
}
.stage-top { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; }

/* phone / computer switch */
.device-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 253 249 / .85);
}
.device-switch button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.device-switch button:hover { color: var(--ink); }
.device-switch button[aria-pressed="true"] { background: var(--ink); color: #FFFDF9; }
.device-switch svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.viewport {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.device iframe { display: block; border: 0; background: #F8F4EE; }

/* phone frame (default) */
.device[data-device="mobile"] {
  position: relative;
  height: min(860px, 100%);
  max-width: 100%;
  aspect-ratio: 410 / 864;
  padding: 10px;
  border-radius: 54px;
  background: #1E1B18;
  box-shadow:
    0 0 0 1px #3B3631 inset,
    0 30px 60px -20px rgb(40 30 20 / .45),
    0 10px 20px -10px rgb(40 30 20 / .3);
}
.device[data-device="mobile"]::before { /* camera island */
  content: "";
  position: absolute;
  z-index: 2;
  top: 17px;
  left: 50%;
  width: 24%;
  height: 20px;
  border-radius: 20px;
  background: #1E1B18;
  transform: translateX(-50%);
  pointer-events: none;
}
.device[data-device="mobile"] .browser-bar { display: none; }
.device[data-device="mobile"] .screen { width: 100%; height: 100%; overflow: hidden; border-radius: 44px; }
.device[data-device="mobile"] iframe { width: 100%; height: 100%; }

/* computer: a 1280×800 browser window, scaled to fit (editor.js sets --s) */
.device[data-device="desktop"] {
  overflow: hidden;
  border: 1px solid #D6CBBB;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 30px 60px -24px rgb(40 30 20 / .4), 0 8px 18px -10px rgb(40 30 20 / .25);
}
.browser-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  background: #F1ECE4;
  border-bottom: 1px solid var(--line);
}
.browser-bar i { width: 10px; height: 10px; border-radius: 50%; background: #D9CFC1; }
.browser-bar span {
  flex: 0 1 380px;
  min-width: 0;
  margin: 0 auto;
  padding: 3px 12px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device[data-device="desktop"] .screen {
  width: calc(1280px * var(--s, .5));
  height: calc(800px * var(--s, .5));
  overflow: hidden;
}
.device[data-device="desktop"] iframe {
  width: 1280px;
  height: 800px;
  transform: scale(var(--s, .5));
  transform-origin: 0 0;
}

/* ───────────── groups ───────────── */
.group {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  transition: opacity .2s;
}
.group-head { display: flex; align-items: center; padding-right: 14px; }
.group-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 18px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.group-title span { font-family: var(--serif); font-size: 21px; font-weight: 600; }
.group-title small {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.chev {
  width: 9px;
  height: 9px;
  margin-left: auto;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .2s;
}
.group.open .chev { transform: rotate(-135deg); }
.group-body { display: none; padding: 2px 18px 20px; }
.group.open .group-body { display: block; }
.group.off .group-title span { color: var(--muted); }
.group.off .group-body { opacity: .55; }

.note { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.grid > * { grid-column: 1 / -1; }
.grid > .half { grid-column: span 1; }
.sub {
  margin: 10px 0 -4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
}
.sub:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* switch (section on/off) */
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span {
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color .2s;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / .2);
  transition: transform .2s;
}
.switch input:checked + span { background: var(--gold); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ───────────── fields ───────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lbl { font-size: 13px; font-weight: 600; color: var(--ink); }
.lbl em { font-style: normal; font-weight: 400; color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
/* an on/off field (e.g. Autoplay): label left, switch right, hint below */
.switch-field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px; cursor: pointer; }
.switch-field .hint { grid-column: 1 / -1; }

input:not([type="checkbox"], [type="radio"], [type="color"], [type="file"], [type="range"]),
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  font-size: 16px; /* ≥16px stops iOS zooming in */
  line-height: 1.35;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgb(168 138 90 / .18);
}
input::placeholder, textarea::placeholder { color: #B2A797; }

/* colour dots of a design (current design, catalogue) */
.swatches { display: flex; }
.swatches i {
  width: 26px;
  height: 26px;
  margin-right: -6px;
  border: 2px solid var(--card);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12);
}
.theme-name { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.reset { justify-self: start; }

/* photos */
.photo { display: flex; align-items: center; gap: 14px; }
.photo.busy, .song.busy { opacity: .5; pointer-events: none; }
.thumb {
  flex: none;
  width: 72px;
  height: 92px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.photo-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.photo-tools .vh:focus-visible + .btn { outline: 2px solid var(--gold); outline-offset: 2px; }
.half .photo { flex-direction: column; align-items: flex-start; }
.half .thumb { width: 100%; height: auto; aspect-ratio: 4 / 5; max-width: 180px; }
.flash { flex-basis: 100%; margin: 4px 0 0; color: var(--danger); font-size: 13px; }

/* song */
.song { display: flex; flex-direction: column; gap: 10px; }
.song-now {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 14px;
}

/* lists (schedule, milestones) */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #FDFBF7;
}
.row-fields { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.mini { flex: 1 1 160px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mini.narrow { flex: 0 1 112px; }
.mini > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.row-tools { display: flex; flex-direction: column; gap: 4px; }
.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--line-strong); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.add {
  min-height: 44px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: none;
  color: var(--gold-dark);
  font-weight: 600;
  cursor: pointer;
}
.add:hover { border-color: var(--gold); background: #FBF7F0; }

/* colourway slider: the track shows each combination's accent colour as a segment */
.cw { display: flex; flex-direction: column; gap: 12px; }
.cw-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.cw-name { font-family: var(--serif); font-size: 21px; font-weight: 600; line-height: 1.2; }
.cw-count { flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.cw-slider {
  width: 100%;
  height: 30px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.cw-slider::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 999px;
  background: var(--track);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1);
}
.cw-slider::-moz-range-track {
  height: 12px;
  border-radius: 999px;
  background: var(--track);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1);
}
.cw-slider::-webkit-slider-thumb {
  width: 26px;
  height: 26px;
  margin-top: -7px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 2px 8px rgb(0 0 0 / .3);
  -webkit-appearance: none;
  appearance: none;
}
.cw-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 2px 8px rgb(0 0 0 / .3);
}
.cw-slider:focus { outline: none; box-shadow: none; }
.cw-slider:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--gold); outline-offset: 2px; }
.cw-slider:focus-visible::-moz-range-thumb { outline: 2px solid var(--gold); outline-offset: 2px; }
.cw-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.cw-sw { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; cursor: pointer; }
.cw-sw input[type="color"] {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0;
  border: 1px solid rgb(0 0 0 / .12);
  border-radius: 10px;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform .15s, box-shadow .15s;
}
.cw-sw input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.cw-sw input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 9px; }
.cw-sw input[type="color"]::-moz-color-swatch { border: 0; border-radius: 9px; }
.cw-sw:hover input[type="color"] { transform: translateY(-2px); box-shadow: 0 6px 12px -6px rgb(40 30 20 / .45); }
.cw-sw input[type="color"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.cw-sw span { color: var(--muted); font-size: 11px; line-height: 1.2; }
.cw-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }

/* palette */
.palette-edit { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { position: relative; }
.swatch input[type="color"] {
  display: block;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  overflow: hidden;
}
.swatch input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.swatch input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.swatch input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }
.swatch .x {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.swatch .x:hover { color: var(--danger); }
.add-swatch {
  width: 48px;
  height: 48px;
  border: 1px dashed var(--line-strong);
  border-radius: 50%;
  background: none;
  color: var(--gold-dark);
  font-size: 22px;
  cursor: pointer;
}

/* ───────────── dialogs ───────────── */
.modal {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 80px -20px rgb(30 20 10 / .45);
}
.modal::backdrop { background: rgb(40 32 24 / .45); backdrop-filter: blur(2px); }
.modal form, .modal .step { display: flex; flex-direction: column; gap: 14px; padding: 26px; }
.modal h2 { margin: 0; font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1.15; }
.modal p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.link-preview {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 13px;
  overflow-wrap: anywhere;
  color: var(--muted);
}
.warn { color: var(--gold-dark); font-size: 13.5px; }
.error { color: var(--danger); font-size: 13.5px; }
.modal .note { margin: 0; font-size: 13px; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { flex: 1; font-size: 14px !important; }
.modal.wide { width: min(680px, calc(100vw - 32px)); }
/* Publish: "I agree to the Terms…" (asked until the current version is accepted) */
.agree { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 13.5px; line-height: 1.45; cursor: pointer; }
.agree[hidden] { display: none; }
.agree input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--ink); }
.agree a { color: var(--gold-dark); }
.agree.missing { border-color: var(--danger); }
/* Shop and legal links under the form */
.panel-foot { margin: 22px 4px 8px; color: var(--muted); font-size: 12.5px; text-align: center; }
.panel-foot a { color: inherit; }

/* "Update" with a gold dot: there are changes guests don't see yet. */
.btn.pending { position: relative; }
.btn.pending::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--gold);
}

/* RSVP replies — up to 1500: the dialog grows to the screen height at most and only the
   list scrolls; totals, search and filters stay in view. */
/* .modal.replies-dialog: must beat .modal.wide */
.modal.replies-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.modal.replies-dialog[open] { display: flex; flex-direction: column; }
.modal.replies-dialog .step { flex: 1; min-height: 0; gap: 12px; padding: 22px 24px; }
.rs-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rs-stats:empty { display: none; }
.rs-stat { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.rs-stat b { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.rs-stat span { color: var(--muted); font-size: 12.5px; }
.rs-stat.main { border-color: var(--ink); background: var(--ink); color: #FFFDF9; }
.rs-stat.main span { color: rgb(255 253 249 / .78); }
.rs-tools { display: flex; flex-direction: column; gap: 8px; }
.rs-tools[hidden] { display: none; }
#repliesSearch { width: 100%; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font-size: 16px; }
.rs-row { display: flex; align-items: center; gap: 10px; }
.rs-row .rs-chips { flex: 1; flex-wrap: wrap; min-width: 0; padding-bottom: 0; overflow: visible; }
.rs-chips .chip { text-transform: none; }
.rs-chips .chip span { margin-left: 2px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rs-chips .chip[aria-pressed="true"] span { color: rgb(255 255 255 / .75); }
.rs-sort { display: flex; flex: none; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.rs-sort select { width: auto; min-height: 34px; padding: 4px 8px; font-size: 13px; }
.rs-count { margin-right: auto; align-self: center; color: var(--muted); font-size: 13px; }
.replies-box { flex: 0 1 auto; min-height: 150px; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 10px; }
.replies-box > .note, .replies-box > .error { padding: 18px; }
.replies { width: 100%; border-collapse: collapse; font-size: 14px; }
.replies th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 12px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-align: left;
  text-transform: uppercase;
}
.replies td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.replies tbody tr:hover { background: rgb(244 239 231 / .6); }
.replies td small { display: block; margin-top: 2px; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.replies td:nth-child(3), .replies th:nth-child(3) { text-align: center; }
.replies td:last-child { color: var(--muted); white-space: nowrap; }
.r-name { font-weight: 600; overflow-wrap: anywhere; }
.r-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-style: normal; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; vertical-align: 1px; white-space: nowrap; }
.r-tag.new { background: var(--gold-dark); color: #fff; }
.r-tag.dup { border: 1px solid var(--line-strong); color: var(--gold-dark); }
.r-tag.chg { border: 1px solid var(--line-strong); color: var(--muted); }
.r-reply { white-space: nowrap; }
.r-reply::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--gold); vertical-align: 1px; }
.replies tr.no .r-reply { color: var(--muted); }
.replies tr.no .r-reply::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.r-when, .r-unit { display: none; }
/* "Remove" a single reply (a guest asked to be taken off, or a mistake) */
.r-del { display: block; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.r-del:hover { color: var(--danger); }
.r-del:disabled { opacity: .5; cursor: default; }

/* Phones: full screen, compact top (totals in one row, filters in one sideways-scrolling
   row) so the list keeps most of the height; each reply is a two-line row. */
@media (max-width: 599px) {
  .modal.replies-dialog { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .modal.replies-dialog .step { gap: 10px; padding: 14px 12px calc(12px + env(safe-area-inset-bottom)); }
  .replies-dialog h2 { font-size: 24px; }
  .rs-stats { gap: 5px; }
  .rs-stat { gap: 2px; padding: 7px 8px; border-radius: 10px; }
  .rs-stat b { font-size: 22px; }
  .rs-stat span { font-size: 11px; line-height: 1.2; }
  #repliesSummary { font-size: 12px; line-height: 1.35; }
  .rs-tools { gap: 6px; }
  #repliesSearch { min-height: 40px; padding: 8px 12px; }
  .rs-row { gap: 6px; }
  .rs-row .rs-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0; scrollbar-width: none; } /* beats .cat-chips */
  .rs-row .rs-chips::-webkit-scrollbar { display: none; }
  .rs-chips .chip { padding: 5px 10px; }
  .rs-sort { font-size: 0; } /* the word "Sort" goes; the menu says what it does */
  .replies-box { flex: 1 1 auto; min-height: 180px; }
  .replies thead { display: none; }
  .replies tr { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
  .replies tr:first-child { border-top: 0; }
  .replies td { padding: 0; border: 0; }
  .replies td:nth-child(1) { grid-row: span 2; }
  .replies td:nth-child(2), .replies td:nth-child(3) { text-align: right; font-size: 13px; }
  .replies td:nth-child(3) { color: var(--muted); }
  .replies td:nth-child(4) { display: none; }
  .r-when { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
  .r-unit { display: inline; }
  .rs-sort select { max-width: 9.5em; min-height: 34px; padding: 4px 6px; font-size: 16px; } /* ≥16px: no iOS zoom */
  .replies-dialog .modal-actions { margin-top: 0; }
  .replies-dialog .modal-actions .btn { flex: 1; }
  .replies-dialog #repliesCsv { display: none; } /* CSV is for computers; Excel opens on phones too */
}

/* The edit link could not be used */
.fatal { margin: 40px auto; max-width: 30em; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); text-align: center; }
.fatal h2 { margin: 0 0 10px; font-family: var(--serif); font-size: 28px; font-weight: 600; }
.fatal p { margin: 0; color: var(--muted); }

/* ───────────── narrow screens: form full width, preview as an overlay ───────────── */
@media (max-width: 899px) {
  .only-mobile { display: inline-flex; }
  .layout { display: block; }
  .panel { padding: 16px 12px 96px; }
  .stage {
    position: fixed;
    inset: 0;
    z-index: 30;
    flex-direction: column;
    gap: 12px;
    height: auto;
    padding: 12px 12px 20px;
    border: 0;
    visibility: hidden;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity .2s, transform .2s, visibility 0s .2s;
  }
  body.previewing { overflow: hidden; }
  body.previewing .stage { visibility: visible; opacity: 1; transform: none; transition: opacity .2s, transform .2s; }
  .stage-top { justify-content: space-between; }
  .stage-close { background: var(--card); }
  .device[data-device="mobile"] { padding: 8px; border-radius: 46px; }
  .device[data-device="mobile"] .screen { border-radius: 38px; }
  .save-state { font-size: 12px; }
  .brand { font-size: 22px; }
}
@media (max-width: 420px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .top-actions { gap: 6px; }
  .top-actions .btn { padding: 0 12px; font-size: 13px; }
  .brand { font-size: 20px; }
  .grid { grid-template-columns: 1fr; }
  .grid > .half { grid-column: 1 / -1; }
  .half .thumb { width: 72px; height: 92px; }
  .half .photo { flex-direction: row; align-items: center; }
  .save-state[data-state="saved"] { font-size: 0; }
  .save-state[data-state="saved"]::before { font-size: 14px; content: "✓ Saved"; }
}

/* ───────────── the current design + the design catalogue ───────────── */
.design-now { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.dn-info { display: flex; align-items: center; gap: 14px; min-width: 0; }
.dn-info > div { display: flex; flex-direction: column; min-width: 0; }
.dn-info small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.design-now .btn { flex: none; }
.catalogue { width: min(1040px, calc(100vw - 24px)); height: min(860px, calc(100dvh - 24px)); max-height: none; overflow: hidden; }
.catalogue[open] { display: flex; flex-direction: column; }
.cat-head { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.cat-top { display: flex; align-items: center; justify-content: space-between; }
.cat-top h2 { font-size: 26px; }
.cat-top .icon-btn { width: 36px; height: 36px; font-size: 22px; }
#catSearch { width: 100%; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: #fff; font: inherit; font-size: 16px; }
.cat-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip { flex: none; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font: inherit; font-size: 13px; text-transform: capitalize; white-space: nowrap; cursor: pointer; }
.chip:hover { border-color: var(--line-strong); }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.cat-status { display: flex; align-items: baseline; gap: 10px; color: var(--muted); font-size: 13px; }
.cat-head .note { color: var(--muted); }
.cat-grid { --s: .4; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: max-content; align-content: start; flex: 1; min-height: 0; gap: 14px; padding: 16px 20px 24px; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 700px) { .cat-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.cat-card { display: flex; flex-direction: column; align-self: start; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: inherit; font: inherit; text-align: left; overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.cat-card:hover { border-color: var(--line-strong); box-shadow: 0 8px 22px -12px rgb(30 20 10 / .35); transform: translateY(-1px); }
.cat-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.cat-card.current { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.cat-shot { position: relative; display: block; flex: none; aspect-ratio: 390 / 600; overflow: hidden; background: var(--bg); }
.cat-shot iframe { position: absolute; left: 0; top: 0; width: 390px; height: calc(600px * 1.02); border: 0; transform: scale(var(--s)); transform-origin: 0 0; pointer-events: none; }
.cat-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 10px 12px 12px; }
.cat-meta b { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.cat-meta em { font-style: normal; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-dark); }
.cat-meta small { flex-basis: 100%; color: var(--muted); font-size: 12px; line-height: 1.35; }
.cat-empty { padding: 30px 20px; color: var(--muted); text-align: center; }

/* ───────────── opening envelope ───────────── */
.env-box { display: flex; flex-direction: column; gap: 12px; }
.env-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; transition: opacity .2s; }
.env-grid.off { opacity: .5; }
.env-opt { display: flex; flex-direction: column; gap: 4px; padding: 4px 4px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: inherit; font: inherit; text-align: center; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.env-opt:hover { border-color: var(--line-strong); }
.env-opt.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.env-opt:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.env-opt img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: 50% 50%; border-radius: 7px; }
.env-opt span { display: flex; flex-direction: column; font-size: 11.5px; line-height: 1.25; }
.env-opt em { font-style: normal; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-dark); }
.env-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.env-actions:empty { display: none; }
/* envelope cards in the catalogue: the sealed photo */
.cat-shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.catalogue[data-kind="envelope"] .cat-shot { aspect-ratio: 1; }
.cat-meta em.def { color: var(--muted); }

/* ───────────── one design or all of them (editor.js "one design or all of them") ───────────── */
.unlock-note { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--bg); font-size: 13.5px; line-height: 1.45; }
.unlock-note p { flex: 1 1 220px; margin: 0; }
.cat-meta em.lock { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.cat-meta em.lock svg, .try-bar svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.cat-card.locked:hover .cat-meta em.lock { color: var(--gold-dark); }
.try-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; width: min(100%, 520px); padding: 10px 14px; border: 1px solid var(--gold); border-radius: 12px; background: var(--card); font-size: 13.5px; text-align: center; }
.try-bar p { margin: 0; }
.try-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.ref-box { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 10px; background: var(--bg); }
.ref-box input { font-weight: 600; letter-spacing: .04em; }
#unlockDialog .link-btn { align-self: flex-start; font-size: 13px; }

/* fields only some designs use (SCHEMA `when`): the wrapper takes no space in the grid */
.when { display: contents; }
.mini.wide { flex-basis: 100%; }
.mini textarea { width: 100%; resize: vertical; font: inherit; }
