/* =====================================================================
   Estilo do Caderno.

   Feito para celular e tablet primeiro: o computador e o caso raro aqui,
   nao o contrario. Por isso as medidas base sao as do celular, e o que
   muda em tela grande vem depois, no unico bloco @media do arquivo.

   Duas regras que valem para tudo:
   - alvo de toque nunca menor que 44px de altura;
   - campo de texto com fonte de 16px, senao o iPhone da zoom sozinho ao
     tocar no campo e a pessoa perde o lugar da tela.
   ===================================================================== */

:root {
  --roxo: #6d5efc;
  --roxo-escuro: #5a4be0;
  --fundo: #f6f6fb;
  --carta: #ffffff;
  --texto: #1c1c28;
  --apagado: #6b6b7b;
  --linha: #e4e4ee;
  --perigo: #d64545;
  --ok: #1f9254;
  --raio: 14px;
  --sombra: 0 2px 10px rgba(28, 28, 40, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #14141c;
    --carta: #1e1e29;
    --texto: #f0f0f5;
    --apagado: #9a9aae;
    --linha: #2e2e3d;
    --sombra: 0 2px 10px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  padding-bottom: env(safe-area-inset-bottom);
}

.muted { color: var(--apagado); }
.erro { color: var(--perigo); font-size: 14px; min-height: 20px; margin: 8px 0 0; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- entrada */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login__cartao {
  width: 100%; max-width: 380px; background: var(--carta);
  border-radius: 20px; padding: 28px 22px 24px; box-shadow: var(--sombra);
}
.login__marca { font-size: 44px; text-align: center; }
.login__cartao h1 { margin: 6px 0 2px; text-align: center; font-size: 26px; }
.login__cartao p { margin: 0 0 22px; text-align: center; font-size: 14px; }
.login__cartao label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }

input, textarea, select {
  width: 100%; font: inherit; font-size: 16px;
  padding: 12px 14px; border: 1px solid var(--linha); border-radius: 12px;
  background: var(--fundo); color: var(--texto);
}
input:focus, textarea:focus {
  outline: none; border-color: var(--roxo);
  box-shadow: 0 0 0 3px rgba(109, 94, 252, .18);
}

/* -------------------------------------------------------------- botoes */
.botao {
  font: inherit; font-size: 15px; font-weight: 600;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--linha); border-radius: 12px;
  background: var(--carta); color: var(--texto); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.botao:active { transform: scale(.98); }
.botao--principal { background: var(--roxo); border-color: var(--roxo); color: #fff; }
.botao--principal:active { background: var(--roxo-escuro); }
.botao--perigo { color: var(--perigo); border-color: rgba(214, 69, 69, .35); }
.botao--largo { width: 100%; margin-top: 20px; }
.botao[disabled] { opacity: .5; cursor: default; }

/* ---------------------------------------------------------------- topo */
.topo {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--carta); border-bottom: 1px solid var(--linha);
}
.topo__titulo {
  flex: 1; margin: 0; font-size: 18px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topo__voltar, .topo__acao {
  min-width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: var(--texto); font-size: 26px; line-height: 1;
  cursor: pointer;
}
.topo__acao { font-size: 22px; }

.busca { padding: 12px 14px 4px; }
.busca input { border-radius: 999px; }

.conteudo { padding: 12px 14px 96px; max-width: 900px; margin: 0 auto; }

/* --------------------------------------------------------------- listas */
.lista { display: flex; flex-direction: column; gap: 10px; }

.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--carta); border-radius: var(--raio);
  padding: 14px; box-shadow: var(--sombra); cursor: pointer;
  border-left: 4px solid var(--roxo);
}
.item__corpo { flex: 1; min-width: 0; }
.item__corpo strong { display: block; font-size: 16px; }
.item__corpo span {
  display: block; color: var(--apagado); font-size: 13px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item__menu {
  border: 0; background: transparent; color: var(--apagado);
  font-size: 20px; min-width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
}

.vazio {
  text-align: center; padding: 48px 20px; color: var(--apagado);
}
.vazio__icone { font-size: 42px; display: block; margin-bottom: 10px; }

/* --------------------------------------------------------------- editor */
.editor__titulo {
  border: 0; background: transparent; padding: 4px 0 10px;
  font-size: 22px; font-weight: 700;
}
.editor__titulo:focus { box-shadow: none; }

/* A barra QUEBRA em duas linhas em vez de rolar de lado. Rolando, o
   ultimo botao fica escondido fora da tela e ninguem descobre que ele
   existe -- ja aconteceu duas vezes aqui. */
.barra {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 10px;
  position: sticky; top: 0; background: var(--fundo); z-index: 5;
}
.barra button {
  min-width: 40px; height: 38px; border-radius: 10px;
  border: 1px solid var(--linha); background: var(--carta);
  color: var(--texto); font-size: 15px; cursor: pointer; flex: 0 0 auto;
}

.folha {
  background: var(--carta); border-radius: var(--raio); box-shadow: var(--sombra);
  padding: 16px; min-height: 45vh; font-size: 16px; line-height: 1.65;
}
.folha:focus { outline: none; box-shadow: var(--sombra), 0 0 0 2px rgba(109, 94, 252, .25); }
.folha h1, .folha h2, .folha h3 { line-height: 1.3; }
.folha ul, .folha ol { padding-left: 22px; }
.folha blockquote {
  margin: 12px 0; padding: 4px 0 4px 14px;
  border-left: 3px solid var(--linha); color: var(--apagado);
}
.folha a { color: var(--roxo); }


.folha img { max-width: 100%; height: auto; border-radius: 10px; margin: 8px 0; }

/* Marca-texto. No modo escuro o amarelo puro cega, entao fica translucido. */
.marca { background: #fff3a3; color: #1c1c28; border-radius: 3px; padding: 0 2px; }
.marca:empty { display: none; }
.folha .marca:has(> br:only-child) { background: none; padding: 0; }
@media (prefers-color-scheme: dark) {
  .marca { background: rgba(255, 224, 89, .35); color: inherit; }
}
.barra .marca { padding: 0 4px; }

/* Lista de tarefas. A caixinha e desenhada pelo CSS, e nao um <input>:
   input dentro de campo editavel briga com o cursor e some ao copiar o
   texto. O estado real mora no atributo data-feito do <li>, que sobrevive
   ao salvar. */
.folha .tarefas { list-style: none; padding-left: 0; }
.folha .tarefas > li {
  position: relative; padding-left: 34px; margin: 6px 0; min-height: 24px;
}
.folha .tarefas > li::before {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 20px; height: 20px; border: 2px solid var(--linha);
  border-radius: 6px; background: var(--fundo);
}
.folha .tarefas > li[data-feito="1"]::before {
  background: var(--roxo); border-color: var(--roxo);
}
.folha .tarefas > li[data-feito="1"]::after {
  content: ''; position: absolute; left: 9px; top: 5px;
  width: 6px; height: 11px; border: solid #fff;
  border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.folha .tarefas > li[data-feito="1"] { color: var(--apagado); text-decoration: line-through; }

.estado { font-size: 13px; color: var(--apagado); padding: 8px 2px; min-height: 22px; }

.anexos { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.anexo {
  display: flex; align-items: center; gap: 10px;
  background: var(--carta); border-radius: 12px; padding: 10px 12px;
  box-shadow: var(--sombra); font-size: 14px;
}
.anexo a { color: var(--texto); text-decoration: none; flex: 1; min-width: 0;
           white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ fab */
.fab {
  position: fixed; right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--roxo); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: 0 6px 18px rgba(109, 94, 252, .45); cursor: pointer; z-index: 30;
}
.fab:active { background: var(--roxo-escuro); }

/* ---------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 10, 18, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal__caixa {
  background: var(--carta); width: 100%; max-width: 440px;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
.modal__caixa h2 { margin: 0 0 14px; font-size: 19px; }
.modal__caixa label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.modal__acoes { display: flex; gap: 10px; margin-top: 18px; }
.modal__acoes .botao { flex: 1; }

/* ---------------------------------------------------------------- aviso */
.aviso {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 90;
  background: #24243a; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; max-width: 90vw; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.aviso--erro { background: var(--perigo); }

/* ------------------------------------------------------- telas grandes */
@media (min-width: 820px) {
  .conteudo { padding: 20px 24px 120px; }
  .topo { padding: 14px 24px; }
  .busca { padding: 16px 24px 0; max-width: 900px; margin: 0 auto; }
  .modal { align-items: center; }
  .modal__caixa { border-radius: 20px; padding-bottom: 20px; }
  .folha { padding: 26px 30px; min-height: 55vh; }
}
