/* ---------- Colores de ítem ---------- */
.col-c1 { --ic: var(--c1); --ic-bg: var(--c1-bg); }
.col-c2 { --ic: var(--c2); --ic-bg: var(--c2-bg); }
.col-c3 { --ic: var(--c3); --ic-bg: var(--c3-bg); }
.col-c4 { --ic: var(--c4); --ic-bg: var(--c4-bg); }
.col-c5 { --ic: var(--c5); --ic-bg: var(--c5-bg); }
.col-c6 { --ic: var(--c6); --ic-bg: var(--c6-bg); }
.col-c7 { --ic: var(--c7); --ic-bg: var(--c7-bg); }
.col-c8 { --ic: var(--c8); --ic-bg: var(--c8-bg); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 20px; border-radius: var(--r-input);
  border: 1.5px solid transparent; background: var(--card); color: var(--text);
  font-weight: 700; font-size: 16px; text-decoration: none; transition: transform .12s, background .2s, opacity .2s;
  max-width: 100%;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-outline { background: var(--card); border-color: var(--border-strong); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-danger { background: transparent; color: var(--error); }
.btn-amber { background: var(--card); border-color: var(--streak); color: var(--streak-text); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text); flex: 0 0 auto;
}
.icon-btn.bordered { border: 1.5px solid var(--card-border); background: var(--card); }
.link-btn { background: none; border: 0; padding: 8px; color: var(--accent-text); font-weight: 600; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-card);
  box-shadow: var(--card-shadow); padding: 16px; min-width: 0;
}
.card.done { background: var(--done-bg); border-color: var(--done-border); transition: background .2s, border-color .2s; }
.card.tap { cursor: pointer; }
.divider { height: 1px; background: var(--card-border); margin: 14px 0; border: 0; }

/* ---------- Formularios ---------- */
.field { display: block; }
.field > .field-label { display: block; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.input {
  width: 100%; height: 52px; padding: 0 16px; border-radius: var(--r-input);
  border: 1.5px solid var(--card-border); background: var(--card); color: var(--text); outline: none;
}
textarea.input { height: auto; min-height: 76px; padding: 12px 16px; resize: vertical; }
.input:focus { border-color: var(--accent-text); }
.input.ok { border-color: var(--accent-text); }
.input.bad { border-color: var(--error); }
.help { font-size: 13px; margin-top: 6px; color: var(--text-muted); }
.help.ok { color: var(--accent-text); }
.help.bad { color: var(--error); }
.num-input { width: 96px; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 20px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; min-height: 38px;
  border-radius: var(--r-pill); border: 1.5px solid var(--card-border); background: var(--card);
  color: var(--text); font-size: 14px; font-weight: 600; max-width: 100%;
}
.chip .icon { width: 16px; height: 16px; color: var(--ic, var(--text-muted)); }
.chip.on { background: var(--accent-soft); border-color: var(--done-border); color: var(--accent-text); }
.chip.on .icon { color: var(--accent-text); }
.chip-season {
  display: inline-flex; align-items: center; gap: 4px; border: 0; padding: 6px 12px;
  border-radius: var(--r-pill); background: var(--chip-bg); font-size: 13px; font-weight: 700; color: var(--text);
}

/* ---------- Control segmentado ---------- */
.segmented {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: var(--chip-bg);
  border: 1px solid var(--card-border);
}
.segmented button {
  flex: 1 1 0; min-width: 0; min-height: 40px; border: 0; border-radius: 10px; background: transparent;
  font-weight: 600; font-size: 14px; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(20,22,28,.12); }
.segmented button[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Casillas (días) ---------- */
.checkrow {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 4px; width: 100%;
  background: transparent; border: 0; border-bottom: 1px solid var(--card-border); text-align: left; color: var(--text);
}
.checkrow:last-child { border-bottom: 0; }
.box {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--border-strong); flex: 0 0 auto;
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.box svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; }
.checkrow[aria-checked="true"] .box { background: var(--ic, var(--accent)); border-color: var(--ic, var(--accent)); }
.checkrow[aria-checked="true"] .box svg { opacity: 1; }

/* ---------- Mini píldoras de días ---------- */
.daypills { display: flex; gap: 4px; flex-wrap: wrap; }
.daypill {
  width: 20px; height: 20px; border-radius: 6px; font-size: 10px; font-weight: 700; display: grid; place-items: center;
  background: var(--chip-bg); color: var(--text-muted);
}
.daypill.on { background: var(--ic); color: #fff; }
[data-theme="dark"] .daypill.on { color: #14161C; }

/* ---------- Cuadro de icono de ítem ---------- */
.ibox {
  width: 44px; height: 44px; border-radius: var(--r-icon); background: var(--ic-bg); color: var(--ic);
  display: grid; place-items: center; flex: 0 0 auto;
}
.ibox .icon { width: 22px; height: 22px; }
.ibox.lg { width: 64px; height: 64px; border-radius: 16px; }
.ibox.lg .icon { width: 30px; height: 30px; }

/* ---------- Check grande (marcar ítem) ---------- */
.check {
  position: relative; width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--border-strong); background: var(--card); display: grid; place-items: center; color: var(--accent-ink);
  transition: background .2s, border-color .2s;
}
.check svg.tick { width: 22px; height: 22px; stroke: currentColor; stroke-width: 3; fill: none; opacity: 0; }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on svg.tick { opacity: 1; }
.check.saving { border-color: var(--track); pointer-events: none; }
.check.saving::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2.5px solid transparent; border-top-color: var(--accent); border-right-color: var(--accent);
  animation: spin .8s linear infinite;
}
.plus-btn {
  position: relative; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ic); background: var(--card);
  color: var(--ic); font-family: var(--font-display); font-weight: 700; font-size: 15px; flex: 0 0 auto;
}
.plus-btn.saving { pointer-events: none; opacity: .7; }
.plus-btn.saving::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2.5px solid transparent; border-top-color: var(--ic); animation: spin .8s linear infinite;
}

/* ---------- Barras ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; min-width: 0; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--ic, var(--accent)); transition: width .4s ease; }
.bar.lvl { height: 10px; }
.bar.lvl > i { background: var(--accent); }
.bar.done > i { background: var(--accent); }
.segbar { display: flex; gap: 4px; }
.segbar > i { flex: 1 1 0; height: 8px; border-radius: 99px; background: var(--track); transition: background .3s; }
.segbar > i.on { background: var(--ic); }
.segbar.done > i.on { background: var(--accent); }

/* ---------- Píldoras ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 700; white-space: nowrap;
}
.pill-streak { background: var(--streak-bg); border: 1px solid var(--streak-border); color: var(--streak-text); }
.pill-streak .flame { width: 18px; height: 18px; }
.pill-soft { background: var(--chip-bg); color: var(--text-muted); font-weight: 600; font-size: 12px; padding: 4px 10px; }
.tag-green { color: var(--accent-text); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.tag-amber { color: var(--streak-text); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- Barra inferior ---------- */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 30;
  width: 100%; max-width: var(--maxw);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--surface-border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; min-width: 0;
  text-decoration: none; color: var(--text-muted); font-size: 12px; font-weight: 600;
}
.bottom-nav a .navicon { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 99px; transition: background .2s; }
.bottom-nav a.on { color: var(--accent-text); }
.bottom-nav a.on .navicon { background: var(--accent-soft); }

/* ---------- Hojas inferiores y diálogos ---------- */
.scrim {
  position: fixed; inset: 0; background: var(--scrim); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.scrim.centered { align-items: center; padding: 20px; }
.sheet {
  position: relative; width: 100%; max-width: var(--maxw); max-height: 92dvh;
  background: var(--surface); border-radius: 22px 22px 0 0; border-top: 1px solid var(--surface-border);
  padding: 8px var(--pad) calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; overflow: hidden; touch-action: pan-y;
}
.sheet.tall { height: 85dvh; }
.sheet-handle { width: 40px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 4px auto 10px; flex: 0 0 auto; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex: 0 0 auto; }
.sheet-body { overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.dialog {
  width: 100%; max-width: 340px; background: var(--card); border-radius: 20px; padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18); max-height: 90dvh; overflow-y: auto;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 80;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); width: calc(100% - 32px); max-width: 440px;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--card-border); box-shadow: 0 6px 20px rgba(0,0,0,.12);
  color: var(--text); font-weight: 600; font-size: 14px;
}
.toast.error { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.toast.level { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Capa sin conexión ---------- */
.offline-layer {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px;
}
.offline-layer .art { width: 220px; height: 176px; }

/* ---------- Interruptor ---------- */
.switch {
  position: relative; width: 52px; height: 32px; border-radius: 99px; border: 0; background: var(--track); flex: 0 0 auto;
  transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- Listas ---------- */
.list { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--r-card); box-shadow: var(--card-shadow); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; width: 100%;
  background: transparent; border: 0; border-bottom: 1px solid var(--card-border); text-align: left; color: var(--text);
  text-decoration: none; font-weight: 500;
}
.list-row:last-child { border-bottom: 0; }
.list-row .chev { color: var(--text-muted); }

/* ---------- Cabecera de pantalla ---------- */
.topbar { display: flex; align-items: center; gap: 8px; min-height: 48px; margin-bottom: 8px; }
.topbar h1 { font-size: 22px; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 24px 0 10px; }
.section-title h2 { flex: 1 1 auto; min-width: 0; }
.section-title .icon { color: var(--text-muted); }

/* ---------- Avatar ---------- */
.avatar { display: inline-block; border-radius: 50%; overflow: hidden; flex: 0 0 auto; background: var(--chip-bg); }
.avatar svg, .avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Insignias ---------- */
.badge-art { position: relative; display: inline-block; flex: 0 0 auto; }
.badge-art > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.badge-art.locked > svg { filter: grayscale(1) contrast(.9); opacity: var(--locked-opacity); }
.badge-art .lock { position: absolute; right: 0; bottom: 0; width: 40%; height: 40%; }
.badge-art .lock svg { width: 100%; height: 100%; }
.badge-art.ring { box-shadow: 0 0 0 3px var(--accent); border-radius: 50%; }
.count-label { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--streak-text); }
