:root {
  --bg: #F1F2F5; --surface: #FFFFFF; --surface-2: #F6F7F9; --line: #ECEEF2;
  --text: #14171C; --muted: #5A606B; --faint: #8A909B;
  --accent: #2457D6; --accent-soft: #EAF0FD; --accent-text: #1C3F99;
  --hero: #14171C; --hero-text: #FFFFFF; --hero-muted: #B9BEC8; --hero-line: #3A3F49; --hero-label: #9FB6F2;
  --danger: #C0362C; --danger-soft: #FDECEA; --ok: #1E8E5A;
  --pessoal: #7A4FE0; --casa: #1E8E5A; --trabalho: #2457D6;
  --shadow: 0 4px 18px rgba(20, 23, 28, .10);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D0F13; --surface: #171A20; --surface-2: #1E2229; --line: #262A32;
    --text: #F2F3F5; --muted: #A3A9B4; --faint: #7D838E;
    --accent: #6E95F2; --accent-soft: #1C2742; --accent-text: #B9CCFA;
    --hero: #F2F3F5; --hero-text: #14171C; --hero-muted: #4B515C; --hero-line: #C9CDD4; --hero-label: #2457D6;
    --danger: #F2776C; --danger-soft: #3A1E1C; --ok: #4CC38A;
    --pessoal: #A68BF0; --casa: #4CC38A; --trabalho: #6E95F2;
    --shadow: 0 4px 18px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: Inter, -apple-system, system-ui, sans-serif; font-size: 16px; line-height: 1.35; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
input, textarea, select { -webkit-appearance: none; appearance: none; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot img { border-radius: 18px; }

/* ---------- Estrutura ---------- */
.shell { min-height: 100dvh; }
.main { max-width: 640px; margin: 0 auto; padding: calc(var(--safe-t) + 20px) 16px calc(var(--safe-b) + 170px); display: flex; flex-direction: column; gap: 12px; }
.main.no-capture { padding-bottom: calc(var(--safe-b) + 110px); }
.sidebar { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 8px calc(var(--safe-b) + 6px); }
.tab { width: 76px; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 500; text-decoration: none; position: relative; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tab .dot { position: absolute; top: 4px; right: 20px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.capture { position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-b) + 76px); z-index: 19; max-width: 608px; margin: 0 auto; }
.capture-fade { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--safe-b) + 170px); background: linear-gradient(to bottom, transparent, var(--bg) 40%); z-index: 18; pointer-events: none; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100dvh; background: var(--surface); border-right: 1px solid var(--line); padding: calc(var(--safe-t) + 26px) 14px 20px; overflow-y: auto; }
  .tabbar, .capture-fade { display: none; }
  .main { max-width: 1120px; padding: calc(var(--safe-t) + 30px) 40px 60px; }
  .main.no-capture { padding-bottom: 60px; }
  .capture { position: static; max-width: 440px; margin: 0; flex: 1; }
  .desk-cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .desk-cols > div { display: flex; flex-direction: column; gap: 16px; }
}
.desk-cols, .desk-cols > div { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 900px) { .desk-cols { display: grid; } }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 18px; font-weight: 700; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link { height: 42px; border-radius: 10px; padding: 0 12px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; text-decoration: none; }
.side-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.side-link .count { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--danger); }
.side-label { padding: 0 12px 6px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }

/* ---------- Cabeçalho ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 4px; }
.top .hello { font-size: 14px; color: var(--muted); }
.top h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
@media (min-width: 900px) { .top h1 { font-size: 30px; } }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; background: var(--surface); display: grid; place-items: center; flex-shrink: 0; color: var(--text); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 4px; height: 44px; color: var(--accent); font-weight: 600; font-size: 16px; }

/* ---------- Cartões ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.card-head h2 { font-size: 16px; font-weight: 700; }
.card-head .meta { font-size: 13px; color: var(--muted); }
.section-label { font-size: 14px; font-weight: 600; color: var(--muted); margin: 6px 4px 0; }
.section-label.danger { color: var(--danger); }

.weather { display: flex; align-items: center; gap: 12px; }
.weather .w-main { font-size: 15px; font-weight: 600; }
.weather .w-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.hours { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); text-align: center; font-size: 12px; color: var(--muted); margin-top: 12px; }
.hours b { display: block; font-size: 14px; color: var(--text); margin-top: 3px; }
.hours .rain, .hours .rain b { color: var(--accent); font-weight: 600; }
.weather-ask { width: 100%; text-align: left; }

.agora { background: var(--hero); color: var(--hero-text); border-radius: 24px; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.agora .a-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.agora .a-label { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--hero-label); }
.agora .a-meta { font-size: 13px; color: var(--hero-muted); }
.agora .a-title { font-size: 24px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.agora .a-sub { font-size: 14px; color: var(--hero-muted); margin-top: -8px; }
.agora .a-actions { display: flex; gap: 10px; }
.agora .btn-hero { flex: 1.3; height: 50px; border-radius: 14px; background: var(--hero-text); color: var(--hero); font-size: 16px; font-weight: 600; }
.agora .btn-hero-2 { flex: 1; height: 50px; border-radius: 14px; border: 1px solid var(--hero-line); color: var(--hero-text); font-size: 15px; font-weight: 500; }
@media (min-width: 900px) { .agora { padding: 26px 28px; } .agora .a-title { font-size: 30px; } .agora .a-actions { max-width: 380px; } }

/* ---------- Linhas ---------- */
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 12px; min-height: 60px; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.row:first-child { border-top: none; }
.card .row { padding-left: 0; padding-right: 0; min-height: 48px; }
.row .r-body { flex: 1; min-width: 0; }
.row .r-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.row .r-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.row .r-sub.danger { color: var(--danger); font-weight: 600; }
.row .r-time { width: 46px; flex-shrink: 0; font-size: 14px; font-weight: 600; color: var(--accent); }
.row .r-amount { font-size: 15px; font-weight: 600; white-space: nowrap; }
.row.done .r-title { color: var(--faint); text-decoration: line-through; font-weight: 500; }
.row-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; min-height: 44px; }
.cat { font-size: 12px; font-weight: 600; white-space: nowrap; }
.cat.pessoal { color: var(--pessoal); } .cat.casa { color: var(--casa); } .cat.trabalho { color: var(--trabalho); }
.cat-dot { width: 10px; height: 10px; border-radius: 5px; flex-shrink: 0; }
.cat-dot.pessoal { background: var(--pessoal); } .cat-dot.casa { background: var(--casa); } .cat-dot.trabalho { background: var(--trabalho); }

.check { width: 44px; height: 44px; margin: -10px -10px -10px -10px; display: grid; place-items: center; flex-shrink: 0; }
.check span { width: 24px; height: 24px; border-radius: 12px; border: 2px solid var(--faint); display: grid; place-items: center; transition: transform .15s; }
.check[aria-pressed="true"] span { background: var(--ok); border-color: var(--ok); }
.check:active span { transform: scale(.85); }
.kind-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.kind-icon.late { background: var(--danger-soft); color: var(--danger); }

.empty { padding: 18px 16px; color: var(--muted); font-size: 14px; text-align: center; }
.add-line { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 12px; color: var(--accent); font-weight: 600; font-size: 15px; border-top: 1px solid var(--line); }
.inbox-chip { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); color: var(--accent-text); border-radius: 16px; padding: 12px 16px; font-size: 15px; font-weight: 600; width: 100%; text-align: left; }
.inbox-chip .go { margin-left: auto; }

/* ---------- Captura rápida ---------- */
.capture-box { height: 56px; border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; padding: 0 6px 0 20px; }
.capture-box input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 16px; }
.capture-box input::placeholder { color: var(--faint); }
.mic { width: 44px; height: 44px; border-radius: 22px; background: var(--accent); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.mic.listening { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ---------- Botões e campos ---------- */
.btn { height: 50px; border-radius: 14px; padding: 0 18px; font-size: 16px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.dark { background: var(--text); color: var(--bg); }
.btn.soft { background: var(--accent-soft); color: var(--accent-text); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 140px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.input { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 14px; font-size: 16px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { padding: 12px 14px; min-height: 90px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { min-height: 40px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.code-box { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--surface-2); border-radius: 12px; padding: 12px; overflow-wrap: anywhere; line-height: 1.5; }
.hint { font-size: 13px; color: var(--muted); }
.ok-text { color: var(--ok); font-weight: 600; }

/* ---------- Folha (bottom sheet) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .18s; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 10px 16px calc(var(--safe-b) + 20px); display: flex; flex-direction: column; gap: 14px; animation: up .22s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 4px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sheet-head h2 { font-size: 20px; font-weight: 700; }
@media (min-width: 900px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 24px; padding-bottom: 24px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 150px); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); border-radius: 14px; padding: 12px 16px; font-size: 15px; font-weight: 500; display: flex; gap: 14px; align-items: center; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
#toast button { color: var(--accent-soft); font-weight: 700; min-height: 32px; }
@media (min-width: 900px) { #toast { bottom: 32px; } }

/* ---------- Agenda ---------- */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.month .wd { font-size: 12px; color: var(--faint); padding: 6px 0; font-weight: 600; }
.month .day { aspect-ratio: 1 / 1; max-height: 56px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 15px; }
.month .day.out { color: var(--faint); }
.month .day.today { color: var(--accent); font-weight: 700; }
.month .day[aria-pressed="true"] { background: var(--text); color: var(--bg); font-weight: 600; }
.month .dots { display: flex; gap: 2px; height: 5px; }
.month .dots i { width: 5px; height: 5px; border-radius: 3px; background: var(--accent); }
.month .dots i.bill { background: var(--danger); }
.month-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.month-nav h2 { font-size: 17px; font-weight: 700; text-transform: capitalize; }

/* ---------- Notas ---------- */
.note-card { width: 100%; text-align: left; }
.note-card .r-sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.editor-title { font-size: 26px; font-weight: 700; border: none; outline: none; background: transparent; width: 100%; padding: 4px 2px; }
.editor { min-height: 50dvh; outline: none; font-size: 17px; line-height: 1.55; padding: 4px 2px 40px; overflow-wrap: anywhere; }
.editor:empty::before { content: attr(data-placeholder); color: var(--faint); }
.editor h2 { font-size: 21px; margin: 14px 0 4px; }
.editor h3 { font-size: 18px; margin: 12px 0 4px; }
.editor ul, .editor ol { padding-left: 22px; }
.toolbar { display: flex; gap: 6px; position: sticky; top: calc(var(--safe-t) + 6px); z-index: 5; background: var(--surface); border-radius: 14px; padding: 4px; box-shadow: var(--shadow); width: max-content; max-width: 100%; overflow-x: auto; }
.toolbar button { min-width: 44px; height: 40px; border-radius: 10px; font-weight: 700; font-size: 15px; padding: 0 8px; }
.toolbar button:active { background: var(--surface-2); }

/* ---------- Entrar / bloqueio ---------- */
.gate { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 32px 24px calc(var(--safe-b) + 32px); text-align: center; }
.gate img { width: 84px; height: 84px; border-radius: 20px; }
.gate h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.gate p { color: var(--muted); max-width: 340px; }
.gate form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.gate .err { color: var(--danger); font-size: 14px; text-align: center; }

/* ---------- Fechar o dia ---------- */
.steps { display: flex; gap: 6px; }
.steps i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--accent); }
.big-q { font-size: 24px; font-weight: 700; letter-spacing: -.01em; padding: 4px 4px 0; }
.small-q { font-size: 15px; color: var(--muted); padding: 0 4px; }
.pick { border: 2px solid transparent; }
.pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.rank { width: 26px; height: 26px; border-radius: 13px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.rank.off { background: var(--surface-2); color: var(--faint); }
.celebrate { text-align: center; padding: 30px 10px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.celebrate .big { font-size: 26px; font-weight: 700; }
