/* Dobrali · casca do editor. Mesmos papéis de token do @baitaos/kit (brand, ink, canvas, line, fonte Inter), tema claro
   como o editor (fundo #f1f1f3) e a cor da marca do Dobrali (violeta do protótipo, escurecido para contraste AA). */
:root {
  --brand: #5b47d6;
  --brand-escuro: #3b2a9e;
  --brand-claro: #8f7ff0;
  --brand-tinta: #ffffff;
  --canvas: #f6f6f9;
  --superficie: #ffffff;
  --superficie-2: #f0f0f5;
  --line: #e2e2ea;
  --ink: #17171c;
  --ink-soft: #45454f;
  --ink-3: #62626e;
  --perigo: #b42318;
  --ok: #157a4a;
  --r: 14px;
  --sombra: 0 1px 2px rgb(23 23 28 / .06), 0 12px 32px rgb(23 23 28 / .10);
  --fonte: "Inter Variable", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body { font: 15px/1.5 var(--fonte); color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--brand); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
h1, h2 { font-weight: 600; letter-spacing: -.015em; margin: 0; }
h1:focus { outline: none; }
@media (pointer: coarse), (max-width: 767px) { input { font-size: max(16px, 1em) !important; } }

/* botões */
.btn, .btn-pri, .btn-perigo, .btn-icone { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--superficie-2); padding: 0 14px; font-weight: 500; text-decoration: none; color: var(--ink); white-space: nowrap; transition: background-color .15s, border-color .15s, transform .15s; }
.btn:hover { background: #e8e8ef; border-color: #d3d3de; }
.btn-pri { background: var(--brand); border-color: var(--brand); color: var(--brand-tinta); font-weight: 600; }
.btn-pri:hover { background: #4b38c4; border-color: #4b38c4; }
.btn-perigo { background: var(--perigo); border-color: var(--perigo); color: #fff; }
.btn-perigo:hover { background: #9a1d14; }
.btn-icone { width: 40px; padding: 0; background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-icone:hover:not(:disabled) { background: var(--superficie-2); color: var(--ink); }
.btn-icone.perigo:hover:not(:disabled) { color: var(--perigo); }
.btn-pri svg, .btn svg { width: 18px; height: 18px; }

/* marca */
.glifo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--brand-claro), var(--brand-escuro)); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / .25), 0 6px 16px rgb(91 71 214 / .25); }
.glifo svg { width: 18px; height: 18px; }
.glifo.grande { width: 60px; height: 60px; border-radius: 16px; }
.glifo.grande svg { width: 30px; height: 30px; }
.glifo.pequeno { width: 26px; height: 26px; border-radius: 7px; }
.glifo.pequeno svg { width: 15px; height: 15px; }
.marca { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 17px; }
.espaco { flex: 1; }

/* esqueleto (carregando) */
.esq { height: 40px; border-radius: 10px; background: linear-gradient(90deg, var(--superficie) 0, var(--superficie-2) 50%, var(--superficie) 100%); background-size: 800px 100%; }
@media (prefers-reduced-motion: no-preference) { .esq { animation: brilho 1.6s linear infinite; } }
@keyframes brilho { 0% { background-position: -400px 0 } 100% { background-position: 400px 0 } }

/* porta: aviso do portão quando o servidor não responde ou a conta BaitaOS não está ligada */
.porta { min-height: 100dvh; display: grid; place-items: center; padding: 40px 20px; background: radial-gradient(1200px 600px at 50% -10%, rgb(91 71 214 / .12), transparent 60%), var(--canvas); }
.cartao-porta { width: 100%; max-width: 460px; text-align: center; }
.cartao-porta h1 { font-size: 24px; }
.sub { color: var(--ink-3); margin: 8px 0 0; }
.cartao-porta .sub { font-size: 15px; line-height: 1.6; }
.acoes-porta { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }
.acoes-porta > * { min-height: 44px; }

/* lista de projetos */
.lista { min-height: 100dvh; background: radial-gradient(1000px 420px at 85% -10%, rgb(91 71 214 / .08), transparent 60%), var(--canvas); }
.topo { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 8px; max-width: 60vw; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--superficie); color: var(--ink-soft); font-size: 14px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip svg { width: 16px; height: 16px; }
.conteudo { max-width: 1200px; margin: 0 auto; padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px) 64px; outline: none; }
.cab-lista { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 28px; }
.faixa-antigos { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: -12px 0 24px; padding: 10px 6px 10px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--superficie); }
.faixa-antigos > svg { width: 20px; height: 20px; color: var(--brand); flex: none; }
.faixa-antigos p { flex: 1 1 260px; margin: 0; font-size: 14px; color: var(--ink-soft); }
.faixa-antigos b { color: var(--ink); }
.cab-lista h1 { font-size: clamp(24px, 3vw, 30px); }
.cab-acoes { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.botoes { display: flex; flex-wrap: wrap; gap: 10px; }
.uso { display: grid; gap: 6px; min-width: 190px; font-size: 13px; color: var(--ink-3); }
.uso-barra { height: 6px; border-radius: 99px; background: var(--superficie-2); overflow: hidden; }
.uso-barra i { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-claro)); }
.grade { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.card { position: relative; display: grid; gap: 4px; padding: 12px 12px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--superficie); transition: border-color .15s, transform .2s, box-shadow .2s; }
.card:hover { border-color: #cfcfdb; box-shadow: var(--sombra); }
@media (prefers-reduced-motion: no-preference) {
  .card:hover { transform: translateY(-2px); }
  .grade > .card { animation: entra .35s cubic-bezier(.2, .7, .3, 1) both; animation-delay: calc(min(var(--i, 0), 8) * 40ms); }
}
@keyframes entra { from { opacity: 0; transform: translateY(8px) } }
.abrir { display: grid; gap: 10px; color: var(--ink); text-decoration: none; border-radius: 10px; }
.abrir::after { content: ""; position: absolute; inset: 0; border-radius: var(--r); }
.capa { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: radial-gradient(120% 140% at 0% 0%, rgb(143 127 240 / .30), transparent 60%), linear-gradient(135deg, #ecebfb, #f6f6f9); }
.folha { display: grid; place-items: center; width: 30%; aspect-ratio: 210 / 297; border-radius: 3px; background: #fff; box-shadow: 0 1px 2px rgb(23 23 28 / .08), 0 6px 18px rgb(59 42 158 / .16); transition: transform .2s; }
.folha svg { width: 78%; height: auto; overflow: visible; fill: #fff; stroke: var(--brand); stroke-width: 1.4; stroke-linecap: round; }
.folha .traco { fill: none; stroke-width: 2.6; }
.folha .alca { fill: none; stroke: var(--brand-claro); stroke-dasharray: 2 2; }
.capa { display: flex; align-items: center; justify-content: center; gap: 2px; }
.capa > img { max-width: 88%; max-height: 88%; width: auto; height: auto; object-fit: contain; display: block; border-radius: 3px; background: #fff; box-shadow: 0 1px 2px rgb(23 23 28 / .08), 0 6px 18px rgb(59 42 158 / .16); transition: transform .2s; }
@media (prefers-reduced-motion: no-preference) { .card:hover .folha, .card:hover .capa > img { transform: translateY(-3px) rotate(-1.5deg); } }
.esqueleto-card .capa { height: auto; background: linear-gradient(90deg, var(--superficie-2) 0, #e6e6ee 50%, var(--superficie-2) 100%); background-size: 800px 100%; }
.nome { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.meta { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.acoes-card { position: relative; z-index: 1; display: flex; gap: 2px; margin: 2px -4px 0; }
.estado { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 64px 20px; border: 1px dashed #d3d3de; border-radius: 20px; background: rgb(255 255 255 / .7); }
.estado h2 { font-size: 20px; }
.estado p { margin: 0 0 8px; max-width: 46ch; color: var(--ink-3); }
.estado.erro > svg { width: 32px; height: 32px; color: var(--perigo); }
.estado .glifo { margin-bottom: 6px; }

/* editor */
.editor { display: flex; flex-direction: column; height: 100dvh; background: #f1f1f3; }
.barra { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--superficie); min-width: 0; }
.nome-projeto { min-width: 0; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px; background: none; font-weight: 600; }
.nome-projeto:hover:not(:disabled) { border-color: var(--line); }
.nome-projeto:disabled { opacity: 1; cursor: default; }
.situacao { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; }
.situacao span { overflow: hidden; text-overflow: ellipsis; }
.situacao svg { width: 16px; height: 16px; }
.situacao.ok svg { color: var(--ok); }
.situacao.erro { color: var(--perigo); }
.link-discreto { font-size: 13px; color: var(--ink-3); text-decoration: none; padding: 6px; }
.presenca { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; color: var(--ink-soft); }
.presenca .quem { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22vw; }
.presenca .rostos { display: inline-flex; }
.rosto { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-left: -6px; border-radius: 50%; border: 2px solid var(--superficie); background: hsl(var(--h, 250) 55% 46%); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.rosto:first-child { margin-left: 0; }
.rosto.mais { background: var(--ink-soft); }
.presenca.fora .rostos { opacity: .45; filter: grayscale(1); }
.presenca.fora .quem { color: var(--ink-3); }
@media (prefers-reduced-motion: no-preference) { .rosto { animation: entra .25s ease-out; } .presenca .rostos { transition: opacity .2s, filter .2s; } }
.link-discreto:hover { color: var(--ink); text-decoration: underline; }
.faixa { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 14px; font-size: 14px; background: #fff4d6; color: #5c3d00; border-bottom: 1px solid #f0d58a; }
.faixa svg { width: 18px; height: 18px; }
.faixa a { color: #5c3d00; font-weight: 600; }
.palco { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.palco iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; transform-origin: 0 0; }
.cobre { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 20px; background: rgb(246 246 249 / .96); }
.cobre-caixa { text-align: center; max-width: 440px; }
.cobre-caixa > div > svg { width: 32px; height: 32px; color: var(--perigo); }
.cobre-titulo { font-size: 18px; font-weight: 600; margin: 14px 0 4px; }
.cobre-sub { margin: 0; color: var(--ink-3); min-height: 1.5em; overflow-wrap: anywhere; }
.cobre .acoes { justify-content: center; margin-top: 20px; }
.roda { display: inline-block; width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgb(91 71 214 / .18); border-top-color: var(--brand); }
.roda.mini { width: 14px; height: 14px; border-width: 2px; }
@media (prefers-reduced-motion: no-preference) { .roda { animation: gira .8s linear infinite; } }
@keyframes gira { to { transform: rotate(360deg) } }

/* diálogos */
.dialogo { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--superficie); color: var(--ink); box-shadow: var(--sombra); }
.dialogo::backdrop { background: rgb(23 23 28 / .45); }
/* editor tirando a cópia das alterações depois que a sessão acabou: fora de vista, mas desenhando (o motor só exporta com quadros) */
.guardando { position: fixed; inset: 0; opacity: 0; pointer-events: none; z-index: -1; }
@media (prefers-reduced-motion: no-preference) { .dialogo[open] { animation: entra .2s ease-out; } }
.dialogo form { display: grid; gap: 14px; padding: 22px; }
.dialogo h2 { font-size: 19px; }
.dialogo p { margin: 0; color: var(--ink-soft); }
.campo { display: grid; gap: 6px; font-size: 14px; color: var(--ink-soft); }
.campo input { min-height: 44px; padding: 0 12px; border: 1px solid #cfcfdb; border-radius: 10px; background: var(--superficie); }
.campo input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgb(91 71 214 / .22); }
.erro-campo { min-height: 0; color: var(--perigo) !important; font-size: 14px; }
.erro-campo:empty { display: none; }
.acoes { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.antigos { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.antigos li + li { border-top: 1px solid var(--line); }
.antigos label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 10px; padding: 10px 12px; cursor: pointer; }
.antigos input { grid-row: span 2; width: 18px; height: 18px; accent-color: var(--brand); }
.antigo-nome { font-weight: 600; overflow-wrap: anywhere; }
.antigo-meta { font-size: 13px; color: var(--ink-3); }
.lista-versoes li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.lista-versoes li > div { display: grid; flex: 1; min-width: 0; }
.lista-versoes .antigo-meta { overflow-wrap: anywhere; }
.versoes-estado { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 0 12px; border: 1px dashed var(--line); border-radius: 12px; font-size: 14px; }
.versoes-estado .btn { margin-left: auto; }
.formatos { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; min-width: 0; }
.formatos[hidden] { display: none; }
.formatos legend { padding: 0; margin-bottom: 8px; font-size: 14px; color: var(--ink-soft); }
.opcoes { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.formato { position: relative; display: grid; justify-items: center; gap: 2px; padding: 10px 6px 8px; border: 1px solid #cfcfdb; border-radius: 12px; cursor: pointer; text-align: center; transition: border-color .15s, background-color .15s; }
.formato:hover { border-color: var(--brand); }
.formato input { position: absolute; opacity: 0; pointer-events: none; }
.formato:has(input:checked) { border-color: var(--brand); background: rgb(91 71 214 / .07); box-shadow: inset 0 0 0 1px var(--brand); }
.formato:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.miniatura { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 4px; }
.miniatura i { display: block; border-radius: 2px; background: #fff; box-shadow: 0 0 0 1px #cfcfdb, 0 3px 8px rgb(59 42 158 / .14); }
.formato-nome { font-size: 14px; font-weight: 600; color: var(--ink); }
.formato-medida { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.dica-formato { font-size: 13px; }

/* aviso */
.aviso { position: fixed; left: 50%; bottom: 24px; z-index: 10; max-width: min(520px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 12px; background: #23232b; color: #fff; border: 1px solid #23232b; box-shadow: var(--sombra); font-size: 14px; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.aviso.on { opacity: 1; transform: translate(-50%, 0); }
.aviso.erro { background: #5a1610; border-color: #5a1610; color: #fff; }
@media (prefers-reduced-motion: reduce) { .aviso { transition: none; } }

@media (max-width: 640px) {
  .barra { gap: 4px; padding: 0 6px; }
  .barra .glifo, .link-discreto, #salvar span, #versoes span { display: none; }
  .presenca .quem { display: none; }
  #salvar, #versoes { width: 40px; padding: 0; }
  .nome-projeto { max-width: 40vw; }
  .cab-acoes { width: 100%; justify-content: space-between; }
  .uso { min-width: 0; flex: 1; }
}
