/* Estilo base da PWA. Mobile primeiro; modo escuro automático; sem framework. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger-bg: #fde8e8;
  --danger: #9b1c1c;
  --radius: 12px;
  --nav-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --surface: #151b26;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #263042;
    --accent: #3b82f6;
    --danger-bg: #3b1212;
    --danger: #fca5a5;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }

/* ---------- formulários ---------- */
label { display: block; margin-top: 1rem; font-weight: 500; }
input, select, textarea {
  display: block; width: 100%; margin-top: .35rem; padding: .7rem .8rem;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  display: inline-block; margin-top: 1.25rem; padding: .75rem 1.2rem;
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); text-decoration: none;
}
.btn-block { display: block; width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.error { background: var(--danger-bg); color: var(--danger); padding: .7rem .8rem; border-radius: 10px; }

/* ---------- páginas públicas (login/cadastro) ---------- */
.auth {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%; max-width: 24rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem;
}
.auth-brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.25rem; font-weight: 700; }
.auth-brand img { width: 36px; height: 36px; border-radius: 9px; }

/* ---------- casca do app (logado) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; }
.topbar form { margin: 0; }
.topbar .btn { margin: 0; padding: .4rem .8rem; font-size: .9rem; }
main.content {
  max-width: 44rem; margin: 0 auto;
  padding: 1rem 1rem calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom));
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
}
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.badge {
  display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem;
  border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
}

/* barra de navegação inferior (estilo app) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .72rem; font-weight: 500; color: var(--muted); text-decoration: none;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); }

/* telas largas: navegação vira coluna lateral */
@media (min-width: 900px) {
  .tabbar {
    top: 0; right: auto; width: 96px; height: auto;
    grid-template-columns: 1fr; grid-auto-rows: 72px; align-content: start;
    padding-top: 72px; border-top: 0; border-right: 1px solid var(--border);
  }
  .topbar, main.content { margin-left: 96px; }
  main.content { padding-bottom: 2rem; }
}

/* ---------- listas, tarefas e formulários (etapa 1.4) ---------- */
.small { font-size: .85rem; }
.back { color: var(--accent); text-decoration: none; font-weight: 600; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.row > label { margin-top: 1rem; }
textarea { resize: vertical; }
details > summary { cursor: pointer; list-style: none; padding: .1rem 0; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: .5rem; }

.list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.list-item {
  display: flex; flex-direction: column; gap: .3rem; padding: .85rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.list-title { font-weight: 600; }
.task-meta { display: flex; flex-wrap: wrap; gap: .35rem; }

.tasks { list-style: none; margin: .5rem 0 1rem; padding: 0; }
.task {
  display: flex; align-items: center; gap: .75rem; padding: .6rem .25rem;
  border-bottom: 1px solid var(--border);
}
.task form { margin: 0; }
.task-title { flex: 1; color: var(--text); text-decoration: none; min-width: 0; overflow-wrap: anywhere; }
.check {
  width: 28px; height: 28px; flex: none; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--border); background: transparent; color: var(--accent-text);
  font-weight: 700; line-height: 1; padding: 0;
}
.task.is-done .check { background: var(--accent); border-color: var(--accent); }
.is-done .task-title, .is-done .list-title { color: var(--muted); text-decoration: line-through; }

.quick-add { display: flex; gap: .5rem; align-items: stretch; }
.quick-add input { margin: 0; }
.quick-add .btn { margin: 0; white-space: nowrap; }

.badge-active { color: var(--accent); border-color: var(--accent); }
.badge-high { color: var(--danger); border-color: var(--danger); }
.badge-done { text-decoration: line-through; }
.notice { border-color: #d97706; background: color-mix(in srgb, #f59e0b 12%, var(--surface)); }

.help { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .85rem; color: var(--muted); }
.check-label { display: flex; align-items: center; gap: .5rem; }
.check-label input[type="checkbox"] { width: auto; margin: 0; }

.danger-zone { margin-top: 1.5rem; color: var(--muted); }
.danger-zone summary { color: var(--danger); font-weight: 600; }
.btn-danger { background: var(--danger); color: #fff; }

/* ---------- agenda (etapa 2.1) ---------- */
.center { text-align: center; }
.btn-small { margin: 0; padding: .35rem .7rem; font-size: .85rem; }
.day-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.day-nav strong { text-align: center; flex: 1; }

.blocks { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.block {
  display: grid; grid-template-columns: 3.4rem 1fr; gap: .25rem .75rem; align-items: start;
  padding: .7rem .8rem; background: var(--surface); border: 1px solid var(--border);
  border-left: 5px solid var(--kind, var(--accent)); border-radius: var(--radius);
}
.block-time { font-variant-numeric: tabular-nums; font-weight: 600; line-height: 1.3; }
.block-body { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.block-title { color: var(--text); text-decoration: none; font-weight: 600; overflow-wrap: anywhere; }
.block-actions { grid-column: 2; display: flex; gap: .4rem; flex-wrap: wrap; }
.block-actions form { margin: 0; }
.block .error { margin: .25rem 0 0; }
.block.status-skipped { opacity: .55; }
.block.status-skipped .block-title { text-decoration: line-through; }
.block.status-done .block-title::after { content: " ✓"; color: var(--accent); }

.kind-focus { --kind: #2563eb; }
.kind-task { --kind: #7c3aed; }
.kind-break { --kind: #9ca3af; }
.kind-leisure { --kind: #16a34a; }
.kind-appointment { --kind: #d97706; }
