/* 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 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink);
  text-decoration: 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; }

.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; }

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; }

/* theme picker */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-opt {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.theme-opt:hover { border-color: var(--line-strong); }
.theme-opt input { position: absolute; opacity: 0; }
.theme-opt:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.theme-opt:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.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)); }

/* "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 */
.replies-box { max-height: min(56vh, 520px); overflow: auto; 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;
  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 td small { display: block; margin-top: 2px; color: var(--muted); font-style: italic; }
.replies td:nth-child(3), .replies th:nth-child(3) { text-align: center; }
.replies td:last-child { color: var(--muted); white-space: nowrap; }

/* 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"; }
}
