body {
    background: #23272e;
    color: #fff;
    font-family: 'Segoe UI', Arial, sans-serif;
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

#main-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #23272e;
    box-shadow: 0 2px 8px #0004;
    padding: 0 40px;
    height: 64px;
    z-index: 2;
}
#appTitle {
    font-family: inherit;
    font-weight: bold;
    font-size: 2em;
    color: #fff;
    margin: 0 32px 0 0;
    letter-spacing: 1px;
}
#menu {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 0 auto;
    padding: 8px 24px;
    background: rgba(35, 39, 46, 0.95);
    border-radius: 10px;
    box-shadow: 0 2px 8px #0002;
}
#menu label {
    color: #fff;
    margin-right: 4px;
}
#menu input[type="number"] {
    width: 48px;
    margin-right: 8px;
    background: #23272e;
    color: #fff;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 6px;
    text-align: center;
}
#menu button {
    padding: 8px 16px;
    border-radius: 6px;
    background: #1976d2;
    color: #fff;
    border: none;
    font-weight: bold;
    cursor: pointer;
    margin-left: 4px;
    transition: background 0.2s;
}
#menu button[type="button"] {
    background: #222;
    color: #fff;
}
#menu button#saveProjectBtn {
    background: #1976d2;
}
#menu button#loadProjectBtn {
    background: #43a047;
}
#menu button:hover {
    filter: brightness(1.15);
}

#workspace {
    display: flex;
    flex: 1 1 auto;
    height: calc(100vh - 64px);
    min-height: 0;
}
#sidebar {
    width: 260px;
    background: #20232a;
    box-shadow: 2px 0 8px #0002;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 32px 0 32px 0;
    z-index: 1;
    min-width: 180px;
    max-width: 300px;
    overflow-y: auto;
    height: 100%;
}
#paletas {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    margin: 0;
}
#canvas-area {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #23272e;
    min-width: 0;
    min-height: 0;
    position: relative;
    overflow: auto; /* Permite rolagem se a grade for maior que a área */
    padding: 24px; /* Espaço ao redor do canvas para centralizar melhor */
}

canvas {
    background: #333;
    border-radius: 12px;
    box-shadow: 0 4px 32px #000a;
    margin: 0 auto;
    display: block;
    max-width: 98vw;
    max-height: 90vh;
}

.palette-menu, .texture-menu, #fixed-texture-menu {
    width: 90%;
    min-width: 120px;
    max-width: 220px;
    margin: 0 auto 24px auto;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,0.10);
    position: relative;
    left: 0;
}

.palette-menu {
    margin-bottom: 0;
    border-bottom: 2px solid #333;
    padding-bottom: 18px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    background: #23272e;
    border-radius: 12px;
    padding: 16px 10px 12px 10px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto 0 auto;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,0.10);
}

.texture-menu {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
    background: #23272e;
    border-radius: 12px;
    padding: 16px 10px 12px 10px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto 0 auto;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,0.10);
}
#fixed-texture-menu {
    margin-top: 0;
    padding-top: 18px;
    border-top: none;
    background: #23272e;
    border-radius: 12px;
    width: 100%;
    max-width: 100%;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,0.10);
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: stretch;
}

#fixed-texture-menu .texture-group {
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}
#fixed-texture-menu .texture-group:last-child {
    margin-bottom: 0;
}
#fixed-texture-menu .texture-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1.5px solid #444;
    background: #23272e;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border 0.2s;
    margin: 0;
    padding: 0;
}
#fixed-texture-menu .texture-btn.selected {
    border: 2.5px solid #1976d2;
}
#fixed-texture-menu img {
    max-width: 32px;
    max-height: 32px;
    border-radius: 6px;
    display: block;
}

.fixed-palette-group {
    margin-bottom: 18px;
    background: #23272e;
    border-radius: 10px;
    box-shadow: 0 1px 6px 0 rgba(0,0,0,0.08);
    padding: 10px 0 0 0;
}
.fixed-palette-group:last-child {
    margin-bottom: 0;
}
.fixed-palette-title {
    font-weight: bold;
    color: #fff;
    background: #23272e;
    border: none;
    border-radius: 8px 8px 0 0;
    padding: 10px 18px;
    cursor: pointer;
    font-size: 1.08em;
    text-align: left;
    width: 100%;
    transition: background 0.2s;
}
.fixed-palette-title.active, .fixed-palette-title:hover {
    background: #1976d2;
    color: #fff;
}
.fixed-palette-textures {
    display: none;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 18px 10px 18px;
    background: #23272e;
    border-radius: 0 0 10px 10px;
}
.fixed-palette-textures.active {
    display: flex;
}
.fixed-palette-textures .texture-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1.5px solid #444;
    background: #23272e;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border 0.2s;
    margin: 0;
    padding: 0;
}
.fixed-palette-textures .texture-btn.selected {
    border: 2.5px solid #1976d2;
}
.fixed-palette-textures img {
    max-width: 32px;
    max-height: 32px;
    border-radius: 6px;
    display: block;
}

#sidebar::-webkit-scrollbar {
    width: 8px;
    background: #23272e;
}
#sidebar::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

#canvas-area::-webkit-scrollbar {
    width: 8px;
    background: #23272e;
}
#canvas-area::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}
