/* Personal OS · Hábitos (ver habitos.js) */
.hb-i { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hb-page { display: flex; flex-direction: column; gap: 20px; }
.hb-page .page-head { margin-bottom: 6px; }
.hb-head { align-items: center; }
.hb-title { display: flex; align-items: center; gap: 16px; }
.hb-page-icon { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.hb-page-icon .hb-i { width: 28px; height: 28px; stroke-width: 1.9; }
.hb-head .btn .hb-i, .hb-page .btn .hb-i, .modal .btn .hb-i { width: 15px; height: 15px; }
.hb-muted { color: var(--text-3); }
.hb-hint { color: var(--text-3); font-size: 12px; margin: 14px 0 0; }
.hb-page .card h3 { margin-bottom: 20px; flex-wrap: wrap; }
.hb-page .card h3 .muted { margin-left: 8px; }

/* Barras de progreso */
.hb-xpbar { height: 10px; border-radius: 6px; background: rgba(255,255,255,0.07); overflow: hidden; flex: 1; }
.hb-xpbar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), #b3a6ff); transition: width .5s cubic-bezier(.2,.9,.3,1); min-width: 0; }
.hb-xpbar.sm { height: 5px; width: 100%; flex: none; }
.hb-xpbar.sm i { background: var(--c, var(--accent)); }

/* Fila de estado: nivel, racha, gemas */
.hb-stats { display: grid; grid-template-columns: 1.25fr 1fr 0.8fr; gap: 20px; }
.hb-stat { display: flex; flex-direction: column; gap: 12px; padding: 24px 26px; }
.hb-stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hb-stat-l { font-size: 17px; font-weight: 600; }
.hb-stat-s { color: var(--text-2); font-size: 13px; }
.hb-big { display: inline-flex; align-items: baseline; gap: 8px; color: var(--text-2); font-size: 14px; }
.hb-big b { font-size: 30px; color: var(--text); letter-spacing: -0.03em; line-height: 1; }
.hb-big .hb-i { width: 26px; height: 26px; align-self: center; }
.hb-level { flex-direction: row; align-items: center; gap: 20px; }
.hb-lvl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.hb-lvl-badge {
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #a596ff, var(--accent) 55%, #6b5ce0); color: #0b0b10;
  box-shadow: 0 6px 0 #4b3fb0, 0 10px 30px rgba(139,124,246,.25);
}
.hb-lvl-badge small { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .7; }
.hb-lvl-badge b { font-size: 26px; line-height: 1; }
.hb-lvl-badge.xl { width: 96px; height: 96px; border-radius: 28px; margin: 8px auto 22px; }
.hb-lvl-badge.xl b { font-size: 40px; }
.hb-xp-chip { display: inline-flex; align-items: center; gap: 4px; color: #c3baff; background: var(--accent-soft); padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.hb-xp-chip .hb-i { width: 13px; height: 13px; fill: currentColor; stroke: none; }

.hb-flame { fill: var(--text-3); stroke: none; transition: fill .3s; }
.hb-streak.lit .hb-flame { fill: var(--accent); filter: drop-shadow(0 0 8px rgba(139,124,246,.55)); }
.hb-shields { display: inline-flex; gap: 4px; }
.hb-shields i { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: rgba(255,255,255,0.05); color: var(--text-3); }
.hb-shields i.on { background: var(--blue-soft); color: var(--blue); }
.hb-shields .hb-i { width: 15px; height: 15px; }
.hb-shields.big { align-items: center; margin-top: 10px; }
.hb-shields.big span { color: var(--text-2); font-size: 12px; margin-left: 4px; }
.hb-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.hb-wday { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.hb-wday i { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,0.05); }
.hb-wday i .hb-i { width: 15px; height: 15px; }
.hb-wday.on i { background: var(--accent); color: #0b0b10; }
.hb-wday.on i .hb-i { fill: #0b0b10; stroke: none; }
.hb-wday.frozen i { background: var(--blue-soft); color: var(--blue); }
.hb-wday.fut i { background: transparent; border: 1.5px dashed rgba(255,255,255,0.08); }
.hb-wday.today i { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent); }
.hb-wday small { color: var(--text-3); font-size: 11px; font-weight: 600; }
.hb-wday.today small { color: var(--text); }

.hb-gem { color: var(--blue); }
.hb-gems .btn { align-self: flex-start; margin-top: auto; }

/* Hoy */
.hb-grid2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; align-items: start; }
.hb-habits { display: flex; flex-direction: column; gap: 10px; }
.hb-habit {
  --c: var(--accent);
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 12px 14px 12px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--card-2);
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
  transition: background .2s, border-color .2s, transform .08s, box-shadow .08s;
}
.hb-habit:hover { border-color: var(--line-strong); }
.hb-habit:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.hb-hicon { width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 0; padding: 0; }
.hb-hicon .hb-i { width: 22px; height: 22px; }
.hb-hmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hb-hmain b { font-size: 15px; font-weight: 600; }
.hb-hmain small { color: var(--text-3); font-size: 12px; }
.hb-hstreak { display: inline-flex; align-items: center; gap: 3px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.hb-hstreak .hb-i { width: 15px; height: 15px; fill: var(--accent); stroke: none; }
.hb-check { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; border: 2px solid rgba(255,255,255,0.14); color: transparent; transition: background .2s, border-color .2s, color .2s; }
.hb-check .hb-i { width: 17px; height: 17px; stroke-width: 2.8; }
.hb-habit.done { background: color-mix(in srgb, var(--c) 11%, var(--card-2)); border-color: color-mix(in srgb, var(--c) 35%, transparent); }
.hb-habit.done .hb-check { background: var(--c); border-color: var(--c); color: #0b0b10; }
.hb-habit.done .hb-hicon { background: var(--c); color: #0b0b10; }
.hb-habit.pop .hb-check { animation: hb-pop .45s cubic-bezier(.2,.9,.3,1.4); }
.hb-foot { margin-top: 16px; color: var(--text-2); font-size: 13px; }
.hb-foot.perfect { color: #c3baff; }
.hb-foot b { color: var(--text); }
.hb-ring {
  --p: 0; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: conic-gradient(var(--accent) calc(var(--p) * 360deg), rgba(255,255,255,0.08) 0);
  font-size: 12px; font-weight: 700;
}
.hb-ring > span { width: 34px; height: 34px; border-radius: 50%; background: var(--card); display: grid; place-items: center; }

/* Retos */
.hb-ch-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hb-ch { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; background: var(--card-2); }
.hb-ch-icon { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.hb-ch-icon .hb-i { width: 20px; height: 20px; }
.hb-ch-main { flex: 1; min-width: 0; }
.hb-ch-title { font-weight: 600; font-size: 14px; }
.hb-ch-sub { color: var(--text-3); font-size: 12px; }
.hb-ch-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.hb-ch-bar .hb-xpbar { height: 8px; }
.hb-ch-bar .hb-xpbar i { background: var(--c); }
.hb-reward { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.hb-reward > span { display: inline-flex; align-items: center; gap: 3px; }
.hb-reward .hb-i { width: 13px; height: 13px; }
.hb-reward > span:first-child .hb-i { fill: #c3baff; stroke: none; }
.hb-reward > span:last-child .hb-i { color: var(--blue); }
.hb-ch.done { background: color-mix(in srgb, var(--c) 10%, var(--card-2)); }
.hb-ch.done .hb-ch-icon { background: var(--c); color: #0b0b10; }
.hb-ch.done .hb-ch-icon .hb-i { stroke-width: 2.6; }
.hb-ch.done .hb-reward { color: var(--c); }

/* Calendario mensual: un cuadrado por hábito y día */
.hb-mpick { gap: 2px; }
.hb-mpick > span { min-width: 130px; text-align: center; font-weight: 600; font-size: 13px; }
.hb-mpick button:disabled { opacity: .25; cursor: default; }
.hb-mpick button:disabled:hover { background: transparent; }
.hb-cal-scroll { overflow-x: auto; margin: 0 -6px; padding: 4px 6px 6px; }
.hb-cal-grid { display: grid; grid-template-columns: 128px repeat(var(--n), minmax(20px, 1fr)) 46px; gap: 5px; align-items: center; min-width: calc(128px + var(--n) * 25px + 46px); }
.hb-cal-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.hb-dot-i { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.hb-dot-i .hb-i { width: 14px; height: 14px; }
.hb-cal-d { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; color: var(--text-2); font-weight: 600; padding-bottom: 2px; }
.hb-cal-d small { color: var(--text-3); font-size: 9.5px; font-weight: 600; }
.hb-cal-d.we small { color: var(--text-2); }
.hb-cal-d.today span { background: var(--accent); color: #0b0b10; border-radius: 6px; padding: 0 4px; }
.hb-sq {
  --c: var(--accent);
  aspect-ratio: 1; width: 100%; min-width: 20px; padding: 0; border: 0; border-radius: 6px;
  background: rgba(255,255,255,0.055);
  transition: background .18s, transform .1s;
}
.hb-sq:not(.fut):hover { background: rgba(255,255,255,0.12); }
.hb-sq.on, .hb-sq.on:hover { background: var(--c); box-shadow: 0 0 10px color-mix(in srgb, var(--c) 35%, transparent); }
.hb-sq.today:not(.on) { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 70%, transparent); }
.hb-sq.fut { background: transparent; border: 1px dashed rgba(255,255,255,0.06); cursor: default; }
.hb-sq.pop { animation: hb-pop .45s cubic-bezier(.2,.9,.3,1.4); }
.hb-sq:active:not(.fut) { transform: scale(.88); }
.hb-cal-n { font-size: 13px; font-weight: 600; text-align: right; }
.hb-cal-n small { color: var(--text-3); font-weight: 500; }
.hb-cal-tot { color: var(--text-3); font-size: 12px; padding-left: 2px; }
.hb-perf { display: grid; place-items: center; height: 18px; color: #c3baff; }
.hb-perf .hb-i { width: 14px; height: 14px; fill: currentColor; stroke: none; }

/* Mapa de calor de 6 meses */
.hb-legend { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 11px; font-weight: 500; }
.hb-legend i { width: 11px; height: 11px; border-radius: 3px; }
.hb-legend i:first-child { margin-left: 4px; }
.hb-legend i:last-child { margin-right: 4px; }
.hb-heat-scroll { overflow-x: auto; }
.hb-heat-wrap { display: flex; gap: 8px; min-width: max-content; }
.hb-heat-days { display: grid; grid-template-rows: 16px repeat(7, 15px); gap: 4px; font-size: 10px; color: var(--text-3); font-weight: 600; }
.hb-heat-months { display: grid; grid-auto-flow: column; grid-auto-columns: 15px; gap: 4px; height: 16px; font-size: 10px; color: var(--text-3); font-weight: 600; white-space: nowrap; }
.hb-heat-grid { display: flex; gap: 4px; margin-top: 4px; }
.hb-heat-col { display: grid; grid-template-rows: repeat(7, 15px); gap: 4px; }
.hb-heat-col i, .hb-legend i { display: block; width: 15px; height: 15px; border-radius: 4px; background: rgba(255,255,255,0.055); }
.hb-legend i { width: 11px; height: 11px; border-radius: 3px; }
.hb-heat-col i.fut { background: transparent; }
i.l1 { background: rgba(139,124,246,.28) !important; }
i.l2 { background: rgba(139,124,246,.5) !important; }
i.l3 { background: rgba(139,124,246,.75) !important; }
i.l4 { background: var(--accent) !important; box-shadow: 0 0 8px rgba(139,124,246,.35); }
.hb-heat-foot { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--text-2); font-size: 13px; }
.hb-heat-foot span { display: inline-flex; align-items: center; gap: 7px; }
.hb-heat-foot b { color: var(--text); }
.hb-heat-foot .hb-i { width: 15px; height: 15px; color: var(--accent); }

/* Hitos */
.hb-badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.hb-badge { --c: var(--accent); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 18px 12px 14px; border-radius: 16px; background: var(--card-2); }
.hb-badge-icon { position: relative; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 6px; background: rgba(255,255,255,0.05); color: var(--text-3); }
.hb-badge-icon .hb-i { width: 26px; height: 26px; }
.hb-lock { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--text-3); }
.hb-lock .hb-i { width: 12px; height: 12px; }
.hb-badge b { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hb-badge small { color: var(--text-3); font-size: 11.5px; min-height: 15px; }
.hb-badge .hb-xpbar.sm { margin-top: 8px; }
.hb-badge-p { font-size: 11px; color: var(--text-3); }
.hb-badge-gems { display: inline-flex; align-items: center; gap: 3px; margin-top: 6px; font-size: 11.5px; font-weight: 600; color: var(--blue); }
.hb-badge-gems .hb-i { width: 12px; height: 12px; }
.hb-badge.on { background: color-mix(in srgb, var(--c) 9%, var(--card-2)); }
.hb-badge.on .hb-badge-icon { background: var(--c); color: #0b0b10; box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 55%, #000), 0 8px 22px color-mix(in srgb, var(--c) 30%, transparent); }
.hb-badge.on b { color: var(--text); }

/* Modales */
.hb-modal-wide { max-width: 640px; }
.hb-modal-center { text-align: center; position: relative; overflow: visible; }
.hb-modal-center .modal-actions { justify-content: center; }
.hb-lvlup h2 { font-size: 24px; margin-bottom: 8px; }
.hb-lvlup p { margin: 0 0 6px; }
.hb-lvlup .hb-lvl-badge { animation: hb-pop .6s cubic-bezier(.2,.9,.3,1.4); }
.hb-shop-item { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 16px; background: var(--card-2); }
.hb-shop-item > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hb-shop-item small { color: var(--text-2); font-size: 12.5px; }
.hb-shop-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; background: var(--blue-soft); color: var(--blue); }
.hb-shop-icon .hb-i { width: 24px; height: 24px; }
.hb-shop-item .btn:disabled { opacity: .4; cursor: default; filter: none; }
.hb-edit-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.hb-edit-row { display: grid; grid-template-columns: 42px 22px 1fr 1.2fr 30px; gap: 8px; align-items: center; }
.hb-edit-row .hb-hicon { cursor: pointer; }
.hb-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.15); background: var(--c); padding: 0; }
.hb-edit-row input { height: 38px; background: rgba(118,118,128,.18); border: 1px solid transparent; border-radius: 10px; padding: 0 12px; width: 100%; min-width: 0; }
.hb-edit-row input:focus { outline: none; border-color: var(--accent); }

/* Animaciones */
.hb-float {
  position: fixed; z-index: 70; pointer-events: none; transform: translate(-50%, -100%);
  font-weight: 800; font-size: 15px; color: #c3baff; text-shadow: 0 2px 10px rgba(0,0,0,.6);
  animation: hb-float 1.2s cubic-bezier(.2,.8,.3,1) forwards;
}
.hb-float.gold { color: #ffd66b; font-size: 17px; }
.hb-confetti { position: absolute; left: 50%; top: 70px; width: 0; height: 0; pointer-events: none; }
.hb-confetti i { position: absolute; width: 9px; height: 9px; border-radius: 2.5px; opacity: 0; animation: hb-confetti 1.1s cubic-bezier(.15,.8,.3,1) var(--d) forwards; }
@keyframes hb-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes hb-float { 0% { opacity: 0; transform: translate(-50%, -60%) scale(.8); } 15% { opacity: 1; transform: translate(-50%, -110%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }
@keyframes hb-confetti { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 60px)) rotate(var(--r)); } }

@media (max-width: 1100px) {
  .hb-stats { grid-template-columns: 1fr 1fr; }
  .hb-level { grid-column: 1 / -1; }
  .hb-grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body[data-page="habitos"] .main-wrap { width: 100%; }
  .hb-stats { grid-template-columns: 1fr; gap: 12px; }
  .hb-page { gap: 14px; }
  .hb-head .actions { width: 100%; }
  .hb-cal-grid { grid-template-columns: 96px repeat(var(--n), 22px) 40px; min-width: 0; }
  .hb-edit-row { grid-template-columns: 42px 22px 1fr 30px; }
  .hb-edit-row input[data-e="note"] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hb-float, .hb-confetti, .hb-habit.pop .hb-check, .hb-sq.pop, .hb-lvlup .hb-lvl-badge { animation: none !important; }
  .hb-confetti { display: none; }
  .hb-xpbar i { transition: none; }
}
