/* Luzinha no celular: papel de post-it, como no computador. */
:root {
  --papel: #FFF4A3;
  --aba: #E6D36B;
  --borda: #9C8A2A;
  --tinta: #2B2B2B;
  --tinta-suave: #5E5A45;
  --fundo: #FBF6EA;
  --sombra: rgba(80, 64, 0, 0.22);
  --erro: #B3261E;
  --ok: #2E6B2F;
  --dobra: 22px;
  --raio: 8px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--fundo);
  color: var(--tinta);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Roboto", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  padding:
    calc(env(safe-area-inset-top, 0px) + 16px)
    calc(env(safe-area-inset-right, 0px) + 16px)
    calc(env(safe-area-inset-bottom, 0px) + 88px)
    calc(env(safe-area-inset-left, 0px) + 16px);
  overflow-wrap: anywhere;
}

body.com-faixa { padding-top: calc(env(safe-area-inset-top, 0px) + 60px); }

main { max-width: 34rem; margin: 0 auto; }

h1 { font-size: 1.35rem; line-height: 1.25; margin: 0 0 0.6rem; padding-right: var(--dobra); }
p { margin: 0 0 0.8rem; }

/* Cartão: papel com cantos de 8 px, sombra leve e o canto de cima dobrado. */
.cartao {
  position: relative;
  margin: 8px 0 20px;
  padding: 20px 18px 18px;
  border-radius: var(--raio) 0 var(--raio) var(--raio);
  background: linear-gradient(225deg, transparent calc(var(--dobra) * 0.7071), var(--papel) 0);
  filter: drop-shadow(0 2px 3px var(--sombra));
}
.cartao::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: var(--dobra);
  height: var(--dobra);
  border-bottom-left-radius: 4px;
  background: linear-gradient(45deg, var(--aba) 50%, transparent 0);
}

.discreto { color: var(--tinta-suave); font-size: 0.92rem; }

/* Formulários */
.formulario { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 6px; }
.formulario[hidden] { display: none; }
label { font-weight: 600; }
input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font: inherit;
  color: var(--tinta);
  background: rgba(255, 255, 255, 0.75);
  border: 1.5px solid var(--borda);
  border-radius: var(--raio);
}
input:focus-visible { outline: 3px solid var(--tinta); outline-offset: 1px; }
input[readonly] { background: transparent; border-style: dashed; }
.campo-codigo {
  font-size: 1.5rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Botões */
button {
  font: inherit;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: var(--raio);
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: 0.6; cursor: default; }
button:focus-visible { outline: 3px solid var(--tinta); outline-offset: 2px; }
button[hidden] { display: none; }
.primario { background: var(--tinta); color: var(--papel); border: 0; font-weight: 600; }
.secundario { background: transparent; color: var(--tinta); border: 1.5px solid var(--borda); }
.perigo { background: var(--erro); color: #fff; border: 0; font-weight: 600; }
.link {
  background: none;
  border: 0;
  padding: 10px 0;
  color: var(--tinta);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.botoes { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.botoes > button { flex: 1 1 auto; }

.erro { color: var(--erro); font-weight: 600; margin: 0; }
.erro[hidden] { display: none; }
.ok { color: var(--ok); margin: 6px 0 0; }

/* Instalar */
.passos { padding-left: 0; list-style: none; margin: 0 0 12px; }
.passos li { margin: 0 0 8px; }
.codigo-grande {
  margin: 14px 0 6px;
  padding: 14px 8px;
  text-align: center;
  font-size: clamp(1.5rem, 9vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.6);
  border: 2px dashed var(--borda);
  border-radius: var(--raio);
  user-select: all;
  -webkit-user-select: all;
}

/* Limite de celulares */
.aparelhos { list-style: none; margin: 12px 0; padding: 0; }
.aparelho {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 0;
  border-top: 1px dashed var(--borda);
}
.aparelho-nome { font-weight: 600; }
.pergunta { flex-basis: 100%; margin: 0; }


/* Faixa fixa no topo */
.faixa {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--tinta);
  color: var(--papel);
  font-size: 0.95rem;
  text-align: center;
}
.faixa[hidden] { display: none; }
/* Com botão ("Tentar agora"): texto e botão lado a lado; o texto quebra se precisar. */
.faixa.com-acao { display: flex; align-items: center; justify-content: center; gap: 12px; text-align: left; }
.faixa.com-acao > span { flex: 0 1 auto; }
body.com-faixa.com-faixa-acao { padding-top: calc(env(safe-area-inset-top, 0px) + 76px); }
.faixa-acao {
  flex: none;
  min-height: 44px;
  background: transparent;
  color: var(--papel);
  border: 1.5px solid var(--papel);
  font-weight: 600;
}

/* Aviso embaixo */
.aviso {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 11;
  max-width: 34rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  background: var(--tinta);
  color: var(--papel);
  border-radius: var(--raio);
  box-shadow: 0 4px 12px var(--sombra);
}
.aviso > span { flex: 1; }
.aviso-acao {
  min-height: 44px;
  background: transparent;
  color: var(--papel);
  border: 1.5px solid var(--papel);
  font-weight: 600;
}

@media (prefers-reduced-motion: no-preference) {
  .aviso { animation: subir 160ms ease-out; }
  @keyframes subir { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* ---------- Post-its (lista, post-it aberto, folhas) ---------- */

/* Papel com cor própria: a tinta vem do núcleo (clara em papel escuro, como no PC). */
.papel-proprio {
  --tinta-suave: color-mix(in srgb, var(--tinta) 70%, var(--papel));
  --borda: color-mix(in srgb, var(--tinta) 40%, var(--papel));
  --aba: color-mix(in srgb, var(--papel) 80%, #000);
  color: var(--tinta);
}
.papel-escuro { --aba: color-mix(in srgb, var(--papel) 75%, #fff); }
.papel-escuro input { background: rgba(0, 0, 0, 0.22); }

/* Topo das telas: título e botões redondos de 44 px ou mais. */
.topo { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; }
.topo h1 { flex: 1; min-width: 0; margin: 0; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icone {
  flex: none;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--tinta);
  background: transparent;
  border: 0;
  border-radius: 50%;
}
.icone:active { background: rgba(0, 0, 0, 0.08); }
.girando { animation: girar 0.9s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .girando { animation: none; opacity: 0.5; } }

/* Puxar para atualizar: a dica aparece enquanto o dedo desce. */
.dica-puxar {
  height: 0;
  margin: 0;
  overflow: hidden;
  text-align: center;
  color: var(--tinta-suave);
  font-size: 0.9rem;
  transition: height 120ms ease-out;
}
.puxando > .dica-puxar { height: 32px; }
.puxando > .dica-puxar::before { content: "↓ Puxe para atualizar"; }
.puxar-pronto > .dica-puxar::before { content: "⟳ Solte para atualizar"; }

/* Grade de cartões, 2 colunas. */
.grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.cartao.nota {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-height: 132px;
  margin: 0;
  padding: 14px 12px 12px;
  text-align: left;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.35;
  border: 0;
}
.nota-titulo { font-weight: 700; font-size: 1.02rem; padding-right: calc(var(--dobra) - 6px); }
.nota-linhas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nota-linhas li { display: flex; flex-direction: column; }
.nota-linhas .texto {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nota-linhas .due { font-size: 0.8rem; color: var(--tinta-suave); padding-left: 0.7em; }
.nota-vazia, .nota-mais { color: var(--tinta-suave); font-size: 0.85rem; }
.feita .texto { text-decoration: line-through; opacity: 0.6; }
.due.atrasada { color: var(--erro); font-weight: 600; }
.papel-escuro .due.atrasada { color: #FFB4AB; }

/* "+ post-it" fixo embaixo; o aviso sobe para não cobrir o botão. */
.acao-fixa {
  position: fixed;
  z-index: 5;
  left: calc(env(safe-area-inset-left, 0px) + 16px);
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  max-width: 34rem;
  margin: 0 auto;
  min-height: 52px;
  font-size: 1.05rem;
  border-radius: 26px;
  box-shadow: 0 4px 12px var(--sombra);
}
body.com-acao-fixa .aviso { bottom: calc(env(safe-area-inset-bottom, 0px) + 80px); }

/* Post-it aberto */
.cartao.postit { padding: 10px 8px 14px; min-height: 50vh; }
.linhas { list-style: none; margin: 0; padding: 0; }
.linha { display: flex; align-items: flex-start; border-bottom: 1px dashed var(--borda); }
.linha:last-child { border-bottom: 0; }
.vazio { padding: 14px 10px; }
.feito {
  flex: none;
  width: 48px;
  min-height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
}
.caixa {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--tinta);
  border-radius: 6px;
  color: var(--papel);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
}
.feita .caixa { background: var(--tinta); }
.linha-texto {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 8px 12px 2px;
  text-align: left;
  color: var(--tinta);
  background: transparent;
  border: 0;
  border-radius: 0;
}
.linha-texto .texto { flex: 1; min-width: 0; }
.linha-texto b { font-weight: 700; }
.quando { flex: none; display: flex; gap: 6px; align-items: baseline; font-size: 0.88rem; color: var(--tinta-suave); white-space: nowrap; }
.repete { font-size: 1rem; }

.escrever { margin: 10px 4px 0; }
.escrever-linha { display: flex; gap: 8px; }
.escrever-linha input { flex: 1; min-width: 0; }
.por { flex: none; min-width: 64px; }
.previa { margin: 6px 2px 0; font-size: 0.9rem; font-weight: 600; color: var(--tinta-suave); }
.previa:empty { display: none; }

/* Folhas que sobem de baixo */
.folha-fundo { position: fixed; inset: 0; z-index: 20; background: rgba(30, 24, 0, 0.38); }
.folha {
  position: fixed;
  z-index: 21;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 36rem;
  max-height: 88vh;
  max-height: 88dvh;
  margin: 0 auto;
  overflow-y: auto;
  padding:
    10px
    calc(env(safe-area-inset-right, 0px) + 16px)
    calc(env(safe-area-inset-bottom, 0px) + 18px)
    calc(env(safe-area-inset-left, 0px) + 16px);
  background: var(--fundo);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 18px var(--sombra);
}
.folha-topo { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.folha-topo h2 { flex: 1; margin: 0; font-size: 1.15rem; }
.folha label { display: flex; flex-direction: column; gap: 6px; }
.folha .botoes { margin-top: 12px; }
.rotulo { font-weight: 600; margin: 14px 0 6px; }
.destinos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.destinos[hidden] { display: none; }
.destinos .rotulo { grid-column: 1 / -1; margin: 10px 0 0; }
.destino {
  min-height: 48px;
  text-align: left;
  background: var(--papel);
  color: var(--tinta);
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-weight: 600;
}
.menu { display: flex; flex-direction: column; gap: 10px; }

.cores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cor {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 56px;
  padding: 6px 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  background: var(--papel);
  color: var(--tinta);
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--raio);
}
.cor[aria-pressed="true"] { border-color: var(--tinta); box-shadow: inset 0 0 0 2px var(--papel), 0 0 0 1px var(--tinta); }
.cor[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 4px; right: 8px; font-size: 1rem; }
.outra-cor {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  background: var(--fundo);
  color: var(--tinta);
  cursor: pointer;
}
.seletor-cor { min-height: 32px; padding: 0; border: 0; background: none; cursor: pointer; }
@media (prefers-reduced-motion: no-preference) {
  .folha { animation: folha-sobe 180ms ease-out; }
  @keyframes folha-sobe { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
}
.papel-proprio input::placeholder { color: var(--tinta-suave); opacity: 1; }
/* O puxar para atualizar é nosso: o Chrome não recarrega a página ao puxar. */
html, body { overscroll-behavior-y: contain; }
/* Navegador sem color-mix: cores fixas para divisória, contorno e dobra. */
@supports not (color: color-mix(in srgb, red, blue)) {
  .papel-proprio { --tinta-suave: var(--tinta); --borda: rgba(0, 0, 0, 0.3); --aba: rgba(0, 0, 0, 0.16); }
  .papel-escuro { --borda: rgba(255, 255, 255, 0.4); --aba: rgba(255, 255, 255, 0.28); }
}

/* Ajustes */
.tela-ajustes .cartao h2,
.tela-vincular-outro .cartao h2 { font-size: 1.1rem; margin: 0 0 6px; padding-right: var(--dobra); }
.tela-ajustes .aparelhos { margin: 4px 0 8px; }
.tela-ajustes .aparelho:first-child { border-top: 0; }
.tela-ajustes .aparelho .botoes { margin-top: 6px; }
.tela-ajustes .aparelho .botoes > button { flex: 1 1 0; }
.selo {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  vertical-align: 2px;
  color: var(--papel);
  background: var(--tinta);
  border-radius: 999px;
}
.email-atual { margin: 0; }
.tela-ajustes > .botoes { margin: 4px 0 12px; }
.vincular-outro { display: flex; flex-direction: column; align-items: stretch; }
.vincular-outro .qr {
  display: block;
  width: min(220px, 60vw);
  height: auto;
  aspect-ratio: 1;
  margin: 4px auto 8px;
  padding: 8px;
  background: #fff;
  border-radius: var(--raio);
}
.vincular-outro .codigo-grande { margin-top: 4px; }
.vinculado { font-size: 1.15rem; font-weight: 600; margin: 8px 0 12px; }
