/* Paleta: morado, blanco y azul claro */
:root {
  --ink: #2A1C47;
  --muted: #675C80;
  --purple: #6A3FC1;
  --purple-deep: #4E2A99;
  --lilac: #F1EBFC;
  --lilac-line: #CDB9F2;
  --sky: #DCEEFB;
  --sky-ink: #235F92;
  --paper: #FFFFFF;
  --line: #E3DCF1;
  --locked: #EEEAF4;
  --danger: #B3261E;
  --danger-bg: #FCEDEC;

  --r-lg: 22px;
  --r-md: 12px;
  --r-sm: 8px;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--font-display); font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.625rem; line-height: 1.15; margin: 0 0 20px; color: var(--purple-deep); }
h3, h4 { margin: 0; font-weight: 600; }

:focus-visible { outline: 3px solid rgba(106, 63, 193, 0.45); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Encabezado con la casa ---------- */
.hero { background: var(--sky); padding: 16px 20px clamp(80px, 10vw, 112px); }
.topbar { max-width: 1080px; margin: 0 auto clamp(12px, 3vw, 28px); display: flex; justify-content: flex-end; }
.hero-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(24px, 5vw, 56px);
  align-items: center;
}
.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2.5rem, 6.4vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-variation-settings: "opsz" 144;
  color: var(--purple-deep);
}
.hero-lead { margin: 0; max-width: 46ch; font-size: 1.125rem; }
.hero-note { margin: 12px 0 22px; max-width: 46ch; font-size: 0.9375rem; color: var(--sky-ink); }

.house { margin: 0; justify-self: center; text-align: center; width: min(100%, 290px); }
.house svg { display: block; width: 100%; height: auto; }
.house-fill {
  fill: var(--purple);
  opacity: 0.9;
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scaleY(0);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.house figcaption { margin-top: 12px; font-weight: 600; color: var(--purple-deep); }

/* ---------- Estructura ---------- */
.layout {
  max-width: 1080px;
  margin: -64px auto 72px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(20px, 3.2vw, 32px);
  box-shadow: 0 24px 48px -32px rgba(78, 42, 153, 0.35);
}
.list-panel { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; }

/* ---------- Pasos ---------- */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step { counter-increment: step; position: relative; padding: 0 0 28px 52px; }
.step::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--lilac); color: var(--purple-deep);
  font-family: var(--font-display); font-weight: 650;
}
.step::after { content: ""; position: absolute; left: 16px; top: 42px; bottom: 8px; width: 2px; background: var(--line); }
.step:last-child::after, .step:has(+ .step[hidden])::after { display: none; }
.step h3 { font-size: 1.0625rem; margin: 5px 0 12px; }
.step-hint { margin: -6px 0 12px; }

/* Pregunta de regalo grupal */
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  font-weight: 600; cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.choice-card:hover { border-color: var(--lilac-line); }
.choice-card input { width: 19px; height: 19px; margin: 0; flex: none; accent-color: var(--purple); }
.choice-card:has(input:checked) { border-color: var(--purple); background: var(--lilac); color: var(--purple-deep); }

/* Personas */
.people { display: grid; gap: 16px; }
.person { display: grid; gap: 8px; }
.person + .person { padding-top: 16px; border-top: 1px dashed var(--line); }
.person-head { display: flex; align-items: center; justify-content: space-between; }
.person-label { font-size: 0.875rem; font-weight: 700; color: var(--purple-deep); }
.add-person { margin-top: 10px; }

/* ---------- Campos ---------- */
.field label { display: block; font-weight: 500; font-size: 0.9375rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--purple); outline: none; box-shadow: 0 0 0 3px rgba(106, 63, 193, 0.18); }
textarea { resize: vertical; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%234E2A99' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.hint { margin: 8px 0 0; font-size: 0.875rem; color: var(--muted); }

/* ---------- Lista desplegable múltiple ---------- */
.picker { position: relative; }
.picker-toggle {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  font: inherit; color: var(--muted); text-align: left;
  background: var(--paper);
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  cursor: pointer;
}
.picker-toggle.has-value { color: var(--ink); font-weight: 600; border-color: var(--purple); }
.picker-toggle svg { color: var(--purple-deep); transition: transform 0.2s; flex: none; }
.picker-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.picker-panel {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--paper);
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 20px 44px -18px rgba(42, 28, 71, 0.4);
  padding: 10px;
}
.picker-panel input[type="search"] { margin-bottom: 6px; }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.picker-item label { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--r-sm); cursor: pointer; }
.picker-item label:hover { background: var(--lilac); }
.picker-item input { width: 19px; height: 19px; margin: 0; flex: none; accent-color: var(--purple); }
.picker-name { flex: 1; }
.picker-item.is-reserved label { cursor: not-allowed; color: var(--muted); }
.picker-item.is-reserved label:hover { background: transparent; }
.picker-item.is-reserved .picker-name { text-decoration: line-through; text-decoration-color: rgba(103, 92, 128, 0.5); }
.picker-empty { padding: 12px 10px; color: var(--muted); }
.picker-done { margin-top: 8px; width: 100%; }

/* ---------- Regalos escogidos ---------- */
.selected-list { display: grid; gap: 12px; }
.chosen { border: 1.5px solid var(--line); border-left: 5px solid var(--purple); border-radius: var(--r-md); padding: 14px 16px 16px; }
.chosen-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.chosen h4 { font-size: 1.0625rem; }
.chosen-facts { margin: -4px 0 10px; }
.notes { margin-top: 12px; padding: 10px 12px; background: var(--sky); border-radius: var(--r-sm); }
.notes-title { display: block; font-size: 0.8125rem; font-weight: 700; color: var(--sky-ink); }
.notes p { margin: 2px 0 0; white-space: pre-line; }
.empty { margin: 0; padding: 16px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--r-md); list-style: none; }
.conflict { margin: 0 0 12px; padding: 12px 14px; background: var(--lilac); border: 1.5px solid var(--lilac-line); border-radius: var(--r-md); color: var(--purple-deep); }

/* ---------- Etiquetas ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 600; white-space: nowrap;
}
.tag-free { background: var(--sky); color: var(--sky-ink); }
.tag-partial { background: var(--lilac); color: var(--purple-deep); }
.tag-locked { background: var(--locked); color: var(--muted); }

/* ---------- Botones ---------- */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px;
  font: inherit; font-weight: 600; text-decoration: none;
  border-radius: 999px; cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}
.btn-primary { width: 100%; font-size: 1.0625rem; color: #fff; background: var(--purple); border: 0; }
.btn-primary:hover { background: var(--purple-deep); }
.btn-primary:active, .btn-danger:active { transform: translateY(1px); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.6; cursor: progress; }
.btn-secondary { color: var(--purple-deep); background: var(--paper); border: 1.5px solid var(--purple); }
.btn-secondary:hover { background: var(--lilac); }
.btn-danger { color: #fff; background: var(--danger); border: 0; }
.btn-danger:hover { background: #8F1E17; }
.btn-ghost {
  padding: 8px 18px;
  font: inherit; font-weight: 600; color: var(--purple-deep);
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid rgba(78, 42, 153, 0.25); border-radius: 999px;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--paper); border-color: var(--purple); }
.btn-link { padding: 4px; font: inherit; font-weight: 600; color: var(--purple); background: none; border: 0; cursor: pointer; text-decoration: none; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.btn-small, .btn-small-outline {
  padding: 8px 14px;
  font: inherit; font-size: 0.875rem; font-weight: 600;
  border-radius: 999px; cursor: pointer;
}
.btn-small { color: #fff; background: var(--purple); border: 0; }
.btn-small-outline { color: var(--purple-deep); background: var(--paper); border: 1.5px solid var(--purple); }

.form-error { margin: 0 0 14px; padding: 11px 14px; color: var(--danger); background: var(--danger-bg); border-radius: var(--r-md); }

/* ---------- Lista completa ---------- */
.live { display: flex; align-items: center; gap: 8px; margin: -10px 0 14px; font-size: 0.875rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3BA776; animation: pulse 2.4s infinite; }
.live.is-offline .dot { background: var(--danger); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(59, 167, 118, 0.5); } 70%, 100% { box-shadow: 0 0 0 7px rgba(59, 167, 118, 0); } }
.gift-list { list-style: none; margin: 0; padding: 0; }
.gift-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.gift-row:last-child { border-bottom: 0; }
.gift-row-name { display: block; font-weight: 500; }
.gift-row-colors { display: block; font-size: 0.8125rem; color: var(--muted); }
.gift-row.is-reserved .gift-row-name { color: var(--muted); }

/* ---------- Reserva hecha / consultada ---------- */
.reservation:focus { outline: none; }
.reservation h2 { font-size: clamp(1.6rem, 3.4vw, 2.1rem); }
.code-box {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin: 0 0 14px; padding: 16px 18px;
  background: var(--lilac);
  border: 2px dashed var(--purple); border-radius: var(--r-md);
}
.code-label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.code { font-family: var(--font-display); font-size: clamp(1.9rem, 5vw, 2.4rem); letter-spacing: 0.08em; line-height: 1.1; color: var(--purple-deep); }
.callout { margin: 0 0 16px; padding: 12px 14px; background: var(--sky); border-radius: var(--r-md); }
.reservation-names { margin: 0 0 4px; }
.reservation-names .hint { margin: 0; }
.confirm-list { list-style: none; margin: 14px 0 20px; padding: 0; display: grid; gap: 10px; }
.confirm-list li { display: grid; gap: 2px; padding: 14px 16px; border: 1.5px solid var(--line); border-left: 5px solid var(--purple); border-radius: var(--r-md); }
.confirm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.confirm-notes { font-size: 0.875rem; color: var(--muted); white-space: pre-line; }
.confirm-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.confirm-actions .btn-primary { width: auto; }

/* ---------- Ventanas ---------- */
.dialog {
  width: min(92vw, 440px);
  padding: clamp(22px, 4vw, 32px);
  color: var(--ink);
  border: 0; border-radius: var(--r-lg);
  box-shadow: 0 30px 70px -20px rgba(42, 28, 71, 0.55);
}
.dialog::backdrop { background: rgba(42, 28, 71, 0.45); backdrop-filter: blur(3px); }
.dialog h2 { margin-bottom: 4px; }
.dialog-hint { margin: 0; color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; margin-top: 8px; }
.dialog-actions > * { flex: 1; width: auto; font-size: 1rem; }
.dialog[open] { animation: dialog-in 0.2s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.stack { display: grid; gap: 14px; }
.code-input { font-family: var(--font-display); font-size: 1.375rem; letter-spacing: 0.1em; text-transform: uppercase; }
.saved-codes { display: grid; gap: 6px; }
.saved-codes .hint { margin: 0; }
.saved-codes-list { display: flex; flex-wrap: wrap; gap: 8px; }
.code-chip {
  padding: 6px 12px;
  font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.06em; color: var(--purple-deep);
  background: var(--lilac); border: 1.5px solid var(--lilac-line); border-radius: 999px;
  cursor: pointer;
}
.code-chip:hover { border-color: var(--purple); }

/* ---------- Avisos ---------- */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { padding: 12px 16px; color: #fff; background: var(--ink); border-radius: var(--r-md); box-shadow: 0 14px 30px -12px rgba(42, 28, 71, 0.6); animation: toast-in 0.25s ease-out; transition: opacity 0.35s; }
.toast.is-leaving { opacity: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Portal de anfitriones ---------- */
.admin-band { background: var(--sky); padding: clamp(24px, 4vw, 40px) 20px 96px; }
.admin-header { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.admin-title { margin: 0; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.05; color: var(--purple-deep); }
.admin-summary { margin: 8px 0 0; font-weight: 600; color: var(--sky-ink); }
.admin-header-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-main { max-width: 1180px; margin: -64px auto 64px; padding: 0 20px; display: grid; gap: 20px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { margin-bottom: 12px; }
.section-hint { margin: -6px 0 16px; }
.count-pill { padding: 4px 12px; font-weight: 700; color: var(--purple-deep); background: var(--lilac); border-radius: 999px; white-space: nowrap; }
.people-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.people-list li:not(.empty) { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); }
.people-list .empty { grid-column: 1 / -1; }
.avatar { width: 32px; height: 32px; flex: none; display: grid; place-items: center; font-size: 0.8125rem; font-weight: 700; color: var(--purple-deep); background: var(--lilac); border-radius: 50%; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.table-wrap { overflow-x: auto; }
.gifts-table { width: 100%; border-collapse: collapse; min-width: 1000px; }
.gifts-table th { text-align: left; font-size: 0.8125rem; font-weight: 600; color: var(--muted); padding: 0 8px 8px; }
.gifts-table td { padding: 8px; border-top: 1px solid var(--line); vertical-align: top; }
.gifts-table input, .gifts-table textarea { padding: 8px 10px; font-size: 0.9375rem; }
.gifts-table td:nth-child(2) { min-width: 170px; }
.gifts-table td:nth-child(3) { min-width: 170px; }
.gifts-table td:nth-child(5) { min-width: 220px; }
.gifts-table .tag { margin-top: 6px; }
.input-order, .input-qty { width: 76px; }
.row-actions { white-space: nowrap; }
.empty-cell { color: var(--muted); padding: 20px 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .hero-inner { grid-template-columns: 1fr; }
  .house { width: min(60%, 220px); justify-self: start; }
  .layout { grid-template-columns: 1fr; margin-top: -48px; }
  .list-panel { position: static; max-height: none; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .choice { grid-template-columns: 1fr; }
  .step { padding-left: 0; }
  .step::before { position: static; margin-bottom: 8px; }
  .step::after { display: none; }
  .confirm-actions > * { width: 100%; }
  .confirm-actions .btn-primary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
