:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1f201c;
  --muted: #66675f;
  --line: #e4dfd4;
  --warm: #f6f1e7;
  --accent: #9a6a1f;
  --danger: #a4342a;
  --danger-bg: #fbeeec;
  --ok: #2f6b45;
  --ok-bg: #edf5ef;
  --warn-bg: #fbf3e2;
  --radius: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: #ece7dc; color: var(--ink); font: 16px/1.5 var(--sans); }
h1, h2, h3, p { margin: 0; }
h1 { font: 500 28px/1.2 var(--serif); }
h2 { font: 500 20px/1.3 var(--serif); }
h3 { font-size: 15px; font-weight: 600; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }

.app { position: relative; max-width: 430px; min-height: 100dvh; margin: 0 auto; background: var(--bg); display: flex; flex-direction: column; }
.noscript { padding: 24px; text-align: center; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 12px 20px calc(24px + env(safe-area-inset-bottom)); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

/* Portada */
.home { flex: 1; min-height: 100dvh; display: flex; flex-direction: column; padding: calc(56px + env(safe-area-inset-top)) 28px calc(28px + env(safe-area-inset-bottom)); background: var(--warm) url("/img/portada.svg") center bottom / cover no-repeat; }
.logo { font: 400 40px/1 var(--serif); letter-spacing: .24em; margin-right: -.24em; }
.home .slogan { margin-top: 14px; font: 400 20px/1.35 var(--serif); max-width: 15em; }
.home-legal { margin-top: 14px; text-align: center; font-size: 13px; }
.home-legal a { padding: 8px 4px; display: inline-block; }
.home .btn + .btn { margin-top: 10px; }

/* Botones */
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 54px; padding: 12px 20px; border-radius: var(--radius); border: 1px solid var(--ink); background: var(--surface); text-decoration: none; text-align: center; font-weight: 500; cursor: pointer; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-priority { border-color: var(--accent); color: #6f4811; background: rgba(255, 255, 255, .82); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-quiet { border-color: var(--line); }
.btn-small { width: auto; min-height: 44px; padding: 8px 14px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.cta { position: sticky; bottom: 0; margin: auto -20px calc(-24px - env(safe-area-inset-bottom)); padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }

/* Cabecera */
.topbar { display: flex; align-items: center; gap: 4px; min-height: 56px; padding: env(safe-area-inset-top) 8px 0; }
.back { width: 44px; height: 44px; border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; border-radius: 50%; text-decoration: none; display: flex; align-items: center; justify-content: center; }
.topbar-brand { font: 400 15px var(--serif); letter-spacing: .24em; }
.topbar > .topbar-brand:first-child { margin-left: 12px; }

/* Lista de pisos */
.piso-card { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.piso-card img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--warm); }
.piso-card-body { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.piso-card-body span { color: var(--muted); font-size: 20px; }

/* Galería */
.gallery { display: flex; gap: 8px; margin: 0 -20px; padding: 0 20px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: 0 0 88%; width: 88%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); scroll-snap-align: center; background: var(--warm); }
.gallery img:only-child { flex-basis: 100%; width: 100%; }
.description { white-space: pre-line; }

/* Suscripción de prioridad */
.priority-screen { padding-top: 28px; }
.priority-kicker { color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: .16em; }
.priority-screen h1 { font-size: 34px; max-width: 10em; }
.priority-benefits { display: grid; gap: 10px; }
.priority-benefits .card { display: grid; gap: 4px; border-color: #ddcba9; background: #fffdf8; }

/* Agenda */
.days { display: flex; gap: 8px; margin: 0 -20px; padding: 2px 20px; overflow-x: auto; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day { flex: 0 0 64px; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.day small { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.day strong { font: 500 22px/1.2 var(--serif); }
.day[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.day[aria-pressed="true"] small { color: #d9d6cc; }
.times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.time { min-height: 50px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-variant-numeric: tabular-nums; }
.time[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field-label { font-size: 14px; font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; min-height: 50px; padding: 12px 14px; border: 1px solid #bdb8ab; border-radius: var(--radius); background: var(--surface); font-size: 16px; }
.field textarea { min-height: 120px; resize: vertical; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; padding: 4px 0; }
.check input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--ink); }
.field-error { color: var(--danger); font-size: 14px; }

/* Bloques */
.card { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.summary { display: flex; flex-direction: column; gap: 2px; }
.rules { padding: 14px 16px; background: var(--warm); border-radius: var(--radius); font-size: 14px; }
.rules ul { margin: 6px 0 0; padding-left: 18px; }
.notice { padding: 12px 14px; border-radius: var(--radius); font-size: 14px; background: var(--warn-bg); }
.notice-error { background: var(--danger-bg); color: var(--danger); }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.empty { padding: 32px 8px; text-align: center; color: var(--muted); }
.status { display: inline-block; align-self: flex-start; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--warn-bg); }
.status-ok { background: var(--ok-bg); color: var(--ok); }
.status-bad { background: var(--danger-bg); color: var(--danger); }
.hero-img { display: block; width: calc(100% + 40px); margin: 0 -20px; aspect-ratio: 16 / 9; object-fit: cover; background: var(--warm); }
.spinner { width: 28px; height: 28px; margin: 48px auto; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* Panel */
.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.tab { flex: 1; min-height: 48px; border: 0; background: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--ink); font-weight: 500; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 8px 20px; }
.visit { display: flex; flex-direction: column; gap: 8px; }
.visit-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1 1 40%; }
.section-title { margin-top: 8px; font: 500 18px var(--serif); }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { position: relative; }
.thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--warm); }
.thumb button { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(31, 32, 28, .8); color: #fff; cursor: pointer; }
.schedule-row { display: grid; grid-template-columns: 1fr 1fr 1fr 44px; gap: 6px; align-items: center; }
.schedule-row select, .schedule-row input { width: 100%; min-height: 46px; padding: 6px; border: 1px solid #bdb8ab; border-radius: 8px; background: var(--surface); font-size: 15px; }
.icon-btn { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; background: var(--surface); }
.chip button { width: 32px; height: 32px; border: 0; background: none; cursor: pointer; }

/* Legal */
.legal { padding: 24px 20px 48px; display: flex; flex-direction: column; gap: 12px; }
.legal h2 { margin-top: 12px; }
.legal ul { margin: 0; padding-left: 20px; }
