/* Cores ficam em themes.css. Aqui ficam medidas, fontes e componentes. */
:root {
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --bar-h: 68px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

html { background: var(--bg); }

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  transition: background-color .25s, color .25s;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }

.muted { color: var(--muted); margin: 0; font-size: 14px; }

/* ---------- Estrutura ---------- */

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 20px calc(env(safe-area-inset-bottom) + var(--bar-h) + 40px);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.brand { font-weight: 600; font-size: 15px; color: var(--muted); }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  overflow: hidden;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 17px/1 var(--display);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 96px; height: 96px; font-size: 38px; cursor: default; }

.hero { padding: 20px 0 22px; }

.hero h1, .view-title {
  font: 700 clamp(40px, 11vw, 60px)/0.98 var(--display);
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  font-variation-settings: "opsz" 96;
}

.hero-sub { margin: 0; color: var(--muted); font-size: 17px; }

/* ---------- Aviso de notificações ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 12px 12px 12px 16px;
  margin-bottom: 18px;
}
.banner p { margin: 0; flex: 1; font-size: 14px; line-height: 1.4; }

/* ---------- Abas (segmentos) ---------- */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  flex: 1;
  border: 0;
  background: none;
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- Lista ---------- */

.group-title {
  font: 600 14px/1.2 var(--body);
  color: var(--muted);
  margin: 22px 4px 8px;
}
.group-title.late { color: var(--late); }
.list > .group-title:first-child { margin-top: 0; }

.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.task {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}
.task:first-child { border-top: 0; }

.check {
  flex: none;
  width: 26px; height: 26px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background .15s, border-color .15s, transform .15s;
}
.check svg { opacity: 0; transition: opacity .15s; }
.check:active { transform: scale(.88); }
.task.is-done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.task.is-done .check svg { opacity: 1; }

.task-body {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.task-title { display: block; font-weight: 500; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-notes {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 4px;
}
.task-meta.late { color: var(--late); }
.task-meta svg { flex: none; }

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty strong {
  display: block;
  font: 700 22px/1.2 var(--display);
  color: var(--ink);
  margin-bottom: 6px;
}
.empty p { margin: 0 0 18px; }

/* ---------- Botões ---------- */

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  background: var(--accent-soft);
  color: var(--accent);
  line-height: 1.2;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: none; color: var(--ink); }
.btn-outline { background: none; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { color: var(--danger); }
.btn-outline.btn-danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn-small { padding: 8px 14px; font-size: 14px; }
.btn-block { display: block; width: 100%; }

/* ---------- Barra inferior ---------- */

.bottombar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottombar-inner {
  max-width: 640px;
  margin: 0 auto;
  height: var(--bar-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 12px;
}
.navbtn {
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 0;
}
.navbtn[aria-current="page"] { color: var(--accent); }
.addbtn {
  width: 58px; height: 58px;
  margin-top: -26px;
  border-radius: 50%;
  border: 4px solid var(--bg);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--accent) 80%, black);
  transition: transform .15s;
}
.addbtn:active { transform: scale(.94); }

/* ---------- Painel inferior (formulários) ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 11, .5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fade .18s ease-out;
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  color: var(--ink);
  border-radius: 26px 26px 0 0;
  padding: 10px 22px calc(env(safe-area-inset-bottom) + 18px);
  animation: rise .24s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 26px; padding-bottom: 18px; }
}

.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { font: 700 26px/1.15 var(--display); margin: 0 0 16px; letter-spacing: -0.01em; }
.sheet h3 { font: 700 18px/1.2 var(--display); margin: 26px 0 12px; }

.sheet label, .auth-form label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 14px;
}
.sheet small, .auth-form small { display: block; font-weight: 400; margin-top: 6px; font-size: 13px; }

.sheet input, .sheet textarea, .sheet select, .auth-form input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  font-weight: 400;
  min-height: 48px;
}
.sheet textarea { resize: vertical; min-height: 80px; }
.sheet select:disabled { opacity: .6; }

.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.row > label { min-width: 0; }

.sheet-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.spacer { flex: 1; }

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.setting:last-of-type { border-bottom: 1px solid var(--line); }
.setting strong { font-weight: 600; }
.setting .muted { margin: 2px 0 0; }
.setting select { width: auto; min-width: 150px; margin: 0; }

.form-error, .form-ok {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin: 0 0 14px;
}
.form-error { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.form-ok { background: var(--accent-soft); color: var(--accent); }

/* ---------- Meu perfil ---------- */

.profile-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}
.profile-head h2 { margin: 0 0 2px; overflow-wrap: anywhere; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-actions .btn { padding: 7px 12px; font-size: 13px; }

.tabs.inner { margin: 4px 0 6px; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}
.theme-card {
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--ink);
  padding: 10px;
  cursor: pointer;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
}
.theme-card .preview {
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
}
.theme-card .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); flex: none; }
.theme-card .bars { flex: 1; display: grid; gap: 4px; }
.theme-card .bars i { display: block; height: 5px; border-radius: 4px; background: var(--line); }
.theme-card .bars i:first-child { background: var(--ink); width: 70%; opacity: .75; }
.theme-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-label { display: block; color: var(--ink); }

.danger-zone { margin-top: 26px; padding-top: 6px; }
.danger-zone .btn { margin-top: 10px; }

/* ---------- Painel (desempenho) ---------- */

.dash-head { padding: 20px 0 18px; }
.dash-head .hero-sub { font-size: 16px; }

.score {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 22px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 14px;
}
.ring { position: relative; width: 132px; height: 132px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1;
}
.ring-label b { display: block; font: 700 36px/1 var(--display); letter-spacing: -0.03em; }
.ring-label span { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.legend { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.legend li b { margin-left: auto; font: 700 18px/1 var(--display); }
.sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.sw.ok { background: var(--accent); }
.sw.late { background: var(--late); }
.sw.none { background: var(--muted); opacity: .45; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 14px;
}
.stat { background: var(--surface); padding: 16px 16px 14px; }
.stat b { display: block; font: 700 28px/1.05 var(--display); letter-spacing: -0.02em; }
.stat span { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.3; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 18px 14px;
  margin-bottom: 14px;
}
.panel h2 { font: 700 18px/1.2 var(--display); margin: 0 0 4px; }
.panel > p { margin: 0 0 14px; font-size: 13px; color: var(--muted); }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 150px;
  border-bottom: 1px solid var(--line);
}
.col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.col .seg { width: 100%; }
.col .seg.ok { background: var(--accent); }
.col .seg.late { background: var(--late); }
.col .seg.none { background: color-mix(in srgb, var(--muted) 45%, transparent); }
.col .seg:first-child { border-radius: 4px 4px 0 0; }
.col.is-today .seg { outline: 0; }
.chart-labels { display: flex; gap: 3px; margin-top: 6px; }
.chart-labels span { flex: 1; min-width: 0; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: visible; }

.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 86px 1fr 34px; gap: 10px; align-items: center; font-size: 14px; }
.hbar .track { height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 6px; }
.hbar.best .fill { background: var(--ink); }
.hbar b { text-align: right; font-weight: 700; }

.insights { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.insights li { padding-left: 16px; position: relative; font-size: 15px; line-height: 1.45; }
.insights li::before { content: ""; position: absolute; left: 0; top: .6em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* ---------- Aviso rápido ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--bar-h) + 16px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  z-index: 60;
  max-width: calc(100% - 40px);
  display: flex;
  align-items: center;
  gap: 14px;
  animation: fade .18s ease-out;
}
.toast button { background: none; border: 0; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }

/* ---------- Login e cadastro ---------- */

body.auth {
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-box { width: 100%; max-width: 380px; }
.auth-logo { border-radius: 16px; display: block; margin-bottom: 22px; }
.auth-box h1 { font: 700 44px/1 var(--display); letter-spacing: -0.03em; margin: 0 0 8px; }
.auth-sub { color: var(--muted); margin: 0 0 26px; font-size: 17px; }
.auth-form .btn { margin-top: 6px; }
.auth-alt { margin-top: 22px; color: var(--muted); font-size: 15px; }

/* ---------- Movimento ---------- */

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }

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