/* Escala da casa. Espaço: 4, 8, 12, 16, 24. Texto: 13, 14, 15, 17, 22, 28.
   Campo de formulário sempre com 17px: abaixo de 16px o Safari do iPhone dá zoom
   ao tocar no campo e não volta sozinho. */

:root {
  --fundo: #ffffff;
  --superficie: #ffffff;
  --suave: #f5f3f0;
  --linha: #e7e2dd;
  --linha-forte: #c9c2bb;
  --texto: #1c1917;
  --texto-2: #736b64;
  --destaque: #d4450e;
  --sobre-destaque: #ffffff;
  --foco: rgb(212 69 14 / .18);
  --perigo: #d92d20;
  --perigo-fundo: rgb(217 45 32 / .08);
  --midia: #f3f0ed;
  --anel: linear-gradient(45deg, #f59f00, #f03e3e 55%, #ae3ec9);
  --vidro: rgb(255 255 255 / .86);
  --sombra: 0 8px 32px rgb(28 25 23 / .16);
  --raio: 12px;
  --topo: 52px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #000000;
    --superficie: #141312;
    --suave: #211f1d;
    --linha: #2b2825;
    --linha-forte: #4a4541;
    --texto: #f5f2ef;
    --texto-2: #a8a099;
    --destaque: #ff8a3d;
    --sobre-destaque: #2a1204;
    --foco: rgb(255 138 61 / .24);
    --perigo: #ff6b5e;
    --perigo-fundo: rgb(255 107 94 / .12);
    --midia: #0f0e0d;
    --vidro: rgb(0 0 0 / .78);
    --sombra: 0 8px 32px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
img, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--destaque); outline-offset: 2px; }

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ------------------------------------------------ botões e campos */

.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 24px;
  border: 0; border-radius: var(--raio);
  background: var(--destaque); color: var(--sobre-destaque);
  font-size: 17px; font-weight: 600; letter-spacing: -.01em;
  transition: opacity .15s, transform .15s;
}
.botao:active:not(:disabled) { opacity: .85; transform: scale(.985); }
.botao:disabled { opacity: .45; cursor: default; }
.botao.secundario { background: var(--suave); color: var(--texto); }
.botao.perigo { background: transparent; color: var(--perigo); }
.botao.largo { width: 100%; }

.icone-botao {
  flex: none;
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: transparent;
  transition: background-color .15s;
}
.icone-botao:active { background: var(--suave); }
.icone-botao svg { width: 26px; height: 26px; }

.campo { display: grid; gap: 6px; margin-bottom: 16px; }
.campo > span { font-size: 13px; font-weight: 600; color: var(--texto-2); }
.campo input, .campo textarea {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1px solid transparent; border-radius: var(--raio);
  background: var(--suave); outline: none;
  font-size: 17px;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.campo input:focus, .campo textarea:focus {
  border-color: var(--destaque);
  box-shadow: 0 0 0 3px var(--foco);
}
.campo textarea { display: block; min-height: 96px; line-height: 1.35; resize: none; }
.campo input::placeholder, .campo textarea::placeholder { color: var(--texto-2); opacity: 1; }
/* No iPhone, data vazia encolhe o campo e o valor vem centralizado. */
.campo input[type="date"] { display: block; }
.campo input::-webkit-date-and-time-value { text-align: left; }
.campo small { font-size: 13px; line-height: 1.35; color: var(--texto-2); }

.marcar { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; margin-bottom: 16px; }
.marcar input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--destaque); }

.erro {
  margin: 0 0 16px; padding: 10px 12px;
  border-radius: 10px; background: var(--perigo-fundo);
  color: var(--perigo); font-size: 14px; line-height: 1.35;
}

/* ------------------------------------------------ entrada */

/* O #app já reserva a safe area de baixo; descontá-la aqui deixa a tela sem
   rolagem e a assinatura acima da barra de início do iPhone. */
.entrada {
  min-height: calc(100dvh - env(safe-area-inset-bottom));
  display: grid; grid-template-rows: auto auto 1fr; justify-content: center; gap: 32px;
  padding: calc(env(safe-area-inset-top) + 12dvh) 24px 16px;
  text-align: center;
}
.entrada .assinatura { align-self: end; margin: 0; font-size: 13px; color: var(--texto-2); }
.entrada img { width: 80px; height: 80px; margin: 0 auto 16px; border-radius: 18px; }
.entrada .marca { display: block; width: 112px; height: auto; margin: 0 auto 20px; color: var(--texto); }
.entrada h1 { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.entrada p { margin: 4px 0 0; color: var(--texto-2); }
.entrada form { width: min(342px, calc(100vw - 48px)); text-align: left; }
.entrada .erro { margin: 0 0 16px; color: var(--perigo); }

/* ------------------------------------------------ topo */

.topo {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 2px;
  height: calc(env(safe-area-inset-top) + var(--topo));
  padding: env(safe-area-inset-top) 6px 0 16px;
  background: var(--vidro);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--linha);
}
.topo h1 {
  flex: 1; min-width: 0; margin: 0;
  font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ------------------------------------------------ perfil */

.perfil { padding: 16px 16px 8px; }
.perfil-linha { display: flex; align-items: center; gap: 24px; }

.avatar {
  flex: none; position: relative;
  width: 88px; height: 88px; border-radius: 50%;
  padding: 2.5px; background: var(--anel);
}
.avatar > * {
  width: 100%; height: 100%; border-radius: 50%;
  border: 3px solid var(--fundo); background: var(--suave);
  object-fit: cover;
  display: grid; place-items: center;
  font-size: 34px; font-weight: 600; color: var(--texto-2);
}
.avatar.pequeno { width: 36px; height: 36px; padding: 2px; }
.avatar.pequeno > * { border-width: 2px; font-size: 13px; }

.numeros { flex: 1; display: flex; justify-content: space-around; text-align: center; }
.numeros b { display: block; font-size: 17px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.numeros span { font-size: 13px; color: var(--texto-2); }

.perfil-nome { margin: 12px 0 0; font-weight: 600; }
.perfil-idade { margin: 2px 0 0; font-size: 14px; color: var(--texto-2); }

.abas {
  display: flex; margin-top: 12px;
  border-top: .5px solid var(--linha);
}
.abas button {
  flex: 1; display: grid; place-items: center;
  min-height: 46px; padding: 0; border: 0; background: transparent;
  color: var(--texto-2);
  box-shadow: inset 0 0 0 transparent;
  transition: color .15s, box-shadow .15s;
}
.abas button[aria-selected="true"] { color: var(--texto); box-shadow: inset 0 1.5px 0 var(--texto); }
.abas svg { width: 24px; height: 24px; }

/* ------------------------------------------------ grade */

.mes {
  position: sticky; top: calc(env(safe-area-inset-top) + var(--topo)); z-index: 2;
  padding: 12px 16px 8px; margin: 0;
  font-size: 15px; font-weight: 600; letter-spacing: -.01em;
  background: var(--vidro);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.mes span { font-size: 14px; color: var(--texto-2); font-weight: 400; letter-spacing: 0; }

.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.grade button {
  position: relative; aspect-ratio: 1; padding: 0; border: 0;
  background: var(--midia); overflow: hidden;
}
.grade img { width: 100%; height: 100%; object-fit: cover; transition: opacity .15s; }
.grade button:active img { opacity: .8; }
.grade .selo {
  position: absolute; top: 6px; right: 6px;
  width: 20px; height: 20px; color: #fff;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / .55));
}

/* ------------------------------------------------ post */

.post { border-bottom: .5px solid var(--linha); padding-bottom: 16px; }
.post-topo { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 6px 6px 16px; }
.post-topo .quem { flex: 1; min-width: 0; line-height: 1.25; }
.post-topo .quem b { display: block; font-size: 15px; font-weight: 600; }
.post-topo .quem small { color: var(--texto-2); font-size: 13px; }

.carrossel {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; background: var(--midia);
  overscroll-behavior-x: contain;
}
.carrossel::-webkit-scrollbar { display: none; }
.carrossel > * {
  flex: 0 0 100%; scroll-snap-align: center;
  display: grid; place-items: center; overflow: hidden;
}
.carrossel img, .carrossel video { width: 100%; height: 100%; object-fit: contain; }
.carrossel img { cursor: zoom-in; }

.pontos { display: flex; justify-content: center; gap: 5px; padding-top: 12px; }
.pontos i { width: 6px; height: 6px; border-radius: 50%; background: var(--linha-forte); transition: background-color .15s; }
.pontos i.ativo { background: var(--destaque); }

.legenda { margin: 12px 16px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.data-post { margin: 4px 16px 0; font-size: 13px; color: var(--texto-2); }
.pontos + .data-post, .carrossel + .data-post { margin-top: 12px; }

.sem-previa {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  color: var(--texto-2); font-size: 13px;
}
.sem-previa svg { width: 32px; height: 32px; }

/* ------------------------------------------------ vazio e avisos */

.vazio { padding: 48px 32px; text-align: center; color: var(--texto-2); }
#app > .vazio { padding-top: calc(env(safe-area-inset-top) + 24dvh); }
.vazio svg {
  display: block; width: 88px; height: 88px; margin: 0 auto 16px; padding: 22px;
  border-radius: 50%; background: var(--suave); color: var(--destaque);
}
.vazio h2 { margin: 0 0 8px; color: var(--texto); font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.vazio p { max-width: 310px; margin: 0 auto 24px; }

.carregando {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 24px; color: var(--texto-2); font-size: 14px;
}
.carregando::before {
  content: ""; flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--linha); border-top-color: var(--texto-2);
  animation: gira .8s linear infinite;
}
.carregando:empty { padding: 0; }
.carregando:empty::before { display: none; }

.aviso {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translateX(-50%); z-index: 50;
  width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 16px; border-radius: var(--raio);
  background: var(--texto); color: var(--fundo);
  box-shadow: var(--sombra); font-size: 14px; font-weight: 500; text-align: center;
  animation: aviso-sobe .2s ease-out;
}

/* ------------------------------------------------ folhas (modais de baixo) */

.veu {
  position: fixed; inset: 0; z-index: 20;
  background: rgb(0 0 0 / .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: aparece .15s ease-out;
}
.folha {
  width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--superficie);
  border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 16px);
  box-shadow: var(--sombra);
  animation: sobe .22s cubic-bezier(.2, .8, .3, 1);
}
.folha-topo { display: flex; align-items: center; gap: 8px; margin: 0 -8px 8px 0; }
.folha-topo h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.folha-topo .icone-botao svg { width: 22px; height: 22px; color: var(--texto-2); }
.folha-puxador { width: 36px; height: 5px; border-radius: 3px; background: var(--linha); margin: 0 auto 8px; }

@media (min-width: 700px) {
  .veu { align-items: center; }
  .folha { border-radius: 16px; padding-bottom: 16px; }
}

.menu { display: grid; }
.menu button {
  min-height: 52px; padding: 12px 16px;
  border: 0; border-top: .5px solid var(--linha);
  background: var(--suave); font-size: 17px; text-align: center;
  transition: opacity .15s;
}
.menu button:active { opacity: .6; }
.menu button:first-child { border-top: 0; border-radius: var(--raio) var(--raio) 0 0; }
.menu button:nth-last-child(2) { border-radius: 0 0 var(--raio) var(--raio); }
.menu button.perigo { color: var(--perigo); }
.menu button:last-child { margin-top: 8px; border: 0; border-radius: var(--raio); font-weight: 600; }

/* escolhidas para postar */
.escolhidas {
  display: flex; gap: 8px; overflow-x: auto;
  margin: 0 -16px 16px; padding: 0 16px;
  scrollbar-width: none;
}
.escolhidas::-webkit-scrollbar { display: none; }
.escolhida {
  position: relative; flex: none;
  width: 92px; height: 92px; border-radius: var(--raio); overflow: hidden;
  background: var(--suave);
}
button.escolhida, label.escolhida {
  padding: 0; border: 1.5px dashed var(--linha-forte);
  background: transparent; color: var(--texto-2);
}
label.escolhida { display: grid; place-items: center; }
.escolhida img { width: 100%; height: 100%; object-fit: cover; }
.escolhida .selo { position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; color: #fff; filter: drop-shadow(0 1px 2px rgb(0 0 0 / .6)); }
.escolhida small {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 12px 6px 4px; font-size: 11px; font-weight: 500; color: #fff;
  background: linear-gradient(transparent, rgb(0 0 0 / .6));
  pointer-events: none;
}
/* O círculo é de 22px, mas a área de toque é de 44px. */
.escolhida .tirar {
  position: absolute; top: 0; left: 0;
  width: 44px; height: 44px; padding: 5px; border: 0;
  display: block; background: transparent; color: #fff;
  font-size: 0;
}
.escolhida .tirar::before {
  content: "×"; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgb(0 0 0 / .6);
  font-size: 15px; line-height: 1;
}

/* Botão de escolher fotos: o <input type=file> cobre o botão, transparente, e é
   o que o dedo toca de fato — assim o 'change' dispara no Safari do iPhone. */
.rotulo-arquivo { position: relative; cursor: pointer; }
.rotulo-arquivo:focus-within { outline: 2px solid var(--destaque); outline-offset: 2px; }
.entrada-arquivo {
  position: absolute; inset: 0;
  width: 100%; height: 100%; margin: 0; padding: 0;
  border: 0; opacity: 0; cursor: pointer;
  font-size: 16px; /* evita o zoom automático do iOS ao focar */
}

.progresso { height: 6px; border-radius: 3px; background: var(--suave); overflow: hidden; margin-bottom: 8px; }
.progresso i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--destaque); transition: width .2s; }
.progresso-texto { font-size: 13px; color: var(--texto-2); margin: 0 0 16px; font-variant-numeric: tabular-nums; }

.folha .perfil-nome { margin: 24px 0 4px; font-size: 13px; font-weight: 600; color: var(--texto-2); }
.lista-numeros { display: grid; grid-template-columns: 1fr auto; margin: 0 0 12px; font-size: 15px; }
.lista-numeros dt, .lista-numeros dd { padding: 11px 0; border-top: .5px solid var(--linha); }
.lista-numeros dt:first-of-type, .lista-numeros dd:first-of-type { border-top: 0; }
.lista-numeros dt { color: var(--texto-2); }
.lista-numeros dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ tela cheia */

.tela-cheia {
  position: fixed; inset: 0; z-index: 30;
  background: #000;
  display: grid; place-items: center;
  animation: aparece .18s ease-out;
}
.tela-cheia img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.tela-cheia .icone-botao {
  position: absolute; top: calc(env(safe-area-inset-top) + 8px); right: 12px;
  color: #fff; background: rgb(255 255 255 / .16);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.tela-cheia .icone-botao svg { width: 22px; height: 22px; }
.tela-cheia .icone-botao:active { background: rgb(255 255 255 / .28); }

/* ------------------------------------------------ post aberto */

.pagina-post { min-height: 100dvh; }
.pagina-post .topo { padding-left: 6px; }
.pagina-post .topo h1 { padding-right: 46px; font-size: 17px; font-weight: 600; letter-spacing: -.01em; text-align: center; }

/* ------------------------------------------------ abertura */

/* Enquanto a câmera abre, o conteúdo da entrada espera para surgir depois. */
.app-abrindo .entrada > div,
.app-abrindo .entrada > form,
.app-abrindo .entrada > .assinatura { opacity: 0; transform: translateY(10px); }
.entrada > div,
.entrada > form,
.entrada > .assinatura { transition: opacity .45s ease, transform .45s ease; }
.entrada > form { transition-delay: .06s; }
.entrada > .assinatura { transition-delay: .12s; }

.abertura {
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
  display: grid; place-items: center;
  background: var(--fundo); color: var(--texto);
  animation: abre-veu 1.15s ease both;
}
.abertura-palco { position: relative; width: 128px; height: 128px; }
.abertura .marca {
  width: 128px; height: 128px; margin: 0; color: var(--texto);
  animation: abre-camera 1.15s cubic-bezier(.2, .7, .25, 1) both;
}
/* Anel que fecha sobre a lente: o "foco". */
.abertura-foco {
  position: absolute; left: 60%; top: 63%;
  width: 49px; height: 49px; border-radius: 50%;
  border: 2.5px solid currentColor; opacity: 0;
  pointer-events: none;
  animation: abre-foco 1.15s ease-out both;
}
/* Flash discreto, do centro da câmera para fora. */
.abertura-flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 52%, rgb(255 255 255 / .85), transparent 55%);
  animation: abre-flash 1.15s ease-out both;
}

@keyframes abre-veu { 0%, 76% { opacity: 1; } 100% { opacity: 0; } }
@keyframes abre-camera {
  0%   { opacity: 0; transform: scale(.78); }
  34%  { opacity: 1; transform: scale(1.03); }
  48%  { transform: scale(1); }
  76%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.05); }
}
@keyframes abre-foco {
  0%, 24% { opacity: 0; transform: translate(-50%, -50%) scale(2.1); }
  40%     { opacity: .85; transform: translate(-50%, -50%) scale(1.45); }
  64%     { opacity: 0; transform: translate(-50%, -50%) scale(1); }
  100%    { opacity: 0; }
}
@keyframes abre-flash { 0%, 52% { opacity: 0; } 60% { opacity: .6; } 74%, 100% { opacity: 0; } }

@keyframes aparece { from { opacity: 0; } }
@keyframes sobe { from { transform: translateY(48px); opacity: 0; } }
@keyframes aviso-sobe { from { transform: translate(-50%, 8px); opacity: 0; } }
@keyframes gira { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
