:root {
  --bg: #EEF5FB;
  --ink: #23324F;
  --title: #3557A8;
  --blue: #4A86E0;
  --blue-soft: #6FA0EA;
  --muted: #6B7A93;
  --card-r: 22px;
  --ok: #43B97F;
  --warn: #F0A030;
  --bad: #EB4E3D;
  --none: #D8D3CB;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif; font-weight: 600;
  padding: env(safe-area-inset-top, 0) 16px calc(110px + var(--safe-b));
  max-width: 560px; margin-inline: auto; min-height: 100dvh;
  overscroll-behavior-y: none;
}
body.no-nav { padding-bottom: 24px; }
body.no-nav .nav { display: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
input, textarea { font-size: 16px; }
a { color: inherit; text-decoration: none; }
.loading { text-align: center; margin-top: 40vh; color: var(--muted); }

/* ---------- cabecera ---------- */
.top { display: flex; align-items: center; justify-content: center; position: relative; min-height: 76px; padding-top: 10px; gap: 10px; }
.top h1 { margin: 0; font-size: 34px; font-weight: 900; color: var(--title); letter-spacing: -.5px; }
.top .back { position: absolute; left: 0; font-size: 38px; color: var(--title); padding: 0 12px 6px 2px; line-height: 1; }
.top .count { background: var(--bad); color: #fff; border-radius: 99px; padding: 2px 10px; font-weight: 800; }
.me {
  position: absolute; right: 0; display: flex; align-items: center; gap: 8px;
  background: #6ED6D2; color: #fff; padding: 6px 12px 6px 6px; border-radius: 14px; font-weight: 800;
}
.me span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%;
  background: var(--u); color: #fff; font-weight: 900; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.notice { background: #FFF1D6; color: #8A5A00; border-radius: 12px; padding: 8px 12px; font-size: 14px; }

/* ---------- banner ---------- */
.banner {
  display: flex; align-items: center; gap: 10px; margin: 8px 0 26px;
  background: var(--blue); color: #fff; border-radius: var(--card-r); padding: 14px 16px 16px 8px;
  box-shadow: 0 6px 18px rgba(74,134,224,.28);
}
.mascot { width: 92px; flex: none; }
.mascot svg { width: 100%; display: block; }
.banner-body { flex: 1; min-width: 0; }
.quote { font-family: 'Kalam', cursive; font-size: 21px; line-height: 1.2; margin: 2px 0 10px; }
.banner-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; opacity: .95; flex-wrap: wrap; }
.bar { height: 22px; margin-top: 4px; background: var(--blue-soft); border-radius: 4px; display: flex; overflow: hidden; border-left: 3px solid rgba(255,255,255,.7); }
.bar span { display: block; height: 100%; transition: width .5s; }

/* ---------- habitaciones ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  position: relative; background: var(--c); border-radius: var(--card-r); aspect-ratio: 1.46;
  padding: 12px 14px; color: #fff; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 3px 10px rgba(0,0,0,.08); transition: transform .12s;
}
.card:active { transform: scale(.97); }
.card h3 { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.1; padding-right: 34px; text-shadow: 0 1px 2px rgba(0,0,0,.12); }
.card .art { flex: 1; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.card .art svg { width: 100%; max-height: 100%; }
.dot { width: 26px; height: 26px; border-radius: 50%; border: 4px solid #fff; flex: none; background: var(--none); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.card .dot { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; }
.dot.l0 { background: var(--ok); } .dot.l1 { background: var(--warn); } .dot.l2 { background: var(--bad); }
.dot.l-1 { background: rgba(255,255,255,.35); }
.card.add { background: transparent; border: 3px solid var(--title); box-shadow: none; align-items: center; justify-content: center; }
.card.add span { font-size: 54px; color: var(--title); font-weight: 400; border-bottom: 4px solid var(--title); line-height: .9; padding: 0 8px; }

/* ---------- habitación ---------- */
.room-head { background: var(--c); color: #fff; margin: 10px -4px 16px; border-radius: var(--card-r); padding: 12px 12px 4px; }
.room-bar { display: flex; align-items: center; gap: 10px; }
.room-bar h1 { flex: 1; margin: 0; font-size: 24px; font-weight: 900; text-align: center; }
.round { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; font-size: 24px; color: #fff; line-height: 1; }
.room-art svg { display: block; width: 78%; margin: 4px auto 0; }

.tasks { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.task { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 12px 12px 12px 14px; box-shadow: 0 1px 4px rgba(35,50,79,.07); }
.task .dot { width: 18px; height: 18px; border-width: 3px; }
.task-info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.task-info strong { font-size: 17px; font-weight: 800; }
.task-info small { font-size: 13.5px; color: var(--ink); }
.task-info em { font-style: normal; color: var(--muted); }
.muted { color: var(--muted) !important; }
.center { text-align: center; }
.done { width: 48px; height: 48px; border-radius: 14px; background: var(--blue); color: #fff; font-size: 24px; font-weight: 900; box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px var(--blue); flex: none; }
.done:active { transform: scale(.92); }
.free { width: 100%; margin-top: 12px; padding: 14px; border: 2px dashed var(--title); color: var(--title); border-radius: 16px; font-weight: 800; }
.sub { font-size: 20px; color: var(--title); margin: 26px 0 8px; font-weight: 900; }
.empty { color: var(--muted); text-align: center; padding: 16px; list-style: none; }
.chip { display: inline-block; background: var(--c); color: #fff; border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 800; }

.edit-box { background: #fff; border-radius: 16px; padding: 14px; margin: 0 0 14px; display: grid; gap: 10px; box-shadow: 0 1px 4px rgba(35,50,79,.07); }
form.edit-box { margin-top: 14px; }
label, .label { display: grid; gap: 4px; font-size: 13px; font-weight: 800; color: var(--muted); }
input, textarea { width: 100%; border: 2px solid #DCE5F2; border-radius: 12px; padding: 10px 12px; background: #F7FAFE; font-weight: 600; }
input:focus, textarea:focus { outline: none; border-color: var(--blue); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.btn { background: #E6EEFB; color: var(--title); padding: 11px 16px; border-radius: 12px; font-weight: 800; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger, .mini.danger { background: #FDE6E3; color: #B8321F; }
.mini { padding: 6px 10px; border-radius: 10px; font-size: 13px; font-weight: 800; }
.mini.ghost { color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; }
.swatch.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }

/* ---------- historial ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.pill { padding: 8px 16px; border-radius: 99px; background: #fff; font-weight: 800; color: var(--muted); white-space: nowrap; box-shadow: 0 1px 3px rgba(35,50,79,.08); }
.pill.on { background: var(--u, var(--blue)); color: #fff; }
.logs { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.day { font-weight: 900; color: var(--title); margin-top: 10px; text-transform: capitalize; }
.log { display: flex; gap: 10px; background: #fff; border-radius: 16px; padding: 12px; align-items: flex-start; box-shadow: 0 1px 4px rgba(35,50,79,.07); }
.log-body { flex: 1; min-width: 0; }
.log-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.log-top .time { margin-left: auto; color: var(--muted); font-size: 12px; }
.log-task { font-weight: 700; margin-top: 2px; }
.log-note { margin: 6px 0 0; background: #F3F7FD; border-radius: 10px; padding: 8px 10px; font-size: 14.5px; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-side { display: grid; justify-items: end; gap: 4px; }
.pts { font-weight: 900; color: var(--ok); }

/* ---------- ranking ---------- */
.rank { display: grid; gap: 12px; margin: 10px 0 20px; }
.rank-row { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 18px; padding: 14px; box-shadow: 0 1px 4px rgba(35,50,79,.07); }
.medal { font-size: 26px; }
.rank-info { flex: 1; display: grid; gap: 2px; }
.rank-info small { color: var(--muted); }
.rank-bar { height: 8px; background: #EEF2F8; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.rank-bar span { display: block; height: 100%; border-radius: 99px; }
.rank-pts { font-size: 28px; font-weight: 900; color: var(--title); text-align: right; line-height: 1; }
.rank-pts small { display: block; font-size: 12px; color: var(--muted); }

/* ---------- ajustes ---------- */
.settings { display: grid; gap: 10px; }
.set-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 14px; box-shadow: 0 1px 4px rgba(35,50,79,.07); }
.set-row .grow { flex: 1; display: grid; gap: 2px; }
.set-row small { color: var(--muted); font-size: 13px; }
.set-row input { width: 90px; text-align: center; }

/* ---------- elegir usuario ---------- */
.choose { text-align: center; padding-top: 8vh; }
.choose-mascot { width: 150px; margin: 0 auto; background: var(--blue); border-radius: 50%; padding: 16px; }
.choose h1 { color: var(--title); font-size: 34px; font-weight: 900; margin: 18px 0 4px; }
.choose p { color: var(--muted); margin: 0 0 24px; }
.choose-list { display: grid; gap: 12px; }
.choose-btn { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 18px; padding: 12px 16px; font-size: 22px; font-weight: 900; box-shadow: 0 2px 8px rgba(35,50,79,.08); border-left: 8px solid var(--u); }

.all-clear { text-align: center; color: var(--muted); padding: 30px 0; }
.all-clear svg { width: 130px; background: var(--ok); border-radius: 50%; padding: 12px; }

/* ---------- barra inferior ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--blue); display: flex; justify-content: center; gap: 18px;
  padding: 12px 16px calc(12px + var(--safe-b));
}
.nav a { position: relative; width: 62px; height: 62px; border-radius: 16px; display: grid; place-items: center; border: 3px solid rgba(255,255,255,.95); background: var(--blue-soft); transition: transform .12s, background .15s; }
.nav a.on { background: #fff; }
.nav a.on svg { stroke: var(--blue); }
.nav a:active { transform: scale(.93); }
.nav svg { width: 32px; height: 32px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.badge[hidden] { display: none; }
.badge { position: absolute; top: -8px; right: -8px; background: var(--bad); color: #fff; min-width: 24px; height: 24px; border-radius: 99px; font-size: 13px; font-weight: 900; display: grid; place-items: center; padding: 0 6px; border: 2px solid #fff; }

/* ---------- modal ---------- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(20,30,50,0); display: flex; align-items: flex-end; justify-content: center; transition: background .2s; }
.modal.open { background: rgba(20,30,50,.45); }
.sheet { width: 100%; max-width: 560px; background: var(--bg); border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); transform: translateY(100%); transition: transform .22s cubic-bezier(.2,.8,.2,1); max-height: 90dvh; overflow-y: auto; }
.modal.open .sheet { transform: none; }
.sheet form { display: grid; gap: 12px; }
.sheet-head h2 { margin: 6px 0 2px; font-size: 24px; font-weight: 900; color: var(--title); }
.art-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.art-opt input { position: absolute; opacity: 0; pointer-events: none; }
.art-opt span { display: block; border-radius: 12px; padding: 4px; border: 3px solid transparent; }
.art-opt input:checked + span { border-color: var(--ink); }
.art-opt svg { display: block; width: 100%; }

.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 800; opacity: 0; pointer-events: none; transition: .2s; z-index: 30; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (hover: hover) {
  .card:hover { filter: brightness(1.04); }
  .done:hover { filter: brightness(1.08); }
}
@media (max-width: 380px) {
  .card h3 { font-size: 16px; }
  .quote { font-size: 18px; }
  .mascot { width: 72px; }
  .top h1 { font-size: 30px; }
  .me span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
