:root {
  --bg: #fdfaf7;
  --surface: #ffffff;
  --tint: #f6eeea;
  --text: #2a1f22;
  --muted: #6f5f63;
  --border: #e6dbd6;
  --brand: #7b2d43;
  --brand-dark: #5f2033;
  --on-brand: #fff8f3;
  --danger: #a3261d;
  --heading-font: "Playfair Display", Georgia, serif;
  --ui-font: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--ui-font);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--heading-font);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: var(--brand);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.wrap {
  width: min(70rem, 100% - 2rem);
  margin-inline: auto;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-brand);
  font: 500 1rem var(--ui-font);
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--brand-dark);
}

.button.ghost {
  background: transparent;
  color: var(--brand);
}

.button.ghost:hover {
  background: var(--tint);
}

.button.small {
  padding: 0.3rem 0.8rem;
  font-size: 0.9rem;
}

.button.danger {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
  padding-block: 0.5rem;
  flex-wrap: wrap;
}

.brand {
  font: 700 1.3rem var(--heading-font);
  color: var(--brand);
  text-decoration: none;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
}

.account img {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
}

.account-name {
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.signin-note {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Home */
.hero {
  background: linear-gradient(160deg, var(--brand-dark), var(--brand));
  color: var(--on-brand);
}

.hero .wrap {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 3rem;
  padding-block: 4rem;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
}

.hero .lead {
  margin-top: 1rem;
  max-width: 32rem;
  font-size: 1.15rem;
  opacity: 0.92;
}

.hero .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.hero .button {
  border-color: var(--on-brand);
  background: var(--on-brand);
  color: var(--brand-dark);
}

.hero .button.ghost {
  background: transparent;
  color: var(--on-brand);
}

.hero-card {
  width: min(21rem, 100%);
  margin-inline: auto;
  box-shadow: 0 1.5rem 3rem rgb(0 0 0 / 0.3);
  transform: rotate(2deg);
}

.section {
  padding-block: 4rem;
}

.section.tinted {
  background: var(--tint);
}

.section h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.section .intro {
  margin-top: 0.5rem;
  color: var(--muted);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.features h3 {
  font-size: 1.15rem;
}

.features p {
  margin-top: 0.35rem;
  color: var(--muted);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 24rem));
  gap: 1.5rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.template-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  overflow: hidden;
}

.template-card .thumb {
  border-bottom: 1px solid var(--border);
}

.template-card .meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  flex: 1;
}

.template-card h3 {
  font-size: 1.1rem;
}

.template-card .meta p {
  color: var(--muted);
  font-size: 0.95rem;
  flex: 1;
}

.template-card .button {
  align-self: flex-start;
  margin-top: 0.75rem;
}

.my-list {
  display: grid;
  gap: 0.75rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.my-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
}

.my-list .title {
  flex: 1 1 12rem;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.my-list .title small {
  display: block;
  color: var(--muted);
  font-weight: 400;
}

.my-list .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge {
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  background: var(--tint);
  color: var(--muted);
  font-size: 0.8rem;
}

.badge.live {
  background: #dff3e6;
  color: #1c6b3e;
}

.empty {
  margin-top: 1.5rem;
  color: var(--muted);
}

.cta {
  text-align: center;
}

.cta .button {
  margin-top: 1.5rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.5rem;
}

/* Editor */
.wrap.editor {
  width: min(96rem, 100% - 2rem);
}

.editor {
  display: grid;
  grid-template-columns: minmax(18rem, 26rem) 1fr;
  gap: 2rem;
  align-items: start;
  padding-block: 2rem 4rem;
}

.editor-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.editor-form fieldset {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  min-width: 0;
}

.editor-form legend {
  padding: 0 0.4rem;
  font: 700 1.1rem var(--heading-font);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field input[type="color"] {
  width: 4rem;
  height: 2.5rem;
  padding: 0.2rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.colour-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.template-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.template-picker label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.8rem;
  text-align: center;
  cursor: pointer;
}

.template-picker input {
  position: absolute;
  opacity: 0;
}

.template-picker label:has(input:checked) {
  border-color: var(--brand);
  background: var(--tint);
}

.template-picker label:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.swatch {
  height: 2.5rem;
  border-radius: 0.3rem;
  border: 1px solid var(--border);
}

.swatch.s-evergreen { background: linear-gradient(90deg, #8fa55a 35%, #ffffff 35%); }
.swatch.s-midnight { background: linear-gradient(90deg, #0e1730 70%, #d9b46a 70%); }

.preview-pane {
  position: sticky;
  top: 5.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.preview-frame {
  padding: 1.5rem;
  border-radius: 0.75rem;
  background: var(--tint);
}

.preview-frame .invite {
  max-width: 24rem;
  box-shadow: 0 0.75rem 2rem rgb(42 31 34 / 0.18);
}

.preview-toggle {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.preview-toggle .button[aria-pressed="true"] {
  background: var(--brand);
  color: var(--on-brand);
}

.preview-scroll.wide {
  max-width: none;
  border-radius: 0.5rem;
}

.preview-scroll {
  max-width: 24rem;
  max-height: min(42rem, 70vh);
  margin: 0 auto;
  overflow-y: auto;
  border-radius: 1.25rem;
  box-shadow: 0 0.75rem 2rem rgb(42 31 34 / 0.18);
}

.preview-scroll .invite {
  box-shadow: none;
}

#play-opening,
#mail-resend {
  align-self: flex-start;
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.5rem;
}

.photo-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--tint);
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-tile button {
  position: absolute;
  inset: auto 0.25rem 0.25rem auto;
  padding: 0.1rem 0.5rem;
  border: 0;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.7);
  color: #ffffff;
  font: 0.8rem var(--ui-font);
  cursor: pointer;
}

.photo-add {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px dashed var(--border);
  border-radius: 0.5rem;
  background: none;
  color: var(--brand);
  font: 500 0.9rem var(--ui-font);
  cursor: pointer;
}

.photo-add:disabled {
  opacity: 0.6;
  cursor: default;
}

.person-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.75rem;
  align-items: start;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row.milestone {
  grid-template-columns: 6rem 1fr auto;
}

.row {
  display: grid;
  grid-template-columns: 8.75rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.row input {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.icon-button {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: none;
  color: var(--muted);
  font: 0.9rem var(--ui-font);
  cursor: pointer;
}

.palette-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.palette-item input {
  width: 2.75rem;
  height: 2.25rem;
  padding: 0.15rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
}

.reply-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 18rem;
  overflow-y: auto;
}

.reply-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow-wrap: anywhere;
}

.reply-list .reply-message {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.95rem;
}

.template-card .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.template-card .card-actions .button {
  margin-top: 0;
}

.save-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.status {
  color: var(--muted);
  font-size: 0.95rem;
}

.status.error {
  color: var(--danger);
}

.share {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
}

.share .link-row {
  display: flex;
  gap: 0.5rem;
}

.share input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  font: 0.9rem ui-monospace, Menlo, monospace;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.check input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.25rem;
  accent-color: var(--brand);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.signin-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px dashed var(--brand);
  border-radius: 0.75rem;
}

/* Guest view */
.guest {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.guest #invite-root {
  width: 100%;
}

.guest .invite {
  --hero-h: 100svh;
}

.guest {
  scroll-behavior: smooth;
}

.demo-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  width: 100%;
  padding: 0.5rem 1rem;
  background: var(--brand-dark);
  color: var(--on-brand);
  font-size: 0.95rem;
}

.demo-bar .button {
  border-color: var(--on-brand);
  background: var(--on-brand);
  color: var(--brand-dark);
}

.guest .made-with {
  margin-block: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.guest .notice {
  max-width: 26rem;
  text-align: center;
}

/* Plain text pages */
.prose {
  max-width: 42rem;
  padding-block: 3rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.prose h1 {
  font-size: 2.2rem;
}

.prose h2 {
  margin-top: 1rem;
  font-size: 1.3rem;
}

.prose ul {
  margin: 0;
  padding-left: 1.25rem;
}

@media (max-width: 52rem) {
  .hero .wrap,
  .editor {
    grid-template-columns: 1fr;
  }

  .hero .wrap {
    padding-block: 3rem;
  }

  .preview-pane {
    position: static;
    order: -1;
  }

  .preview-frame {
    padding: 1rem;
  }

  .preview-scroll {
    max-width: 18rem;
    max-height: 26rem;
  }
}

/* If Google's button falls back to plain markup, keep its logo at icon size. */
#google-button svg {
  max-width: 1.25rem;
  max-height: 1.25rem;
}
