:root {
  --bg: #fdf6e8;
  --surface: #ffffff;
  --ink: #2b2118;
  --muted: #7a6a5b;
  --line: #eadfcb;
  --red: #b3261e;
  --red-dark: #8c1d17;
  --green: #1f6b45;
  --gold: #e9a23b;
  --chip: #fbe9e5;
  --chip-ink: #8c1d17;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 18px rgba(60, 40, 20, .08);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1612; --surface: #2a221c; --ink: #f6ecdf; --muted: #bba995; --line: #3d332a;
    --red: #e5534b; --red-dark: #ff7b72; --green: #4cc38a; --chip: #3e2522; --chip-ink: #ffb4ab;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1612; --surface: #2a221c; --ink: #f6ecdf; --muted: #bba995; --line: #3d332a;
  --red: #e5534b; --red-dark: #ff7b72; --green: #4cc38a; --chip: #3e2522; --chip-ink: #ffb4ab;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
button, input, textarea { font: inherit; color: inherit; }

/* ---------- Encabezado ---------- */
.hero {
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.14) 0 2px, transparent 3px) 0 0/38px 38px,
    radial-gradient(circle at 70% 60%, rgba(255,255,255,.10) 0 1.5px, transparent 2.5px) 0 0/27px 27px,
    linear-gradient(160deg, #c0392b, #8c1d17);
  color: #fff;
  padding: calc(28px + env(safe-area-inset-top)) 16px 46px;
  text-align: center;
  border-radius: 0 0 28px 28px;
}
.hero-inner { max-width: 720px; margin: 0 auto; }
.hero h1 {
  font-family: "Pacifico", cursive;
  font-weight: 400;
  font-size: clamp(30px, 8vw, 48px);
  line-height: 1.2;
  margin: 0 0 8px;
  text-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.year { color: #ffd88a; white-space: nowrap; }
.tagline { margin: 0; font-size: 17px; opacity: .95; }

/* ---------- Contenido ---------- */
.wrap { width: 100%; max-width: 960px; margin: -26px auto 0; padding: 0 16px 32px; flex: 1; }

.banner {
  background: #fff4d6; color: #6b4b00; border: 1px solid #f1d98c;
  padding: 10px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 12px; text-align: center;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 14px; border: 0;
  font-weight: 800; cursor: pointer; text-decoration: none;
  transition: transform .08s ease, background .15s ease, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn:focus-visible, .card:focus-visible, input:focus-visible, textarea:focus-visible, .pick button:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 4px 0 #134a2f; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-big { font-size: 19px; min-height: 58px; width: 100%; }
.btn-full { width: 100%; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 2px solid var(--line); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-danger { background: var(--red); color: #fff; }
.btn-link { background: none; min-height: 44px; font-weight: 700; text-decoration: none; }
.danger { color: var(--red); }

.search { position: relative; margin: 16px 0 6px; }
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search input {
  width: 100%; min-height: 54px; padding: 12px 16px 12px 48px;
  border-radius: 16px; border: 2px solid var(--line); background: var(--surface);
  font-size: 18px;
}
.search input:focus { border-color: var(--gold); outline: none; }

.count { color: var(--muted); font-size: 14px; margin: 6px 4px 10px; min-height: 1.2em; }

.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 880px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  width: 100%; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.card:hover { transform: translateY(-2px); }
.card:active { transform: scale(.99); }
.card-name { font-weight: 800; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.card-sub { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.card-arrow { color: var(--muted); font-size: 22px; }
.dots { display: flex; gap: 4px; margin-top: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--green); }

.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px;
  flex: none;
}
.avatar-lg { width: 72px; height: 72px; font-size: 30px; margin: 0 auto 8px; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.empty-emoji { font-size: 56px; }

.foot { text-align: center; color: var(--muted); font-size: 14px; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }

/* ---------- Ventana ---------- */
.sheet {
  border: 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface); color: var(--ink);
  width: 100%; max-width: 100%; max-height: 92vh; max-height: 92dvh;
  margin: auto 0 0; border-radius: 24px 24px 0 0;
  overflow-y: auto; overscroll-behavior: contain;
}
.sheet[open] { animation: up .22s ease-out; }
.sheet::backdrop { background: rgba(30, 15, 5, .5); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .sheet { max-width: 560px; margin: auto; border-radius: 24px; padding: 28px; }
  .sheet-handle { display: none; }
}
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: -8px auto 12px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--bg); color: var(--ink); font-size: 18px; font-weight: 800;
}

.view-head { text-align: center; margin-bottom: 8px; clear: both; }
.view-name { margin: 0; font-size: 26px; line-height: 1.2; overflow-wrap: anywhere; }
.block { margin: 18px 0; }
.block h3 { margin: 0 0 8px; font-size: 16px; color: var(--muted); font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--chip); color: var(--chip-ink); padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.ideas { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.ideas li {
  background: var(--bg); border-radius: 12px; padding: 10px 12px; overflow-wrap: anywhere;
  display: flex; gap: 10px;
}
.ideas li::before { content: "🎀"; }
.ideas a { color: var(--green); font-weight: 700; }
.sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.size {
  background: var(--bg); border-radius: 14px; padding: 12px 6px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.size-ico { font-size: 24px; }
.size-lbl { font-size: 12px; color: var(--muted); line-height: 1.2; }
.size strong { font-size: 20px; overflow-wrap: anywhere; }
.prose { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.none { color: var(--muted); font-style: italic; }

/* ---------- Formulario ---------- */
.form-title { margin: 0; font-size: 24px; clear: both; }
.form-sub { margin: 4px 0 16px; }
.field { display: block; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.label { display: block; font-weight: 800; margin-bottom: 6px; padding: 0; }
.req { color: var(--red); }
.field input, .field textarea {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--bg);
  font-size: 17px; /* evita zoom en iPhone */
}
.field textarea { resize: vertical; line-height: 1.4; }
.field input:focus, .field textarea:focus { border-color: var(--gold); outline: none; background: var(--surface); }
.field input.invalid { border-color: var(--red); }
.hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.error { display: block; font-size: 14px; color: var(--red); margin-top: 4px; font-weight: 700; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.pick button {
  min-width: 52px; min-height: 44px; padding: 6px 12px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--line); background: var(--surface); font-weight: 800;
}
.pick button.on { background: var(--green); border-color: var(--green); color: #fff; }
.form-actions { display: grid; gap: 8px; margin-top: 8px; }
.confirm { background: var(--chip); border-radius: 14px; padding: 12px; text-align: center; }
.confirm p { margin: 0 0 10px; font-weight: 700; }
.confirm-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- Aviso ---------- */
.toast {
  display: flex; align-items: center; gap: 12px;
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, calc(100% + 60px)); transition: transform .25s ease; visibility: hidden;
  background: #2b2118; color: #fff; padding: 12px 18px; border-radius: 14px;
  font-weight: 700; width: max-content; max-width: min(calc(100% - 32px), 460px); text-align: left; z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.toast.bad { background: var(--red); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ================= Asistente por pasos y mejoras de UX ================= */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.help { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; margin: 12px 0 0; padding: 0 16px; }
.help summary { cursor: pointer; font-weight: 800; padding: 12px 0; min-height: 44px; list-style: none; display: flex; align-items: center; gap: 8px; }
.help summary::-webkit-details-marker { display: none; }
.help summary::before { content: "💡"; }
.help summary::after { content: "Ver"; margin-left: auto; color: var(--green); font-size: 15px; text-decoration: none; }
.help[open] summary::after { content: "Ocultar"; }
.help ol { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 6px; }
.help p { margin: 0 0 10px; }
.help p:last-child { margin-bottom: 14px; }

.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--bg); cursor: pointer; font-weight: 800;
}
.search input { padding-right: 56px; }
.search input::-webkit-search-cancel-button { display: none; }

.skeleton { height: 92px; border-radius: var(--radius); background: linear-gradient(90deg, var(--line) 0%, var(--surface) 50%, var(--line) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.card-body { min-width: 0; display: block; }
.card-name, .card-sub { display: block; }
.dots { align-items: center; }
.dots-lbl { font-size: 12px; color: var(--muted); margin-left: 6px; }

.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.step-count { font-weight: 800; color: var(--green); font-size: 15px; }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.progress-bar { height: 100%; width: 0; background: var(--green); border-radius: 999px; transition: width .3s ease; }
.draft-note { margin: 4px 0 0; }
.link-inline { background: none; border: 0; padding: 6px 2px; min-height: 36px; color: var(--green); font-weight: 800; text-decoration: none; cursor: pointer; }

.step { padding-top: 12px; }
.step-emoji { font-size: 44px; line-height: 1; }
.step-title { margin: 8px 0 4px; font-size: 26px; line-height: 1.2; }
.step-help { margin: 0 0 16px; color: var(--muted); }

.msg { border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; font-size: 15px; }
.msg p { margin: 0 0 8px; }
.msg-bad { background: var(--chip); color: var(--red); font-weight: 700; }
.msg-info { background: #e8f3ec; color: #134a2f; }
:root[data-theme="dark"] .msg-info { background: #1d3a2b; color: #bfe8d0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg-info { background: #1d3a2b; color: #bfe8d0; } }
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: 15px; }

.chips-edit { min-height: 36px; margin-bottom: 12px; }
.chip-edit { display: inline-flex; align-items: center; gap: 4px; padding-right: 4px; }
.chip-x {
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; color: inherit;
  cursor: pointer; font-weight: 800; flex: none;
}
.chip-x:hover { background: rgba(0,0,0,.08); }
.chip-no { background: #eee6dc; color: #5b4a3a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip-no { background: #3a3129; color: #e4d5c2; } }
.chip-suggest {
  border: 2px dashed var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  min-height: 40px; font: inherit; font-weight: 700; font-size: 15px;
}
.chip-suggest.on { border-style: solid; border-color: var(--green); background: var(--green); color: #fff; }
.suggest-lbl { margin: 16px 0 8px; }

.add-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.add-row input {
  min-height: 50px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); font-size: 17px; width: 100%; min-width: 0;
}
.add-row input:focus { border-color: var(--gold); outline: none; background: var(--surface); }

.ideas-edit { margin-bottom: 12px; }
.ideas-edit li { align-items: center; }
.ideas-edit li > span { flex: 1; min-width: 0; }
.ideas-edit li.none::before { content: none; }

.review { margin: 0; display: grid; gap: 8px; }
.review-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: start;
  background: var(--bg); border-radius: 14px; padding: 12px 14px;
}
.review-row dt { font-weight: 800; font-size: 14px; color: var(--muted); }
.review-row dd { margin: 0; grid-column: 1; overflow-wrap: anywhere; }
.review-edit { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

.wizard-nav {
  position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); z-index: 3;
  display: grid; grid-template-columns: 1fr 2fr; gap: 10px;
  background: var(--surface); padding: 14px 0 calc(6px + env(safe-area-inset-bottom)); margin-top: 20px;
  border-top: 1px solid var(--line);
}
@media (min-width: 640px) { .wizard-nav { bottom: -28px; padding-bottom: 6px; } }
.wizard-nav .btn { min-height: 54px; font-size: 17px; }
.optional-note { margin: 16px 0 0; text-align: center; }
.btn:disabled { opacity: .75; cursor: progress; }

.spinner { width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view-actions { display: grid; gap: 4px; margin-top: 8px; }

.toast-btn {
  background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.6); border-radius: 10px;
  padding: 6px 12px; min-height: 40px; font-weight: 800; cursor: pointer; flex: none;
}
#toastMsg { flex: 1 1 auto; min-width: 0; }
.sheet .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
.pick-big { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pick-big button { min-height: 60px; font-size: 20px; border-radius: 14px; }

/* Interruptor "Y medio" */
.switch {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  background: var(--bg); border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; margin-bottom: 12px;
  -webkit-tap-highlight-color: transparent;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { flex: none; width: 56px; height: 32px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; }
.switch-thumb { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(24px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--gold); outline-offset: 2px; }
.switch:has(input:checked) { border-color: var(--green); }
.switch-text { display: grid; line-height: 1.3; }
.calzado-show { margin: 0 0 12px; font-weight: 800; font-size: 20px; color: var(--green); min-height: 1.2em; }

/* Sin subrayados en ningún enlace o botón de texto */
a, .btn-link, .link-inline { text-decoration: none; }
