:root {
  --bg: #f6f2ec; --surface: #fffdf9; --surface-2: #faf6f0; --ink: #24211d; --muted: #6e675e; --faint: #9a9187; --line: #e7e0d5;
  --accent: #a94a62; --accent-ink: #fff; --accent-soft: #f5e4e8;
  --sage: #4f7360; --sage-soft: #e3ede6; --amber: #96600f; --amber-soft: #fbefd9; --red: #ad3434; --red-soft: #f9e2df; --info-soft: #e7ecf3; --info: #3d5878;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Source Serif Pro", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 18px; --r-sm: 12px; --shadow: 0 1px 2px rgba(60, 40, 20, .05), 0 6px 20px rgba(60, 40, 20, .06);
  --nav-h: 68px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412; --surface: #201d1a; --surface-2: #1b1917; --ink: #eee8e0; --muted: #aaa196; --faint: #7d756c; --line: #332f2a;
    --accent: #e48ba2; --accent-ink: #241417; --accent-soft: #3a2329;
    --sage: #8fbf9f; --sage-soft: #1f2e25; --amber: #e3b25e; --amber-soft: #352a18; --red: #f08b80; --red-soft: #3b1f1c; --info-soft: #1e2733; --info: #9fb8d6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- estrutura ---------- */
.app { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: calc(env(safe-area-inset-top, 0px) + 12px) 18px 10px; display: flex; align-items: center; gap: 12px; }
.top .brand { flex: 1; min-width: 0; }
.top .brand small { display: block; color: var(--muted); font-size: 13px; letter-spacing: .02em; }
.top .brand strong { font: 600 21px/1.2 var(--serif); }
main { max-width: 760px; margin: 0 auto; padding: 4px 16px 0; }
.view-title { font: 600 28px/1.15 var(--serif); margin: 14px 2px 14px; letter-spacing: -.01em; }
.section-title { font: 600 13px/1.2 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 4px 10px; display: flex; align-items: center; gap: 8px; }
.section-title .count { color: var(--faint); font-weight: 500; }

/* ---------- navegação ---------- */
.nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); }
.nav button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--muted); cursor: pointer; position: relative; min-height: 56px; }
.nav button svg { width: 24px; height: 24px; }
.nav button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.nav button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.badge { position: absolute; top: 7px; left: calc(50% + 6px); min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font: 700 11px/19px var(--sans); text-align: center; }
.fab { position: fixed; z-index: 31; right: 18px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); width: 60px; height: 60px; border-radius: 30px; border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px rgba(120, 40, 60, .3); cursor: pointer; display: grid; place-items: center; }
.fab svg { width: 28px; height: 28px; }

@media (min-width: 960px) {
  .app { padding-bottom: 40px; padding-left: 232px; }
  .nav { top: 0; bottom: 0; right: auto; width: 232px; height: auto; grid-template-columns: none; grid-auto-rows: min-content; align-content: start; padding: 92px 14px 20px; border-top: 0; border-right: 1px solid var(--line); background: var(--surface-2); gap: 4px; }
  .nav button { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 16px; padding: 0 14px; border-radius: 12px; min-height: 48px; }
  .nav button[aria-current="page"] { background: var(--accent-soft); }
  .nav button[aria-current="page"]::before { display: none; }
  .badge { position: static; margin-left: auto; }
  .top { padding-left: 28px; padding-right: 28px; }
  .fab { bottom: 28px; right: 28px; }
  main { padding: 4px 28px 0; }
}

/* ---------- elementos ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.list { display: grid; gap: 10px; }
.item { padding: 14px 16px; display: grid; gap: 6px; cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; }
.item:active { transform: scale(.995); }
.item .title { font-weight: 600; font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.item .sub { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.item .next { font-size: 15px; display: flex; gap: 6px; color: var(--ink); }
.item .next::before { content: "→"; color: var(--accent); font-weight: 700; }
.row { display: flex; gap: 12px; align-items: flex-start; }
.row > .grow { flex: 1; min-width: 0; }
.time { font: 600 15px/1.3 var(--sans); font-variant-numeric: tabular-nums; color: var(--accent); min-width: 52px; padding-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 13px; line-height: 1.5; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.high { background: var(--red-soft); color: var(--red); border-color: transparent; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 4px; background: currentColor; }
.sync.synced { background: var(--sage-soft); color: var(--sage); }
.sync.pending { background: var(--info-soft); color: var(--info); }
.sync.pending::before { animation: pulse 1.4s ease-in-out infinite; }
.sync.error { background: var(--red-soft); color: var(--red); }
.sync.waiting { background: var(--amber-soft); color: var(--amber); }
.sync.none, .sync.past { background: transparent; color: var(--faint); padding-left: 0; }
.sync.none::before, .sync.past::before { display: none; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--red); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 12px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 20px; height: 20px; }
.icon-btn { width: 48px; height: 48px; border-radius: 14px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- captura ---------- */
.capture { padding: 14px; margin-top: 4px; }
.capture textarea { width: 100%; border: 0; background: transparent; resize: none; font-size: 18px; line-height: 1.45; min-height: 56px; max-height: 40vh; outline: none; padding: 4px 4px 2px; }
.capture textarea::placeholder { color: var(--faint); }
.capture .preview { min-height: 24px; font-size: 14px; color: var(--muted); padding: 2px 4px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.capture .bar { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); padding-top: 10px; }
.seg { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 2px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; min-height: 40px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.capture .save { flex: none; }

/* ---------- atenção / estados ---------- */
.attention { padding: 6px 4px; border-color: color-mix(in srgb, var(--amber) 30%, var(--line)); background: color-mix(in srgb, var(--amber-soft) 55%, var(--surface)); }
.attention h3 { margin: 8px 12px 4px; font: 600 16px/1.3 var(--serif); }
.att { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; font-size: 15px; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; color: inherit; }
.att .dot { width: 9px; height: 9px; border-radius: 5px; margin-top: 7px; flex: none; background: var(--amber); }
.att.error .dot { background: var(--red); }
.att.info .dot { background: var(--info); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; cursor: pointer; white-space: nowrap; }
.status-pill .d { width: 9px; height: 9px; border-radius: 5px; background: var(--sage); }
.status-pill.pending .d { background: var(--info); animation: pulse 1.4s infinite; }
.status-pill.error { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); color: var(--red); }
.status-pill.error .d { background: var(--red); }
.status-pill.offline .d { background: var(--faint); }
.empty { color: var(--muted); padding: 18px; text-align: center; font-size: 15px; border: 1px dashed var(--line); border-radius: var(--r); }
.banner { margin: 10px 0 0; padding: 12px 14px; border-radius: 14px; background: var(--red-soft); color: var(--red); font-size: 15px; }

/* ---------- filtros ---------- */
.search { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 6px 0 14px; min-height: 50px; }
.search input { flex: 1; border: 0; background: transparent; outline: none; min-height: 48px; font-size: 17px; min-width: 0; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.tabs2 { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 10px; }
.tabs2 button { min-height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; font-size: 15px; cursor: pointer; }
.tabs2 button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.check { width: 30px; height: 30px; border-radius: 15px; border: 2px solid var(--faint); background: transparent; flex: none; display: grid; place-items: center; cursor: pointer; margin: 9px -9px; box-sizing: content-box; padding: 0; background-clip: content-box; }
.check-wrap { width: 48px; height: 48px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; flex: none; margin: -6px -4px -6px -10px; }
.check-wrap .ring { width: 26px; height: 26px; border-radius: 13px; border: 2px solid var(--faint); display: grid; place-items: center; }
.check-wrap[aria-checked="true"] .ring { background: var(--sage); border-color: var(--sage); color: #fff; }
.check-wrap svg { width: 16px; height: 16px; }
.done .title { text-decoration: line-through; color: var(--muted); }
details.more > summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 15px; padding: 12px 4px; min-height: 48px; display: flex; align-items: center; gap: 6px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; transition: transform .15s; }
details.more[open] > summary::before { transform: rotate(90deg); }

/* ---------- folha de edição ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20, 14, 10, .38); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { width: 100%; max-width: 640px; max-height: 94dvh; background: var(--surface); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .2s ease-out; }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 22px; max-height: 88dvh; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.sheet header { display: flex; align-items: center; gap: 8px; padding: 10px 10px 4px 20px; }
.sheet header h2 { flex: 1; margin: 0; font: 600 21px/1.25 var(--serif); }
.sheet .body { overflow-y: auto; padding: 6px 20px 18px; display: grid; gap: 14px; overscroll-behavior: contain; }
.sheet footer { display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface); border-radius: 0 0 22px 22px; }
.sheet footer .spacer { flex: 1; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--muted); }
.field input, .field textarea, .field select { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 10px 12px; font-size: 17px; }
.field textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.hint { font-size: 14px; color: var(--muted); line-height: 1.45; }
.syncbox { padding: 12px 14px; border-radius: 14px; font-size: 15px; display: grid; gap: 4px; }
.syncbox.synced { background: var(--sage-soft); color: var(--sage); }
.syncbox.error { background: var(--red-soft); color: var(--red); }
.syncbox.pending { background: var(--info-soft); color: var(--info); }
.syncbox.waiting { background: var(--amber-soft); color: var(--amber); }
.syncbox.none, .syncbox.past { background: var(--surface-2); color: var(--muted); }
.original { font-size: 15px; color: var(--muted); background: var(--surface-2); border-left: 3px solid var(--accent-soft); padding: 8px 12px; border-radius: 0 10px 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.checklist { display: grid; gap: 6px; }
.checklist .ck { display: flex; gap: 6px; align-items: center; }
.checklist .ck input[type="text"] { flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); padding: 8px 10px; font-size: 16px; min-width: 0; }
.checklist .ck input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--sage); flex: none; margin: 10px; }

/* ---------- toast ---------- */
.toast { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 90px); max-width: min(92vw, 520px); background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); display: flex; gap: 12px; align-items: center; animation: up .2s ease-out; }
.toast button { background: none; border: 0; color: var(--accent-soft); font-weight: 700; cursor: pointer; min-height: 40px; padding: 0 4px; }
@media (min-width: 960px) { .toast { bottom: 32px; } }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(100%, 380px); padding: 28px 24px; display: grid; gap: 16px; }
.login h1 { font: 600 30px/1.15 var(--serif); margin: 0; }
.login p { margin: 0; color: var(--muted); }
.login .error { color: var(--red); min-height: 22px; font-size: 15px; }
.logo { width: 52px; height: 52px; border-radius: 16px; }
.solo { padding: 28px; max-width: 380px; } .solo h1 { font: 600 28px/1.2 var(--serif); margin: 0 0 8px; }
.spacer-s { height: 6px; } .body-in { display: grid; gap: 14px; padding-top: 4px; }
.attention-wrap { margin-top: 14px; }
@media (max-width: 599px) {
  .capture .bar { flex-direction: column; align-items: stretch; }
  .capture .save { width: 100%; min-height: 52px; font-size: 17px; }
  .seg { flex: none; }
}
.ic { display: inline-flex; color: var(--muted); } .ic svg { width: 20px; height: 20px; } .btn .ic { color: inherit; }
