:root {
  --bg: #ffffff;
  --surface: #f5f6f8;
  --card: #ffffff;
  --text: #323338;
  --muted: #676879;
  --border: #e6e9ef;
  --line: #eceef3;
  --primary: #0073ea;
  --primary-soft: #e5f0ff;
  --danger: #e2445c;
  --auto: #fdab3d;
  --auto-soft: #fff3e0;
  --auto-ink: #a35d00;
  --casa: #00a9a5;
  --casa-soft: #ddf6f5;
  --casa-ink: #00706d;
  --free: #00c875;
  --free-soft: #e1f8ec;
  --free-ink: #00804a;
  --now: #e2445c;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(50, 51, 56, .06), 0 4px 14px rgba(50, 51, 56, .06);
  --gutter: 46px;
  /* Un color por día, estilo etiquetas de Trello / Monday */
  --day-1: #a25ddc;
  --day-2: #ff642e;
  --day-3: #00c875;
  --day-4: #fdab3d;
  --day-5: #ff5ac4;
  --day-6: #579bfc;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
#app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Foto de perfil (o inicial) ---------- */
.av {
  position: relative; flex: none; display: inline-grid; place-items: center;
  width: var(--s, 32px); height: var(--s, 32px); border-radius: 50%;
  background: var(--c, #8a8fa8); color: #fff;
  font-weight: 800; font-size: calc(var(--s, 32px) * .42); line-height: 1;
  box-shadow: 0 0 0 2px #fff;
}
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
/* Aparece con un rebote y un anillo de color que se expande una vez */
.av.pop { animation: av-pop .55s cubic-bezier(.34, 1.56, .64, 1) both; animation-delay: var(--d, 0ms); }
.av.pop::after {
  content: ''; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid var(--c, #8a8fa8); opacity: 0; pointer-events: none;
  animation: av-ring .9s ease-out both; animation-delay: calc(var(--d, 0ms) + .25s);
}
@keyframes av-pop {
  0% { transform: scale(.2); opacity: 0; }
  70% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes av-ring {
  0% { transform: scale(1); opacity: .9; }
  100% { transform: scale(1.9); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .av.pop, .av.pop::after, .ev-flag, .bell-btn.has-new { animation: none; }
}

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand > div { min-width: 0; }
.brand-logo {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px; font-size: 20px;
  background: linear-gradient(135deg, #a25ddc, #ff5ac4 50%, #fdab3d);
}
.brand h1 { font-size: 17px; font-weight: 800; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { flex: none; display: flex; align-items: center; gap: 10px; }
.bell-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: #fff; font-size: 19px; line-height: 1;
  display: grid; place-items: center;
}
.bell-btn.has-new { border-color: #ffcb8a; background: #fff6ea; animation: wiggle 1.4s ease-in-out 2; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; box-shadow: 0 0 0 2px #fff;
}
@keyframes wiggle {
  0%, 60%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(-12deg); }
  20%, 40% { transform: rotate(12deg); }
}
.me-btn {
  flex: none; border: 0; background: transparent; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
}
.me-btn .av { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); }
.me-empty {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1.5px dashed #c5c7d0; font-size: 18px;
}

/* ---------- Vistas, período y filtros ---------- */
.controls { padding: 4px 16px 8px; display: flex; flex-direction: column; gap: 10px; }
.view-toggle {
  display: flex; padding: 3px; gap: 2px;
  background: var(--surface); border-radius: 12px;
}
.view-toggle button {
  flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; white-space: nowrap;
  font-size: 14px; font-weight: 700; color: var(--muted);
}
.view-toggle button.is-on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.period { display: flex; align-items: center; gap: 6px; }
.period-label { margin: 0 4px; font-size: 18px; font-weight: 800; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); font-size: 20px; line-height: 1;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--surface); }
.today-btn {
  flex: none; border: 0; background: var(--primary-soft); color: var(--primary);
  font-weight: 800; font-size: 13px; padding: 9px 14px; border-radius: 10px;
}
.chips { display: flex; gap: 6px; }
.chip {
  border: 1.5px solid var(--border); background: var(--card);
  padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 700;
}
.chip.is-active { background: var(--text); border-color: var(--text); color: #fff; }
.chip-auto.is-active { background: var(--auto); border-color: var(--auto); color: #fff; }
.chip-casa.is-active { background: var(--casa); border-color: var(--casa); color: #fff; }

/* ---------- Tira de 2 semanas ---------- */
.strip {
  display: flex; align-items: stretch; gap: 6px;
  padding: 4px 16px 10px; overflow-x: auto; scroll-behavior: smooth;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip-sep { flex: none; width: 2px; margin: 6px 4px; border-radius: 2px; background: var(--border); }
.pill {
  flex: none; width: 48px; padding: 7px 0 6px; border-radius: 14px;
  border: 1.5px solid var(--border); background: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.pill-dow { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.pill-num { font-size: 17px; font-weight: 800; }
.pill-dots { display: flex; gap: 2px; height: 6px; }
.pill-dots i { width: 6px; height: 6px; border-radius: 50%; }
.pill.is-past { opacity: .5; }
.pill.in-view { background: var(--surface); border-color: transparent; }
.pill.is-today .pill-num { color: var(--primary); }
.pill.is-sel { background: var(--text); border-color: var(--text); opacity: 1; }
.pill.is-sel .pill-dow, .pill.is-sel .pill-num { color: #fff; }

/* ---------- Horarios libres (tipo Calendly) ---------- */
.free {
  margin: 0 16px 12px; padding: 12px 14px; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.free-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.free-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.free-head span { font-size: 12px; color: var(--muted); font-weight: 600; }
.free-row { display: grid; grid-template-columns: 76px 1fr; align-items: start; gap: 8px; }
.free-res { font-size: 13px; font-weight: 800; padding-top: 7px; }
.free-auto .free-res { color: var(--auto-ink); }
.free-casa .free-res { color: var(--casa-ink); }
.free-slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot {
  border: 1.5px solid color-mix(in srgb, var(--free) 45%, white); background: var(--free-soft); color: var(--free-ink);
  font-weight: 700; font-size: 13px; padding: 6px 10px; border-radius: 10px;
}
.slot:active, .slot:hover { background: var(--free); color: #fff; border-color: var(--free); }
.slot-none { font-size: 13px; color: var(--muted); font-weight: 600; padding-top: 7px; }

.welcome { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; }
.welcome-emoji { font-size: 30px; }
.welcome h3 { margin: 0; font-size: 16px; font-weight: 800; }
.welcome p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.welcome .btn { grid-column: 1 / -1; margin-top: 6px; }

/* ---------- Calendario con horas ---------- */
.cal { margin: 0 8px 0 0; }
.cal-head, .cal-body {
  display: grid; grid-template-columns: var(--gutter) repeat(var(--ndias), minmax(0, 1fr));
}
.cal-head {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.day-head {
  position: relative; border: 0; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 0 6px; margin: 0 2px; border-radius: 12px;
  border-top: 4px solid var(--day-color);
}
.day-head .dh-dow { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.day-head .dh-num {
  font-size: 18px; font-weight: 800; width: 34px; height: 34px; line-height: 34px; text-align: center; border-radius: 50%;
}
.day-head.is-today .dh-num { background: var(--day-color); color: #fff; }
.day-head.is-sel { background: color-mix(in srgb, var(--day-color) 12%, white); }
.dh-count {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; font-size: 10px; font-weight: 800; line-height: 16px;
  background: color-mix(in srgb, var(--day-color) 18%, white); color: var(--text);
}
.is-dia .day-head { flex-direction: row; justify-content: center; gap: 10px; }
.is-dia .day-head .dh-dow { font-size: 14px; text-transform: none; color: var(--text); }
.is-dia .dh-count { position: static; }
.is-tres .day-head .dh-dow { text-transform: none; font-size: 13px; }

.cal-body { position: relative; margin-top: 8px; }
.gutter { position: relative; }
.hour {
  position: absolute; right: 8px; transform: translateY(-50%);
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.cal-body .hour:first-child { transform: none; }
.day-col {
  position: relative; border-left: 1px solid var(--line);
  background-image:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, transparent calc(var(--hora-h) / 2), #f4f5f8 calc(var(--hora-h) / 2), #f4f5f8 calc(var(--hora-h) / 2 + 1px), transparent calc(var(--hora-h) / 2 + 1px));
  background-size: 100% var(--hora-h);
  cursor: copy;
}
.day-col:last-child { border-right: 1px solid var(--line); }
.day-col.is-sel { background-color: #fafbff; }
.past {
  position: absolute; left: 0; right: 0; top: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(103, 104, 121, .05) 0 6px, transparent 6px 12px);
}
.now { position: absolute; left: -1px; right: 0; height: 2px; background: var(--now); z-index: 3; pointer-events: none; }
.now::before {
  content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--now);
}

/* Reserva: foto de quien reservó + ícono del auto o la casa. El detalle, al tocarla. */
.ev {
  position: absolute; z-index: 2; overflow: hidden; text-align: left;
  border: 0; border-radius: 10px; padding: 6px 8px 6px 9px;
  background: color-mix(in srgb, var(--person-color) 18%, white);
  box-shadow: inset 4px 0 0 var(--person-color), 0 1px 2px rgba(50, 51, 56, .08);
  display: flex; align-items: flex-start; gap: 8px;
  color: var(--text); cursor: pointer;
}
.ev:hover, .ev:active { background: color-mix(in srgb, var(--person-color) 30%, white); }
.ev-av { position: relative; flex: none; display: grid; }
.ev-res {
  position: absolute; right: -5px; bottom: -4px;
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; font-size: 11px; font-style: normal; line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.ev-flag {
  position: absolute; top: 3px; right: 3px; z-index: 1;
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; font-size: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  animation: flag-pulse 1.8s ease-in-out infinite;
}
@keyframes flag-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(253, 171, 61, .6), 0 1px 3px rgba(0, 0, 0, .2); }
  50% { box-shadow: 0 0 0 5px rgba(253, 171, 61, 0), 0 1px 3px rgba(0, 0, 0, .2); }
}
.ev.is-apelada { outline: 2px dashed #fdab3d; outline-offset: -2px; }
.is-semana .ev-flag { width: 16px; height: 16px; font-size: 9px; top: 2px; right: 2px; }
.ev-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ev-time { font-size: 12px; font-weight: 800; white-space: nowrap; }
.ev-who { font-size: 12px; font-weight: 700; color: color-mix(in srgb, var(--person-color) 65%, black); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-desc { font-size: 13px; line-height: 1.3; font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.ev.is-mid .ev-desc { display: none; }
.ev.is-short { align-items: center; padding-top: 2px; padding-bottom: 2px; }
.ev.is-short .ev-who, .ev.is-short .ev-desc { display: none; }
.ev.is-short .ev-res { width: 14px; height: 14px; font-size: 9px; right: -4px; bottom: -3px; }

/* 3 días: foto, hora y nombre */
.is-tres .ev-desc { display: none; }
.is-tres .ev.is-narrow { flex-direction: column; gap: 6px; padding: 5px 4px 5px 7px; }
.is-tres .ev.is-narrow .ev-who { display: none; }
.is-tres .ev.is-narrow .ev-time { white-space: normal; font-size: 11px; line-height: 1.25; }

/* Semana: foto arriba y la hora debajo */
.is-semana .ev { flex-direction: column; align-items: flex-start; gap: 6px; padding: 4px 3px 4px 6px; border-radius: 8px; }
.is-semana .ev-time { font-size: 10px; }
.is-semana .ev-who, .is-semana .ev-desc { display: none; }
.is-semana .ev.is-short { flex-direction: row; gap: 4px; }
.is-semana .ev.is-short .ev-time { display: none; }

/* Celular, semana: si dos reservas se pisan, solo la foto */
@media (max-width: 899px) {
  .is-semana .dh-count { display: none; }
  .is-semana .ev.is-narrow { align-items: center; padding: 4px 2px 4px 4px; }
  .is-semana .ev.is-narrow .ev-body { display: none; }
  .is-semana .ev.is-narrow .av { width: 20px; height: 20px; font-size: 9px; }
  .is-semana .ev.is-narrow .ev-res { right: -4px; bottom: -5px; width: 14px; height: 14px; font-size: 8px; }
}

.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  width: 60px; height: 60px; border-radius: 20px; border: 0;
  background: linear-gradient(135deg, #0073ea, #a25ddc);
  color: #fff; font-size: 32px; font-weight: 400; line-height: 1;
  box-shadow: 0 10px 24px rgba(0, 115, 234, .35);
}
.fab:active { transform: scale(.96); }

/* ---------- Hojas (formulario, detalle, familia) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(20, 22, 40, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  background: #fff; border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 800; }

.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }
.field-label small { font-weight: 600; }
input, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  border: 1.5px solid var(--border); border-radius: 12px; padding: 12px; background: #fff;
  -webkit-appearance: none; appearance: none; min-height: 48px;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 6px 0 0; }
.hint a { color: var(--primary); font-weight: 700; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 10px 8px;
  border: 1.5px solid var(--border); background: #fff; border-radius: 12px;
  font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg-big button { min-height: 52px; font-size: 16px; }
.seg button.is-on, .person.is-on {
  border-color: var(--sel, var(--primary));
  background: color-mix(in srgb, var(--sel, var(--primary)) 14%, white);
  color: color-mix(in srgb, var(--sel, var(--primary)) 75%, black);
}
#f-recurso [data-value="auto"] { --sel: var(--auto); }
#f-recurso [data-value="casa"] { --sel: var(--casa); }

/* Elegir persona: foto + nombre */
.people, .reg-ya-list { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.person {
  flex: none; min-width: 78px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 8px 8px; border: 1.5px solid var(--border); background: #fff; border-radius: 14px;
  font-size: 13px; font-weight: 700;
}
.person span:last-child { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-empty { font-size: 14px; color: var(--muted); }

.form-error { color: var(--danger); font-weight: 600; font-size: 14px; min-height: 1.2em; margin: 12px 0 0; }
.sheet-actions { display: flex; gap: 10px; margin-top: 12px; }
.btn {
  flex: 1; border: 0; border-radius: 14px; padding: 15px; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:disabled { opacity: .6; }
.btn-soft { background: var(--primary-soft); color: var(--primary); cursor: pointer; }
.btn-danger { flex: 0 0 auto; background: #fdecee; color: var(--danger); padding: 15px 18px; }
/* Botón de Google (estilo oficial: blanco, borde gris, G de color) */
.btn-google {
  background: #fff; color: #1f1f1f; border: 1px solid #747775; font-weight: 600; font-family: inherit;
  gap: 10px; cursor: pointer; transition: background .15s, box-shadow .15s;
}
.btn-google:hover { background: #f8faff; box-shadow: 0 1px 3px rgba(60, 64, 67, .2); }
.btn-google:disabled { opacity: .6; cursor: progress; }
.btn-google .g-logo { flex: none; }
.link-btn { border: 0; background: none; color: var(--primary); font-weight: 700; font-size: 14px; padding: 8px; }

/* Detalle de reserva */
.det-top { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; margin-top: -6px; }
.det-foto .av { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--person-color); }
.det-top h2 { margin: 6px 0 0; font-size: 22px; font-weight: 800; }
.tag { font-size: 13px; font-weight: 800; padding: 4px 12px; border-radius: 999px; }
.tag-auto { background: var(--auto-soft); color: var(--auto-ink); }
.tag-casa { background: var(--casa-soft); color: var(--casa-ink); }
.det-info {
  margin: 16px 0 4px; padding: 14px 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--person-color, var(--primary)) 9%, white);
  display: flex; flex-direction: column; gap: 8px; font-size: 15px;
}
.det-info div { display: flex; gap: 10px; align-items: center; }
.det-info p { margin: 4px 0 0; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

/* ---------- Apelaciones ---------- */
.sheet-intro { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.btn-sm { flex: 0 0 auto; padding: 9px 14px; font-size: 14px; border-radius: 10px; }
.btn-apelar {
  width: 100%; margin-top: 12px; flex-direction: column; gap: 2px;
  background: linear-gradient(135deg, #fff3e0, #ffe8f5); color: #a35d00;
  border: 1.5px solid #ffd59c;
}
.btn-apelar small { font-size: 12px; font-weight: 600; color: var(--muted); }
.apel-resumen {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px;
  background: var(--surface);
}
.apel-resumen div { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
.apel-resumen .muted { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apel-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
#det-apel { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
#det-apel:empty { display: none; }
.apel-card {
  border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 14px;
  padding: 12px; background: #fff; display: flex; flex-direction: column; gap: 6px;
}
.apel-card.is-pendiente { background: #fffaf2; border-color: #ffe1b5; border-left-color: var(--c); }
.apel-card.is-retirada, .apel-card.is-cerrada { opacity: .65; }
.apel-head { display: flex; align-items: center; gap: 10px; }
.apel-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.apel-who b { font-size: 15px; }
.apel-who span { font-size: 13px; color: var(--muted); font-weight: 600; }
.apel-estado {
  flex: none; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
  background: var(--surface); white-space: nowrap;
}
.is-pendiente .apel-estado { background: #fff0d6; color: var(--auto-ink); }
.is-aceptada .apel-estado { background: var(--free-soft); color: var(--free-ink); }
.is-rechazada .apel-estado { background: #fdecee; color: var(--danger); }
.apel-para { margin: 0; font-size: 14px; }
.apel-msg { margin: 0; font-size: 14px; font-style: italic; color: var(--text); background: rgba(50, 51, 56, .04); padding: 8px 10px; border-radius: 10px; }
.apel-resp { font-style: normal; background: var(--primary-soft); }
.apel-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }
.apel-pedido { margin-bottom: 14px; }
#rs-decision button[data-value="si"] { --sel: var(--free); }
#rs-decision button[data-value="no"] { --sel: var(--danger); }
.hint.center { text-align: center; padding: 8px 0; }

/* Familia */
.fam-list { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 14px; }
.fam-item { display: flex; align-items: center; gap: 12px; padding: 8px 4px; font-weight: 700; }
.fam-item small {
  margin-left: auto; font-size: 11px; font-weight: 800; color: var(--primary);
  background: var(--primary-soft); padding: 3px 8px; border-radius: 999px;
}
.fam-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Registro ---------- */
.registro {
  min-height: 100dvh; padding: calc(24px + env(safe-area-inset-top)) 16px 32px;
  background:
    radial-gradient(circle at 10% 0%, #f3e8ff 0, transparent 40%),
    radial-gradient(circle at 100% 10%, #ffe4f3 0, transparent 35%),
    radial-gradient(circle at 50% 100%, #e1f8ec 0, transparent 40%), #fff;
}
.reg-card {
  max-width: 460px; margin: 0 auto; background: #fff; border-radius: 22px;
  padding: 22px 18px; border: 1px solid var(--border); box-shadow: var(--shadow);
}
.reg-top { text-align: center; }
.reg-top .brand-logo { margin: 0 auto 10px; width: 52px; height: 52px; font-size: 26px; border-radius: 16px; }
.reg-top h2 { margin: 0; font-size: 22px; font-weight: 800; }
.reg-top p { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.foto-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 18px 0 4px; cursor: pointer; }
.foto-preview {
  width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  font-size: 34px; background: var(--surface); border: 2px dashed #c5c7d0;
}
.foto-preview img { width: 100%; height: 100%; object-fit: cover; animation: av-pop .5s cubic-bezier(.34, 1.56, .64, 1); }
.foto-text { font-size: 14px; font-weight: 800; color: var(--primary); }
.reg-card .btn { width: 100%; margin-top: 8px; }
.reg-ya { margin-top: 18px; }
.reg-ya p { font-size: 13px; color: var(--muted); font-weight: 700; margin: 0 0 8px; }
.reg-card > .link-btn { display: block; margin: 10px auto 0; }

/* ---------- Acceso (login, registro, contraseña, espera) ---------- */
.acc-panel { margin-top: 8px; }
.acc-link { display: block; margin: 8px auto 0; }
.acc-sep {
  display: flex; align-items: center; gap: 10px; margin: 16px 0 4px;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.acc-sep::before, .acc-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.acc-msg { text-align: center; padding: 8px 0 4px; }
.acc-emoji { display: block; font-size: 48px; margin: 6px 0 4px; }
.acc-msg p { font-size: 15px; line-height: 1.5; margin: 6px 0 12px; }

/* ---------- Perfil ---------- */
.me-btn { position: relative; }
.me-av { display: grid; place-items: center; }
.perfil-top { display: flex; align-items: center; gap: 14px; margin: 6px 0 14px; }
.perfil-top div { display: flex; flex-direction: column; min-width: 0; }
.perfil-top b { font-size: 18px; }
.perfil-top span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-sub { font-size: 15px; font-weight: 800; margin: 18px 0 2px; }
.btn-admin { background: #f3e8ff; color: #6b2fa0; }
.badge-inline {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 800; display: inline-grid; place-items: center;
}
.quien {
  display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; padding: 10px 12px;
  border-radius: 14px; background: var(--surface); font-size: 14px;
}
.quien b { font-weight: 800; }
.banner-foto {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 10px;
  border-radius: 14px; background: var(--primary-soft); font-size: 14px; font-weight: 600;
}
.banner-foto span { flex: 1; }

/* ---------- Administrar usuarios ---------- */
.sheet-tall { min-height: 70dvh; }
.chips-scroll { overflow-x: auto; scrollbar-width: none; margin: 8px 0 10px; }
.chips-scroll .chip { flex: none; white-space: nowrap; }
.chips-scroll::-webkit-scrollbar { display: none; }
.adm-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.adm-card {
  border: 1px solid var(--border); border-radius: 14px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; background: #fff;
}
.adm-card.is-pendiente { background: #fffaf2; border-color: #ffe1b5; }
.adm-card.is-bloqueado, .adm-card.is-baja { background: var(--surface); }
.adm-head { display: flex; gap: 12px; align-items: flex-start; }
.adm-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; font-size: 13px; }
.adm-info b { font-size: 15px; }
.adm-info span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.adm-tag { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--surface); white-space: nowrap; }
.adm-tag.t-pendiente { background: #fff0d6; color: var(--auto-ink); }
.adm-tag.t-activo { background: var(--free-soft); color: var(--free-ink); }
.adm-tag.t-bloqueado { background: #fdecee; color: var(--danger); }
.adm-tag.t-baja { background: #eceef3; color: var(--muted); }
.adm-tag.t-admin { background: #f3e8ff; color: #6b2fa0; }
.adm-tag.t-metodo-google { background: #e8f0fe; color: #1a56c4; }
.adm-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.adm-actions .btn-sm { flex: 1 1 auto; }
.btn-ok { background: var(--free-soft); color: var(--free-ink); }
.btn-warn { background: #fdecee; color: var(--danger); }
.sheet-confirm { padding-top: 8px; }
.conf-texto { font-size: 16px; font-weight: 600; line-height: 1.45; margin: 8px 2px 4px; white-space: pre-line; }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: #fff; font-weight: 600; font-size: 14px;
  padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px); text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- Tablet / escritorio ---------- */
@media (min-width: 900px) {
  #app { padding-bottom: 40px; }
  .topbar, .controls { padding-left: 28px; padding-right: 28px; }
  .controls { flex-direction: row; align-items: center; gap: 16px; }
  .view-toggle { flex: none; }
  .period { flex: 1; }
  .period-label { flex: none; min-width: 200px; }
  .strip { padding-left: 28px; padding-right: 28px; }
  .pill { width: 56px; }
  .free { margin-left: 28px; margin-right: 28px; }
  .cal { margin: 0 28px 0 12px; }
  :root { --gutter: 56px; }
  .is-semana .ev-time { font-size: 11px; }
  .is-semana .ev:not(.is-narrow):not(.is-short) .ev-who { display: block; font-size: 11px; }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; }
  .sheet-handle { display: none; }
}
