/* =========================================================
   BYTA NOTAS APP — Estilos
   Mobile-first, modo oscuro automático, safe areas del iPhone.
   Colores principales en variables (fácil de cambiar).
   ========================================================= */
:root {
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #F0EDE6;
  --text: #1C1A17;
  --muted: #8A847A;
  --line: #E6E1D7;
  --gold: #C9A227;
  --gold-strong: #A8851A;
  --gold-soft: #F6EDCF;
  --on-gold: #1C1A17;
  --p-high: #E5484D;
  --p-med: #F0B400;
  --p-low: #30A46C;
  --danger: #E5484D;
  --ok: #30A46C;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 14px rgba(40, 30, 10, .06);
  --radius: 18px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1D1B19;
    --surface-2: #272421;
    --text: #F3F0EA;
    --muted: #9A9389;
    --line: #2F2B27;
    --gold: #E0B84A;
    --gold-strong: #F0CB66;
    --gold-soft: #3A3120;
    --p-med: #F5C33B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html.noscroll, html.noscroll body { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.fill { fill: currentColor; stroke: none; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Encabezado ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: calc(var(--safe-top) + 10px) calc(18px + var(--safe-right)) 8px calc(18px + var(--safe-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
}
.brand-name { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--gold-strong); }
.logo {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px;
  background: var(--gold); color: var(--on-gold); font-size: 12px; font-weight: 900; letter-spacing: 0;
}
h1 { margin: 2px 0 0; font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; }
.view-date { font-size: 13px; color: var(--muted); margin-top: 2px; }
.view-date::first-letter { text-transform: uppercase; }
.top-actions { display: flex; gap: 6px; padding-bottom: 4px; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--text);
}
.icon-btn.on { color: var(--gold-strong); background: var(--gold-soft); }
.icon-btn.danger { color: var(--danger); box-shadow: none; background: transparent; }

.search-wrap { padding: 4px calc(18px + var(--safe-right)) 6px calc(18px + var(--safe-left)); }
.search-wrap input {
  width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); padding: 0 14px; font-size: 16px; outline: none;
}
.search-wrap input:focus { border-color: var(--gold); }

/* ---------- Filtros ---------- */
.filters {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 6px calc(18px + var(--safe-right)) 10px calc(18px + var(--safe-left));
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 34px; padding: 0 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip i { width: 9px; height: 9px; border-radius: 50%; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.add { border-style: dashed; color: var(--muted); }
.chip-sep { width: 1px; flex: none; background: var(--line); margin: 6px 2px; }

/* ---------- Lista ---------- */
.list {
  padding: 4px calc(14px + var(--safe-right)) calc(var(--tabbar-h) + var(--safe-bottom) + 96px) calc(14px + var(--safe-left));
  max-width: 760px; margin: 0 auto;
}
.group { margin-bottom: 18px; }
.group-title { font-size: 14px; font-weight: 700; color: var(--muted); margin: 14px 6px 8px; text-transform: uppercase; letter-spacing: .04em; display: flex; gap: 8px; align-items: center; }
.group-title.collapsible { cursor: pointer; }
.group-title .count { background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.group-title .chev { margin-left: auto; }
.group.overdue .group-title { color: var(--danger); }
.cards { display: flex; flex-direction: column; gap: 10px; position: relative; }
.empty-inline { text-align: center; color: var(--muted); padding: 14px; margin: 0; }
.today-done { margin: 6px 4px 4px; padding: 10px 14px; border-radius: 14px; background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); font-weight: 600; font-size: 14px; }

.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-ico { font-size: 46px; }
.empty h3 { color: var(--text); margin: 10px 0 6px; font-size: 20px; }
.empty p { margin: 0 auto; max-width: 320px; }

.daily-head { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin: 6px 0 4px; display: grid; gap: 8px; }

.done-actions { display: flex; gap: 10px; margin: 6px 0 4px; }
.done-actions .btn { flex: 1; font-size: 14px; padding: 0 10px; white-space: nowrap; }

/* ---------- Tarjeta ---------- */
.card {
  position: relative; border-radius: var(--radius);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: pan-y;
}
.swipe-inner {
  position: relative; z-index: 1;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 12px 10px 12px;
  border-left: 5px solid transparent;
  will-change: transform;
}
.card.prio-high .swipe-inner { border-left-color: var(--p-high); }
.card.prio-med .swipe-inner { border-left-color: var(--p-med); }
.card.prio-low .swipe-inner { border-left-color: var(--p-low); }
.swipe-bg {
  position: absolute; inset: 0; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
  font-weight: 700; color: #fff; opacity: 0;
}
.card.swiping .swipe-bg { opacity: 1; }
.card[data-swipe="right"] .swipe-bg { background: var(--ok); }
.card[data-swipe="left"] .swipe-bg { background: var(--danger); }
.card[data-swipe="right"] .sb-left, .card[data-swipe="left"] .sb-right { visibility: hidden; }
.card.swipe-armed .swipe-bg span { transform: scale(1.12); }
.swipe-bg span { transition: transform .15s; }

.card-top { display: flex; align-items: flex-start; gap: 10px; }
.check {
  flex: none; width: 30px; height: 30px; border-radius: 50%; margin-top: 1px;
  border: 2px solid var(--line); display: grid; place-items: center; color: transparent;
  transition: background .2s, border-color .2s, transform .15s;
}
.check svg { width: 18px; height: 18px; stroke-width: 2.6; }
.check:active { transform: scale(.9); }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.card-main { flex: 1; min-width: 0; cursor: pointer; }
.card-title { font-size: 17px; font-weight: 650; line-height: 1.3; word-wrap: break-word; }
.pin-mark { margin-right: 4px; font-size: 13px; }
.card-text { font-size: 14px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.meta span { display: inline-flex; align-items: center; gap: 3px; }
.meta svg { width: 14px; height: 14px; }
.m-due.late { color: var(--danger); font-weight: 700; }
.m-streak { color: #E8730C; font-weight: 700; }
.m-sec { background: var(--surface-2); border-radius: 6px; padding: 0 6px; font-weight: 600; }
.m-tag i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.m-doneat { color: var(--ok); }
.drag-handle {
  flex: none; display: grid; place-items: center; width: 34px; height: 40px; margin: -4px -4px 0 0;
  color: var(--muted); opacity: .55; touch-action: none; cursor: grab;
}

.progress { display: flex; align-items: center; gap: 10px; margin: 10px 2px 2px 40px; cursor: pointer; }
.progress span { font-size: 12.5px; font-weight: 700; color: var(--muted); min-width: 36px; text-align: right; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--gold-strong)); transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.bar.big { height: 12px; }
.card.done .bar i, .ed-progress .bar i[style*="100%"] { background: var(--ok); }

.card-bottom { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 0 40px; }
.prio-btns { display: flex; gap: 6px; }
.pb {
  height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  border: 1.5px solid var(--line); color: var(--muted); transition: all .15s;
}
.pb-high.on { background: var(--p-high); border-color: var(--p-high); color: #fff; }
.pb-med.on { background: var(--p-med); border-color: var(--p-med); color: #2A2100; }
.pb-low.on { background: var(--p-low); border-color: var(--p-low); color: #fff; }
.prio-btns.big { margin: 12px 0; }
.prio-btns.big .pb { flex: 1; height: 42px; font-size: 15px; }
.prio-btns.big .pb-high:not(.on) { color: var(--p-high); }
.prio-btns.big .pb-med:not(.on) { color: #B98900; }
.prio-btns.big .pb-low:not(.on) { color: var(--p-low); }
.mini-pin { width: 36px; height: 30px; display: grid; place-items: center; color: var(--muted); opacity: .5; }
.mini-pin svg { width: 18px; height: 18px; }
.mini-pin.on { color: var(--gold-strong); opacity: 1; }

/* Completadas: tachado y en gris */
.card.done .swipe-inner { background: var(--surface-2); box-shadow: none; }
.card.done .card-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.card.done .card-bottom, .card.done .card-text { opacity: .5; }

/* Arrastrar */
.card.dragging { z-index: 50; pointer-events: none; transition: none; }
.card.dragging .swipe-inner { box-shadow: 0 16px 36px rgba(0, 0, 0, .22); }
body.is-dragging { -webkit-user-select: none; user-select: none; }
body.is-dragging .fab { opacity: 0; }
.card.flash .swipe-inner { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--gold); } 100% { box-shadow: var(--shadow); } }

/* ---------- Botón + ---------- */
.fab {
  position: fixed; z-index: 30;
  right: calc(18px + var(--safe-right)); bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  width: 62px; height: 62px; border-radius: 22px; display: grid; place-items: center;
  background: var(--gold); color: var(--on-gold);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--gold) 45%, transparent);
  transition: transform .15s, opacity .2s;
}
.fab svg { width: 30px; height: 30px; stroke-width: 2.6; }
.fab:active { transform: scale(.92); }

/* ---------- Pestañas inferiores ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 6px var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(16px); backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--line);
}
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); border-radius: 14px; margin: 0 3px; transition: background .15s, transform .15s; }
.tab svg { width: 25px; height: 25px; }
.tab.active { color: var(--gold-strong); }
.tab.drop-hover { background: var(--gold-soft); color: var(--gold-strong); transform: scale(1.08); }
.badge { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

/* ---------- Hojas ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0); transition: background .25s; display: flex; align-items: flex-end; justify-content: center; }
.overlay.open { background: rgba(0, 0, 0, .38); }
.sheet {
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 8px calc(18px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(18px + var(--safe-left));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  overscroll-behavior: contain;
}
.overlay.open .sheet { transform: none; }
.sheet.full { max-width: none; height: 100%; max-height: none; border-radius: 0; padding: 0; }
.overlay.dark .sheet { background: #000; }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 4px 0 12px; font-size: 21px; }

.inp {
  width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); padding: 10px 13px; font: inherit; font-size: 16px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.inp:focus { border-color: var(--gold); }
.inp.big { font-size: 18px; min-height: 52px; }
select.inp { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 13px; font-weight: 650; font-size: 15px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--text);
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.97); }
.btn.gold { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.big { min-height: 54px; font-size: 16px; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.grow { flex: 1; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.row label { flex: none; color: var(--muted); font-size: 15px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }
.hint.center { text-align: center; }
.link-btn { color: var(--gold-strong); font-weight: 600; padding: 10px; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; height: 38px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Editor ---------- */
.editor { min-height: 100%; background: var(--bg); }
.ed-bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-top) + 8px) calc(14px + var(--safe-right)) 8px calc(14px + var(--safe-left));
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.ed-done { font-weight: 700; color: var(--on-gold); background: var(--gold); padding: 10px 18px; border-radius: 13px; }
.ed-status { font-size: 13px; font-weight: 700; color: var(--ok); }
.ed-bar-actions { display: flex; gap: 8px; }
.ed-body { padding: 4px calc(16px + var(--safe-right)) calc(40px + var(--safe-bottom)) calc(16px + var(--safe-left)); max-width: 680px; margin: 0 auto; }
.ed-title {
  width: 100%; border: 0; background: transparent; color: var(--text); resize: none; outline: none;
  font: 800 26px/1.2 inherit; font-family: inherit; padding: 6px 2px; overflow: hidden;
}
.ed-card { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-top: 12px; box-shadow: var(--shadow); }
.ed-h { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.ed-h svg { width: 18px; height: 18px; color: var(--gold-strong); }
.ed-h .pct { margin-left: auto; font-size: 18px; }
.ed-h.small { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 16px 0 8px; }
.ed-text { width: 100%; border: 0; background: transparent; color: var(--text); resize: none; outline: none; font: inherit; font-size: 16px; min-height: 60px; }
.ed-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }

.range { width: 100%; margin: 16px 0 6px; accent-color: var(--gold); height: 30px; }
.quick { display: flex; gap: 6px; }
.quick button { flex: 1; height: 38px; border-radius: 10px; background: var(--surface-2); font-weight: 700; font-size: 14px; }
.quick button.on { background: var(--gold); color: var(--on-gold); }

.subs { display: flex; flex-direction: column; }
.sub { display: flex; align-items: center; gap: 6px; padding: 2px 0; border-bottom: 1px solid var(--line); background: var(--surface); position: relative; }
.sub .drag-handle { width: 28px; height: 40px; margin: 0; }
.sub-check { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; }
.sub-check svg { width: 16px; height: 16px; stroke-width: 2.8; }
.sub-check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.sub-input { flex: 1; min-width: 0; height: 42px; border: 0; background: transparent; color: var(--text); font-size: 16px; outline: none; }
.sub.done .sub-input { text-decoration: line-through; color: var(--muted); }
.sub-del { flex: none; width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); opacity: .6; }
.sub-del svg { width: 16px; height: 16px; }
.sub.dragging { z-index: 5; box-shadow: 0 10px 24px rgba(0, 0, 0, .18); border-radius: 10px; pointer-events: none; }
.add-sub { display: flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--gold-strong); font-weight: 700; padding: 8px 4px; }
.add-sub svg { width: 18px; height: 18px; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.thumb { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.add { border: 2px dashed var(--line); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; align-content: center; gap: 2px; }
.link-out { display: block; margin-top: 10px; color: var(--gold-strong); font-weight: 600; word-break: break-all; }
.tag-chips, .tpl-list { display: flex; flex-wrap: wrap; gap: 8px; }

.photo-view { height: 100%; display: flex; flex-direction: column; background: #000; }
.photo-view img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.pv-bar { display: flex; justify-content: space-between; padding: 12px 16px calc(12px + var(--safe-bottom)); }

/* ---------- Menú y hojas varias ---------- */
.menu-brand { display: flex; gap: 12px; align-items: center; margin: 0 4px 12px; }
.menu-brand .logo { width: 44px; height: 44px; border-radius: 13px; font-size: 22px; }
.menu-brand span { display: block; font-size: 13px; color: var(--muted); }
.menu-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 0 14px; margin-bottom: 6px;
  background: var(--surface); border-radius: 14px; font-size: 16px; font-weight: 600; text-align: left;
}
.menu-row span { font-size: 20px; }
.menu-row small { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 500; }
.menu-row small.warn { color: var(--danger); }
.menu-row.danger { color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 26px; color: var(--gold-strong); }
.stat span { font-size: 12px; color: var(--muted); }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; background: var(--surface); border-radius: 14px; padding: 12px; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.chart .b { width: 100%; max-width: 26px; min-height: 3px; border-radius: 6px 6px 3px 3px; background: var(--gold); }
.chart .v { font-size: 11px; font-weight: 700; color: var(--muted); }
.chart .d { font-size: 11px; color: var(--muted); }
.habit-grid { background: var(--surface); border-radius: 14px; padding: 6px 12px; }
.hg-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hg-row:last-child { border: 0; }
.hg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.hg-dots { display: flex; gap: 4px; }
.hg-dots i { width: 12px; height: 12px; border-radius: 4px; background: var(--surface-2); }
.hg-dots i.on { background: var(--ok); }
.hg-streak { font-size: 12px; width: 34px; text-align: right; }

.custom-range input { flex: 1; }
.share-count { margin: 12px 2px 0; font-size: 14px; }

.tag-list, .tpl-rows { display: grid; gap: 8px; }
.tag-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 6px 8px; }
.tag-row .inp { border: 0; min-height: 40px; }
.color-dot { width: 28px; height: 28px; border-radius: 50%; flex: none; margin-left: 4px; }
.tpl-info { flex: 1; display: grid; padding: 4px 6px; }
.tpl-info span { font-size: 13px; }

.switch-row { display: flex; align-items: center; gap: 12px; background: var(--surface); padding: 14px; border-radius: 14px; font-weight: 600; cursor: pointer; }
.switch-row span { flex: 1; }
.switch-row input { display: none; }
.switch { width: 50px; height: 30px; border-radius: 99px; background: var(--surface-2); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch-row input:checked + .switch { background: var(--ok); }
.switch-row input:checked + .switch::after { transform: translateX(20px); }
.info-box, .warn-box { background: var(--surface); border-radius: 14px; padding: 14px; margin-top: 14px; font-size: 14px; }
.info-box p { margin: 6px 0 0; color: var(--muted); }
.warn-box { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.help ul { padding-left: 20px; margin: 0; display: grid; gap: 8px; }
.backup p { margin-top: 0; }

/* ---------- Diálogos ---------- */
.dialog-wrap { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, 0); transition: background .18s; }
.dialog-wrap.open { background: rgba(0, 0, 0, .45); }
.dialog { width: 100%; max-width: 360px; background: var(--bg); border-radius: 20px; padding: 20px; transform: scale(.92); opacity: 0; transition: all .18s; }
.dialog-wrap.open .dialog { transform: none; opacity: 1; }
.dialog h3 { margin: 0 0 8px; font-size: 19px; }
.dialog p { margin: 0 0 16px; white-space: pre-line; color: var(--text); }
.dialog .inp { margin-bottom: 14px; }
.dialog-btns { display: flex; gap: 10px; }
.dialog-btns .btn { flex: 1; }

/* ---------- Aviso (toast) ---------- */
.toast {
  position: fixed; z-index: 300; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 92px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px);
  background: #1C1A17; color: #fff; padding: 12px 16px; border-radius: 14px; font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: all .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast span { flex: 1 1 auto; }
.toast button { flex: none; color: var(--gold); font-weight: 800; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .toast { background: #F3F0EA; color: #1C1A17; } .toast button { color: #8C6C0C; } }

/* ---------- Confeti ---------- */
.confetti { position: fixed; z-index: 400; width: 8px; height: 12px; border-radius: 2px; pointer-events: none; }

/* ---------- Pantalla de PIN ---------- */
.lock {
  position: fixed; inset: 0; z-index: 150; background: var(--bg);
  display: grid; place-items: center; overflow-y: auto;
  padding: calc(var(--safe-top) + 20px) 24px calc(var(--safe-bottom) + 20px);
  animation: fadein .2s ease;
}
.lock.out { opacity: 0; transition: opacity .2s; }
@keyframes fadein { from { opacity: 0; } }
.lock-inner { width: 100%; max-width: 340px; text-align: center; }
.lock-logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center; background: var(--gold); color: var(--on-gold); font-size: 34px; font-weight: 900; }
.lock-brand { font-size: 12px; font-weight: 800; letter-spacing: .18em; color: var(--gold-strong); margin-top: 10px; }
.lock-title { margin: 18px 0 4px; font-size: 24px; }
.lock-sub { margin: 0; color: var(--muted); min-height: 1.4em; }
.pin-dots { display: flex; justify-content: center; gap: 18px; margin: 26px 0 8px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gold); transition: background .12s; }
.pin-dots i.on { background: var(--gold); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.lock-msg { min-height: 1.4em; color: var(--danger); font-weight: 600; margin: 4px 0 14px; font-size: 14px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); justify-content: center; gap: 16px 22px; }
.pin-key { width: 76px; height: 76px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); font-size: 30px; font-weight: 500; }
.pin-key:active { background: var(--gold-soft); }
.pin-extra, .pin-del { background: transparent; box-shadow: none; font-size: 15px; font-weight: 600; color: var(--muted); }
.pin-del { font-size: 26px; }
.lock-links { margin-top: 18px; }
.welcome-actions { display: grid; gap: 10px; margin: 28px 0 14px; }

/* Pantallas anchas (iPad / computadora) */
@media (min-width: 700px) {
  .tabbar { left: 50%; right: auto; width: 560px; transform: translateX(-50%); bottom: 14px; border-radius: 22px; border: 1px solid var(--line); height: var(--tabbar-h); padding: 6px; box-shadow: var(--shadow); }
  .fab { right: calc(50% - 360px); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Selector de vista ---------- */
.viewbar { padding: 0 calc(18px + var(--safe-right)) 8px calc(18px + var(--safe-left)); max-width: 760px; margin: 0 auto; }
.view-seg button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; }
.view-seg svg { width: 18px; height: 18px; }

/* ---------- Vista Libreta / Títulos ---------- */
.cards:has(.card.compact) { gap: 6px; }
.card.compact .swipe-inner { padding: 9px 12px 9px 10px; border-left-width: 4px; }
.c-row { display: flex; align-items: center; gap: 10px; min-height: 30px; }
.check.small { width: 26px; height: 26px; margin: 0; }
.check.small svg { width: 15px; height: 15px; }
.c-title { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: baseline; cursor: pointer; font-size: 16.5px; font-weight: 600; line-height: 1.3; }
.c-num { flex: none; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.c-text { min-width: 0; overflow-wrap: anywhere; }
.c-side { flex: none; display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.c-side span { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.c-side svg { width: 13px; height: 13px; }
.c-subs { list-style: none; margin: 4px 0 2px 36px; padding: 0; }
.c-sub { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 3px 0; text-align: left; font-size: 15px; color: var(--text); }
.c-box { flex: none; width: 18px; height: 18px; border-radius: 5px; border: 1.8px solid var(--line); display: grid; place-items: center; }
.c-box svg { width: 12px; height: 12px; stroke-width: 3; color: #fff; }
.c-sub.done .c-box { background: var(--ok); border-color: var(--ok); }
.c-sub.done span { text-decoration: line-through; color: var(--muted); }
.card.compact.done .c-text { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.card.compact.done .c-sub span { text-decoration: line-through; color: var(--muted); }
@media (max-width: 380px) { .view-seg span { display: none; } }
