/* Táchalo: papel, rotulador y tinta. Una columna de móvil a pantalla completa con la barra de pestañas abajo. */
:root {
  --paper: #fff6ef;
  --card: #ffffff;
  --ink: #2b1610;
  --muted: #8a6a5d;
  --coral: #e5532d;
  --butter: #ffd36b;
  --dash: #ecd2c4;
  --soft: #f1ddd1;
  --good: #1f7a4d;
  --bad: #c2391a;
  --font: "Bricolage Grotesque", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rad: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.body {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; background: var(--paper); border-top: 2px solid var(--ink);
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
}
.tabs-in { width: 100%; max-width: 560px; display: flex; justify-content: space-around; }
.tabs button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 10px; font-family: var(--body); }
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { color: var(--coral); font-weight: 700; }

/* Cabeceras */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hello small { display: block; font-size: 12.5px; color: var(--muted); font-family: var(--body); }
.hello b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.iconbtn { background: var(--card); border: 2px solid var(--ink); border-radius: 12px; width: 40px; height: 40px; display: grid; place-items: center; padding: 0; box-shadow: 2px 2px 0 var(--ink); flex: none; }
.iconbtn svg { width: 20px; height: 20px; }
.counter { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.counter h3 { margin: 0; font-size: 42px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.cnt { font-weight: 800; font-size: 14px; background: var(--ink); color: var(--paper); border-radius: 10px; padding: 6px 10px; transform: rotate(2deg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 10px; border-radius: 6px; background: var(--soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--coral); transition: width .35s ease; }
.sec { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0 -4px; }
.sec h4 { margin: 0; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-family: var(--body); font-weight: 700; }
.sec span { font-size: 12px; color: var(--muted); font-family: var(--body); }
.muted { color: var(--muted); font-size: 13px; font-family: var(--body); margin: 0; }
.total { font-family: var(--body); font-size: 13px; color: var(--muted); margin: -6px 0 0; }
.total b { color: var(--ink); }

/* Tarjetas y filas */
.card { background: var(--card); border: 2px solid var(--ink); border-radius: var(--rad); box-shadow: 3px 3px 0 var(--ink); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.list { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 26px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px 2px; border-bottom: 2px dashed var(--dash); position: relative; }
.row.plain { grid-template-columns: minmax(0,1fr) auto; }
.tick { width: 26px; height: 26px; border-radius: 7px; border: 2.5px solid var(--ink); background: var(--card); display: grid; place-items: center; padding: 0; }
.tick svg { width: 15px; height: 15px; opacity: 0; color: #fff; }
.row.done .tick { background: var(--coral); border-color: var(--coral); }
.row.done .tick svg { opacity: 1; }
.rt { font-size: 16px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; min-width: 0; }
.rt small { display: block; font-family: var(--body); font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.lbl { position: relative; }
.lbl::after { content: ""; position: absolute; left: -3px; top: 52%; height: 5px; border-radius: 3px; background: var(--coral); width: 0; transform: rotate(-2deg); transition: width .35s cubic-bezier(.6,0,.2,1); }
.row.done .lbl::after { width: calc(100% + 6px); }
.row.done .rt { color: #b39589; }
.urg { color: var(--bad); font-weight: 700; }
.ra { display: flex; align-items: center; gap: 6px; }
.x { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; padding: 4px 6px; }
.x:hover { color: var(--ink); }
.stamp { position: absolute; right: 34px; top: 8px; font-weight: 800; font-size: 13px; color: var(--coral); border: 2px solid var(--coral); border-radius: 6px; padding: 0 6px; background: var(--paper); transform: rotate(-12deg) scale(1.6); opacity: 0; animation: stamp .45s ease-out forwards; pointer-events: none; }
@keyframes stamp { 60% { transform: rotate(-12deg) scale(.95); opacity: 1; } to { transform: rotate(-12deg) scale(1); opacity: 1; } }

/* Formularios */
.add { display: flex; gap: 8px; flex-wrap: wrap; }
.in { flex: none; width: 100%; min-width: 0; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 11px 12px; font-size: 15px; font-family: var(--body); color: var(--ink); }
.in::placeholder { color: #b39589; }
select.in { flex: none; }
.add .in { flex: 1 1 100px; width: auto; }
.add select.in { flex: 0 1 auto; }
.prow .av { justify-self: start; }
textarea.in { resize: vertical; min-height: 84px; }
.plus { width: 46px; height: 46px; flex: none; border: 0; border-radius: 12px; background: var(--coral); color: #fff; font-size: 24px; font-weight: 800; display: grid; place-items: center; box-shadow: 2px 2px 0 var(--ink); }
.btn { border: 0; border-radius: 12px; background: var(--coral); color: #fff; font-weight: 800; padding: 12px 16px; font-size: 15px; font-family: var(--font); box-shadow: 2px 2px 0 var(--ink); }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--ink); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; box-shadow: none; }
.btn.block { width: 100%; }
.btn[aria-disabled="true"] { opacity: .5; }
.chip { border: 2px solid var(--ink); background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 700; font-family: var(--body); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip.red[aria-pressed="true"] { background: var(--coral); border-color: var(--coral); color: #fff; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 3px; gap: 3px; }
.seg3 { grid-template-columns: repeat(3, 1fr); }
.seg button { border: 0; background: none; border-radius: 9px; padding: 8px 4px; font-size: 13px; font-weight: 700; color: var(--muted); font-family: var(--body); }
.seg button[aria-pressed="true"] { background: var(--coral); color: #fff; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 2px solid var(--ink); border-radius: 14px; padding: 12px; }
.tile small { display: block; font-size: 11px; color: var(--muted); font-family: var(--body); text-transform: uppercase; letter-spacing: .06em; }
.tile b { font-size: 21px; font-variant-numeric: tabular-nums; }
.amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 15px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.cut .rt, .cut .amt { text-decoration: line-through; text-decoration-color: var(--coral); text-decoration-thickness: 3px; color: var(--muted); }
.saved { color: var(--good) !important; font-weight: 600 !important; }
.back { background: none; border: 0; color: var(--coral); font-weight: 800; font-size: 15px; padding: 0; text-align: left; font-family: var(--font); width: max-content; }
.linkcard { background: var(--card); border: 2px solid var(--ink); border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; box-shadow: 3px 3px 0 var(--ink); color: var(--ink); font-family: var(--font); }
.monthnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monthnav b { font-size: 16px; }
.monthnav button { width: 36px; height: 36px; border-radius: 10px; border: 2px solid var(--ink); background: var(--card); font-weight: 800; }
.monthnav button:disabled { opacity: .3; }

/* Hábitos */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); font-family: var(--body); }
.wd button { width: 34px; height: 34px; max-width: 100%; border-radius: 8px; border: 2.5px solid var(--ink); background: var(--card); padding: 0; display: grid; place-items: center; }
.wd button svg { width: 16px; height: 16px; color: #fff; opacity: 0; }
.wd button.on { background: var(--coral); border-color: var(--coral); }
.wd button.on svg { opacity: 1; }
.wd button.today { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.streak { font-weight: 800; font-size: 13px; color: var(--coral); white-space: nowrap; }

/* Compartidos */
.avs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.av { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-family: var(--body); background: var(--card); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px 2px 2px; }
.av i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 700; color: #fff; }
.pick { display: flex; flex-wrap: wrap; gap: 6px; }
.pick button { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--ink); background: var(--card); border-radius: 999px; padding: 3px 12px 3px 3px; font-size: 14px; font-family: var(--body); }
.pick button i { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 700; color: #fff; }
.pick button[aria-pressed="true"] { background: var(--coral); color: #fff; border-color: var(--coral); }
.sheet-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-h b { font-size: 17px; }
.big-in { font-size: 30px; font-weight: 800; font-family: var(--font); }
.ppl { gap: 0; padding: 4px 12px; }
.prow { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 2px dashed var(--dash); }
.prow:last-child { border-bottom: 0; }
.prow input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--coral); }
.pamt { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 70px; text-align: right; }
.mini-in { flex: none; width: 92px; padding: 8px; text-align: right; }
.step { display: inline-flex; align-items: center; gap: 8px; }
.step button { width: 32px; height: 32px; border-radius: 9px; border: 2px solid var(--ink); background: var(--card); padding: 0; font-weight: 800; }
.step b { min-width: 16px; text-align: center; font-variant-numeric: tabular-nums; }
.warnline { min-height: 1.3em; }
.balrow { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 4px 0; }
.balrow .bn { width: 64px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.btrack { flex: 1; height: 10px; position: relative; }
.btrack::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--dash); }
.btrack i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.btrack i.bp { left: 50%; background: var(--good); }
.btrack i.bm { right: 50%; background: var(--bad); }
.exp { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px 2px; border: 0; border-bottom: 2px dashed var(--dash); background: transparent; text-align: left; width: 100%; color: var(--ink); font-family: var(--font); }
.eic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; font-family: var(--body); }
.ea { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.ea small { font-size: 11.5px; font-family: var(--body); font-weight: 600; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--paper); border: 2px dashed var(--ink); border-radius: 10px; padding: 8px 10px; overflow-wrap: anywhere; user-select: all; }
.idea p { margin: 0; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--body); }
.idea .ra { justify-content: flex-end; }

/* Bienvenida e instalar */
.welcome { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 20px; padding-block: calc(24px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)); padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.welcome img { width: 96px; height: 96px; border-radius: 24px; box-shadow: 4px 4px 0 var(--ink); }
.wm { font-weight: 800; font-size: 52px; letter-spacing: -0.03em; position: relative; display: inline-block; margin: 0; line-height: 1; }
.wm::after { content: ""; position: absolute; left: -4px; right: -6px; top: 52%; height: 10px; background: var(--coral); border-radius: 6px; transform: rotate(-4deg); }
.wm span { position: relative; z-index: 1; }
.welcome .lead { font-size: 18px; margin: 0; }
.welcome label { font-family: var(--body); font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.welcome label input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--coral); }
.install { background: var(--butter); border: 2px solid var(--ink); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: 3px 3px 0 var(--ink); }
.install b { font-size: 15px; }
.install p { margin: 0; font-family: var(--body); font-size: 13px; }
.install .ra { justify-content: flex-start; flex-wrap: wrap; }
.steps { margin: 0; padding-left: 20px; font-family: var(--body); font-size: 14px; display: flex; flex-direction: column; gap: 6px; }

/* Avisos y celebración */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 40; background: var(--ink); color: var(--paper); border-radius: 12px; padding: 10px 14px; font-size: 14px; font-family: var(--body); width: max-content; max-width: calc(100% - 32px); text-align: center; }
.big { position: fixed; left: 50%; top: 40%; z-index: 45; pointer-events: none; font-weight: 800; font-size: 30px; color: var(--coral); border: 5px solid var(--coral); border-radius: 14px; padding: 8px 18px; background: var(--paper); white-space: nowrap; transform: translateX(-50%) rotate(-10deg) scale(2); opacity: 0; transition: transform .35s cubic-bezier(.3,1.5,.5,1), opacity .2s; }
.big.show { transform: translateX(-50%) rotate(-10deg) scale(1); opacity: 1; }
canvas.fx { position: fixed; inset: 0; pointer-events: none; z-index: 44; }

@media (prefers-reduced-motion: reduce) {
  .stamp { animation: none; opacity: 1; }
  .big, .bar i, .lbl::after { transition: none; }
}
@media (min-width: 600px) {
  .body { padding-top: calc(32px + env(safe-area-inset-top, 0px)); }
}

/* Ayuda */
.help-list { gap: 0; }
.help-c { margin: 12px 0 2px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-family: var(--body); }
.help-c:first-child { margin-top: 0; }
.help-q { border-bottom: 2px dashed var(--dash, #ecd2c4); padding: 10px 0; }
.help-q:last-child { border-bottom: 0; }
.help-q summary { font-family: var(--font); font-weight: 700; font-size: 15.5px; cursor: pointer; }
.help-q p { margin: 8px 0 0; font-size: 14px; line-height: 1.45; color: var(--muted); font-family: var(--body); }
