:root {
  --fundo: #f6f5fa;
  --superficie: #ffffff;
  --borda: #e7e4ef;
  --texto: #1e1a2b;
  --texto-suave: #6e6980;
  --primaria: #7c3aed;
  --primaria-escura: #5b21b6;
  --primaria-suave: #f1ebfe;
  --escuro: #16112a;
  --whatsapp: #16a34a;
  --whatsapp-escuro: #15803d;
  --perigo: #dc2626;
  --alerta: #b45309;
  --raio: 16px;
  --sombra: 0 1px 2px rgba(22, 17, 42, .05), 0 8px 24px rgba(22, 17, 42, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  line-height: 1.45;
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- topo ---------- */
.topo {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--escuro);
  color: #fff;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  box-shadow: 0 6px 24px rgba(22, 17, 42, .18);
}
.topo-faixa, .topo-ferramentas { max-width: 1180px; margin: 0 auto; }
.aviso-loja {
  max-width: 1180px; margin: 12px auto 0; padding: 10px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff;
  font-weight: 600; font-size: .92rem; line-height: 1.35;
  white-space: pre-line; overflow-wrap: anywhere;
}
.topo-faixa { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.marca { display: flex; align-items: center; gap: 12px; min-width: 0; }
.marca-icone {
  flex: none; width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #8b5cf6, #5b21b6);
}
.marca-textos { min-width: 0; }
.marca h1 {
  margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.endereco {
  margin: 0; font-size: .8rem; color: #b9b2cf;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contato {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .1); color: #fff;
  text-decoration: none; font-weight: 600; font-size: .9rem;
}
.contato:hover { background: rgba(255, 255, 255, .18); }
@media (max-width: 420px) {
  .contato span { display: none; }
  .contato { padding: 10px; }
}

.topo-ferramentas { margin-top: 12px; display: grid; gap: 10px; }
.busca {
  display: flex; align-items: center; gap: 10px;
  background: #fff; color: var(--texto-suave);
  border-radius: 12px; padding: 0 14px; height: 46px;
}
.busca input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 1rem; color: var(--texto);
}
.busca:focus-within { box-shadow: 0 0 0 3px rgba(167, 139, 250, .6); }
.categorias { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.categorias::-webkit-scrollbar { display: none; }
.chip-categoria {
  flex: none; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .2); background: transparent; color: #ddd6fe;
  padding: 7px 14px; border-radius: 999px; font-size: .88rem;
}
.chip-categoria[aria-pressed="true"] { background: #fff; color: var(--escuro); border-color: #fff; font-weight: 600; }

/* ---------- catalogo ---------- */
.conteudo { max-width: 1180px; margin: 0 auto; padding: 16px 16px 40px; }
.resumo { margin: 4px 2px 14px; color: var(--texto-suave); font-size: .9rem; }
.grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 720px) { .grade { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1024px) { .grade { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.cartao {
  display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer;
  border: 1px solid var(--borda); border-radius: var(--raio); background: var(--superficie);
  overflow: hidden; box-shadow: var(--sombra);
  transition: transform .18s ease, box-shadow .18s ease;
}
.cartao:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(22, 17, 42, .06), 0 14px 32px rgba(22, 17, 42, .1); }
.cartao:focus-visible { outline: 3px solid #a78bfa; outline-offset: 2px; }
.cartao-foto { position: relative; aspect-ratio: 3 / 4; max-width: 100%; background: var(--primaria-suave); }
.cartao-foto img { width: 100%; height: 100%; object-fit: cover; }
.cartao.esgotado .cartao-foto img, .cartao.esgotado .sem-foto { filter: grayscale(.7); opacity: .75; }
.sem-foto {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 2.6rem; font-weight: 650; color: #c4b5fd;
  background: linear-gradient(160deg, #f5f3ff, #e9e3fb);
}
.selo {
  position: absolute; top: 10px; left: 10px;
  padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: rgba(255, 255, 255, .92); color: var(--texto);
}
.selo-esgotado { background: var(--escuro); color: #fff; }
.selo-fotos { left: auto; right: 10px; }
.cartao-info { padding: 12px 14px 14px; display: grid; gap: 4px; }
.cartao-info h3 {
  margin: 0; font-size: .95rem; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.preco { margin: 0; font-weight: 700; font-size: 1.05rem; color: var(--primaria-escura); }
.cores { display: flex; align-items: center; gap: 5px; min-height: 16px; margin-top: 2px; }
.cores small {
  color: var(--texto-suave); font-size: .75rem; margin-left: 2px;
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bolinha { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .14); }

.esqueleto { border-radius: var(--raio); background: #fff; border: 1px solid var(--borda); overflow: hidden; }
.esqueleto::before {
  content: ""; display: block; aspect-ratio: 3 / 4;
  background: linear-gradient(100deg, #eeebf5 30%, #f8f6fc 50%, #eeebf5 70%);
  background-size: 200% 100%; animation: brilho 1.2s linear infinite;
}
.esqueleto::after { content: ""; display: block; height: 58px; margin: 12px 14px; border-radius: 8px; background: #f1eff6; }
@keyframes brilho { to { background-position: -200% 0; } }

.estado { text-align: center; padding: 48px 16px; color: var(--texto-suave); }
.estado h2 { color: var(--texto); font-size: 1.15rem; margin: 0 0 6px; }
.estado p { margin: 0; }
.botao {
  margin-top: 16px; border: 0; border-radius: 12px; padding: 11px 18px; cursor: pointer;
  background: var(--primaria); color: #fff; font-weight: 600;
}
.botao:hover { background: var(--primaria-escura); }

.rodape {
  text-align: center; color: var(--texto-suave); font-size: .8rem;
  padding: 0 16px max(32px, env(safe-area-inset-bottom));
}

/* ---------- detalhe da peca ---------- */
.detalhe {
  padding: 0; border: 0; width: 100%; max-width: 920px; max-height: 92vh;
  border-radius: 22px; overflow: hidden;
  background: var(--superficie); color: var(--texto);
  box-shadow: 0 30px 80px rgba(22, 17, 42, .35);
}
.detalhe::backdrop { background: rgba(22, 17, 42, .55); backdrop-filter: blur(3px); }
.detalhe[open] { animation: subir .22s ease-out; }
@keyframes subir { from { transform: translateY(24px); opacity: 0; } }
.detalhe-conteudo { display: grid; grid-template-columns: 1.05fr 1fr; max-height: 92vh; }

.galeria { position: relative; min-width: 0; background: var(--primaria-suave); }
.galeria-trilho { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.galeria-trilho::-webkit-scrollbar { display: none; }
.galeria-trilho > img, .galeria-trilho > .sem-foto {
  flex: none; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; scroll-snap-align: center;
}
.galeria-pontos { position: absolute; left: 0; right: 0; bottom: 12px; display: flex; justify-content: center; gap: 6px; }
.galeria-pontos span {
  width: 7px; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .6);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); transition: width .2s;
}
.galeria-pontos span.ativo { width: 20px; background: #fff; }

.detalhe-info { padding: 26px 26px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.detalhe-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detalhe-topo h2 { margin: 0; font-size: 1.35rem; line-height: 1.25; letter-spacing: -.01em; }
.detalhe-topo h2:focus { outline: none; }
.codigo { margin: 4px 0 0; color: var(--texto-suave); font-size: .82rem; }
.acoes-topo { display: flex; gap: 6px; flex: none; }
.botao-icone {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--borda); background: #fff; color: var(--texto);
  display: grid; place-items: center;
}
.botao-icone:hover { background: var(--fundo); }
.detalhe-preco { margin: 0; font-size: 1.6rem; font-weight: 750; color: var(--primaria-escura); }
.descricao { margin: 0; color: #4b4660; white-space: pre-line; }
.grupo h3 { margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-suave); }
.opcoes { display: flex; flex-wrap: wrap; gap: 8px; }
.opcao {
  min-width: 48px; padding: 9px 14px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--borda); background: #fff; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.opcao:hover:not(:disabled) { border-color: #c4b5fd; }
.opcao[aria-pressed="true"] { border-color: var(--primaria); background: var(--primaria-suave); color: var(--primaria-escura); }
.opcao:disabled { color: #b8b3c7; text-decoration: line-through; cursor: not-allowed; background: #faf9fc; }
.opcao:focus-visible, .botao-icone:focus-visible, .botao-whatsapp:focus-visible, .chip-categoria:focus-visible { outline: 3px solid #a78bfa; outline-offset: 2px; }
.estoque-aviso { margin: 0; min-height: 1.2em; font-size: .88rem; font-weight: 600; }
.estoque-aviso.ultimas { color: var(--alerta); }
.estoque-aviso.esgotado { color: var(--perigo); }
.botao-whatsapp {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 18px; border-radius: 14px; text-decoration: none;
  background: var(--whatsapp); color: #fff; font-weight: 700; font-size: 1.02rem;
  box-shadow: 0 8px 20px rgba(22, 163, 74, .28);
}
.botao-whatsapp:hover { background: var(--whatsapp-escuro); }
.botao-whatsapp[aria-disabled="true"] { background: #a7a3b5; box-shadow: none; pointer-events: none; }
.nota { margin: 0; text-align: center; font-size: .78rem; color: var(--texto-suave); }

@media (max-width: 719px) {
  .detalhe { margin: auto 0 0; max-width: 100%; max-height: 94vh; border-radius: 22px 22px 0 0; }
  .detalhe-conteudo { grid-template-columns: 1fr; max-height: 94vh; overflow-y: auto; }
  .detalhe-info { overflow: visible; padding: 20px 18px max(20px, env(safe-area-inset-bottom)); }
}

.aviso {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 50;
  transform: translateX(-50%); padding: 12px 18px; border-radius: 12px;
  background: var(--escuro); color: #fff; font-size: .9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

@media (prefers-reduced-motion: reduce) {
  .esqueleto::before, .detalhe[open] { animation: none; }
  .cartao, .galeria-pontos span { transition: none; }
}
