:root {
  --paper: #f6f1e6;
  --paper-line: #e4dcc8;
  --ink: #1c1710;
  --ink-soft: #7a7160;
  --teal: #0c776f;
  --teal-deep: #08544e;
  --teal-wash: #e4f0ee;
  --mustard: #f3c165;
  --mustard-deep: #d9a53d;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.bg-wash {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at 20% 0%, rgba(12, 119, 111, 0.08) 0%, transparent 45%),
    radial-gradient(ellipse at 100% 20%, rgba(243, 193, 101, 0.14) 0%, transparent 40%);
}

main {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px 40px;
  flex: 1 0 auto;
}

.hero {
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.brand-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 25px;
  letter-spacing: -0.01em;
}

.chest-badge {
  position: relative;
  width: 26px;
  height: 20px;
  background: var(--mustard);
  border: 2px solid var(--ink);
  border-radius: 5px;
  flex: 0 0 auto;
}
.chest-badge::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: 6px;
  height: 2px;
  background: var(--ink);
}
.chest-badge::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background: var(--ink);
  border-radius: 2px;
}

.tagline {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 23px;
  color: var(--ink);
  max-width: 22ch;
  margin: 0;
  line-height: 1.25;
}
.hl {
  display: inline-block;
  background: var(--mustard);
  padding: 1px 12px;
  border-radius: 999px;
}
.tagline-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--teal-deep);
  letter-spacing: 0.02em;
  margin: 10px 0 0;
}

.status {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--teal-deep);
  background: var(--teal-wash);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 24px;
}

.donation-fab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--mustard);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-left: none;
  border-radius: 0 18px 18px 0;
  padding: 18px 10px;
  cursor: pointer;
  box-shadow: 6px 10px 24px rgba(28, 23, 16, 0.2);
  transition: padding .15s ease, background .15s ease;
}
.donation-fab:hover {
  background: var(--mustard-deep);
  padding-left: 14px;
}
.donation-fab .fab-icon {
  display: flex;
}
.donation-fab .fab-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
@media (max-width: 480px) {
  .donation-fab {
    padding: 12px 8px;
  }
  .donation-fab .fab-label {
    display: none;
  }
}

.tool-area.hidden {
  display: none;
}

.skeleton-loader.hidden {
  display: none;
}
@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
.skeleton-pill,
.skeleton-line,
.skeleton-block {
  background: linear-gradient(90deg, var(--paper-line) 25%, #f0e9d8 37%, var(--paper-line) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}
.skeleton-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.skeleton-pill {
  height: 34px;
  border-radius: 999px;
}
.skeleton-card {
  border: 1px solid var(--paper-line);
  border-radius: 22px;
  padding: 26px;
  background: #fffdf9;
  box-shadow: 0 14px 32px rgba(70, 62, 45, 0.08);
}
.skeleton-line {
  display: block;
  height: 14px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.skeleton-line.w-70 {
  width: 70%;
}
.skeleton-line.w-40 {
  width: 40%;
}
.skeleton-block {
  display: block;
  height: 44px;
  width: 160px;
  border-radius: 999px;
  margin-top: 8px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  background: #fffdf9;
  border: 1.5px solid var(--paper-line);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tab.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}
.tab:hover:not(.active) {
  border-color: var(--teal);
  color: var(--teal-deep);
}

.card {
  border: 1px solid var(--paper-line);
  border-radius: 22px;
  padding: 26px;
  background: #fffdf9;
  box-shadow: 0 14px 32px rgba(70, 62, 45, 0.08);
}
.panel.hidden {
  display: none;
}
.hint {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 16px;
}
.note {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--paper-line);
}
.note-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  background: var(--mustard);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 14px;
}
.subtab {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}
.subtab.active {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}
.submode.hidden {
  display: none;
}
.submode-explain {
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
}
.range-num {
  font-family: var(--mono);
  font-size: 12px;
  color: #fff;
  background: var(--teal);
  border-radius: 999px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.range-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 13px;
}
.range-row input[type="number"] {
  width: 68px;
}
.range-remove {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 16px;
  cursor: pointer;
  margin-left: auto;
  padding: 0 4px;
}
.range-remove:hover {
  color: var(--ink);
}

input[type="file"] {
  display: block;
  width: 100%;
  font-size: 14px;
  margin-bottom: 16px;
  color: var(--ink-soft);
}
input[type="number"],
input[type="text"] {
  font-family: var(--sans);
  font-size: 14px;
  border: 1px solid var(--paper-line);
  border-radius: 10px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
}
select {
  font-family: var(--sans);
  font-size: 14px;
  border: 1px solid var(--paper-line);
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
}
input[type="range"] {
  accent-color: var(--teal);
}
label.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 14px 0 18px;
  cursor: pointer;
}
.angle-picker {
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
  font-size: 14px;
}
.angle-picker label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

#sig-canvas {
  display: block;
  width: 100%;
  max-width: 360px;
  height: 140px;
  background: #fff;
  border: 1px dashed var(--paper-line);
  border-radius: 10px;
  margin: 4px 0 12px;
  touch-action: none;
  cursor: crosshair;
}
.sign-options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 16px 0 4px;
}

button.primary {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
}
button.primary:hover:not(:disabled) {
  background: var(--teal-deep);
}
button.primary:disabled {
  background: var(--paper-line);
  color: var(--ink-soft);
  cursor: not-allowed;
}
button.ghost {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--teal-deep);
  background: var(--teal-wash);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  margin-right: 8px;
}
button.ghost:hover {
  border-color: var(--teal);
}
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.rsvp-stage.hidden {
  display: none;
}
.rsvp-stage {
  margin-top: 20px;
  text-align: center;
}
.rsvp-word {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 44px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  margin-bottom: 14px;
  word-break: break-word;
}
.rsvp-slider {
  width: 100%;
  margin-bottom: 14px;
}
.rsvp-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-soft);
}
.rsvp-controls label.inline {
  margin-bottom: 0;
}
.rsvp-counter {
  font-family: var(--mono);
  margin-left: auto;
}

.tts-controls.hidden {
  display: none;
}
.tts-controls {
  margin-top: 18px;
}
.tts-buttons {
  display: flex;
  gap: 10px;
  margin: 14px 0;
}

.rotate-preview.hidden {
  display: none;
}
.rotate-preview {
  margin-top: 20px;
}
.rotate-preview embed {
  width: 100%;
  height: 420px;
  border: 1px solid var(--paper-line);
  border-radius: 14px;
  background: #fff;
}
.rotate-preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.md-output {
  width: 100%;
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 10px;
  padding: 12px;
  resize: vertical;
}
.md-output.hidden,
.md-actions.hidden {
  display: none;
}
.md-actions {
  margin-top: 12px;
}

.foot {
  flex-shrink: 0;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  border-top: 1px solid var(--paper-line);
}
.foot a {
  color: var(--teal-deep);
  font-weight: 600;
  text-decoration: none;
}
.foot a:hover {
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 23, 16, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility 0s linear .22s;
}
.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity .22s ease;
}
.modal {
  position: relative;
  background: #fffdf9;
  border-radius: 22px;
  padding: 32px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(28, 23, 16, 0.28);
  text-align: center;
  transform: translateY(10px) scale(.96);
  transition: transform .22s ease;
}
.modal-overlay.visible .modal {
  transform: translateY(0) scale(1);
}
.modal-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mustard-deep);
  margin: 0 0 8px;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 6px;
}
.modal-close:hover {
  color: var(--ink);
}

.donation-modal {
  max-width: 560px;
  padding: 40px 36px 36px;
  text-align: left;
}
.donation-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.2;
  margin: 4px 0 14px;
}
.donation-copy {
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0 0 24px;
}
.donation-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 24px;
}
.donation-qr {
  width: 100%;
  height: 300px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--paper-line);
  padding: 10px;
}
.donation-qr-caption {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0;
  text-align: center;
}
.donation-done {
  width: 100%;
}
@media (max-width: 480px) {
  .donation-modal {
    padding: 32px 22px 28px;
  }
  .donation-title {
    font-size: 22px;
  }
  .donation-qr {
    width: 180px;
    height: 180px;
  }
}

.alert-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 14px;
  background: var(--teal-wash);
  color: var(--teal-deep);
}
.alert-icon.error {
  background: #fbe4e1;
  color: #b3392c;
}
.alert-message {
  font-size: 14.5px;
  color: var(--ink);
  margin: 0 0 20px;
  line-height: 1.5;
}
.alert-close {
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
@media (max-width: 480px) {
  main {
    padding: 32px 16px 32px;
  }
  .foot {
    padding: 20px 16px 32px;
  }
}