:root {
  --paper: #f5efe3;
  --paper-strong: #fff9ee;
  --ink: #3e2a16;
  --muted: #7c6751;
  --brown: #5a3a18;
  --brown-soft: #8b6637;
  --line: rgba(90, 58, 24, 0.24);
  --shadow: 0 20px 60px rgba(38, 25, 12, 0.18);
  --radius: 28px;
  --max-phone: 480px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 5%, rgba(255,255,255,0.55), transparent 28rem),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.35), transparent 22rem),
    linear-gradient(135deg, #d5c6ad, #efe5d3 44%, #cbb99d);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(45deg, rgba(90,58,24,.07) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(90,58,24,.045) 25%, transparent 25%);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
}

.site-shell {
  width: min(100%, var(--max-phone));
  margin: 0 auto;
  padding: 0;
}

.single-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.paper-card {
  position: relative;
  overflow: hidden;
  margin: 0;
  padding: 34px 22px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 30% 15%, rgba(255,255,255,0.82), transparent 12rem),
    linear-gradient(180deg, rgba(255,255,255,0.64), rgba(255,255,255,0.18)),
    var(--paper);
  box-shadow: none;
}

.paper-card + .paper-card,
main > .paper-card + .paper-card {
  border-top: 1px solid rgba(90, 58, 24, 0.16);
}

.admin-shell .paper-card {
  margin: 0 0 16px;
  border: 1px solid rgba(90, 58, 24, 0.18);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.paper-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.13;
  background-image:
    repeating-linear-gradient(0deg, rgba(90,58,24,.13) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgba(90,58,24,.08) 0 1px, transparent 1px 7px);
}

.paper-card > * { position: relative; z-index: 1; }
.compact { padding: 32px 22px; }

.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.language-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .58);
  color: var(--brown);
  font-weight: 900;
  font-size: 12px;
  backdrop-filter: blur(8px);
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.lang-btn.active { color: var(--brown); text-decoration: underline; text-underline-offset: 3px; }

.ornament {
  color: var(--brown);
  font-size: 42px;
  line-height: 1;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--brown-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, .signature {
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  margin: 0;
  color: var(--brown);
  font-size: clamp(48px, 16vw, 74px);
  line-height: .9;
  letter-spacing: -0.04em;
}

h1 small {
  display: block;
  margin: 12px auto;
  font-size: .68em;
  font-weight: 400;
}

h2 {
  margin-bottom: 12px;
  color: var(--brown);
  font-size: clamp(28px, 9vw, 42px);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

h3 {
  margin-bottom: 6px;
  color: var(--brown);
  font-size: 22px;
}

p {
  color: var(--muted);
  line-height: 1.68;
  font-size: 16px;
}

.date-line {
  margin: 22px 0 12px;
  color: var(--brown);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.blessing { margin-left: auto; margin-right: auto; max-width: 32ch; }
.tagline { margin: 20px 0 0; color: var(--brown); font-weight: 800; }
.script-label { color: var(--brown); font-style: italic; }

.hero-actions,
.admin-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 18px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .62; cursor: not-allowed; }
.btn.primary {
  color: #fffaf0;
  background: linear-gradient(135deg, var(--brown), #7e5526);
  box-shadow: 0 12px 25px rgba(90,58,24,.24);
}
.btn.secondary {
  color: var(--brown);
  background: rgba(255,255,255,.42);
  border: 1px solid var(--line);
}
.btn.full { width: 100%; }

.text-link {
  color: var(--brown);
  font-weight: 800;
  text-underline-offset: 4px;
}

.couple {
  text-align: center;
}
.couple article p { margin-bottom: 0; }
.ampersand {
  color: var(--brown);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 80px;
  line-height: .85;
  margin: 14px 0;
}

.story {
  background:
    radial-gradient(circle at 100% 10%, rgba(90,58,24,.08), transparent 11rem),
    linear-gradient(180deg, rgba(255,255,255,0.62), rgba(255,255,255,0.18)),
    var(--paper);
}

.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}
.countdown-grid div {
  padding: 14px 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.35);
  text-align: center;
}
.countdown-grid strong {
  display: block;
  color: var(--brown);
  font-size: 26px;
  line-height: 1;
}
.countdown-grid span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.event-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.event-item:first-of-type { border-top: 0; }
.event-item p { margin-bottom: 4px; line-height: 1.45; }
.time {
  color: var(--brown);
  font-weight: 900;
  font-size: 17px;
}

.map-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.34);
  margin-top: 14px;
}
.map-card iframe {
  width: 100%;
  height: 210px;
  border: 0;
  border-radius: 18px;
  margin: 8px 0 12px;
  background: #e7dcc9;
}

.field {
  display: block;
  margin: 0 0 16px;
}
.field span,
.field legend {
  display: block;
  margin: 0 0 8px;
  color: var(--brown);
  font-weight: 900;
}
.field small { color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  color: var(--ink);
  font: inherit;
  min-height: 52px;
  padding: 13px 15px;
  outline: none;
}
textarea { min-height: 118px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brown-soft);
  box-shadow: 0 0 0 4px rgba(139,102,55,.13);
}
fieldset {
  border: 0;
  padding: 0;
}
.radio-group label,
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.45);
  font-weight: 750;
}
.radio-group input,
.checkbox-group input {
  width: 22px;
  min-height: 22px;
  flex: 0 0 22px;
  accent-color: var(--brown);
}
.checkbox-group span { margin: 0; }
.helper { font-size: 15px; }
.form-message {
  min-height: 24px;
  color: var(--brown);
  font-weight: 800;
}
.form-message.error { color: #9b2d1f; }
.form-message.success { color: #27693f; }
.signature {
  color: var(--brown);
  font-size: 30px;
  line-height: 1;
}
.closing { text-align: center; }

.admin-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 18px 14px 40px;
}
.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.admin-header h1 {
  font-size: clamp(34px, 7vw, 56px);
}
.hidden { display: none !important; }
.dashboard { display: grid; gap: 16px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.stat {
  margin: 0;
  padding: 20px;
}
.stat span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}
.stat strong {
  display: block;
  color: var(--brown);
  font-size: 34px;
  margin-top: 8px;
}
.admin-tools,
.admin-add-form {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-tools .field,
.admin-add-form .field { margin: 0; min-width: 220px; flex: 1; }
.admin-add-form .btn { flex: 0 0 auto; }
.table-card { padding: 0; }
.table-scroll { overflow: auto; }
.rsvp-table,
.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}
.admin-table { min-width: 620px; }
.rsvp-table th,
.rsvp-table td,
.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}
.rsvp-table th,
.admin-table th {
  position: sticky;
  top: 0;
  color: var(--brown);
  background: var(--paper-strong);
  z-index: 2;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.small-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.65);
  color: var(--brown);
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.small-btn.danger { color: #9b2d1f; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-tools, .admin-add-form { align-items: stretch; flex-direction: column; }
  .admin-tools .field, .admin-add-form .field { max-width: none; width: 100%; }
  .admin-add-form .btn { width: 100%; }
}

@media (max-width: 390px) {
  .paper-card { padding: 30px 18px; }
  .countdown-grid { gap: 6px; }
  .countdown-grid strong { font-size: 22px; }
  .event-item { grid-template-columns: 1fr; }
  .time { font-size: 18px; }
}

/* v3: invitation gate, cleaner webtoon strip, dashboard/editor upgrades */
:root { --accent: #d6bb8e; }
html.locked,
body.locked {
  overflow: hidden;
  height: 100svh;
  overscroll-behavior: none;
}
body.locked main { display: none; }
body.locked .site-shell { height: 100svh; overflow: hidden; }
body.locked .hero { min-height: 100svh; }

.recipient-card {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.45);
  color: var(--brown);
}
.recipient-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.recipient-card strong { display: block; margin-top: 4px; font-family: Georgia, "Times New Roman", serif; font-size: 22px; }

.floating-rsvp {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 46px;
  padding: 12px 16px;
  border-radius: 999px;
  color: #fffaf0;
  background: linear-gradient(135deg, var(--brown), #7e5526);
  box-shadow: 0 14px 34px rgba(90,58,24,.34);
  text-decoration: none;
  font-weight: 900;
}

.webtoon-stack .paper-card {
  border-top: 0;
  border-bottom: 1px solid rgba(90, 58, 24, 0.14);
}
.webtoon-stack main > .paper-card { min-height: auto; }
.webtoon-stack .paper-card + .paper-card { border-top: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(90,58,24,.1);
  color: var(--brown);
  font-weight: 900;
  font-size: 12px;
  white-space: nowrap;
}
.badge.warn { background: rgba(155,45,31,.1); color: #9b2d1f; }
.badge.ok { background: rgba(39,105,63,.1); color: #27693f; }

.admin-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}
.tab-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.5);
  color: var(--brown);
  padding: 10px 14px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.tab-btn.active { color: #fffaf0; background: var(--brown); }
.tab-panel.hidden { display: none !important; }

.admin-tools.v3-tools {
  align-items: stretch;
}
.admin-tools.v3-tools .field { min-width: 170px; }
.admin-tools.v3-tools .field.search-field { min-width: 260px; flex: 2; }

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.editor-grid .field.full { grid-column: 1 / -1; }
.editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.color-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.color-row input[type="color"] {
  padding: 4px;
  min-height: 52px;
}
.switch-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  color: var(--brown);
}
.switch-field input {
  width: 22px;
  min-height: 22px;
  flex: 0 0 22px;
  accent-color: var(--brown);
}
.edit-panel {
  border: 2px solid rgba(90,58,24,.25);
}
.edit-panel h2,
#invitationEditor h2 { margin-bottom: 8px; }

.rsvp-table td.message-cell {
  max-width: 260px;
  white-space: normal;
}
.rsvp-table td.nowrap { white-space: nowrap; }

@media (max-width: 700px) {
  .editor-grid,
  .color-row { grid-template-columns: 1fr; }
  .admin-tabs { position: sticky; top: 0; z-index: 10; background: var(--paper); padding: 10px 0; }
}
