:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --text: #1d1f24;
  --muted: #747782;
  --line: #e7e2da;
  --accent: #e8613c;
  --accent-soft: #fde6dd;
  --ok: #1f9d55;
  --danger: #c2410c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 14px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181d; --card: #20232a; --text: #eceef2; --muted: #9a9ea8; --line: #2e323b;
    --accent: #ff7a52; --accent-soft: #3a2620; --ok: #34c477; --danger: #fb923c;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16181d; --card: #20232a; --text: #eceef2; --muted: #9a9ea8; --line: #2e323b;
  --accent: #ff7a52; --accent-soft: #3a2620; --ok: #34c477; --danger: #fb923c;
  --shadow: none; color-scheme: dark;
}
/* Color por casa (app.js → setCasa) */
:root[data-casa="papa"] { --accent: #2563eb; --accent-soft: #dbeafe; }
:root[data-casa="mama"] { --accent: #db2777; --accent-soft: #fce7f3; }
@media (prefers-color-scheme: dark) {
  :root[data-casa="papa"]:not([data-theme="light"]) { --accent: #60a5fa; --accent-soft: #1c2a44; }
  :root[data-casa="mama"]:not([data-theme="light"]) { --accent: #f472b6; --accent-soft: #3a1f2e; }
}
:root[data-theme="dark"][data-casa="papa"] { --accent: #60a5fa; --accent-soft: #1c2a44; }
:root[data-theme="dark"][data-casa="mama"] { --accent: #f472b6; --accent-soft: #3a1f2e; }

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1rem; margin: 1.5rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.hint { color: var(--muted); font-size: .88rem; margin: .4rem 0 1rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.mb { margin-bottom: .6rem; }

#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }

/* Cabecera y pestañas */
.top { display: flex; justify-content: space-between; align-items: center; padding: calc(14px + env(safe-area-inset-top)) 0 10px; }
.brand { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.top-right { display: flex; gap: 8px; align-items: center; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; max-width: 112px; background: none; border: 0; padding: 8px 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; color: var(--muted);
}
.tabs button span { font-size: 1.25rem; filter: grayscale(1); opacity: .7; }
.tabs button.active { color: var(--accent); font-weight: 600; }
.tabs button.active span { filter: none; opacity: 1; }

/* Piezas comunes */
.card { background: var(--card); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 10px; border: 1px solid var(--line); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: .82rem;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--text); white-space: nowrap; margin-right: 4px;
}
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: .95rem;
  background: color-mix(in srgb, var(--c) 22%, var(--card)); border: 2px solid var(--c);
}
.tag { font-size: .72rem; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.btn {
  border: 0; border-radius: 12px; padding: 10px 16px; background: var(--accent); color: #fff; font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { color: var(--danger); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 1.3rem;
}
.icon-btn:disabled { opacity: .3; cursor: default; }
input, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
label { display: block; font-size: .88rem; color: var(--muted); margin: .5rem 0; }
label input, label select { margin-top: 4px; color: var(--text); }

/* Navegación de día / semana / mes */
.nav-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; }
.nav-title { flex: 1; text-align: center; display: flex; flex-direction: column; }
.nav-title strong::first-letter { text-transform: uppercase; }
.nav-title .muted { font-size: .85rem; }

.progress { position: relative; height: 28px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: 14px; }
.progress div { height: 100%; background: var(--ok); transition: width .3s; }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: .82rem; font-weight: 600; }

/* Tareas de hoy */
.list { display: flex; flex-direction: column; gap: 8px; }
.task {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; box-shadow: var(--shadow);
  transition: transform .1s;
}
.task:active { transform: scale(.98); }
.task.pending { opacity: .5; }
.check {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; color: #fff; font-weight: 700;
}
.task.done .check { background: var(--c, var(--ok)); border-color: var(--c, var(--ok)); }
.task.done .task-name { text-decoration: line-through; color: var(--muted); }
.task.locked { cursor: default; }
.task-emoji { font-size: 1.5rem; }
.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.task-name { font-weight: 600; }
.task-meta { font-size: .82rem; color: var(--muted); }
.pts { font-weight: 700; color: var(--accent); font-size: .9rem; white-space: nowrap; }

.slot-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 0; }
.slot-row + .slot-row { border-top: 1px solid var(--line); }
.slot-name { width: 70px; font-size: .88rem; color: var(--muted); }

/* Semana */
.day-card.is-today { border-color: var(--accent); }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.avail { display: flex; gap: 10px; }
.mini-slot { display: inline-flex; align-items: center; gap: 2px; font-size: .8rem; }
.mini-slot .avatar { width: 22px; height: 22px; font-size: .7rem; border-width: 1.5px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
  border: 1px dashed var(--line); font-size: 1.05rem; opacity: .65;
}
.pill.done { border-style: solid; opacity: 1; background: var(--bg); }
.pill .avatar { width: 20px; height: 20px; font-size: .65rem; border-width: 1.5px; }

/* Ranking */
.rank-row { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.rank-row + .rank-row { border-top: 1px solid var(--line); }
.rank-pos { width: 30px; text-align: center; font-size: 1.2rem; font-weight: 700; }
.rank-body { flex: 1; }
.rank-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: 3px; }
.bar div { height: 100%; border-radius: 999px; transition: width .4s; }
.prize, .form-row { display: flex; gap: 8px; }
.prize input, .form-row input[name="name"], .form-row input[name="link"] { flex: 1; }

/* Horario */
.grid-row { display: grid; grid-template-columns: 88px repeat(3, 1fr); gap: 6px; align-items: center; padding: 3px 0; }
.grid-day { font-size: .88rem; }
.slot { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 2px; font-size: .82rem; color: var(--muted); }
.slot.on { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.mini-grid { display: grid; grid-template-columns: 24px repeat(7, 1fr); gap: 4px; text-align: center; font-size: .75rem; align-items: center; }
.dot { width: 14px; height: 14px; border-radius: 4px; background: var(--line); justify-self: center; }
.dot.on { background: var(--c); }

/* Ajustes */
.list-lines { display: flex; flex-direction: column; gap: 6px; }
.task-line {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 2px;
}
.task-form { background: var(--bg); }
.emoji-input { width: 56px; text-align: center; font-size: 1.2rem; }
.days { display: flex; gap: 6px; margin: .6rem 0; }
.day-toggle { margin: 0; flex: 1; }
.day-toggle input { position: absolute; opacity: 0; width: 0; }
.day-toggle span {
  display: grid; place-items: center; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 600;
}
.day-toggle input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.day-toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: .8rem; }
div.card > .btn + .btn { margin-top: 8px; }
div.card > .btn { display: block; width: 100%; }

/* Entrada */
.login { min-height: 90vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; }
.login .logo { font-size: 3.5rem; }
.login .btn { min-width: 220px; }
.login form { width: 100%; max-width: 320px; }
.who { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; width: 100%; max-width: 360px; }
.who-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 8px; border-radius: 18px;
  border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 12%, var(--card)); font-weight: 600;
}
.who-btn span { font-size: 2rem; }
.pin-form { display: flex; flex-direction: column; gap: 10px; }
.pin-form input { text-align: center; font-size: 1.6rem; letter-spacing: .5em; }

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