:root {
  color-scheme: light;
  --ink: #15113f;
  --muted: #68627e;
  --navy: #101143;
  --violet: #7245f5;
  --pink: #ff4f9a;
  --yellow: #ffda43;
  --cream: #fffdf7;
  --line: rgba(21, 17, 63, 0.13);
  --shadow: 0 18px 55px rgba(13, 11, 56, 0.18);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 79, 154, 0.24), transparent 30rem),
    radial-gradient(circle at 88% 0%, rgba(114, 69, 245, 0.28), transparent 34rem),
    #f6f1ff;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, calc((100vw - 1180px) / 2));
  color: white;
  background: rgba(16, 17, 67, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(18px);
}

.topbar h1, .panel-heading h2, .login-card h1 { margin: 0; letter-spacing: -0.04em; }
.topbar h1 { font-size: clamp(1.45rem, 4vw, 2.1rem); }
.topbar__identity { min-width: max-content; }
.eyebrow { margin: 0 0 0.25rem; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.13em; text-transform: uppercase; }
.topbar .eyebrow { color: var(--yellow); }

.admin-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}
.admin-tab {
  min-height: 40px;
  padding: 0.6rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
  font-weight: 850;
  text-decoration: none;
  border-radius: 999px;
}
.admin-tab.is-active { color: var(--ink); background: var(--yellow); }

.logout-button {
  padding: 0.72rem 1rem;
  color: white;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  cursor: pointer;
}

.dashboard-shell { width: min(1180px, calc(100% - 1.5rem)); margin: 1.2rem auto 4rem; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; }
.summary-card {
  min-height: 122px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(255, 253, 247, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 1.35rem;
  box-shadow: 0 12px 35px rgba(40, 23, 102, 0.11);
}
.summary-card span { color: var(--muted); font-size: 0.86rem; font-weight: 750; }
.summary-card strong { font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1; }
.summary-card--accent { color: var(--ink); background: linear-gradient(145deg, #ffe26a, var(--yellow)); border-color: #ffcc16; }
.summary-card--accent span { color: #554516; }

.guest-panel {
  margin-top: 1rem;
  padding: clamp(1rem, 2.4vw, 1.8rem);
  background: rgba(255, 253, 247, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 1.7rem;
  box-shadow: var(--shadow);
}

.panel-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.panel-heading .eyebrow { color: var(--violet); }
.panel-heading h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); }
.refresh-note { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.82rem; }
.panel-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.55rem; }
.button {
  min-height: 44px;
  padding: 0.72rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
  border-radius: 0.9rem;
  cursor: pointer;
}
.button--primary { color: white; background: var(--navy); border: 2px solid var(--navy); }
.button--secondary { background: white; border: 2px solid var(--line); }
.button:disabled { opacity: 0.55; cursor: wait; }

.filters { display: flex; gap: 0.45rem; margin: 1.3rem 0 0.9rem; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: 0 0 auto;
  padding: 0.58rem 0.88rem;
  color: var(--muted);
  font-weight: 800;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.filter.is-active { color: white; background: var(--violet); border-color: var(--violet); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 1rem; }
table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 0.85rem 0.75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; color: var(--muted); font-size: 0.73rem; letter-spacing: 0.06em; text-transform: uppercase; background: #f8f5ff; }
tbody tr:last-child td { border-bottom: 0; }
td:nth-child(5), td:nth-child(6) { min-width: 170px; white-space: normal; }

.delete-button {
  min-height: 36px;
  padding: 0.5rem 0.72rem;
  color: #9a2559;
  font-size: 0.78rem;
  font-weight: 850;
  background: #fff1f7;
  border: 1px solid #f3b7d0;
  border-radius: 0.7rem;
  cursor: pointer;
}
.delete-button:hover { background: #ffe2ee; border-color: #e890b5; }
.delete-button:focus-visible { outline: 3px solid rgba(255, 79, 154, 0.28); outline-offset: 2px; }
.delete-button:disabled { opacity: 0.58; cursor: wait; }
.delete-button--table { min-height: 32px; padding: 0.38rem 0.58rem; }

.status { display: inline-flex; padding: 0.38rem 0.62rem; font-size: 0.73rem; font-weight: 900; white-space: nowrap; border-radius: 999px; }
.status--coming { color: #075b4d; background: #cdf6e7; }
.status--declined { color: #8b2854; background: #ffe0ed; }
.status--thinking { color: #6b4e00; background: #fff0ad; }

.guest-cards { display: none; }
.empty-state { padding: 2.4rem 1rem; margin: 0; color: var(--muted); text-align: center; }
.sync-message { min-height: 1.2rem; margin: 0.7rem 0 0; color: var(--muted); font-size: 0.82rem; text-align: right; }
.sync-message:not(:empty) {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  min-height: 0;
  margin: 0;
  padding: 0.72rem 1rem;
  color: white;
  font-weight: 800;
  text-align: center;
  background: var(--navy);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(13, 11, 56, 0.3);
  transform: translateX(-50%);
}
.load-error, .form-error { padding: 0.8rem 1rem; color: #8a1746; background: #ffe2ee; border: 1px solid #ffc1d9; border-radius: 0.85rem; }

.admin-flash { padding: 0.9rem 1rem; font-weight: 800; border-radius: 1rem; box-shadow: 0 10px 28px rgba(13, 11, 56, 0.11); }
.admin-flash--success { color: #075b4d; background: #d8f8ed; border: 1px solid #9fe5d3; }
.admin-flash--error { color: #8a1746; background: #ffe2ee; border: 1px solid #ffc1d9; }

.gift-editor { scroll-margin-top: 7.5rem; }
.gift-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.25rem; }
.form-field { display: grid; align-content: start; gap: 0.42rem; }
.form-field--wide { grid-column: 1 / -1; }
.form-field > span { font-size: 0.82rem; font-weight: 900; }
.form-field input, .form-field textarea {
  width: 100%;
  min-height: 50px;
  padding: 0.8rem 0.9rem;
  color: var(--ink);
  background: white;
  border: 2px solid var(--line);
  border-radius: 0.9rem;
  outline: none;
}
.form-field textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.form-field input:focus, .form-field textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(114, 69, 245, 0.13); }
.form-field input[type="file"] { padding: 0.65rem; }
.form-field small { color: var(--muted); font-size: 0.74rem; line-height: 1.35; }
.form-check { display: flex; align-items: center; gap: 0.6rem; color: #8a1746; font-weight: 800; }
.form-check input { width: 1.1rem; height: 1.1rem; accent-color: var(--pink); }
.gift-form__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.image-cropper { padding: 1rem; background: #f7f3ff; border: 1px solid #ddd4f4; border-radius: 1.1rem; }
.image-cropper__heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.image-cropper__heading strong { display: block; color: var(--ink); font-size: 1rem; }
.image-cropper__heading div > span { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.78rem; line-height: 1.4; }
.image-cropper__ratio { flex: 0 0 auto; padding: 0.42rem 0.62rem; color: #5f35c8; font-size: 0.7rem; font-weight: 900; background: #e9e0ff; border-radius: 999px; }
.image-cropper__stage { position: relative; width: min(100%, 620px); aspect-ratio: 4 / 3; margin: 0 auto; overflow: hidden; touch-action: none; background: white; border: 2px solid var(--ink); border-radius: 0.95rem; cursor: grab; user-select: none; }
.image-cropper__stage:active { cursor: grabbing; }
.image-cropper__stage img { position: absolute; top: 0; left: 0; max-width: none; transform-origin: 0 0; pointer-events: none; user-select: none; }
.image-cropper__frame { position: absolute; inset: 0; border: 1px solid rgba(255,255,255,0.72); border-radius: 0.75rem; box-shadow: inset 0 0 0 999px rgba(12, 10, 53, 0.04); pointer-events: none; }
.image-cropper__zoom { width: min(100%, 620px); margin: 0.85rem auto 0; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0.75rem; color: var(--ink); font-size: 0.78rem; font-weight: 900; }
.image-cropper__zoom input { width: 100%; accent-color: var(--violet); }
.image-cropper__actions { width: min(100%, 620px); margin: 0.8rem auto 0; display: flex; gap: 0.55rem; }
.image-cropper__actions .button { flex: 1 1 0; }
.image-cropper__status { width: min(100%, 620px); min-height: 1.2em; margin: 0.65rem auto 0; color: var(--muted); font-size: 0.76rem; font-weight: 750; text-align: center; }
.image-cropper__status.is-ready { color: #08705d; }
.image-cropper__status.is-error { color: #9a2559; }

.wishlist-panel { overflow: hidden; }
.wishlist-empty { padding: 3.2rem 1rem 2.3rem; color: var(--muted); text-align: center; }
.wishlist-empty span { display: block; font-size: 3rem; }
.wishlist-empty h3 { margin: 0.75rem 0 0.3rem; color: var(--ink); font-size: 1.45rem; }
.wishlist-empty p { margin: 0; }
.admin-gift-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.admin-gift-card { overflow: hidden; display: flex; flex-direction: column; background: white; border: 1px solid var(--line); border-radius: 1.25rem; box-shadow: 0 12px 35px rgba(40, 23, 102, 0.09); }
.admin-gift-card--reserved { border-color: rgba(255, 79, 154, 0.5); }
.admin-gift-card__meta { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.8rem 0.85rem 0; color: var(--muted); font-size: 0.72rem; font-weight: 850; }
.admin-gift-card__preview { margin: 0.65rem; padding: 0.75rem; background: white; border: 1px solid #e5dff0; border-radius: 1rem; box-shadow: 0 9px 24px rgba(15, 13, 60, 0.08); }
.admin-gift-card__image { position: relative; min-height: 190px; padding: 0.55rem; overflow: hidden; display: grid; place-items: center; background: #f7f4fc; border-radius: 0.85rem; }
.admin-gift-card__image img { width: 100%; height: auto; max-height: 430px; display: block; object-fit: contain; object-position: center; border-radius: 0.55rem; }
.admin-gift-card__image em { position: absolute; top: 0.65rem; left: 0.65rem; padding: 0.42rem 0.62rem; color: #075b4d; font-size: 0.7rem; font-style: normal; font-weight: 950; background: #cdf6e7; border-radius: 999px; box-shadow: 0 4px 14px rgba(15, 13, 60, 0.1); }
.admin-gift-card--reserved .admin-gift-card__image em { color: white; background: var(--pink); }
.gift-image-placeholder { width: 100%; height: 100%; display: grid; place-items: center; font-size: 3.4rem; background: linear-gradient(145deg, #f4efff, #fff2f8); }
.gift-status { padding: 0.45rem 0.7rem; font-size: 0.72rem; font-weight: 950; border-radius: 999px; box-shadow: 0 5px 18px rgba(15, 13, 60, 0.14); }
.gift-status--hidden { color: #5d5672; background: rgba(255, 255, 255, 0.94); }
.gift-status--free { color: #075b4d; background: #cdf6e7; }
.gift-status--reserved { color: white; background: var(--pink); }
.admin-gift-card__preview h3 { margin: 0.9rem 0.2rem 0.45rem; font-size: 1.25rem; letter-spacing: -0.025em; line-height: 1.2; }
.admin-gift-card__preview > p { margin: 0 0.2rem 0.7rem; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.admin-gift-card__preview > strong { display: block; margin: 0 0.2rem; color: var(--violet); font-size: 0.95rem; }
.admin-gift-card__preview-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; margin-top: 0.9rem; }
.admin-gift-card__preview-actions a, .admin-gift-card__preview-actions span { color: var(--violet); font-size: 0.78rem; font-weight: 900; }
.admin-gift-card__preview-actions button { min-height: 42px; padding: 0 0.85rem; color: white; font-weight: 900; background: var(--navy); border: 0; border-radius: 0.75rem; opacity: 1; }
.admin-gift-card--reserved .admin-gift-card__preview-actions button { background: #9b91a8; }
.admin-gift-card__reservation { padding: 0 0.85rem 0.85rem; }
.reservation-details { display: grid; gap: 0.45rem; margin: 0.9rem 0 0; padding: 0.8rem; background: #fff0f6; border: 1px solid #ffc9df; border-radius: 0.85rem; }
.reservation-details div { display: grid; grid-template-columns: minmax(105px, 0.7fr) 1fr; gap: 0.55rem; }
.reservation-details dt { color: #8b2854; font-size: 0.7rem; font-weight: 850; }
.reservation-details dd { margin: 0; font-size: 0.82rem; font-weight: 800; overflow-wrap: anywhere; }
.admin-gift-card__actions { padding: 0.85rem; display: flex; flex-wrap: wrap; gap: 0.45rem; background: #faf8ff; border-top: 1px solid var(--line); }
.admin-gift-card__actions form { display: contents; }
.admin-gift-card__actions .button, .admin-gift-card__actions .delete-button { flex: 1 1 auto; min-height: 44px; }
.delete-confirm { flex: 1 1 auto; min-width: 118px; }
.delete-confirm[open] { flex-basis: 100%; }
.delete-confirm > summary { display: flex; align-items: center; justify-content: center; list-style: none; }
.delete-confirm > summary::-webkit-details-marker { display: none; }
.delete-confirm__cancel-label { display: none; }
.delete-confirm[open] .delete-confirm__delete-label { display: none; }
.delete-confirm[open] .delete-confirm__cancel-label { display: inline; }
.delete-confirm__panel { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; margin-top: 0.55rem; padding: 0.75rem; background: #fff1f7; border: 1px solid #f3b7d0; border-radius: 0.85rem; }
.delete-confirm__panel p { margin: 0; color: #7b1f4a; font-size: 0.82rem; font-weight: 850; line-height: 1.35; }
.delete-confirm__panel form { display: block; flex: 0 0 auto; }
.delete-button--confirm { min-width: 112px; color: white; background: #a62660; border-color: #a62660; }
.delete-button--confirm:hover { background: #841d4c; border-color: #841d4c; }
.button--publish { color: var(--ink); background: var(--yellow); border: 2px solid #f1c600; }
.button--quiet { color: var(--ink); background: #efeaff; border: 2px solid #ddd2ff; }

.login-page { display: grid; place-items: center; padding: 1rem; }
.login-shell { width: min(430px, 100%); }
.login-card {
  padding: clamp(1.5rem, 6vw, 2.4rem);
  text-align: center;
  background: rgba(255, 253, 247, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 1.8rem;
  box-shadow: var(--shadow);
}
.login-star { width: 3.4rem; height: 3.4rem; margin: 0 auto 1rem; display: grid; place-items: center; font-size: 1.5rem; background: var(--yellow); border: 2px solid var(--ink); border-radius: 50%; }
.login-card .eyebrow { color: var(--violet); }
.login-card h1 { font-size: clamp(2rem, 9vw, 3.15rem); }
.login-copy { margin: 0.75rem auto 1.35rem; color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 0.65rem; text-align: left; }
.login-form label { font-size: 0.82rem; font-weight: 850; }
.login-form input { width: 100%; min-height: 52px; padding: 0.85rem 1rem; color: var(--ink); background: white; border: 2px solid var(--line); border-radius: 0.95rem; outline: none; }
.login-form input:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(114, 69, 245, 0.14); }
.login-form button { min-height: 52px; margin-top: 0.25rem; color: white; font-weight: 900; background: var(--navy); border: 0; border-radius: 0.95rem; cursor: pointer; }
.back-link { display: inline-block; margin-top: 1.1rem; color: var(--muted); font-size: 0.86rem; font-weight: 750; }

@media (max-width: 760px) {
  .topbar { padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem 0.75rem; flex-wrap: wrap; gap: 0.55rem; }
  .topbar h1 { font-size: 1.35rem; }
  .topbar .eyebrow { font-size: 0.65rem; }
  .topbar__identity { flex: 1 1 auto; }
  .admin-tabs { order: 3; width: 100%; }
  .admin-tab { flex: 1 1 0; min-height: 44px; }
  .logout-button { padding: 0.62rem 0.8rem; font-size: 0.82rem; }
  .dashboard-shell { width: min(100% - 1rem, 620px); margin-top: 0.65rem; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 0.55rem; }
  .summary-card { min-height: 106px; padding: 0.9rem; border-radius: 1.1rem; }
  .summary-card strong { font-size: 2.35rem; }
  .guest-panel { padding: 0.9rem; border-radius: 1.35rem; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .panel-actions { width: 100%; justify-content: stretch; }
  .panel-actions .button { flex: 1 1 0; }
  .table-wrap { display: none; }
  .guest-cards { display: grid; gap: 0.65rem; }
  .guest-card { padding: 0.95rem; background: white; border: 1px solid var(--line); border-radius: 1rem; }
  .guest-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.7rem; }
  .guest-card h3 { margin: 0.38rem 0 0; font-size: 1.15rem; }
  .adult-count { flex: 0 0 auto; padding: 0.4rem 0.55rem; color: var(--muted); font-size: 0.75rem; font-weight: 850; background: #f5f1ff; border-radius: 0.65rem; }
  .guest-card dl { display: grid; gap: 0.55rem; margin: 0.9rem 0; }
  .guest-card dl div { padding-top: 0.55rem; border-top: 1px solid var(--line); }
  .guest-card dt { margin-bottom: 0.15rem; color: var(--muted); font-size: 0.7rem; font-weight: 850; letter-spacing: 0.04em; text-transform: uppercase; }
  .guest-card dd { margin: 0; line-height: 1.4; overflow-wrap: anywhere; }
  .guest-card time { color: var(--muted); font-size: 0.74rem; }
  .guest-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; }
  .guest-card .delete-button { min-height: 44px; }
  .delete-confirm__panel { align-items: stretch; flex-direction: column; }
  .delete-confirm__panel form, .delete-button--confirm { width: 100%; }
  .sync-message { text-align: center; }
  .gift-form { grid-template-columns: 1fr; gap: 0.85rem; }
  .form-field--wide { grid-column: auto; }
  .image-cropper { padding: 0.75rem; }
  .image-cropper__heading { flex-direction: column; gap: 0.55rem; }
  .image-cropper__actions { flex-direction: column; }
  .admin-gift-grid { grid-template-columns: 1fr; gap: 0.8rem; }
  .admin-gift-card__image { min-height: 180px; }
  .admin-gift-card__image img { max-height: none; }
  .admin-gift-card__meta { align-items: flex-start; }
  .admin-gift-card__preview h3 { font-size: 1.15rem; }
  .admin-gift-card__preview > p { font-size: 0.84rem; }
  .admin-gift-card__preview-actions button { min-height: 40px; padding-inline: 0.75rem; font-size: 0.82rem; }
  .admin-gift-card__actions .button, .admin-gift-card__actions .delete-button { font-size: 0.84rem; }
  .reservation-details div { grid-template-columns: 1fr; gap: 0.12rem; }
}

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