:root {
  color-scheme: light dark;
  --bg: #f6f6f8;
  --card: #ffffff;
  --text: #16161a;
  --muted: #6b6b75;
  --line: #e4e4ea;
  --accent: #3b6cf6;
  --danger: #e5484d;
  --alta: #e5484d;
  --media: #f59e0b;
  --baja: #10b981;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --card: #1c1c21;
    --text: #f2f2f5;
    --muted: #9a9aa5;
    --line: #2c2c33;
    --accent: #6b8eff;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  padding: env(safe-area-inset-top) 0 calc(72px + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }

/* Filtros */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { padding: 7px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); white-space: nowrap; font-size: 15px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Lista */
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.task { position: relative; border-radius: var(--radius); overflow: hidden; }
.task-inner { position: relative; background: var(--card); padding: 12px 14px; transition: transform .2s ease; touch-action: pan-y; border: 1px solid var(--line); border-radius: var(--radius); }
.task .delete { opacity: 0; }
.task.open .delete, .task.swiping .delete { opacity: 1; }
.task.open .task-inner { transform: translateX(-96px); }
.task .delete { position: absolute; inset: 0 0 0 auto; width: 120px; padding-left: 24px; background: var(--danger); color: #fff; font-weight: 600; border-radius: var(--radius); }
.task.overdue .task-inner { border-color: var(--danger); box-shadow: inset 4px 0 0 var(--danger); }
.task.overdue .title, .task.overdue .task-head .check span { color: var(--danger); }
.task.complete .task-inner { opacity: .55; }
.task-head { display: flex; align-items: center; gap: 10px; }
.task-head .title, .task-head .check { flex: 1; font-weight: 600; }
.progress { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.edit { font-size: 26px; line-height: 1; color: var(--muted); padding: 0 4px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.prio { text-transform: capitalize; font-weight: 600; }
.prio-alta { color: var(--alta); }
.prio-media { color: var(--media); }
.prio-baja { color: var(--baja); }
.subtasks { list-style: none; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.subtasks li { display: flex; align-items: center; gap: 10px; }
.subtasks .check { flex: 1; }
.time { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
.check input:checked + span { text-decoration: line-through; color: var(--muted); }
.check.disabled { opacity: .7; }
.empty { text-align: center; color: var(--muted); margin-top: 48px; }

.fab {
  position: fixed; right: 20px; bottom: calc(84px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 32px; line-height: 1; box-shadow: 0 6px 18px rgb(0 0 0 / .25);
}

/* Barra inferior */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 8px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs button { flex: 1; max-width: 200px; padding: 10px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 15px; }
.tabs button.active { color: var(--accent); background: var(--card); }

/* Editor */
.editor { display: grid; gap: 14px; }
.bar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--bg); padding: 6px 0; z-index: 1; }
.bar h1 { font-size: 17px; margin: 0; }
.link { color: var(--accent); padding: 6px 0; }
.link.strong { font-weight: 700; }
.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.field input, .field select, .sub-row input, .editor input[type=date] {
  font-size: 17px; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; width: 100%; min-height: 46px;
}
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
legend { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.segmented, .days { display: flex; gap: 6px; }
.seg { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.subs { display: grid; gap: 8px; }
.sub-row { display: grid; grid-template-columns: 1fr 132px 32px; gap: 8px; align-items: center; }
.icon { font-size: 24px; color: var(--muted); }
.secondary { padding: 13px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--accent); font-weight: 600; }
.danger { padding: 13px; border-radius: 12px; color: var(--danger); font-weight: 600; }
.error:empty { display: none; }
.error { margin: 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
[hidden] { display: none !important; }

/* Resumen */
.summary-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.summary-card h2 { font-size: 16px; margin: 0 0 12px; }
.period { margin: 0; color: var(--muted); font-size: 15px; }
.big { font-size: 48px; font-weight: 700; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 14px; }
.summary-card .muted { margin: 10px 0 0; }
progress { -webkit-appearance: none; appearance: none; width: 100%; height: 12px; border: 0; border-radius: 999px; background: var(--line); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.cat-row { display: grid; gap: 6px; margin-bottom: 14px; }
.cat-row:last-child { margin-bottom: 0; }
.cat-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; }
.cat-head .muted { font-size: 14px; }

/* Ajustes */
.settings h1 { font-size: 28px; margin: 4px 0 16px; }
.settings .summary-card { display: grid; gap: 14px; }
.settings h2 { margin: 0; }
.status { margin: 0; font-size: 15px; }
.primary { padding: 13px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
.primary:disabled { opacity: .5; }
.banner { display: block; width: 100%; text-align: left; margin-bottom: 12px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--media) 18%, var(--card)); border: 1px solid var(--media); font-size: 15px; font-weight: 600; }
