/* Sinapse v1.0.0 - estilos */
:root {
  color-scheme: light dark;
  --bg: #EEF2F6;
  --surface: #FFFFFF;
  --surface-2: #E4EAF0;
  --ink: #17212B;
  --ink-2: #4F5E6B;
  --line: #D3DCE4;
  --acc: #077A86;
  --acc-ink: #FFFFFF;
  --acc-soft: #D4EEF0;
  --warn: #9A5200;
  --warn-soft: #FBE8CC;
  --bad: #B93333;
  --bad-soft: #F8DCDC;
  --ok: #1B7F55;
  --foco: #077A86;
  --fonte-titulo: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --fonte-corpo: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --tab-h: 58px;
  --topo: env(safe-area-inset-top, 0px);
  --base: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E151B;
    --surface: #16202A;
    --surface-2: #1F2B37;
    --ink: #E8EEF3;
    --ink-2: #9DAEBB;
    --line: #2A3945;
    --acc: #43C6D1;
    --acc-ink: #06262A;
    --acc-soft: #123A40;
    --warn: #F2B441;
    --warn-soft: #3B2E12;
    --bad: #FF8A8A;
    --bad-soft: #3D1E1E;
    --ok: #55D6A0;
    --foco: #43C6D1;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--fonte-corpo);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body.travado { overflow: hidden; }
#app { min-height: 100dvh; }
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--foco); outline-offset: 2px; }
svg.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.ic.p { width: 18px; height: 18px; }

/* ---------- telas cheias: instalação e login ---------- */
.tela-cheia { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: calc(28px + var(--topo)) 22px calc(28px + var(--base)); max-width: 460px; margin: 0 auto; gap: 22px; }
.marca { display: flex; align-items: center; gap: 12px; }
.marca svg { width: 44px; height: 44px; }
.marca strong { font: 600 32px/1 var(--fonte-titulo); letter-spacing: -0.01em; }
.tela-cheia .lema { color: var(--ink-2); margin-top: -10px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label { font-weight: 600; font-size: 15px; }
.campo .dica { font-size: 14px; color: var(--ink-2); }
.campo input, .campo textarea, .campo select, .entrada {
  width: 100%; min-height: 48px; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); font-size: 16px; line-height: 1.4;
}
.campo textarea { min-height: 96px; resize: vertical; }
.campo input:focus, .campo textarea:focus, .campo select:focus, .entrada:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.senha-oculta { -webkit-text-security: disc; text-security: disc; }
.linha-senha { display: flex; gap: 8px; }
.linha-senha input { flex: 1; }
.rodape-versao { color: var(--ink-2); font-size: 13px; text-align: center; margin-top: 4px; }
.rodape-versao a { color: inherit; }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; }
.btn:active { transform: translateY(1px); }
.btn.primario { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.btn.perigo { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.fantasma { border-color: transparent; background: transparent; color: var(--acc); padding: 0 12px; }
.btn.pequeno { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn.cheio { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.icone { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; }
.icone:active { background: var(--surface-2); }

/* ---------- alertas ---------- */
.erro, .aviso-ia { border-radius: 12px; padding: 12px 14px; font-size: 15px; display: flex; gap: 10px; align-items: flex-start; }
.erro { background: var(--bad-soft); color: var(--bad); }
.erro strong { display: block; }
.erro span { color: var(--ink); }
.aviso-ia { background: var(--warn-soft); color: var(--ink); }
.aviso-ia svg { color: var(--warn); margin-top: 1px; }
.info { background: var(--acc-soft); border-radius: 12px; padding: 12px 14px; font-size: 15px; }

/* ---------- estrutura do app ---------- */
.conteudo { max-width: 640px; margin: 0 auto; padding: calc(14px + var(--topo)) 16px calc(var(--tab-h) + var(--base) + 32px); }
.topo-app { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.topo-app .marca strong { font-size: 24px; }
.topo-app .marca svg { width: 30px; height: 30px; }
.topo-app time { color: var(--ink-2); font-size: 14px; text-align: right; }
.titulo-tela { font: 600 30px/1.15 var(--fonte-titulo); letter-spacing: -0.01em; margin: 6px 0 14px; }
.secao { margin-top: 26px; }
.secao-topo { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.secao h2 { font: 600 22px/1.2 var(--fonte-titulo); }
.secao .contagem { color: var(--ink-2); font-size: 14px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line); padding-bottom: var(--base); }
.tabbar-int { display: flex; width: 100%; max-width: 640px; }
.tab { flex: 1; min-height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: transparent; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.tab[aria-current="page"] { color: var(--acc); }
.tab svg { width: 24px; height: 24px; }

/* ---------- a caixa ---------- */
.caixa { background: var(--surface); border: 1.5px solid var(--line); border-radius: 22px; padding: 14px; display: flex; flex-direction: column; gap: 10px; transition: border-color 0.15s, box-shadow 0.15s; }
.caixa:focus-within { border-color: var(--acc); box-shadow: 0 0 0 4px var(--acc-soft); }
.caixa-texto { width: 100%; border: 0; background: transparent; resize: none; outline: none; font: 400 20px/1.4 var(--fonte-titulo); min-height: 84px; max-height: 260px; padding: 2px 2px; }
.caixa-texto::placeholder { color: var(--ink-2); opacity: 0.8; }
.caixa-acoes { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; min-height: 38px; padding: 0 16px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.atalhos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.limite-ia { font-size: 14px; color: var(--ink-2); margin-top: 8px; }

/* ---------- cartões e listas ---------- */
.cartao { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.lista { display: flex; flex-direction: column; gap: 10px; }
.cartao-mem { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; }
.cartao-mem:active { background: var(--surface-2); }
.cartao-mem h3 { font: 600 18px/1.25 var(--fonte-titulo); display: flex; align-items: center; gap: 6px; }
.cartao-mem p { color: var(--ink-2); font-size: 15px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.meta .par { display: inline-flex; align-items: center; gap: 4px; }
.meta svg { width: 15px; height: 15px; }
.selo { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--acc-soft); color: var(--acc); font-weight: 600; font-size: 12px; }
.selo.aviso { background: var(--warn-soft); color: var(--warn); }
.selo.cinza { background: var(--surface-2); color: var(--ink-2); }
.vazio { text-align: center; color: var(--ink-2); padding: 26px 16px; border: 1.5px dashed var(--line); border-radius: 14px; }
.vazio strong { display: block; color: var(--ink); font: 600 18px var(--fonte-titulo); margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-size: 15px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--acc-soft); border-color: var(--acc); color: var(--acc); font-weight: 600; }
.chips.rolagem { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips.rolagem::-webkit-scrollbar { display: none; }

/* ---------- checklist ---------- */
.item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.check { flex: none; width: 28px; height: 28px; margin-top: 1px; border-radius: 9px; border: 2px solid var(--ink-2); background: transparent; display: inline-flex; align-items: center; justify-content: center; color: transparent; padding: 0; }
.check[aria-checked="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.check svg { width: 18px; height: 18px; stroke-width: 2.6; }
.item-texto { flex: 1; min-width: 0; background: transparent; border: 0; text-align: left; padding: 2px 0; }
.item.feito .item-texto span.t { text-decoration: line-through; color: var(--ink-2); }
.item-texto small { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.prazo { display: inline-block; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.prazo.atrasado { color: var(--bad); }
.prazo.hoje { color: var(--warn); }
.add-item { display: flex; gap: 8px; margin-top: 10px; }
.add-item input { flex: 1; min-height: 44px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 16px; }
.add-item input:focus { outline: none; border-color: var(--acc); }

/* ---------- resposta com fontes (a linha que liga resposta e origem) ---------- */
.resposta { background: var(--surface); border: 1.5px solid var(--acc); border-radius: 18px; padding: 16px; }
.resposta .texto { font: 400 19px/1.5 var(--fonte-titulo); white-space: pre-wrap; }
.resposta .pergunta { color: var(--ink-2); font-size: 14px; margin-bottom: 8px; }
.ref { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; margin: 0 2px; padding: 0 6px; border-radius: 999px; border: 0; background: var(--acc); color: var(--acc-ink); font: 700 12px var(--fonte-corpo); vertical-align: 2px; }
.fios { position: relative; margin: 0 0 0 22px; padding: 4px 0 0 22px; display: flex; flex-direction: column; gap: 10px; }
.fios::before { content: ""; position: absolute; left: 0; top: -1px; bottom: 26px; width: 2px; background: var(--acc); border-radius: 2px; }
.fios .no { position: relative; }
.fios .no::before { content: ""; position: absolute; left: -22px; top: 24px; width: 22px; height: 2px; background: var(--acc); }
.fios .no::after { content: ""; position: absolute; left: -28px; top: 19px; width: 12px; height: 12px; border-radius: 50%; background: var(--acc); border: 3px solid var(--bg); box-sizing: content-box; }
.fios .no .num { font-size: 12px; font-weight: 700; color: var(--acc); }
.fios.tracejado::before { background: repeating-linear-gradient(to bottom, var(--ink-2) 0 6px, transparent 6px 11px); }
.fios.tracejado .no::before { background: var(--ink-2); }
.fios.tracejado .no::after { background: var(--ink-2); }
.subtitulo { font-weight: 600; font-size: 15px; margin: 16px 0 8px; color: var(--ink-2); }

/* ---------- folhas (janelas de baixo) e páginas ---------- */
.folha-fundo { position: fixed; inset: 0; z-index: 60; background: rgba(8, 14, 20, 0.5); display: flex; align-items: flex-end; justify-content: center; }
.folha { width: 100%; max-width: 640px; max-height: 92dvh; background: var(--bg); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: sobe 0.2s ease-out; }
@keyframes sobe { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.folha-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 6px 18px; }
.folha-topo h2 { font: 600 21px/1.2 var(--fonte-titulo); }
.folha-corpo { overflow-y: auto; padding: 4px 18px calc(22px + var(--base)); display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.folha-botoes { display: flex; gap: 10px; }
.folha-botoes .btn { flex: 1; }
.pagina { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pagina-topo { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 4px; padding: calc(6px + var(--topo)) 8px 6px; background: color-mix(in srgb, var(--bg) 90%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.pagina-topo h1 { font: 600 19px/1.2 var(--fonte-titulo); }
.pagina-corpo { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(40px + var(--base)); display: flex; flex-direction: column; gap: 16px; }
.pagina h2.titulo-mem { font: 600 28px/1.2 var(--fonte-titulo); letter-spacing: -0.01em; }
.resumo-mem { border-left: 3px solid var(--acc); padding: 2px 0 2px 12px; color: var(--ink-2); font: 400 17px/1.5 var(--fonte-titulo); }
.texto-mem { white-space: pre-wrap; word-wrap: break-word; font-size: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.texto-mem.recolhido { max-height: 220px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.acoes { display: flex; flex-wrap: wrap; gap: 8px; }
.bloco-acesso { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.bloco-acesso dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.bloco-acesso dt { color: var(--ink-2); font-size: 14px; }
.bloco-acesso dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- editor de sugestões ---------- */
.editor { display: flex; flex-direction: column; gap: 16px; }
.editor .grupo > .rotulo { font-weight: 600; font-size: 15px; margin-bottom: 8px; display: block; }
.editor .pergunta-pessoa { background: var(--warn-soft); border-radius: 12px; padding: 10px 12px; font-size: 15px; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.editor .item-ed { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.editor .item-ed input[type="text"] { flex: 1 1 180px; min-height: 44px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); }
.editor .item-ed input[type="date"] { flex: 0 1 150px; min-height: 44px; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); }
.editor .prazo-ext { flex-basis: 100%; font-size: 13px; color: var(--ink-2); margin: -4px 0 0 36px; }
.proposta { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.proposta > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; }
.proposta > summary::-webkit-details-marker { display: none; }
.proposta .resumo-prop { color: var(--ink-2); font-size: 14px; margin: 2px 0 0 38px; }
.proposta .corpo-prop { margin-top: 12px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--base) + 16px); transform: translateX(-50%); z-index: 90; max-width: min(92vw, 520px); background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 15px; font-weight: 500; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); }
.toast.erro-t { background: var(--bad); color: #fff; }

.spinner { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: gira 0.7s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.carregando { display: flex; justify-content: center; padding: 40px; color: var(--ink-2); }
.pequeno-texto { font-size: 14px; color: var(--ink-2); }
.aba-vazia { min-height: 40vh; }
.lista-ajustes { display: flex; flex-direction: column; gap: 10px; }
.cartao h3 { font: 600 18px var(--fonte-titulo); margin-bottom: 6px; }
.cartao .linha { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.cartao .linha + .linha { border-top: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) { .folha, .spinner { animation: none; } * { transition: none !important; } }
@media (min-width: 700px) { .folha-fundo { align-items: center; } .folha { border-radius: 22px; } }
