:root {
  --paper: #fbfaf7;
  --paper-soft: #f5f1ec;
  --white: #fff;
  --ink: #493f3a;
  --muted: #80736c;
  --terracotta: #b66f56;
  --terracotta-dark: #8b503e;
  --blush: #f2e5de;
  --sand: #e7d8cb;
  --sage: #768575;
  --sage-soft: #e9eee8;
  --danger: #a64f45;
  --line: #ded6d0;
  --shadow: 0 22px 65px rgba(75, 58, 49, .13);
  color: var(--ink);
  background: var(--paper-soft);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; font-size: 16px; line-height: 1.55; }
body.app-bg { background: radial-gradient(circle at 15% 5%, rgba(182,111,86,.07), transparent 28rem), radial-gradient(circle at 90% 80%, rgba(118,133,117,.08), transparent 32rem), var(--paper-soft); }
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
h1, h2, h3, p, a, small, strong, label { overflow-wrap: anywhere; }
.login-paper > *, .welcome > *, .rsvp-grid > *, .upload-panel > *, .gift-grid > *, .photo-grid > *, .two-col > *, .quantity-choice > *, form { min-width: 0; }
h1, h2, h3 { margin: 0 0 .7rem; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-weight: 400; line-height: 1.18; }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); }
h2 { font-size: clamp(1.45rem, 3vw, 2rem); }
h3 { font-size: 1.25rem; }
p { margin: .45rem 0 1rem; }
small { color: var(--muted); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: clamp(.75rem, 3vw, 2rem); }
.login-paper { width: min(100%, 1120px); min-height: min(690px, calc(100vh - 2rem)); display: grid; grid-template-columns: 1fr 1.08fr; overflow: hidden; border: 1px solid var(--line); border-radius: 1.35rem; background: var(--white); box-shadow: var(--shadow); }
.login-photo { position: relative; min-height: 620px; overflow: hidden; background: var(--sand); }
.login-photo > img { width: 100%; height: 100%; object-fit: cover; object-position: center 35%; }
.login-photo::after { content: ""; position: absolute; inset: 42% 0 0; background: linear-gradient(transparent, rgba(255,255,255,.95) 72%, #fff); }
.photo-caption { position: absolute; z-index: 1; left: clamp(1.5rem, 4vw, 3.5rem); right: 1.5rem; bottom: 2.5rem; }
.script-title, .brand strong { font-family: "Snell Roundhand", "Segoe Script", "Brush Script MT", cursive; color: var(--terracotta); font-weight: 400; }
.script-title { margin: 0 0 1rem; font-size: clamp(3.2rem, 8vw, 5.6rem); line-height: .95; }
.event-facts { display: flex; flex-wrap: wrap; gap: .45rem 1rem; color: var(--terracotta-dark); font-family: Georgia, serif; font-size: .9rem; }
.event-facts span:not(:last-child)::after { content: "·"; margin-left: 1rem; color: var(--sand); }
.login-content { display: flex; flex-direction: column; justify-content: center; padding: clamp(2rem, 6vw, 5rem); }
.terracotta-cross { margin-bottom: 1rem; color: var(--terracotta); font-size: 2.2rem; }
.eyebrow { margin: 0 0 .5rem; color: var(--terracotta-dark); text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; font-weight: 750; }
.login-content > p:not(.eyebrow) { max-width: 32rem; color: var(--muted); }
.login-card { margin-top: 1rem; }
.site-header { position: sticky; z-index: 10; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4.6rem; padding: .65rem max(1rem, env(safe-area-inset-right), calc((100vw - 1160px)/2)); padding-left: max(1rem, env(safe-area-inset-left), calc((100vw - 1160px)/2)); border-bottom: 1px solid var(--line); background: rgba(251,250,247,.95); backdrop-filter: blur(10px); }
.site-header nav { display: flex; gap: .55rem; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand .cross { color: var(--terracotta); font-size: 1.6rem; }
.brand strong { display: block; font-size: 1.75rem; line-height: 1; }
.brand small { display: block; margin-top: .18rem; color: var(--muted); font-size: .66rem; letter-spacing: .13em; text-transform: uppercase; }

.button { display: inline-flex; min-height: 2.75rem; align-items: center; justify-content: center; gap: .35rem; padding: .65rem 1rem; border: 1px solid transparent; border-radius: .65rem; font-weight: 750; line-height: 1.25; text-align: center; text-decoration: none; cursor: pointer; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--terracotta); }
.button.primary:hover { background: var(--terracotta-dark); }
.button.ghost { border-color: var(--line); color: var(--ink); background: #fff; }
.button.danger { color: #fff; background: var(--danger); }
.button.small { min-height: 2rem; padding: .35rem .7rem; font-size: .82rem; }
.button:disabled { opacity: .52; cursor: not-allowed; transform: none; }

.stack-form { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.align-end { align-self: end; }
label { display: grid; gap: .4rem; color: var(--ink); font-weight: 650; }
input, select, textarea { width: 100%; max-width: 100%; min-width: 0; min-height: 2.8rem; padding: .7rem .8rem; color: var(--ink); border: 1px solid var(--line); border-radius: .65rem; background: #fff; outline: none; font-size: 16px; }
input[type="file"] { min-height: 3.15rem; overflow: hidden; }
input[type="file"]::file-selector-button { min-height: 2.2rem; margin: -.35rem .65rem -.35rem -.35rem; padding: .45rem .7rem; border: 0; border-radius: .45rem; color: var(--terracotta-dark); background: var(--blush); font-weight: 750; }
textarea { min-height: 7rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(182,111,86,.14); }
label small { display: block; font-weight: 400; }
.check { display: flex; align-items: center; gap: .55rem; min-height: 2.8rem; }
.check input { width: 1.15rem; min-height: 1.15rem; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: .8rem; font-family: Georgia, serif; font-size: 1.15rem; }

.content-wrap, .center-wrap, .setup-wrap { width: min(100% - 2rem, 1160px); margin: 0 auto; padding: 2rem 0 4rem; }
.center-wrap, .setup-wrap { min-height: 100vh; display: grid; place-items: center; }
.panel { padding: clamp(1.2rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: 1rem; background: var(--white); box-shadow: 0 9px 28px rgba(75,58,49,.055); }
.panel.narrow, .setup-panel { width: min(100%, 640px); }
.setup-panel { margin: 2rem auto; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.badge { display: inline-flex; width: max-content; max-width: 100%; padding: .3rem .7rem; border-radius: 999px; color: var(--sage); background: var(--sage-soft); font-size: .78rem; font-weight: 750; }

.welcome { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .65fr); gap: clamp(1.5rem, 4vw, 3rem); align-items: center; background: linear-gradient(120deg, #fff 0 63%, #faf4f0 63%); }
.welcome h1 { margin-top: .8rem; }
.welcome-copy > p { max-width: 48rem; color: var(--muted); }
.location-card { padding-left: clamp(0rem, 2vw, 1.3rem); text-align: center; }
.location-card .location-icon { display: grid; width: 4.2rem; height: 4.2rem; place-items: center; margin: 0 auto .8rem; border: 1px solid var(--terracotta); border-radius: 50%; color: var(--terracotta); font-family: Georgia, serif; font-size: 2.2rem; }
.location-card h2 { font-size: 1.25rem; }
.location-card strong { color: var(--terracotta-dark); }
.location-card p { color: var(--muted); font-size: .9rem; }
.location-card a, .more-link { color: var(--terracotta-dark); font-size: .9rem; font-weight: 750; text-underline-offset: .2rem; }

.tabs { display: flex; gap: .25rem; margin: 1.15rem 0; padding: .35rem; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: none; border: 1px solid var(--line); border-radius: .85rem; background: var(--white); -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: 1; min-width: max-content; padding: .7rem 1rem; border-radius: .55rem; color: var(--muted); text-align: center; text-decoration: none; font-weight: 750; }
.tabs a.active { color: var(--terracotta-dark); background: var(--blush); }

.rsvp-grid { display: grid; grid-template-columns: minmax(260px, .55fr) minmax(0, 1.45fr); gap: 1.15rem; align-items: start; }
.schedule-panel { position: sticky; top: 6rem; }
.timeline { padding-left: 1.25rem; border-left: 2px solid var(--sand); }
.timeline p { position: relative; padding-bottom: .8rem; }
.timeline p::before { content: ""; position: absolute; width: .55rem; height: .55rem; left: -1.58rem; top: .42rem; border-radius: 50%; background: var(--terracotta); }
.choice-list { display: grid; gap: 1.1rem; }
.people-fieldset { padding: 1rem; border-radius: .85rem; background: var(--paper-soft); }
.count-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.activity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.activity-option { position: relative; display: grid; }
.activity-option.full { grid-column: 1 / -1; }
.choice { display: flex; min-height: 100%; align-items: flex-start; gap: .75rem; padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; background: #fff; cursor: pointer; }
.choice input { flex: 0 0 auto; width: 1.15rem; min-height: 1.15rem; margin-top: .2rem; accent-color: var(--terracotta); }
.choice strong, .choice small { display: block; }
.choice small { margin-top: .3rem; font-weight: 400; line-height: 1.45; }
.activity-option:has(input:checked) .choice { border-color: var(--terracotta); background: #fbf3ef; box-shadow: 0 0 0 1px var(--terracotta); }
.selection-help { margin-bottom: .7rem; color: var(--muted); }
.selection-total { width: max-content; max-width: 100%; margin: 0 0 1rem; padding: .55rem .8rem; border-radius: .65rem; color: var(--terracotta-dark); background: var(--blush); }
.quantity-choice { display: grid; min-height: 100%; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: start; padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; background: #fff; }
.quantity-choice strong, .quantity-choice small { display: block; }
.quantity-choice small { margin-top: .3rem; font-weight: 400; line-height: 1.45; }
.quantity-control { min-width: 5.2rem; color: var(--muted); font-size: .78rem; text-align: center; }
.quantity-control input { width: 5.2rem; min-height: 2.5rem; padding: .45rem; border-color: var(--sand); text-align: center; font-size: 1rem; font-weight: 750; }
.activity-option:has(.selection-quantity:focus) .quantity-choice { border-color: var(--terracotta); box-shadow: 0 0 0 1px var(--terracotta); }
.activity-option .more-link { width: max-content; margin: -.2rem 0 0 1rem; padding: .25rem 0 .5rem; z-index: 1; }
.section-title { margin: 1.6rem 0; }
.gift-intro { max-width: 55rem; color: var(--muted); }
.gift-note { color: var(--terracotta-dark); font-size: .9rem; font-weight: 700; }

.gift-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.gift-card { overflow: hidden; border: 1px solid var(--line); border-radius: 1rem; background: var(--white); box-shadow: 0 8px 25px rgba(75,58,49,.05); }
.gift-card.reserved { opacity: .63; }
.gift-card > img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.gift-card > div { display: grid; gap: .7rem; padding: 1.2rem; }
.gift-card h3 { min-height: 2.95rem; }
.gift-description { margin: 0; }
.gift-description summary { min-height: 2.75rem; list-style: none; cursor: pointer; }
.gift-description summary::-webkit-details-marker { display: none; }
.description-preview { display: -webkit-box; min-height: 4.35rem; overflow: hidden; color: var(--muted); line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; }
.description-action { display: inline-block; margin-top: .45rem; color: var(--terracotta-dark); font-size: .88rem; font-weight: 750; text-decoration: underline; text-underline-offset: .2rem; }
.hide-description { display: none; }
.gift-description[open] .show-description { display: none; }
.gift-description[open] .hide-description { display: inline; }
.description-full { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--line); color: var(--muted); }
.gift-card form .button, .gift-card > div > .button { width: 100%; }

.upload-panel { display: grid; grid-template-columns: 1fr minmax(280px, .7fr); gap: 1.5rem; align-items: center; }
.upload-form { display: grid; gap: .7rem; padding: 1rem; border: 1px dashed var(--terracotta); border-radius: .85rem; background: #faf3ef; }
.photo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin-top: 1rem; }
.photo-card { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: .85rem; background: var(--white); }
.photo-card > img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo-card figcaption { display: grid; gap: .35rem; padding: .8rem; }
.photo-card strong, .photo-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { margin-top: 1rem; padding: 3rem 1rem; border: 1px dashed var(--terracotta); border-radius: .85rem; background: var(--white); text-align: center; }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.card-list { display: grid; gap: 1rem; margin-top: 1rem; }
.user-card .form-grid { grid-template-columns: 1fr 1fr 180px auto auto; align-items: end; }
.card-footer { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--line); }
.card-footer form { margin-left: auto; }
.danger-row { margin-top: 1rem; text-align: right; }
.table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; border-radius: .7rem; -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .8rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--terracotta-dark); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }

.notice, .flash { padding: .9rem 1rem; border-radius: .7rem; }
.notice { margin: 1rem 0; background: var(--paper-soft); }
.notice.success, .flash.success { color: #345944; background: #e4f2e8; }
.notice.error, .flash.error { color: #7b2927; background: #f8e2e0; }
.flash { position: fixed; z-index: 20; top: 5rem; left: 50%; width: min(calc(100% - 2rem), 540px); transform: translateX(-50%); box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .login-paper { grid-template-columns: 1fr; }
  .login-photo { min-height: 390px; }
  .login-content { padding: 2.2rem; }
  .welcome, .rsvp-grid, .upload-panel, .two-col { grid-template-columns: 1fr; }
  .welcome { background: var(--white); }
  .location-card { padding: 1.4rem; border-radius: .8rem; background: #faf4f0; }
  .schedule-panel { position: static; }
  .gift-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .user-card .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .login-shell { padding: 0; }
  .login-paper { min-height: 100vh; border: 0; border-radius: 0; }
  .login-photo { min-height: min(330px, 43vh); }
  .photo-caption { left: 1.2rem; bottom: 1.5rem; }
  .script-title { font-size: 3.5rem; }
  .event-facts { display: grid; gap: .15rem; }
  .event-facts span::after { display: none; }
  .login-content { padding: 1.5rem 1.2rem 2.5rem; }
  .site-header { align-items: center; gap: .55rem; min-height: 3.9rem; padding: .5rem max(.75rem, env(safe-area-inset-right)); padding-left: max(.75rem, env(safe-area-inset-left)); }
  .site-header nav { margin-left: auto; flex-direction: row; gap: .35rem; }
  .site-header .button { min-height: 2.55rem; padding: .48rem .7rem; font-size: .86rem; }
  .site-header.admin-header { flex-wrap: wrap; }
  .site-header.admin-header nav { display: grid; flex: 1 0 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-left: 0; }
  .brand { min-width: 0; gap: .55rem; }
  .brand .cross { font-size: 1.35rem; }
  .brand strong { font-size: 1.45rem; }
  .brand small { display: none; }
  .content-wrap, .center-wrap, .setup-wrap { width: min(calc(100% - 1rem), 1160px); padding-top: 1rem; padding-bottom: max(2.5rem, env(safe-area-inset-bottom)); }
  .panel { padding: 1.15rem; }
  .welcome h1 { margin-top: 0; }
  .welcome-copy > p { margin-bottom: .3rem; }
  .location-card { padding: 1.15rem .9rem; }
  .location-card .location-icon { width: 3.5rem; height: 3.5rem; font-size: 1.85rem; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .activity-grid, .count-grid, .form-grid, .user-card .form-grid { grid-template-columns: 1fr; }
  .activity-option.full, .form-grid .wide { grid-column: auto; }
  .quantity-choice { grid-template-columns: 1fr; }
  .quantity-control { display: flex; align-items: center; justify-content: space-between; text-align: left; }
  .quantity-control input { min-height: 2.75rem; }
  .gift-grid { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-card figcaption { padding: .7rem; }
  .photo-card .button { width: 100%; }
  .upload-panel { gap: 1rem; }
  .upload-form { padding: .85rem; }
  .tabs { scroll-padding-inline: .35rem; }
  .tabs a { min-height: 2.75rem; display: grid; place-items: center; padding: .58rem .72rem; font-size: .92rem; }
  .card-footer form, .card-footer form .button, .danger-row .button { width: 100%; margin-left: 0; }
  .empty { padding: 2rem .8rem; }
  .flash { top: 4.5rem; width: calc(100% - 1rem); }
}

@media (max-width: 360px) {
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.4rem; }
  .script-title { font-size: 3rem; }
  .login-content { padding-inline: 1rem; }
  .brand strong { font-size: 1.3rem; }
  .site-header .button { padding-inline: .55rem; }
  .panel { padding: 1rem; }
  .tabs a { padding-inline: .62rem; font-size: .86rem; }
  .photo-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .login-photo { min-height: 250px; }
  .login-content { padding-block: 1.5rem; }
}

@media (hover: none) {
  .button:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
