:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --text: #17171a;
  --muted: #6b6a73;
  --line: #e4e1d8;
  --brand: #db2777;
  --brand-ink: #ffffff;
  --brand-soft: #fde4f0;
  --good: #1a8f55;
  --good-soft: #def5e8;
  --warn: #b45309;
  --warn-soft: #fff2d6;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 6px 24px rgba(20, 20, 30, .06);
  --radius: 18px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --surface: #1b1b20;
    --surface-2: #26262d;
    --text: #f2f1ee;
    --muted: #a09fa8;
    --line: #2f2f37;
    --brand: #f472b6;
    --brand-soft: #3d1529;
    --good: #4cc98a;
    --good-soft: #12301f;
    --warn: #f5b04c;
    --warn-soft: #33260f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .65rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; text-decoration: none; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: #d93025; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: .3rem .8rem; font-size: .85rem; }
.btn-lg { min-height: 54px; font-size: 1.05rem; padding: .8rem 1.5rem; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; font-size: 1.2rem;
}
.icon-btn:hover { background: var(--surface-2); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

/* ---------- App shell ---------- */
.app { max-width: 720px; margin: 0 auto; padding: 0 16px 120px; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .5rem;
  padding: 12px 0; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 700; font-size: 1.25rem; text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.topbar .spacer { flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card h2 { font-size: 1.1rem; margin-bottom: 12px; display: flex; align-items: baseline; gap: .5rem; }
.card h2 .right { margin-left: auto; font-family: var(--font); font-size: .9rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }

/* Resumen */
.summary { background: var(--text); color: var(--bg); border: 0; padding: 24px 22px; }
.summary .big { font-family: var(--display); font-size: clamp(2.6rem, 11vw, 3.6rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.summary .label { opacity: .7; margin-top: 6px; }
.summary .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 20px; }
.summary .grid div { background: color-mix(in srgb, var(--bg) 10%, transparent); border-radius: 12px; padding: 10px; min-width: 0; }
.summary .grid b { display: block; font-size: clamp(.84rem, 3.9vw, 1.05rem); line-height: 1.25; overflow-wrap: anywhere; }
.summary .grid span { font-size: .8rem; opacity: .7; }
.summary .note { margin-top: 14px; font-weight: 600; }
.summary .sub-note { margin-top: 6px; font-size: .9rem; opacity: .75; }

.insights { display: grid; gap: 12px; grid-template-columns: 1fr; margin-bottom: 16px; }
@media (min-width: 560px) { .insights.two { grid-template-columns: 1fr 1fr; } }
.insight { border-radius: var(--radius); padding: 16px 18px; }
.insight b { display: block; font-family: var(--display); font-size: 1.15rem; }
.insight.save { background: var(--brand-soft); }
.insight.saved { background: var(--good-soft); }
.insight.tip { background: var(--surface-2); font-size: .92rem; }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.avatar {
  flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-family: var(--display); font-size: 1.05rem; text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: .85rem; }
.row .amount { text-align: right; font-weight: 700; white-space: nowrap; }
.row .amount small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }
.chip { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--brand-soft); color: var(--brand); }
.chip.good { background: var(--good-soft); color: var(--good); }

.sub-item { cursor: pointer; border-radius: 12px; }
.sub-item:hover { background: var(--surface-2); margin: 0 -10px; padding-left: 10px; padding-right: 10px; }
.sub-item.cancelled { opacity: .55; }
.sub-item.cancelled .title { text-decoration: line-through; }

.trial-alert { background: var(--warn-soft); border-color: transparent; }
.trial-alert h2 { color: var(--warn); }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.toolbar select { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; min-height: 36px; }

.bars .bar { margin: 10px 0; }
.bars .bar-top { display: flex; justify-content: space-between; font-size: .9rem; gap: 8px; }
.bars .track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bars .fill { height: 100%; background: var(--brand); border-radius: 99px; }

details.cancelled-list summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 8px 0; }

/* FAB */
.fab {
  position: fixed; right: max(16px, calc(50% - 344px)); bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20; box-shadow: 0 8px 30px color-mix(in srgb, var(--brand) 45%, transparent);
}

/* Empty / onboarding */
.hero { text-align: center; padding: 40px 8px 20px; }
.hero h1 { font-size: clamp(1.7rem, 7vw, 2.4rem); margin: 0 auto 12px; max-width: 18ch; }
.hero p { max-width: 46ch; margin: 0 auto 22px; }
.guess { display: flex; gap: 8px; max-width: 420px; margin: 0 auto; }
.guess input { flex: 1; min-width: 0; }

/* Formularios */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-weight: 600; font-size: .9rem; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.input:focus { border-color: var(--brand); }
.input.invalid { border-color: #d93025; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; margin-bottom: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.hint { font-size: .8rem; color: var(--muted); }
.err { color: #d93025; font-size: .85rem; min-height: 1.2em; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .9rem; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Diálogos */
dialog {
  border: 0; padding: 0; width: min(560px, 100%); max-height: min(92vh, 900px);
  border-radius: 24px; background: var(--surface); color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(10, 10, 14, .5); backdrop-filter: blur(2px); }
@media (max-width: 600px) {
  dialog { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 24px 24px 0 0; max-height: 94vh; }
}
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 6px 20px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.dlg-head h2 { font-size: 1.2rem; flex: 1; }
.dlg-body { padding: 8px 20px 24px; }
.dlg-foot { display: flex; gap: 10px; padding-top: 6px; flex-wrap: wrap; }
.dlg-foot .btn { flex: 1; }

.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.cat-item {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; min-height: 52px;
}
.cat-item:hover { border-color: var(--brand); }
.cat-item .avatar { width: 34px; height: 34px; border-radius: 9px; font-size: .9rem; }
.cat-item span { font-weight: 600; font-size: .88rem; line-height: 1.2; }

.section { padding: 14px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; padding-top: 0; }
.section h3 { font-size: 1rem; margin-bottom: 8px; }
.stack { display: grid; gap: 8px; }
.rates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.pro-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.pro-list li { display: flex; gap: 10px; align-items: flex-start; }
.pro-list li::before { content: '✓'; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--good-soft); color: var(--good); display: grid; place-items: center; font-weight: 800; font-size: .8rem; margin-top: 1px; }
.price-tag { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 2px; }
.price-tag b { font-family: var(--display); font-size: 2.2rem; letter-spacing: -0.03em; }
.price-tag s { color: var(--muted); }

.link-list { display: grid; gap: 8px; margin: 8px 0 16px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 10px 10px 18px; border-radius: 999px;
  display: flex; gap: 12px; align-items: center; opacity: 0; pointer-events: none;
  transition: .2s; z-index: 100; max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast button { background: transparent; border: 0; color: var(--brand); font-weight: 700; cursor: pointer; padding: 6px 10px; }

/* Donaciones */
.donate-btn { min-height: 38px; padding: .4rem .8rem; font-size: .92rem; }
@media (max-width: 420px) { .donate-btn span { display: none; } }
.donate p { margin: 0 0 12px; }
.donate-hero { font-size: 2.6rem; text-align: center; margin: 4px 0 8px; }
.donate-reason { background: var(--good-soft); border-radius: 12px; padding: 12px 14px; font-weight: 600; }
.donate-facts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.donate-facts li { display: flex; gap: 8px; font-size: .92rem; }
.donate-facts li::before { content: '✓'; color: var(--good); font-weight: 800; }
.donate-links { display: grid; gap: 8px; margin-bottom: 12px; }
.donate-link { justify-content: space-between; text-align: left; }
.donate-link small { font-weight: 500; font-size: .8rem; opacity: .8; }
.donate-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }


/* ---------- Liviana ---------- */
.drop { text-align: center; padding: 34px 20px; border: 2px dashed var(--line); border-radius: 22px; background: var(--surface); transition: border-color .15s, background .15s; }
.drop.over, body.dragging .drop { border-color: var(--brand); background: var(--brand-soft); }
.drop .big-icon { font-size: 3rem; line-height: 1; }
.drop h1 { font-size: clamp(1.6rem, 6vw, 2.2rem); margin: 10px 0 8px; }
.drop p { margin: 0 0 18px; }
.files { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.file { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.thumb { width: 56px; height: 56px; border-radius: 6px; background: var(--surface-2); flex: none; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); }
.thumb canvas, .thumb img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.file .main { flex: 1; min-width: 0; }
.file .main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.file .main span { font-size: .8rem; color: var(--muted); }
.file .tools { display: flex; gap: 2px; flex: none; }
.file .tools button { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 1rem; }
.file .tools button:hover { background: var(--surface-2); color: var(--text); }
.qualities { display: grid; gap: 8px; }
.q { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; background: var(--surface); }
.q:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.q input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.q b { display: block; }
.q span { font-size: .85rem; color: var(--muted); }
.progress { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.progress div { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.result { text-align: center; }
.result .big { font-size: 2.6rem; }
.result h2 { justify-content: center; }
.saved-pill { display: inline-block; margin: 6px 0 14px; padding: 6px 12px; border-radius: 99px; background: var(--good-soft); color: var(--good); font-weight: 700; }
.err-box { background: #fde2e2; color: #b91c1c; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: .9rem; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions .btn { flex: 1; }
.custom { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.custom .field { margin: 0; }
.file .ok { color: var(--good); font-weight: 600; }
.file .warn { color: var(--warn); font-weight: 600; }
.file .dl { flex: none; }
.file.done .main span { display: block; }
.sticky-cta { position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 5; }

/* Manual de uso (shared/manual.js) */
.manual h3 { font-size: 1rem; margin: 18px 0 6px; }
.manual ol, .manual ul { margin: 0; padding-left: 1.3em; }
.manual li { margin: 6px 0; }
.manual-note { margin-top: 16px; padding: 10px 12px; border-radius: 12px; background: var(--brand-soft); font-size: .9rem; }
.manual-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 14px 0 16px; font-size: .9rem; }
.topbar .brand { white-space: nowrap; }
@media (max-width: 400px) { .topbar .donate-btn span { display: none; } }
