:root {
  --bg: #FBF6EF;
  --card: #FFFFFF;
  --ink: #2A2624;
  --muted: #7B726B;
  --line: #EDE4DA;
  --soft: #F4ECE2;
  --accent: #C65D3B;
  --fest: #D2453B;
  --radius: 22px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .05), 0 6px 22px rgba(60, 40, 20, .07);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --tabs-h: 68px;
  --tabs-bg: rgba(255, 255, 255, .92);
  --tabs-shadow: 0 8px 30px rgba(60, 40, 20, .14);
  --warn-bg: #FFF4D6; --warn-ink: #7A5A00;
  --fest-bg: #FDE8E5;
  --swap-bg: #E7EEFB; --swap-ink: #3557A0;
  --esp-bg: #FFF1D6; --esp-ink: #8A5B00;
  --note-bg: #FFF8EA;
  --star: #C98A00;
  --hero-dim: 0%;
  color-scheme: light;
}

/* Modo oscuro: cálido, no negro puro, para que siga sintiéndose amable. */
:root[data-theme="dark"] {
  --bg: #15110E;
  --card: #221C18;
  --ink: #F3ECE4;
  --muted: #A89B90;
  --line: #352D27;
  --soft: #2D2621;
  --fest: #FF8274;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 22px rgba(0, 0, 0, .28);
  --tabs-bg: rgba(34, 28, 24, .9);
  --tabs-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  --warn-bg: #3A2F14; --warn-ink: #F2D27A;
  --fest-bg: #3D201C;
  --swap-bg: #1E2A40; --swap-ink: #A9C2F2;
  --esp-bg: #3A2D12; --esp-ink: #F0C66A;
  --note-bg: #2F2817;
  --star: #F0B43C;
  --hero-dim: 18%;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom));
}

/* ---------- Encabezado ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.01em; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(.95); }

.sim {
  margin: 0 0 12px; padding: 8px 12px; border-radius: 12px;
  background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; font-weight: 600;
}

main:focus { outline: none; }

/* ---------- Pestañas ---------- */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(528px, calc(100% - 24px));
  height: var(--tabs-h);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--tabs-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-radius: 24px; box-shadow: var(--tabs-shadow);
  padding: 6px; z-index: 20;
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 18px; color: var(--muted); font-size: 12px; font-weight: 700;
}
.tabs svg { width: 23px; height: 23px; }
.tabs button[aria-current="page"] { color: var(--ink); background: var(--soft); }

/* ---------- Elementos comunes ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.section-title {
  font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 22px 4px 10px;
}
.avatar {
  --s: 38px;
  width: var(--s); height: var(--s); flex: 0 0 var(--s);
  border-radius: 50%; display: grid; place-items: center;
  background: var(--c); color: #fff; font-weight: 800; font-size: calc(var(--s) * .44);
}
.avatar.sm { --s: 28px; }
.avatar.xs { --s: 22px; font-size: 11px; }
.avatar.lg { --s: 64px; background: rgba(255,255,255,.22); box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 13%, var(--card)); color: color-mix(in srgb, var(--c) 68%, var(--ink));
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; background: var(--soft); color: var(--muted);
}
.tag.fest { background: var(--fest-bg); color: var(--fest); }
.tag.swap { background: var(--swap-bg); color: var(--swap-ink); }
.tag.esp { background: var(--esp-bg); color: var(--esp-ink); }
.muted { color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 700;
}
.btn.ghost { background: var(--soft); color: var(--ink); }

/* ---------- Hoy ---------- */
.hero {
  background: color-mix(in srgb, var(--c), black var(--hero-dim)); color: #fff; border-radius: 28px; padding: 22px 22px 20px;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--c) 35%, transparent);
  position: relative; overflow: hidden; margin-bottom: 14px; cursor: pointer;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px;
  border-radius: 50%; background: rgba(255,255,255,.10);
}
.hero-kicker { font-weight: 700; opacity: .9; font-size: 15px; }
.hero-name { display: flex; align-items: center; gap: 14px; margin: 12px 0 6px; }
.hero-name strong { font-size: 38px; line-height: 1.05; letter-spacing: -.02em; }
.hero-dates { font-size: 17px; font-weight: 700; opacity: .95; }
.week-bar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 18px 0 8px; }
.week-bar div { text-align: center; font-size: 11.5px; font-weight: 800; opacity: .8; }
.week-bar i {
  display: block; height: 8px; border-radius: 99px; background: rgba(255,255,255,.28); margin-bottom: 5px;
}
.week-bar .done i { background: rgba(255,255,255,.75); }
.week-bar .now i { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }
.week-bar .now { opacity: 1; }
.hero-foot { font-size: 14.5px; font-weight: 600; opacity: .92; margin-top: 10px; }

.me-card { display: flex; gap: 14px; align-items: center; }
.me-card .big { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.me-card .sub { color: var(--muted); font-size: 14.5px; }
.note-card { display: flex; gap: 12px; align-items: flex-start; background: var(--note-bg); }
.note-card .ico { font-size: 22px; line-height: 1; }

.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; width: 100%; text-align: left;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--soft); }
.row .main { flex: 1; min-width: 0; }
.row .name { font-weight: 800; font-size: 16.5px; }
.row .dates { color: var(--muted); font-size: 14px; }
.row .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.row .when { font-size: 13px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.row.current { background: color-mix(in srgb, var(--c) 9%, var(--card)); }

/* ---------- Mes ---------- */
.nav-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.nav-head h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; text-transform: capitalize; }
.nav-btns { display: flex; gap: 8px; }
.nav-btns button { height: 40px; min-width: 40px; padding: 0 12px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-weight: 800; }

.cal { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 10px 12px; }
.cal-head, .cal-week { display: grid; grid-template-columns: 30px repeat(7, 1fr); align-items: center; }
.cal-head div { text-align: center; font-size: 12px; font-weight: 800; color: var(--muted); padding: 4px 0 8px; }
.cal-week {
  border-radius: 14px; margin-top: 4px; padding: 4px 0; cursor: pointer;
  background: color-mix(in srgb, var(--c, #ddd) 14%, var(--card));
}
.cal-week.none { background: transparent; cursor: default; }
.cal-week .who { display: grid; place-items: center; }
.day {
  position: relative; text-align: center; height: 40px; display: grid; place-items: center;
  font-weight: 700; font-size: 15.5px;
}
.day.out { color: color-mix(in srgb, var(--ink) 35%, transparent); }
.day.today span {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
}
.day.fest::after {
  content: ""; position: absolute; bottom: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--fest);
}
.day.esp::before {
  content: "★"; position: absolute; top: 0; right: 2px; font-size: 10px; color: var(--star);
}
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 2px 0; }
.legend .k { font-size: 12.5px; color: var(--muted); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fest); display: inline-block; }

/* ---------- Año ---------- */
.fair { display: grid; gap: 12px; }
.fair-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; }
.fair-row .bar { height: 12px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.fair-row .bar i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.fair-row .nm { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.fair-row .num { font-weight: 800; font-size: 14px; text-align: right; }
.fair-row .num small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; }

.months { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mini { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 12px; cursor: pointer; }
.mini h4 { margin: 0 0 8px; font-size: 14px; text-transform: capitalize; }
.mini .pill {
  display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 10px; margin-top: 4px;
  background: color-mix(in srgb, var(--c) 13%, var(--card)); font-size: 13px; font-weight: 700;
}
.mini .pill .d { color: var(--muted); font-weight: 700; min-width: 42px; }
.mini .pill.cur { box-shadow: inset 0 0 0 2px var(--c); }

/* ---------- Familia ---------- */
.who-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.who-pick button {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px;
  background: var(--soft); font-weight: 800; text-align: left;
}
.who-pick button[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 16%, var(--card)); box-shadow: inset 0 0 0 2px var(--c); }
.person { border-top: 6px solid var(--c); }
.person-head { display: flex; align-items: center; gap: 12px; }
.person-head h3 { margin: 0; font-size: 20px; }
.person .next { margin: 12px 0 6px; font-weight: 700; }
.person ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.person li { display: flex; justify-content: space-between; font-size: 14.5px; padding: 8px 10px; background: var(--soft); border-radius: 10px; }
.steps { margin: 6px 0 0; padding-left: 20px; }
.steps li { margin: 4px 0; }

/* ---------- Hoja de detalle ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(30, 20, 10, .35); z-index: 30; animation: fade .2s; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(560px, 100%); max-height: 85vh; overflow: auto;
  background: var(--card); border-radius: 26px 26px 0 0; z-index: 31;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2,.8,.2,1);
}
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { margin: 6px 0 2px; font-size: 24px; letter-spacing: -.01em; }
.sheet .block { padding: 12px 14px; border-radius: 14px; background: var(--soft); margin-top: 10px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet .actions .btn { flex: 1; }
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Escritorio ---------- */
@media (min-width: 900px) {
  .app { max-width: 620px; }
  .months { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Apariencia ---------- */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--soft); border-radius: 14px; }
.seg button { padding: 10px 6px; border-radius: 11px; font-weight: 800; font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.top-actions { display: flex; gap: 10px; }
.icon-btn .i-sol { display: none; }
:root[data-theme="dark"] .icon-btn .i-sol { display: block; }
:root[data-theme="dark"] .icon-btn .i-luna { display: none; }
