/* Editor de imagem em camadas (prefixo rpc-). Classes próprias: não depende do build do Tailwind. */
.rpc-editor { position: fixed; inset: 0; z-index: 9990; display: grid; grid-template-rows: auto auto minmax(0, 1fr); background: #08090d; color: #e2e8f0; font-size: 13px; line-height: 1.35; outline: none; }
.rpc-editor *, .rpc-editor *::before, .rpc-editor *::after { box-sizing: border-box; }
.rpc-editor svg { width: 1em; height: 1em; flex: none; }
.rpc-editor button { font-family: inherit; }

/* Botões e campos */
.rpc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 5px 11px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .11); background: rgba(255, 255, 255, .04); color: #e2e8f0; font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.rpc-btn:hover { background: rgba(255, 255, 255, .09); border-color: rgba(126, 203, 255, .45); }
.rpc-btn:focus-visible, .rpc-mini:focus-visible, .rpc-input:focus-visible, .rpc-escolha:focus-visible, .rpc-modelo:focus-visible, .rpc-peca:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
.rpc-btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.rpc-btn svg { font-size: 15px; }
.rpc-btn-ic { width: 30px; padding: 0; font-size: 16px; }
.rpc-btn-pri { background: linear-gradient(90deg, #2563eb, #38a3ff); border-color: transparent; color: #fff; }
.rpc-btn-pri:hover { filter: brightness(1.12); background: linear-gradient(90deg, #2563eb, #38a3ff); border-color: transparent; }
.rpc-btn-perigo:hover { border-color: rgba(244, 63, 94, .65); color: #fecdd3; background: rgba(244, 63, 94, .12); }
.rpc-btn.rpc-ativo { border-color: rgba(126, 203, 255, .75); background: rgba(56, 163, 255, .2); color: #fff; }
.rpc-btn-p { min-height: 28px; padding: 4px 9px; font-size: 12px; }
.rpc-input { width: 100%; min-height: 30px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .12); background: rgba(0, 0, 0, .32); color: #e2e8f0; font-size: 12.5px; font-family: inherit; padding: 5px 8px; outline: none; }
.rpc-input:focus { border-color: #60a5fa; }
select.rpc-input option { background: #13161f; color: #e2e8f0; }
.rpc-area { min-height: 64px; resize: vertical; font-family: ui-monospace, Consolas, monospace; line-height: 1.4; }

/* Barra do topo */
.rpc-topo { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid rgba(255, 255, 255, .08); background: #0d0f16; }
.rpc-titulo { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; font-weight: 800; color: #fff; }
.rpc-medida { border-radius: 999px; padding: 2px 9px; background: rgba(96, 165, 250, .14); color: #bfdbfe; font-size: 11px; font-weight: 700; white-space: nowrap; }
.rpc-sep { width: 1px; height: 22px; margin: 0 3px; background: rgba(255, 255, 255, .1); }
.rpc-espaco { flex: 1 1 8px; }
.rpc-zoom { min-width: 30px; text-align: center; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.rpc-grade-tam { width: 54px; }

.rpc-avisos { padding: 0 12px; }
.rpc-avisos:not(:empty) { padding-top: 8px; padding-bottom: 8px; background: #0d0f16; }
.rpc-aviso { display: flex; align-items: flex-start; gap: 10px; border-radius: 10px; padding: 8px 12px; font-size: 12.5px; font-weight: 600; border: 1px solid rgba(96, 165, 250, .35); background: rgba(59, 130, 246, .12); color: #bfdbfe; }
.rpc-aviso span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rpc-aviso-erro { border-color: rgba(248, 113, 113, .45); background: rgba(239, 68, 68, .13); color: #fecaca; }
.rpc-aviso-alerta { border-color: rgba(251, 191, 36, .4); background: rgba(251, 191, 36, .1); color: #fde68a; }
.rpc-aviso-ok { border-color: rgba(52, 211, 153, .4); background: rgba(16, 185, 129, .12); color: #a7f3d0; }
.rpc-aviso-x { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; font-size: 14px; }
.rpc-aviso-x:hover { background: rgba(255, 255, 255, .12); }

/* Corpo: camadas | palco | propriedades */
.rpc-corpo { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr) 19.5rem; min-height: 0; }
.rpc-esq, .rpc-dir { min-height: 0; overflow-y: auto; background: #0d0f16; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
.rpc-esq { border-right: 1px solid rgba(255, 255, 255, .08); padding: 10px; }
.rpc-dir { border-left: 1px solid rgba(255, 255, 255, .08); }
.rpc-centro { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.rpc-secao { display: flex; align-items: baseline; gap: 8px; margin: 2px 2px 8px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #93c5fd; }
.rpc-secao small { font-size: 10.5px; font-weight: 500; text-transform: none; letter-spacing: 0; color: #64748b; }
.rpc-adicionar { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.rpc-adicionar .rpc-btn { justify-content: flex-start; }

/* Lista de camadas */
.rpc-camadas { display: flex; flex-direction: column; gap: 4px; }
.rpc-camada { position: relative; display: flex; align-items: center; gap: 2px; min-height: 34px; padding: 3px 4px 3px 2px; border-radius: 9px; border: 1px solid transparent; background: rgba(255, 255, 255, .035); cursor: pointer; user-select: none; }
.rpc-camada:hover { border-color: rgba(96, 165, 250, .35); }
.rpc-camada.rpc-sel { border-color: #60a5fa; background: rgba(59, 130, 246, .18); }
.rpc-camada.rpc-oculta .rpc-nome, .rpc-camada.rpc-oculta .rpc-tipo { opacity: .45; }
.rpc-camada.rpc-arrastando { opacity: .5; }
.rpc-camada.rpc-alvo-cima::before, .rpc-camada.rpc-alvo-baixo::after { content: ''; position: absolute; left: 4px; right: 4px; height: 2px; border-radius: 2px; background: #38a3ff; }
.rpc-camada.rpc-alvo-cima::before { top: -4px; }
.rpc-camada.rpc-alvo-baixo::after { bottom: -4px; }
.rpc-pega { display: grid; place-items: center; width: 18px; height: 28px; color: #64748b; cursor: grab; touch-action: none; font-size: 15px; }
.rpc-pega:hover { color: #cbd5e1; }
.rpc-tipo { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: rgba(255, 255, 255, .06); color: #93c5fd; font-size: 13px; flex: none; }
.rpc-nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: #e2e8f0; padding: 0 2px 0 5px; }
.rpc-renomear { flex: 1; min-width: 0; min-height: 26px; padding: 2px 6px; }
.rpc-falta { display: grid; place-items: center; color: #fb7185; font-size: 14px; }
.rpc-mini { display: grid; place-items: center; width: 22px; height: 24px; flex: none; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #7c8aa3; font-size: 14px; cursor: pointer; }
.rpc-mini:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.rpc-mini.rpc-ligado { color: #fbbf24; }
.rpc-extra { display: none; }
.rpc-camada.rpc-sel .rpc-extra, .rpc-camada:hover .rpc-extra { display: grid; }
.rpc-vazio { padding: 18px 10px; text-align: center; font-size: 12.5px; color: #64748b; }

/* Palco */
.rpc-palco-area { display: flex; min-width: 0; min-height: 0; overflow: auto; background: #0a0c12 radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .045) 1px, transparent 0) 0 0 / 18px 18px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
.rpc-palco-caixa { position: relative; flex: none; margin: auto; }
.rpc-palco { position: absolute; display: block; image-rendering: -moz-crisp-edges; image-rendering: crisp-edges; image-rendering: pixelated; background-color: #1c1f29; background-image: conic-gradient(#2b2f3c 25%, #1c1f29 0 50%, #2b2f3c 0 75%, #1c1f29 0); background-size: 16px 16px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .16), 0 12px 40px rgba(0, 0, 0, .55); }
.rpc-sobre { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
.rpc-rodape { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px; padding: 6px 12px; border-top: 1px solid rgba(255, 255, 255, .08); background: #0d0f16; font-size: 11.5px; color: #7c8aa3; }
.rpc-info { font-variant-numeric: tabular-nums; color: #a8b4c9; white-space: nowrap; }
.rpc-info.rpc-pesado { color: #fbbf24; font-weight: 700; }

/* Painel de propriedades */
.rpc-props { padding: 4px 0 20px; }
.rpc-grupo { padding: 11px 12px 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.rpc-grupo h4 { margin: 0 0 8px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #93c5fd; }
.rpc-campo { display: block; margin-bottom: 9px; min-width: 0; }
.rpc-campo > span { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 3px; font-size: 11px; font-weight: 600; color: #94a3b8; }
.rpc-valor { color: #e2e8f0; font-weight: 700; font-variant-numeric: tabular-nums; }
.rpc-campo input[type=range] { display: block; width: 100%; height: 22px; margin: 0; accent-color: #38a3ff; cursor: pointer; }
.rpc-l2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.rpc-cor { display: flex; align-items: center; gap: 6px; }
.rpc-cor input[type=color] { width: 38px; height: 30px; flex: none; padding: 1px; border: 1px solid rgba(255, 255, 255, .15); border-radius: 8px; background: transparent; cursor: pointer; }
.rpc-cor .rpc-input { font-family: ui-monospace, Consolas, monospace; text-transform: lowercase; }
.rpc-marca { display: flex; align-items: center; gap: 8px; min-height: 26px; margin-bottom: 8px; font-size: 12.5px; color: #cbd5e1; cursor: pointer; }
.rpc-marca input { width: 16px; height: 16px; flex: none; margin: 0; accent-color: #38a3ff; cursor: pointer; }
.rpc-botoes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.rpc-seg { display: flex; gap: 4px; }
.rpc-seg .rpc-btn { flex: 1; min-width: 0; padding-left: 4px; padding-right: 4px; }
.rpc-nota { margin: 0 0 9px; font-size: 11.5px; line-height: 1.4; color: #7c8aa3; }
.rpc-nota-alerta { color: #fcd34d; }
.rpc-nota-erro { border-radius: 8px; padding: 7px 9px; border: 1px solid rgba(248, 113, 113, .4); background: rgba(239, 68, 68, .12); color: #fecaca; }
.rpc-cabeca-linha { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; }
.rpc-cabeca-linha .rpc-tipo { width: 30px; height: 30px; font-size: 16px; }
.rpc-mostra { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.rpc-mostra img { width: 56px; height: 56px; flex: none; object-fit: contain; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .1); background: #1c1f29; image-rendering: pixelated; }
.rpc-mostra small { font-size: 11.5px; color: #94a3b8; }
.rpc-ajuda { margin: 0 0 10px; padding: 0 0 0 16px; font-size: 12px; line-height: 1.5; color: #a8b4c9; }
.rpc-ajuda li { margin-bottom: 4px; }
.rpc-ajuda kbd { display: inline-block; padding: 0 5px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06); font-family: inherit; font-size: 11px; font-weight: 700; color: #e2e8f0; }

/* Diálogos */
.rpc-veu { position: absolute; inset: 0; z-index: 5; display: flex; padding: 16px; overflow: auto; background: rgba(4, 6, 12, .74); }
.rpc-dialogo { width: min(27rem, 100%); margin: auto; padding: 18px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .12); background: #121522; box-shadow: 0 24px 70px rgba(0, 0, 0, .6); }
.rpc-dialogo-largo { width: min(47rem, 100%); }
.rpc-dialogo h3 { margin: 0 0 8px; font-size: 16px; font-weight: 800; color: #fff; }
.rpc-dialogo p { margin: 0 0 14px; font-size: 13px; line-height: 1.5; color: #a8b4c9; white-space: pre-line; }
.rpc-dialogo-botoes { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.rpc-escolhas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.rpc-escolha, .rpc-modelo, .rpc-peca { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; border-radius: 11px; border: 1px solid rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .04); color: #e2e8f0; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.rpc-escolha:hover, .rpc-modelo:hover, .rpc-peca:hover { border-color: #60a5fa; background: rgba(59, 130, 246, .14); }
.rpc-escolha b, .rpc-modelo b { font-size: 13px; font-weight: 700; }
.rpc-escolha small, .rpc-modelo small, .rpc-peca small { font-size: 11px; line-height: 1.3; color: #7c8aa3; }
.rpc-escolha i { display: block; width: 44px; height: 30px; margin-bottom: 4px; }
.rpc-des-ret { border-radius: 4px; background: #3b82f6; }
.rpc-des-eli { border-radius: 50%; background: #3b82f6; }
.rpc-des-lin { background: linear-gradient(to top right, transparent calc(50% - 1.5px), #e2e8f0 calc(50% - 1.5px), #e2e8f0 calc(50% + 1.5px), transparent calc(50% + 1.5px)); }
.rpc-modelos { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 10px; margin-bottom: 14px; }
.rpc-modelo { align-items: stretch; padding: 8px; }
.rpc-modelo-previa, .rpc-peca span { display: grid; place-items: center; height: 108px; margin-bottom: 4px; overflow: hidden; border-radius: 8px; background-color: #1c1f29; background-image: conic-gradient(#2b2f3c 25%, #1c1f29 0 50%, #2b2f3c 0 75%, #1c1f29 0); background-size: 12px 12px; }
.rpc-modelo-previa canvas { display: block; max-width: 100%; max-height: 100%; image-rendering: pixelated; }
.rpc-pecas { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: 8px; max-height: 46vh; margin-bottom: 14px; overflow-y: auto; }
.rpc-peca { align-items: stretch; padding: 6px; }
.rpc-peca span { height: 76px; }
.rpc-peca img { display: block; max-width: 100%; max-height: 76px; object-fit: contain; image-rendering: pixelated; }
.rpc-peca small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rpc-ocupado { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; background: rgba(4, 6, 12, .6); cursor: progress; }
.rpc-ocupado > div { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .12); background: #121522; font-size: 13.5px; font-weight: 700; color: #fff; }
.rpc-ocupado i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); border-top-color: #38a3ff; animation: rpc-girar .8s linear infinite; }
@keyframes rpc-girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rpc-ocupado i { animation-duration: 2.4s; } .rpc-btn, .rpc-escolha, .rpc-modelo, .rpc-peca { transition: none; } }

/* Janela estreita: o palco fica em cima; camadas e propriedades vão para baixo */
@media (max-width: 1000px) {
  .rpc-corpo { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-rows: max-content; align-content: start; overflow-y: auto; }
  .rpc-centro { order: -1; grid-column: 1 / -1; height: 50vh; min-height: 230px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
  .rpc-esq, .rpc-dir { min-height: auto; overflow: visible; }
  .rpc-dica-rodape { display: none; }
  .rpc-topo { padding: 7px 8px; gap: 5px; }
  .rpc-sep { display: none; }
}
@media (max-width: 640px) {
  .rpc-corpo { grid-template-columns: minmax(0, 1fr); }
  .rpc-esq { border-right: 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
  .rpc-dir { border-left: 0; }
  .rpc-adicionar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rpc-titulo { max-width: 100%; flex-basis: 100%; }
  .rpc-escolhas { grid-template-columns: 1fr; }
  .rpc-camada .rpc-extra { display: grid; }
}
