:root {
  --bg: #F4F4F1;
  --card: #FFFFFF;
  --ink: #141414;
  --ink2: #5E5E5A;
  --ink3: #9A9A94;
  --line: #E3E3DE;
  --top: #111111;
  --top-ink: #FFFFFF;
  --acc: #E4FC14;
  --acc-ink: #111111;
  --late: #D64545;
  --late-bg: #FBEAEA;
  --ok: #2F9E5B;
  --chip: #EBEBE6;
  --sheet-shadow: 0 -8px 30px rgba(0,0,0,.18);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0E0E;
    --card: #1A1A1A;
    --ink: #F2F2EE;
    --ink2: #B4B4AE;
    --ink3: #7D7D78;
    --line: #2A2A2A;
    --top: #000000;
    --late: #FF7A7A;
    --late-bg: #3A1D1D;
    --ok: #5FD38F;
    --chip: #262626;
    --sheet-shadow: 0 -8px 30px rgba(0,0,0,.6);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--top); }
.logo { color: #fff; font-weight: 800; font-size: 44px; letter-spacing: 1px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.logo span { width: 46px; height: 8px; border-radius: 8px; background: var(--acc); }

/* ---------- topo ---------- */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--top); color: var(--top-ink);
  padding: calc(var(--safe-t) + 14px) 16px 14px;
}
.top h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.3px; }
.top .sub { color: #A8A8A2; font-size: 13px; margin-top: 2px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 600;
  background: #262626; color: #DADAD4;
}
.chip.on { background: var(--acc); color: var(--acc-ink); }
.chip .n { opacity: .65; margin-left: 4px; font-weight: 500; }

/* ---------- conteúdo ---------- */
main { padding: 12px 16px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
.sec { margin: 18px 0 8px; font-size: 13px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--ink2); display: flex; justify-content: space-between; align-items: baseline; }
.sec .cnt { font-weight: 600; color: var(--ink3); }
.sec.late { color: var(--late); }
.empty { text-align: center; color: var(--ink3); padding: 28px 12px; font-size: 15px; }

.item {
  display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 12px 12px 10px; margin-bottom: 8px; width: 100%; text-align: left;
}
.item .bar { width: 4px; align-self: stretch; border-radius: 4px; flex: none; }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 600; font-size: 15.5px; overflow-wrap: anywhere; }
.item .m { color: var(--ink2); font-size: 13px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.item .m .late { color: var(--late); font-weight: 600; }
.item .m .alta { color: var(--late); }
.item.done .t { text-decoration: line-through; color: var(--ink3); }
.check {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink3); background: transparent;
  display: grid; place-items: center; margin-top: 1px; padding: 0;
}
.check.on { background: var(--ok); border-color: var(--ok); }
.check.on::after { content: ""; width: 7px; height: 12px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px,-1px); }
.hora { flex: none; font-weight: 700; font-size: 14px; min-width: 46px; color: var(--ink); margin-top: 2px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--chip); color: var(--ink2); }

/* ---------- navegação ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
}
nav.tabs button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--ink3); padding: 4px 10px; min-width: 64px;
}
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button.on { color: var(--ink); }
nav.tabs button.on svg { stroke: var(--ink); }
nav.tabs .dot { position: relative; }
nav.tabs .badge { position: absolute; top: -4px; right: -10px; background: var(--late); color: #fff; font-size: 10px; border-radius: 999px; padding: 0 5px; min-width: 16px; line-height: 16px; }

.fab {
  position: fixed; right: 18px; bottom: calc(78px + var(--safe-b)); z-index: 6; width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--acc); color: var(--acc-ink); font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

/* ---------- folha (detalhe/edição) ---------- */
.veil { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; animation: fade .15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: var(--card); border-radius: 18px 18px 0 0;
  max-height: 92vh; overflow-y: auto; padding: 8px 16px calc(20px + var(--safe-b)); box-shadow: var(--sheet-shadow);
  animation: up .2s ease-out; max-width: 720px; margin: 0 auto;
}
.fechar { position: absolute; top: 10px; right: 10px; border: 0; background: var(--chip); color: var(--ink2); width: 32px; height: 32px; border-radius: 50%; font-size: 22px; line-height: 1; }
.grip { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 4px auto 10px; }
@keyframes up { from { transform: translateY(40px); opacity: .5 } to { transform: none; opacity: 1 } }
@keyframes fade { from { opacity: 0 } }
.sheet h2 { margin: 4px 0 12px; font-size: 19px; }
.f { margin-bottom: 12px; }
.f label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.f input, .f select, .f textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 11px 12px; font-size: 16px;
}
.f textarea { min-height: 84px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > .f { flex: 1; min-width: 0; }
.ck { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ck input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--ok); flex: none; }
.ck input[type=text] { flex: 1; border: 0; background: transparent; padding: 4px 0; font-size: 15.5px; }
.ck.done input[type=text] { text-decoration: line-through; color: var(--ink3); }
.ck .x { border: 0; background: none; color: var(--ink3); font-size: 20px; padding: 0 4px; }
.btns { display: flex; gap: 10px; margin-top: 16px; }
.btn { flex: 1; border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 16px; background: var(--chip); }
.btn.pri { background: var(--top); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.pri { background: var(--acc); color: var(--acc-ink); } }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: transparent; color: var(--late); flex: none; padding: 14px 6px; font-weight: 600; }
.link { border: 0; background: none; color: var(--ink2); text-decoration: underline; padding: 6px 0; font-size: 14px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login .logo { color: var(--ink); align-items: flex-start; font-size: 38px; margin-bottom: 6px; }
.login p { color: var(--ink2); margin: 0 0 22px; }
.msg { font-size: 14px; margin-top: 10px; color: var(--ink2); }
.msg.err { color: var(--late); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--safe-b)); z-index: 20;
  background: var(--top); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; animation: fade .2s;
}
.offline { background: var(--late-bg); color: var(--late); text-align: center; font-size: 13px; padding: 6px; }
