:root {
  --bg: #f4f6f8; --card: #fff; --text: #1d2733; --muted: #6b7785; --line: #e2e7ec;
  --brand: #1f5f8b; --accent: #f2b134; --red: #c8382d; --red-bg: #fdecea; --amber-bg: #fff6e0; --green: #2e7d4f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161c; --card: #1b232c; --text: #e6ebf0; --muted: #94a1ae; --line: #2a3540;
    --brand: #5aa6db; --red-bg: #3a1d1b; --amber-bg: #3a3018; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
h2 { font-size: 1.2rem; margin: .2rem 0 .6rem; }
h3 { font-size: 1.02rem; margin: .1rem 0 .5rem; }
small, .muted { color: var(--muted); }
header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; background: var(--brand); color: #fff; }
header a { color: #fff; font-weight: 700; font-size: 1.1rem; }
header small { color: #dbe9f4; }
main { padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 2; }
nav a { flex: 1; text-align: center; padding: 8px 0 10px; font-size: .75rem; color: var(--muted); }
nav a svg { display: block; margin: 0 auto 2px; }
nav a.on { color: var(--brand); font-weight: 600; }
section { margin-bottom: 14px; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; color: var(--text); }
.card.act h3 { margin: .35rem 0 .15rem; }
.meta { color: var(--muted); font-size: .88rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--bg); border-radius: 999px; padding: 2px 10px; font-size: .82rem; font-weight: 600; }
.chip.hot { background: var(--red); color: #fff; }
.gaps { list-style: none; padding: 0; margin: 0; }
.gaps li { border-radius: 12px; margin-bottom: 8px; border-left: 5px solid var(--line); background: var(--card); }
.gaps li.urgente { border-color: var(--red); background: var(--red-bg); }
.gaps li.aviso { border-color: var(--accent); background: var(--amber-bg); }
.gaps a { display: block; padding: 10px 12px; color: var(--text); }
.gaps b { display: block; font-size: .85rem; }
.ok { color: var(--green); font-weight: 600; }
details summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); margin-top: 3px; }
button, .btn { background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; display: inline-block; }
button.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--red); }
.small { padding: 6px 12px; font-size: .88rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.checks, .qs, .log { list-style: none; padding: 0; margin: 0 0 8px; }
.checks li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.checks li label { flex: 1; display: flex; align-items: center; gap: 10px; margin: 0; color: var(--text); font-size: 1rem; }
.checks input[type=checkbox] { width: 22px; height: 22px; margin: 0; flex: none; }
.done { text-decoration: line-through; color: var(--muted); }
.narrow { max-width: 38%; }
.x { background: none; color: var(--muted); padding: 4px 8px; font-size: 1.2rem; }
.add { display: flex; gap: 6px; margin-top: 6px; }
.add input { margin: 0; }
.add button { padding: 0 16px; }
.qs li { position: relative; padding: 8px 30px 8px 0; border-bottom: 1px solid var(--line); }
.qs li p { margin: 0 0 4px; }
.qs li .x { position: absolute; right: 0; top: 4px; }
.qs .answer { color: var(--green); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; margin-bottom: 14px; }
.cal b { font-size: .75rem; color: var(--muted); }
.day { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 6px 0 4px; min-height: 48px; font-weight: 500; }
.day span { display: flex; justify-content: center; gap: 2px; min-height: 8px; margin-top: 2px; }
.day i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.day i.due { background: var(--red); } .day i.ok { background: var(--green); } .day i.ret { background: var(--accent); }
.day.today { border-color: var(--brand); border-width: 2px; }
.day.sel { background: var(--brand); color: #fff; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
td:nth-child(2) { color: var(--muted); white-space: nowrap; }
.score { width: 72px; padding: 6px; }
.big { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.log li small { display: block; }
.log li.undone span { text-decoration: line-through; color: var(--muted); }
code.wrap { display: block; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 8px; margin-bottom: 8px; font-size: .85rem; }
.back { display: inline-block; margin-bottom: 8px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #222c; color: #fff;
  padding: 10px 18px; border-radius: 999px; z-index: 5; max-width: 90vw; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
textarea { resize: vertical; }
.form h2 { margin-top: 0; }
body.plain { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
body.plain .card { max-width: 420px; width: 100%; padding: 24px; }
body.plain form button { margin-top: 10px; margin-right: 6px; }
.gaps ul { margin: 4px 0 0; padding-left: 18px; }
.gaps ul li { border: 0; background: none; margin: 0 0 2px; border-radius: 0; }
.quick { display: flex; gap: 8px; padding: 0 12px 10px; }
.secondary-link { background: var(--card); color: var(--text); border: 1px solid var(--line); }
