:root {
    --bg: #090909;
    --panel: #141414;
    --panel-2: #1c1c1c;
    --panel-3: #222;
    --line: #333;
    --line-soft: #2a2a2a;
    --text: #f2f2f2;
    --text-soft: #9aa4ad;
    --accent: #00e5ff;
    --accent-soft: rgba(0, 229, 255, 0.18);
    --danger: #e53935;
    --warning: #ffca28;
    --slot: #111;
    --slot-border: #242424;
    --shadow: 0 0 22px rgba(0, 229, 255, 0.14);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

button,
select,
input {
    font: inherit;
}

button,
select {
    border-radius: 10px;
    border: 1px solid #3a3a3a;
    background: #1f1f1f;
    color: var(--text);
}

button {
    cursor: pointer;
    transition: 0.18s ease;
}

button:hover,
select:hover {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.14);
}

button:active {
    transform: translateY(1px);
}

select,
button {
    min-height: 40px;
    padding: 0 12px;
}

.hidden {
    display: none !important;
}

.criador-app-topbar {
    width: 100%;
    min-height: 46px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 6px 10px;
    background: rgba(7, 10, 15, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.30);
    z-index: 1000;
}

.criador-topbar-left,
.criador-topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.criador-topbar-right {
    justify-content: flex-end;
}

.criador-topbar-center {
    color: rgba(255, 255, 255, 0.92);
    font-size: 16px;
    white-space: nowrap;
}

.criador-topbar-btn {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border-radius: 7px;
    background: #242424;
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid #444;
    text-decoration: none;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.criador-topbar-btn:hover {
    background: #333;
}

.criador-menu {
    position: relative;
}

.criador-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1200;
    min-width: 180px;
    padding: 6px;
    background: rgba(7, 10, 15, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.48);
}

.criador-menu-item {
    display: block;
    padding: 9px 10px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 13px;
}

.criador-menu-item:hover {
    background: rgba(255, 255, 255, 0.10);
}

.criador-layout {
    display: flex;
    width: 100%;
    height: calc(100% - 46px);
    min-height: 0;
}

.panel.side-panel.left-panel {
    width: 320px;
    min-width: 320px;
    height: 100%;
    padding: 18px;
    background: linear-gradient(180deg, #141414 0%, #111 100%);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.editor-exit-btn {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    width: fit-content;
}

.editor-title {
    margin: 0;
    color: var(--accent);
    font-size: 29px;
    line-height: 1.05;
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.12);
}

.editor-model-name {
    min-height: 24px;
    color: var(--text-soft);
    font-size: 14px;
}

.section-label {
    font-size: 17px;
    color: rgba(255, 255, 255, 0.78);
    letter-spacing: 0.6px;
}

.controle-box {
    padding: 12px;
    border: 1px solid var(--line-soft);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
}

.checkbox-label input {
    accent-color: var(--accent);
}

.divider {
    width: 100%;
    border: none;
    border-top: 1px solid var(--line);
    margin: 2px 0;
}

.marker-info {
    display: flex;
    align-items: center;
}

.marker-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #191919;
    font-size: 13px;
}

.marker-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 8px currentColor;
}

.lista-pecas {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-right: 4px;
}

.lista-pecas::-webkit-scrollbar,
.viewport::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.lista-pecas::-webkit-scrollbar-thumb,
.viewport::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 999px;
}

.loading-card,
.empty-card {
    grid-column: 1 / -1;
    padding: 18px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #181818;
    color: var(--text-soft);
    text-align: center;
}

.peca-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: #181818;
    border: 1px solid #2b2b2b;
    border-radius: 14px;
    cursor: grab;
    user-select: none;
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.peca-item:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 229, 255, 0.44);
    box-shadow: var(--shadow);
}

.peca-thumb-wrap {
    width: 100%;
    aspect-ratio: 1;
    position: relative;
    background: #0b0b0b;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #2b2b2b;
}

.peca-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.peca-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.peca-id {
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
}

.peca-nome {
    font-size: 11px;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top, #101010 0%, #080808 65%);
}

.workspace-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(10, 10, 10, 0.85);
}

.workspace-title {
    font-size: 22px;
    color: var(--accent);
    font-weight: 700;
}

.workspace-subtitle {
    margin-top: 4px;
    color: var(--text-soft);
    font-size: 13px;
}

.workspace-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.secondary-btn {
    background: #252525;
}

.viewport {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: auto;
    cursor: grab;
    padding: 16px 18px 18px 16px;
}

.viewport:active {
    cursor: grabbing;
}

.tabuleiro-stage {
    width: max-content;
    min-width: max-content;
    min-height: max-content;
    padding: 0;
    margin: 0;
    transform-origin: 0 0;
}

.tabuleiro {
    width: 800px;
    height: 800px;
    display: grid;
    grid-template-columns: repeat(10, 80px);
    grid-template-rows: repeat(10, 80px);
    border: 2px solid #2c2c2c;
    background:
            linear-gradient(rgba(255,255,255,0.025), rgba(255,255,255,0.025)),
            #0b0b0b;
    box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.05), 0 0 28px rgba(0, 229, 255, 0.05);
}

.slot {
    position: relative;
    width: 80px;
    height: 80px;
    border: 1px solid var(--slot-border);
    background: rgba(255, 255, 255, 0.02);
    overflow: visible;
}

.slot.drag-over {
    background: rgba(0, 229, 255, 0.1);
    box-shadow: inset 0 0 0 2px rgba(0, 229, 255, 0.32);
}

.slot.invalid {
    background: rgba(229, 57, 53, 0.18) !important;
    box-shadow: inset 0 0 0 2px rgba(229, 57, 53, 0.65) !important;
}

.slot.has-piece {
    cursor: move;
}

.slot.selected-slot {
    z-index: 6;
    box-shadow: inset 0 0 0 2px var(--warning), 0 0 16px rgba(255, 202, 40, 0.32);
}

.peca-instancia {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #000;
}

.peca-base,
.camada-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.peca-base img,
.camada-layer img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
}

.camada-layer img {
    position: absolute;
}

.drag-feedback-image {
    width: 80px;
    height: 80px;
    position: fixed;
    top: -1000px;
    left: -1000px;
    border: 2px solid var(--accent);
    background-size: cover;
    background-position: center;
    border-radius: 10px;
    pointer-events: none;
    z-index: 99999;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.38);
    opacity: 0.86;
}

.marcador-overlay {
    position: absolute;
    inset: 0;
    display: none;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    pointer-events: none;
    z-index: 5;
}

body.marker-visible .marcador-overlay.show {
    display: grid;
}

.marcador-pixel {
    border: 1px solid transparent;
}

.marcador-pixel.ativo {
    background: currentColor;
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 5px currentColor;
}

.porta-overlay {
    position: absolute;
    inset: 0;
    display: none;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    pointer-events: none;
    z-index: 6;
}

body.validacao-ativa .porta-overlay {
    display: grid;
}

.porta-pixel.ativo {
    background: var(--accent);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 5px var(--accent);
}

.help-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.76);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
}

.help-modal-card {
    width: min(560px, 100%);
    border: 1px solid rgba(0, 229, 255, 0.36);
    border-radius: 18px;
    background: linear-gradient(180deg, #161616 0%, #101010 100%);
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.18);
}

.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.help-modal-header h3 {
    margin: 0;
    color: var(--accent);
    font-size: 24px;
}

.help-close-btn {
    width: 40px;
    min-width: 40px;
    padding: 0;
}

.help-modal-body {
    padding: 18px;
    color: #ddd;
    line-height: 1.5;
}

.help-modal-body p {
    margin-top: 0;
}

.help-modal-body ul {
    margin: 0;
    padding-left: 22px;
}

@media (max-width: 1000px) {
    .panel.side-panel.left-panel {
        width: 290px;
        min-width: 290px;
    }

    .workspace-topbar {
        flex-direction: column;
        align-items: flex-start;
    }
}
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

#zoomLabel {
    min-width: 56px;
    text-align: center;
    font-weight: 700;
    color: var(--accent);
}
.campo-linha {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.btn-importar-modelo {
    border: 1px solid rgba(255,255,255,0.12);
    background: #2a2a2a;
    color: #f2f2f2;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-importar-modelo:hover {
    background: #343434;
}
.modal-confirm-card {
    max-width: 520px;
}

.modal-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 18px 18px 18px;
}
