* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --green: #30d158;
  --green-deep: #1f9d4d;
  --red: #ff453a;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #aeaeb2;
  --hairline: rgba(60, 60, 67, 0.1);
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.75);
  --fill: rgba(120, 120, 128, 0.1);
  --fill-strong: rgba(120, 120, 128, 0.16);
  --shadow-soft: 0 8px 28px rgba(22, 28, 45, 0.06);
  --shadow-float: 0 12px 36px rgba(22, 28, 45, 0.1);
  --lvl0: rgba(120, 120, 128, 0.08);
  --lvl1: rgba(48, 209, 88, 0.16);
  --lvl2: rgba(48, 209, 88, 0.34);
  --lvl3: rgba(48, 209, 88, 0.6);
  --lvl4: #30d158;
  --spring: cubic-bezier(0.32, 1.25, 0.44, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --sheet-ease: cubic-bezier(0.32, 0.72, 0, 1);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background-color: #f2f3f7;
  background-image:
    radial-gradient(60% 50% at 12% 0%, rgba(0, 122, 255, 0.09), transparent 65%),
    radial-gradient(50% 42% at 92% 8%, rgba(48, 209, 88, 0.07), transparent 65%),
    radial-gradient(75% 60% at 50% 105%, rgba(94, 92, 230, 0.06), transparent 65%);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; }

.icon { display: block; flex-shrink: 0; }

:focus-visible { outline: 2px solid rgba(0, 122, 255, 0.55); outline-offset: 2px; border-radius: 8px; }

/* ---------- Superficies de vidrio ---------- */
.card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 26px;
  padding: 20px;
  margin: 14px 16px;
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.hint { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  border-radius: 15px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform 0.35s var(--spring), opacity 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: rgba(0, 122, 255, 0.92);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 122, 255, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

input[type="text"], input[type="date"] {
  width: 100%;
  padding: 13px 14px;
  border: none;
  border-radius: 13px;
  font-size: 16px;
  font-family: inherit;
  background: var(--fill);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  min-height: 48px;
  transition: box-shadow 0.25s var(--ease-out), background-color 0.25s ease;
}
input::placeholder { color: var(--faint); }
input:focus {
  outline: none;
  background: rgba(120, 120, 128, 0.07);
  box-shadow: 0 0 0 3.5px rgba(0, 122, 255, 0.22);
}

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: -0.005em; }
label input { margin-top: 7px; font-weight: 400; }
form label + label, form label + .row, form .row + button, form label + button { margin-top: 16px; }
.row { display: flex; gap: 10px; }
.row label { flex: 1; min-width: 0; }
.row label + label { margin-top: 0; }
.row input { min-width: 0; }

/* ---------- Portada ---------- */
.hero { text-align: center; padding: 64px 28px 10px; }
.hero .logo {
  width: 78px;
  height: 78px;
  margin: 0 auto;
  border-radius: 24px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  display: grid;
  place-items: center;
  color: var(--accent);
}
.hero h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.022em; margin-top: 18px; }
.hero p { color: var(--muted); margin-top: 10px; font-size: 16px; line-height: 1.5; }

/* ---------- Cabecera del plan ---------- */
.plan-header {
  position: sticky;
  top: calc(env(safe-area-inset-top) + 10px);
  z-index: 10;
  margin: 10px 16px 2px;
  padding: 12px 16px;
  border-radius: 22px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-float), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  gap: 12px;
}
.plan-header .info { flex: 1; min-width: 0; }
.plan-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-header .sub { font-size: 13px; color: var(--muted); }
.icon-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--accent);
  display: grid;
  place-items: center;
  transition: transform 0.35s var(--spring), background-color 0.2s ease;
}
.icon-btn:active { transform: scale(0.9); background: var(--fill-strong); }

.share-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--ink);
}
.share-banner .btn { width: auto; padding: 10px 16px; font-size: 14px; flex-shrink: 0; border-radius: 12px; }

/* ---------- Barra de pestañas flotante ---------- */
.tabbar {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 4px;
  width: min(330px, calc(100% - 44px));
  padding: 6px;
  border-radius: 30px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow-float), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.tabbar button {
  flex: 1;
  padding: 9px 0 8px;
  border-radius: 24px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: color 0.25s ease, background-color 0.25s ease, transform 0.35s var(--spring);
}
.tabbar button:active { transform: scale(0.95); }
.tabbar button.on { color: var(--accent); background: var(--accent-soft); }

main { padding-bottom: calc(118px + env(safe-area-inset-bottom)); }

/* Aparición suave del contenido */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
main > *, #app > .hero, #app > form, #app > .hint, #app > .empty {
  animation: rise 0.5s var(--ease-out) both;
}
main > :nth-child(2) { animation-delay: 0.04s; }
main > :nth-child(3) { animation-delay: 0.08s; }
main > :nth-child(4) { animation-delay: 0.12s; }
main > :nth-child(5) { animation-delay: 0.16s; }
main > :nth-child(n+6) { animation-delay: 0.2s; }

/* Re-render dentro de la misma pestaña: sin entrada escalonada. Solo el
   calendario, que es lo que cambia, hace un fundido corto. */
main.no-anim > * { animation: none; }
main.no-anim #resultsCal { animation: fade-in 0.28s var(--ease-out) both; }

/* ---------- Selector de modo ---------- */
.seg {
  display: flex;
  background: var(--fill-strong);
  border-radius: 13px;
  padding: 2.5px;
  gap: 2px;
}
.seg button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 0;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--muted);
  transition: color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease, transform 0.35s var(--spring);
}
.seg button:active { transform: scale(0.97); }
.seg button.on {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(22, 28, 45, 0.12), inset 0 0.5px 0 rgba(255, 255, 255, 0.8);
}
.mode-card .hint { margin-top: 12px; text-align: center; line-height: 1.5; }

/* ---------- Calendario ---------- */
.cal { padding: 0 16px; }
.month { margin-top: 22px; }
.month h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; text-transform: capitalize; padding-left: 6px; }
.wd, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd { margin-top: 10px; }
.wd span { text-align: center; font-size: 11px; font-weight: 600; color: var(--faint); letter-spacing: 0.02em; }
.grid { margin-top: 7px; }
.day {
  aspect-ratio: 1;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(22, 28, 45, 0.04), inset 0 0.5px 0 rgba(255, 255, 255, 0.6);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
  transition: transform 0.35s var(--spring), background-color 0.2s ease, color 0.2s ease;
}
button.day:active { transform: scale(0.88); }
.results .day { touch-action: auto; }
.day.off { background: transparent; box-shadow: none; color: rgba(174, 174, 178, 0.55); }
.day.today { box-shadow: inset 0 0 0 1.5px var(--accent), 0 1px 2px rgba(22, 28, 45, 0.04); }
.day.sel.no { background: var(--red); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(255, 69, 58, 0.28); }
.day.sel.si { background: var(--green); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(48, 209, 88, 0.28); }

.edit-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px 0;
  font-size: 13px;
  color: var(--muted);
}
.edit-toolbar .link { color: var(--red); font-weight: 600; font-size: 13px; transition: opacity 0.2s ease; }
.edit-toolbar .link:active { opacity: 0.5; }
.save-status { transition: opacity 0.3s ease; }
.save-status.ok { color: var(--green-deep); font-weight: 600; }

.whoami { text-align: center; font-size: 13px; color: var(--muted); padding: 20px 0 6px; }
.whoami a { color: var(--accent); font-weight: 600; text-decoration: none; }

/* ---------- Resultados ---------- */
.chips {
  display: flex;
  gap: 8px;
  padding: 6px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 8px rgba(22, 28, 45, 0.05);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--muted);
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.35s var(--spring), box-shadow 0.25s ease;
}
.chips button:active { transform: scale(0.95); }
.chips button.on {
  background: rgba(0, 122, 255, 0.92);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.25);
}

.best-list { padding: 8px 20px; }
.best-item { display: flex; align-items: center; gap: 14px; padding: 13px 0; }
.best-item + .best-item { border-top: 0.5px solid var(--hairline); }
.best-item .rank {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--fill);
  color: var(--muted);
  flex-shrink: 0;
}
.best-item .rank.top { background: var(--accent-soft); color: var(--accent); }
.best-item .when { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.best-item .who { font-size: 13px; color: var(--muted); }
.best-item .count {
  margin-left: auto;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--lvl1);
  color: var(--green-deep);
}
.best-item .count.full { background: var(--green); color: #fff; box-shadow: 0 3px 10px rgba(48, 209, 88, 0.25); }

.legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding-top: 18px;
}
.legend i { width: 14px; height: 14px; border-radius: 5px; display: inline-block; }

.day.lvl-0 { background: var(--lvl0); box-shadow: none; color: var(--faint); }
.day.lvl-1 { background: var(--lvl1); box-shadow: none; }
.day.lvl-2 { background: var(--lvl2); box-shadow: none; }
.day.lvl-3 { background: var(--lvl3); }
.day.lvl-4 { background: var(--lvl4); color: #fff; font-weight: 600; box-shadow: 0 3px 10px rgba(48, 209, 88, 0.22); }

.people-list { list-style: none; }
.people-list li + li { border-top: 0.5px solid var(--hairline); }
.people-list .person {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 0;
  text-align: left;
  transition: transform 0.35s var(--spring), opacity 0.2s ease;
}
.people-list .person:active { transform: scale(0.98); opacity: 0.6; }
.people-list .person > .icon { color: var(--faint); transition: transform 0.35s var(--spring), color 0.25s ease; }
.people-list .person.on .avatar { background: var(--accent-soft); color: var(--accent); }
.people-list .person.on .pname { color: var(--accent); }
.people-list .person.on > .icon { color: var(--accent); transform: rotate(90deg); }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.people-list .pname { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.people-list .pdays { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

h2.section {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 26px 24px 0;
}
.section-hint { font-size: 13px; color: var(--faint); padding: 2px 24px 0; }

.section-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 26px 24px 0;
}
.section-row h2.section { padding: 0; }
.section-action {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
  transition: opacity 0.2s ease;
}
.section-action:active { opacity: 0.5; }

/* ---------- Detalle de día (hoja inferior) ---------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 28, 45, 0.18);
  -webkit-backdrop-filter: blur(1.5px);
  backdrop-filter: blur(1.5px);
  z-index: 20;
  animation: fade-in 0.3s ease both;
}
.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 520px;
  margin: 0 auto;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.6);
  border-bottom: none;
  border-radius: 30px 30px 0 0;
  padding: 14px 24px calc(28px + env(safe-area-inset-bottom));
  z-index: 21;
  box-shadow: 0 -12px 40px rgba(22, 28, 45, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  animation: slide-up 0.45s var(--sheet-ease) both;
}
.sheet::before {
  content: "";
  display: block;
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: rgba(120, 120, 128, 0.24);
  margin: 0 auto 16px;
}
@keyframes slide-up {
  from { transform: translateY(40%); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.sheet .group { margin-top: 16px; font-size: 15px; line-height: 1.5; }
.sheet .group b {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sheet .group.can b { color: var(--green-deep); }
.sheet .group.cant b { color: var(--red); }

.empty { text-align: center; padding: 48px 32px; color: var(--muted); }
.empty .empty-icon { color: var(--faint); display: grid; place-items: center; margin-bottom: 14px; }
.empty h2 { color: var(--ink); font-size: 20px; font-weight: 600; letter-spacing: -0.015em; margin-bottom: 4px; }
.empty a { color: var(--accent); font-weight: 600; text-decoration: none; }
