/* Construtor da página inicial e Aparência (Fase 3, etapa 1 — 02/12/2026). Só tokens --p-* do painel (docs/FASE-2.md §2). */
/* o formato do botão escolhido em Aparência vale só no site: no painel, os botões continuam como sempre */
body.modo-painel { --raio-botao: 999px; }

.cst-abas { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 16px; padding: 4px; width: fit-content; max-width: 100%; border-radius: 99px; background: var(--p-cartao); border: 1px solid var(--p-linha); }
.cst-abas a { padding: 8px 18px; border-radius: 99px; font: 600 14px var(--p-fonte); color: var(--p-suave); text-decoration: none; white-space: nowrap; }
.cst-abas a:hover { color: var(--p-texto); }
.cst-abas a.ativo { background: var(--p-escuro); color: var(--p-verde-claro); }
.cst-raiz { --cst-alto: calc(100vh - 150px); color: var(--p-texto); }
.cst-carregando { min-height: 260px; background: none; }
.cst-carregando p { color: var(--p-suave); }

/* barra: desfazer, status, histórico, descartar, publicar */
.cst-barra { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 0; margin-bottom: 6px; background: color-mix(in srgb, var(--p-fundo) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cst-barra-esq, .cst-barra-dir { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cst-status { font: 500 13px var(--p-fonte); color: var(--p-suave); margin-left: 4px; }
.cst-status.ok::before { content: '✓ '; color: var(--p-verde); font-weight: 700; }
.cst-status.erro { color: var(--p-perigo); }
body.modo-painel .cst-raiz .botao.cst-bt { height: 40px; padding: 0 16px; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.cst-bt svg { width: 17px; height: 17px; }
.cst-aviso { margin: 0 0 14px; padding: 11px 14px; border-radius: 12px; background: #FFF6E5; border: 1px solid #F3DDAE; color: #6B4B0E; font: 500 13.5px/1.45 var(--p-fonte); }
.cst-aviso b { font-weight: 600; }

/* botões de ícone */
.cst-ib { width: 34px; height: 34px; flex: none; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--p-linha); background: var(--p-cartao); color: var(--p-texto); cursor: pointer; padding: 0; transition: border-color .2s, background-color .2s, color .2s; }
.cst-ib svg { width: 17px; height: 17px; }
.cst-ib:hover:not(:disabled) { border-color: var(--p-verde); }
.cst-ib:disabled { opacity: .35; cursor: default; }
.cst-ib.on { background: var(--p-escuro); color: var(--p-verde-claro); border-color: var(--p-escuro); }
.cst-ib.cst-perigo:hover:not(:disabled) { border-color: var(--p-perigo); color: var(--p-perigo); }

/* grade: lista à esquerda, prévia à direita */
.cst-grade { display: grid; grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); gap: 22px; align-items: start; }
.cst-ver { display: none; }
.cst-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cst-card { display: grid; grid-template-columns: auto auto minmax(0, 1fr); grid-template-areas: 'alca ico txt' 'acoes acoes acoes'; align-items: center; gap: 4px 10px; padding: 10px 12px; background: var(--p-cartao); border: 1px solid var(--p-linha); border-radius: 14px; transition: border-color .2s, box-shadow .2s, opacity .2s; }
.cst-card:hover { border-color: #D2D2D7; }
.cst-card.sel { border-color: var(--p-verde); box-shadow: 0 0 0 3px var(--p-verde-claro); }
.cst-card.arrastando { opacity: .4; }
.cst-card.alvo-antes { box-shadow: 0 -3px 0 0 var(--p-verde); }
.cst-card.alvo-depois { box-shadow: 0 3px 0 0 var(--p-verde); }
.cst-alca { grid-area: alca; color: #AEAEB2; cursor: grab; display: grid; place-items: center; }
.cst-alca svg { width: 16px; height: 16px; }
.cst-ico { grid-area: ico; width: 36px; height: 36px; border-radius: 10px; background: var(--p-verde-claro); color: var(--p-verde-forte); display: grid; place-items: center; flex: none; }
.cst-ico svg { width: 19px; height: 19px; }
.cst-card-txt { grid-area: txt; min-width: 0; text-align: left; background: none; border: 0; padding: 2px 0; cursor: pointer; color: inherit; font: inherit; }
.cst-card-txt b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font: 600 14.5px/1.3 var(--p-fonte); letter-spacing: -.01em; }
.cst-card-txt small { display: block; margin-top: 2px; font: 400 12.5px/1.35 var(--p-fonte); color: var(--p-suave); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cst-card.desligada .cst-ico, .cst-card.desligada .cst-card-txt { opacity: .5; }
.cst-card-acoes { grid-area: acoes; display: flex; align-items: center; gap: 6px; padding-top: 6px; margin-top: 4px; border-top: 1px solid #F0F0F3; }
.cst-card-acoes .cst-chave { margin-left: auto; }
body.modo-painel .cst-raiz .botao.cst-editar-bt { height: 34px; padding: 0 14px; font-size: 13.5px; }
.cst-selo { font: 600 10.5px/1 var(--p-fonte); font-style: normal; letter-spacing: .02em; padding: 4px 7px; border-radius: 99px; background: #F1F1F3; color: var(--p-suave); white-space: nowrap; }
.cst-selo.verde { background: var(--p-verde-claro); color: var(--p-verde-forte); }

/* interruptor liga/desliga */
.cst-chave { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; cursor: pointer; }
.cst-chave input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.cst-chave span { position: absolute; inset: 0; border-radius: 99px; background: #D1D1D6; transition: background-color .2s; }
.cst-chave span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.cst-chave input:checked + span { background: var(--p-verde); }
.cst-chave input:checked + span::after { transform: translateX(18px); }
.cst-chave input:focus-visible + span { outline: 2px solid var(--p-verde); outline-offset: 2px; }

.cst-add-linha { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.cst-add-linha small { color: var(--p-suave); font-size: 12.5px; }

/* prévia */
.cst-previa-col { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 10px; height: var(--cst-alto); min-height: 480px; }
.cst-previa-barra { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cst-abrir { display: inline-flex; align-items: center; gap: 6px; font: 500 13px var(--p-fonte); color: var(--p-suave); text-decoration: none; }
.cst-abrir:hover { color: var(--p-texto); }
.cst-abrir svg { width: 15px; height: 15px; }
.cst-previa-caixa { position: relative; flex: 1; min-height: 0; overflow: hidden; border-radius: 16px; border: 1px solid var(--p-linha); background: #fff; box-shadow: 0 18px 40px -30px rgba(0, 0, 0, .4); }
.cst-previa-caixa.celular { flex: none; align-self: center; width: 410px; max-width: 100%; height: min(820px, 100%); border: 10px solid #111; border-radius: 36px; }
.cst-previa-escala { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.cst-previa-escala iframe { display: block; border: 0; background: #fff; }

/* botões de escolha (segmentado) */
.cst-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 12px; background: #EDEDF0; }
.cst-seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 7px 12px; border-radius: 9px; font: 600 13px var(--p-fonte); color: var(--p-suave); cursor: pointer; }
.cst-seg button svg { width: 16px; height: 16px; }
.cst-seg button[aria-pressed="true"] { background: var(--p-cartao); color: var(--p-texto); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.cst-seg button small { font-weight: 400; color: var(--p-suave); }

/* gaveta de edição */
.cst-gaveta { position: fixed; top: 0; right: 0; bottom: 0; z-index: 60; width: min(460px, 100vw); display: flex; flex-direction: column; background: var(--p-cartao); border-left: 1px solid var(--p-linha); box-shadow: -24px 0 60px -30px rgba(0, 0, 0, .35); animation: cst-entra .22s ease-out; }
.cst-gaveta[hidden] { display: none; }
@keyframes cst-entra { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
/* computador largo: a gaveta abre por cima da LISTA, ao lado do menu, e a prévia continua à vista */
@media (min-width: 1101px) {
  .cst-gaveta { right: auto; left: 250px; width: 470px; border-left: 0; border-right: 1px solid var(--p-linha); box-shadow: 24px 0 60px -30px rgba(0, 0, 0, .35); animation-name: cst-entra-esq; }
}
@keyframes cst-entra-esq { from { transform: translateX(-30px); opacity: 0; } to { transform: none; opacity: 1; } }
.cst-gaveta-topo { display: flex; gap: 12px; align-items: flex-start; padding: 18px 20px 14px; border-bottom: 1px solid var(--p-linha); }
.cst-gaveta-topo > div { flex: 1; min-width: 0; }
.cst-gaveta-topo h2 { margin: 0; font: 600 17px/1.25 var(--p-fonte); letter-spacing: -.02em; }
.cst-gaveta-topo p { margin: 3px 0 0; font: 400 13px/1.4 var(--p-fonte); color: var(--p-suave); }
.cst-gaveta-corpo { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px 24px; display: grid; gap: 14px; align-content: start; }
.cst-gaveta-corpo .pn-campo { margin: 0; }
.cst-gaveta-corpo textarea { resize: vertical; }
.cst-gaveta-pe { padding: 12px 20px; border-top: 1px solid var(--p-linha); display: flex; justify-content: flex-end; }
.cst-gaveta-extra { display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid var(--p-linha); }
.cst-nota { margin: 0; padding: 10px 12px; border-radius: 10px; background: #F5F5F7; font: 400 13px/1.45 var(--p-fonte); color: var(--p-suave); }
.cst-nota a, .cst-link { color: var(--p-verde-forte); font-weight: 600; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.cst-ligado { margin: -8px 0 0; font: 500 12px/1.4 var(--p-fonte); color: var(--p-verde-forte); }
.cst-erro-campo { display: block; font: 500 12.5px/1.4 var(--p-fonte); font-style: normal; color: var(--p-perigo); margin-top: 4px; }
.cst-erro-campo[hidden] { display: none; }
.cst-raiz [aria-invalid="true"] { border-color: var(--p-perigo) !important; }
.cst-check { display: flex; align-items: flex-start; gap: 10px; font: 500 14px/1.4 var(--p-fonte); cursor: pointer; }
.cst-check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--p-verde); flex: none; }

/* foto */
.cst-foto { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: start; }
.cst-foto-img { width: 96px; height: 72px; border-radius: 10px; overflow: hidden; background: #F1F1F3; display: grid; place-items: center; font-size: 12px; color: var(--p-suave); }
.cst-foto-img img { width: 100%; height: 100%; object-fit: cover; }
.cst-foto-txt b { display: block; font: 600 14px/1.3 var(--p-fonte); }
.cst-foto-txt small { display: block; font-size: 12.5px; color: var(--p-suave); margin-top: 2px; }
.cst-foto-acoes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
body.modo-painel .cst-raiz .cst-foto-acoes .botao, body.modo-painel .cst-raiz .cst-chip-novo .botao, body.modo-painel .cst-raiz .botao.cst-item-add { height: 36px; padding: 0 14px; font-size: 13.5px; }
.cst-foto.carregando { opacity: .6; pointer-events: none; }
.cst-msg { display: block; font-size: 12.5px; color: var(--p-suave); margin-top: 4px; }

/* listas (chips) e itens */
.cst-lista-campo > span small, .cst-itens-rot small { font-weight: 400; color: var(--p-suave); }
.cst-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.cst-chips:empty { display: none; }
.cst-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 6px 5px 11px; border-radius: 99px; background: var(--p-verde-claro); color: var(--p-verde-forte); font: 600 12.5px/1.2 var(--p-fonte); }
.cst-chip button { width: 20px; height: 20px; border: 0; border-radius: 50%; background: none; color: inherit; display: grid; place-items: center; cursor: pointer; padding: 0; }
.cst-chip button:hover { background: rgba(18, 116, 74, .14); }
.cst-chip button svg { width: 12px; height: 12px; }
.cst-chip-novo { display: flex; gap: 6px; }
.cst-chip-novo input { flex: 1; min-width: 0; }
.cst-itens { display: grid; gap: 10px; }
.cst-itens-rot { font: 600 13px var(--p-fonte); }
.cst-item { display: grid; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--p-linha); background: #FAFAFB; }
.cst-item-topo { display: flex; align-items: center; justify-content: space-between; }
.cst-item-topo b { width: 24px; height: 24px; border-radius: 50%; background: var(--p-escuro); color: #fff; display: grid; place-items: center; font: 600 12px var(--p-fonte); }
.cst-item-topo span { display: flex; gap: 4px; }
.cst-item-topo .cst-ib { width: 30px; height: 30px; }
.cst-item-add { justify-self: start; }

/* janelas: biblioteca e histórico */
.cst-dialogo { width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 18px; background: var(--p-cartao); color: var(--p-texto); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); overflow-y: auto; }
.cst-dialogo::backdrop { background: rgba(10, 12, 11, .45); backdrop-filter: blur(2px); }
.cst-dialogo-topo { position: sticky; top: 0; z-index: 1; display: flex; gap: 12px; align-items: flex-start; padding: 20px 22px 14px; background: var(--p-cartao); border-bottom: 1px solid var(--p-linha); }
.cst-dialogo-topo > div { flex: 1; }
.cst-dialogo-topo h2 { margin: 0; font: 600 19px/1.2 var(--p-fonte); letter-spacing: -.02em; }
.cst-dialogo-topo p { margin: 4px 0 0; font-size: 13.5px; color: var(--p-suave); line-height: 1.45; }
.cst-bib { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; padding: 16px 22px 22px; }
.cst-bib-item { position: relative; display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--p-linha); background: var(--p-cartao); color: inherit; font: inherit; cursor: pointer; transition: border-color .2s, box-shadow .2s; }
.cst-bib-item:hover:not(:disabled) { border-color: var(--p-verde); box-shadow: 0 0 0 3px var(--p-verde-claro); }
.cst-bib-item:disabled { opacity: .45; cursor: default; }
.cst-bib-item b { display: block; font: 600 14px/1.3 var(--p-fonte); }
.cst-bib-item small { display: block; margin-top: 3px; font: 400 12.5px/1.4 var(--p-fonte); color: var(--p-suave); }
.cst-bib-item .cst-selo { display: inline-block; margin-top: 8px; }
.cst-hist-lista { list-style: none; margin: 0; padding: 8px 22px 22px; }
.cst-hist-lista li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--p-linha); }
.cst-hist-lista li:last-child { border-bottom: 0; }
.cst-hist-lista b { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font: 600 14px var(--p-fonte); }
.cst-hist-lista small { display: block; color: var(--p-suave); font-size: 12.5px; margin-top: 2px; }
body.modo-painel .cst-raiz .cst-hist-lista .botao { height: 36px; padding: 0 14px; font-size: 13.5px; flex: none; }

/* aviso rápido */
.cst-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 14px; background: var(--p-escuro); color: #F2F2F0; font: 500 14px/1.4 var(--p-fonte); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .5); }
.cst-toast[hidden] { display: none; }
.cst-toast button { border: 0; background: none; color: #7FE0AE; font: 600 14px var(--p-fonte); cursor: pointer; padding: 0; }

/* aparência */
.cst-ap { display: grid; gap: 14px; }
.cst-ap-grupo h2 { margin: 0 0 4px; }
.cst-ap-dica { margin: 0 0 12px; font-size: 13px; color: var(--p-suave); line-height: 1.45; }
.cst-ap-grupo .cst-ap-dica:last-child { margin: 12px 0 0; }
.cst-paletas { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.cst-paleta, .cst-fonte, .cst-opcao { text-align: left; padding: 10px; border-radius: 12px; border: 1px solid var(--p-linha); background: var(--p-cartao); color: inherit; font: inherit; cursor: pointer; transition: border-color .2s, box-shadow .2s; }
.cst-paleta:hover, .cst-fonte:hover, .cst-opcao:hover { border-color: #C7C7CC; }
.cst-paleta[aria-pressed="true"], .cst-fonte[aria-pressed="true"], .cst-opcao[aria-pressed="true"] { border-color: var(--p-verde); box-shadow: 0 0 0 3px var(--p-verde-claro); }
.cst-paleta b, .cst-fonte b, .cst-opcao b { display: block; font: 600 13px/1.3 var(--p-fonte); margin-top: 8px; }
.cst-paleta b small, .cst-fonte b small, .cst-opcao b small { font-weight: 400; color: var(--p-suave); }
.cst-amostras { display: flex; height: 34px; border-radius: 8px; overflow: hidden; border: 1px solid rgba(0, 0, 0, .06); }
.cst-amostras i { flex: 1; }
.cst-amostras-livre { background: conic-gradient(from 90deg, #E67C34, #C2556D, #3C7BE8, #2FAE74, #D4A24C, #E67C34); }
.cst-amostras-livre i { background: none !important; }
.cst-cores { display: grid; gap: 8px; margin-top: 14px; }
.cst-cor { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--p-linha); cursor: pointer; }
.cst-cor input { width: 44px; height: 36px; border: 0; padding: 0; background: none; cursor: pointer; flex: none; }
.cst-cor span { flex: 1; display: grid; grid-template-columns: 1fr auto; gap: 0 10px; align-items: center; }
.cst-cor b { font: 600 13.5px var(--p-fonte); }
.cst-cor small { grid-column: 1; font-size: 12px; color: var(--p-suave); }
.cst-cor code { grid-column: 2; grid-row: 1 / span 2; font: 500 12px ui-monospace, monospace; color: var(--p-suave); }
.cst-contraste { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: #FFF1EF; color: #8A2A22; font: 500 13px/1.45 var(--p-fonte); }
.cst-contraste p { margin: 0; }
.cst-contraste p + p { margin-top: 6px; }
.cst-contraste.ok { background: var(--p-verde-claro); color: var(--p-verde-forte); }
.cst-fontes { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.cst-fonte-tit { display: block; font-size: 21px; line-height: 1.1; letter-spacing: -.02em; color: var(--p-texto); }
.cst-fonte-txt { display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.4; color: var(--p-suave); }
.cst-fonte > small { display: block; font-size: 11.5px; color: var(--p-suave); margin-top: 2px; }
.cst-botoes, .cst-anims { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cst-botao-amostra { display: flex; align-items: center; justify-content: center; height: 36px; padding: 0 10px; font: 600 12px var(--p-fonte); white-space: nowrap; overflow: hidden; }
.cst-opcao-txt small { display: block; margin-top: 4px; font-size: 12px; line-height: 1.4; color: var(--p-suave); }
.cst-opcao-txt b { margin-top: 0; }

/* telas menores: lista e prévia viram duas abas */
@media (max-width: 1100px) {
  .cst-grade { grid-template-columns: minmax(0, 1fr); }
  .cst-ver { display: inline-flex; gap: 4px; padding: 3px; border-radius: 12px; background: #EDEDF0; margin-bottom: 12px; }
  .cst-ver button { border: 0; background: none; padding: 8px 18px; border-radius: 9px; font: 600 14px var(--p-fonte); color: var(--p-suave); cursor: pointer; }
  .cst-ver button[aria-pressed="true"] { background: var(--p-cartao); color: var(--p-texto); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
  .cst-previa-col { display: none; position: static; height: calc(100vh - 230px); }
  .cst-grade.mostra-previa .cst-previa-col { display: flex; }
  .cst-grade.mostra-previa .cst-editar { display: none; }
}
@media (max-width: 640px) {
  .cst-abas { width: 100%; }
  .cst-abas a { flex: 1; text-align: center; padding: 8px 6px; font-size: 13px; }
  .cst-barra { gap: 8px; }
  .cst-barra-dir { width: 100%; }
  .cst-barra-dir .cst-bt { flex: 1; justify-content: center; padding: 0 10px; }
  body.modo-painel .cst-raiz .cst-bt[data-historico] span { display: none; }
  body.modo-painel .cst-raiz .botao.cst-bt[data-historico] { flex: none; }
  .cst-card { padding: 10px; }
  .cst-card-acoes { gap: 5px; }
  .cst-ib { width: 32px; height: 32px; }
  .cst-previa-caixa.celular { width: 100%; border-width: 6px; border-radius: 26px; }
  .cst-botoes, .cst-anims { grid-template-columns: minmax(0, 1fr); }
  .cst-gaveta { width: 100vw; }
  .cst-hist-lista li { flex-direction: column; align-items: flex-start; }
}
