.tool-editor-container {
    position: absolute;
    inset: 0;
    z-index: 1000;

    display: flex;
    flex-direction: column;

    background: #1e1e1e;
}

.tool-editor-container.d-none {
    display: none !important;
}

.tool-editor-header {
    height: 42px;
    flex: 0 0 42px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 10px;

    background: #252525;
    border-bottom: 1px solid #3a3a3a;
}

.tool-editor-title {
    color: #ddd;
    font-size: 14px;
    font-weight: 600;
}

.tool-editor-content {
    flex: 1;
    min-height: 0;

    overflow: hidden;

    position: relative;
}

/* ============================================================
   IMAGE EDITOR
============================================================ */

.image-editor {
    width: 100%;
    height: 100%;

    display: flex;
    flex-direction: column;

    background: #1b1b1b;

    overflow: hidden;
}


/* ============================================================
   TOOLBAR
============================================================ */

.image-editor-toolbar {

    height: 44px;
    flex: 0 0 44px;

    display: flex;
    align-items: center;

    padding: 0 8px;

    background: #252525;
    border-bottom: 1px solid #3a3a3a;

    user-select: none;
}


.image-editor-toolbar-group {

    display: flex;
    align-items: center;

    gap: 3px;
}


.image-editor-toolbar-spacer {
    flex: 1;
}


.image-editor-toolbar-separator {

    width: 1px;
    height: 24px;

    margin: 0 8px;

    background: #444;
}


/* ============================================================
   TOOL BUTTON
============================================================ */

.image-editor-tool,
.image-editor-action,
.image-editor-opt {

    width: 34px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 1px solid transparent;
    border-radius: 4px;

    background: transparent;
    color: #ccc;

    cursor: pointer;

    font-size: 17px;
}


.image-editor-tool:hover,
.image-editor-action:hover:not(:disabled) {

    background: #353535;
    color: #fff;
}


.image-editor-tool.active,
.image-editor-opt.active
 {

    background: #3d3d3d;
    border-color: #555;

    color: #fff;
}


.image-editor-action:disabled {

    opacity: 0.35;
    cursor: default;
}


/* ============================================================
   WORKSPACE
============================================================ */

.image-editor-workspace {
    position: relative;

    flex: 1;

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    background: #151515;

    display: flex;

    align-items: center;
    justify-content: center;

    user-select: none;
}
.image-editor-workspace.panning {
    cursor: grabbing;
}

.image-editor-canvas-viewport {

    position: absolute;

    left: 0;
    top: 0;

    width: 0;
    height: 0;

    transform-origin: 0 0;

    pointer-events: none;

    will-change: transform;
}

/* ============================================================
   CANVAS WRAPPER
============================================================ */

.image-editor-canvas-wrapper {

    position: relative;

    display: flex;

    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    padding: 20px;

    overflow: auto;
}


/* ============================================================
   CANVAS
============================================================ */

#imageEditorCanvas {
	touch-action: none;
    display: block;
    width: auto;
    height: auto;
    background:
        repeating-conic-gradient(
            #d0d0d0 0% 25%,
            #ffffff 0% 50%
        )
        50% / 20px 20px;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.45);
    image-rendering: auto;
    user-select: none;
}

#imageEditorPreviewCanvas {
    position: absolute;

    left: 0;
    top: 0;

    pointer-events: none;

    z-index: 1000;
}

#TileEditorCanvas {
	touch-action: none;
    display: block;
    width: auto;
    height: auto;
    background: #fff;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.45);
    image-rendering: auto;
    user-select: none;
}


/* ============================================================
   STATUS BAR
============================================================ */

.image-editor-statusbar {

    height: 26px;
    flex: 0 0 26px;

    display: flex;
    align-items: center;

    padding: 0 10px;

    background: #252525;

    border-top: 1px solid #3a3a3a;

    color: #aaa;

    font-size: 11px;

    user-select: none;
}


.image-editor-status-spacer {
    flex: 1;
}

.image-editor-color-picker {

    display: flex;
    align-items: center;
    justify-content: center;

    height: 32px;

    color: #ccc;
}


/* ============================================================
   SIZE CONTROL
============================================================ */

.image-editor-size-control {

    height: 32px;

    padding: 0 6px;

    gap: 7px;

    color: #aaa;

    font-size: 12px;
}


.image-editor-size-control > i {

    font-size: 13px;
}


.image-editor-size-control input[type="range"] {

    width: 150px;

    cursor: pointer;
}


.image-editor-size-control span {

    width: 24px;

    text-align: right;

    color: #ccc;

    font-size: 11px;
}

/* ============================================================
   IMAGE ASSET DIALOG
============================================================ */

.image-editor-asset-dialog {

    position: absolute;

    inset: 0;

    z-index: 100;

    display: flex;

    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.65);
}


.image-editor-asset-dialog.d-none {
    display: none !important;
}


.image-editor-asset-dialog-panel {

    width: min(800px, 90%);
    height: min(600px, 85%);

    display: flex;
    flex-direction: column;

    background: #252525;

    border: 1px solid #444;
    border-radius: 6px;

    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5);

    overflow: hidden;
}


/* ============================================================
   HEADER
============================================================ */

.image-editor-asset-dialog-header {

    height: 44px;
    flex: 0 0 44px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 12px;

    background: #2d2d2d;

    border-bottom: 1px solid #444;

    color: #ddd;

    font-size: 14px;
    font-weight: 600;
}


.image-editor-dialog-close {

    width: 30px;
    height: 30px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 4px;

    background: transparent;

    color: #aaa;

    cursor: pointer;
}


.image-editor-dialog-close:hover {

    background: #3a3a3a;

    color: #fff;
}


/* ============================================================
   BODY
============================================================ */

.image-editor-asset-dialog-body {

    flex: 1;

    min-height: 0;

    padding: 12px;

    overflow: auto;
}


/* ============================================================
   ASSET GRID
============================================================ */

.image-editor-asset-list {

    display: grid;

    grid-template-columns:
        repeat(
            auto-fill,
            minmax(130px, 1fr)
        );

    gap: 10px;
}


/* ============================================================
   ASSET CARD
============================================================ */

.image-editor-asset-card {

    min-width: 0;

    padding: 6px;

    border: 2px solid transparent;
    border-radius: 5px;

    background: #1e1e1e;

    cursor: pointer;

    transition:
        border-color 0.1s,
        background 0.1s;
}


.image-editor-asset-card:hover {

    background: #303030;
}


.image-editor-asset-card.selected {

    border-color: #4da3ff;

    background: #303030;
}


/* ============================================================
   IMAGE
============================================================ */

.image-editor-asset-card img {

    width: 100%;
    height: 100px;

    display: block;

    object-fit: contain;

    background:
        repeating-conic-gradient(
            #333 0% 25%,
            #292929 0% 50%
        )
        50% / 12px 12px;

    border-radius: 3px;
}


/* ============================================================
   NAME
============================================================ */

.image-editor-asset-name {

    margin-top: 6px;

    overflow: hidden;

    white-space: nowrap;

    text-overflow: ellipsis;

    color: #ccc;

    font-size: 12px;

    text-align: center;
}


/* ============================================================
   FOOTER
============================================================ */

.image-editor-asset-dialog-footer {

    height: 52px;
    flex: 0 0 52px;

    display: flex;

    align-items: center;
    justify-content: flex-end;

    gap: 8px;

    padding: 0 12px;

    background: #2d2d2d;

    border-top: 1px solid #444;
}


/* ============================================================
   EMPTY
============================================================ */

.image-editor-empty-assets {

    grid-column: 1 / -1;

    min-height: 200px;

    display: flex;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 10px;

    color: #777;

    font-size: 13px;
}


.image-editor-empty-assets i {

    font-size: 32px;
}

.image-editor-warning-dialog {

    position: absolute;

    inset: 0;

    z-index: 200;

    display: flex;

    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.65);
}


.image-editor-warning-dialog.d-none {
    display: none !important;
}


.image-editor-warning-panel {

    width: min(420px, 90%);

    padding: 20px;

    display: flex;
    flex-direction: column;

    background: #292929;

    border: 1px solid #444;
    border-radius: 6px;

    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5);
}


.image-editor-warning-icon {

    display: flex;

    justify-content: center;

    margin-bottom: 12px;

    color: #e5a11a;

    font-size: 30px;
}


.image-editor-warning-content {

    text-align: center;
}


.image-editor-warning-title {

    margin-bottom: 8px;

    color: #eee;

    font-size: 15px;
    font-weight: 600;
}


.image-editor-warning-message {

    color: #aaa;

    font-size: 13px;

    line-height: 1.5;
}


.image-editor-warning-actions {

    display: flex;

    justify-content: flex-end;

    gap: 8px;

    margin-top: 20px;
}


.image-editor-brush-cursor {
    position: absolute;

    width: 20px;
    height: 20px;

    border: 1px solid white;

    border-radius: 50%;

    pointer-events: none;

    display: none;

    transform: translate(-50%, -50%);

    z-index: 1000;

    box-sizing: border-box;
	box-shadow: 0 0 0 1px black;
}

.image-editor-crop-selection {
    position: absolute;

    display: none;

    border: 1px dashed #ffffff;

    box-shadow:
        0 0 0 1px #000000;

    background: rgba(255, 255, 255, 0.08);

    pointer-events: none;

    box-sizing: border-box;

    z-index: 1001;
}


/* ============================================================
   TILE EDITOR - ACTIVE TILE PREVIEW
============================================================ */

.tile-editor-palette {
    position: absolute;
    left: 12px;
    top: 60px;
    z-index: 100;
    width: 54px;
    height: 54px;
    padding: 6px;
    box-sizing: border-box;
    background: rgba(35, 35, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.tile-editor-layer {
    position: absolute;
    left: 12px;
    top: 132px;
    z-index: 100;
    width: 54px;
    height: 54px;
    padding: 6px;
    box-sizing: border-box;
    background: rgba(35, 35, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.tile-editor-type {
    position: absolute;
    left: 12px;
    top: 204px;
    z-index: 100;
    width: 54px;
    height: 54px;
    padding: 6px;
    box-sizing: border-box;
    background: rgba(35, 35, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.tile-editor-option {
    position: absolute;
    left: 12px;
    top: 276px;
    z-index: 100;
    width: 54px;
    height: 54px;
    padding: 6px;
    box-sizing: border-box;
    background: rgba(35, 35, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.tile-editor-ui-content {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 5px;
    cursor: pointer;
    background-color: #222;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-sizing: border-box;
}

/* ============================================================
   ACTIVE TILE CONTENT
============================================================ */

#TileEditorPaletteContent {

    width: 40px;
    height: 40px;

    display: flex;

    align-items: center;
    justify-content: center;

    overflow: hidden;

    border-radius: 5px;

    cursor: pointer;

    background-color: #222;

    border: 1px solid rgba(255, 255, 255, 0.12);

    box-sizing: border-box;
}


#TileEditorPaletteContent canvas {

    display: block;

    width: 40px;
    height: 40px;

    image-rendering: pixelated;

    image-rendering: crisp-edges;
}


/* ============================================================
   FULL TILESET POPUP
============================================================ */

.tile-editor-tileset-popup {

    position: absolute;

    left: 70px;
    top: 0;

    z-index: 200;

    padding: 8px;

    background: rgba(30, 30, 30, 0.97);

    border: 1px solid rgba(255, 255, 255, 0.18);

    border-radius: 8px;

    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.45);

    max-width: 80vw;
    max-height: 80vh;

    overflow: auto;
}


/* ============================================================
   TILESET CANVAS
============================================================ */

.tile-editor-tileset-popup canvas {

    display: block;

    image-rendering: pixelated;

    image-rendering: crisp-edges;

    cursor: crosshair;

    user-select: none;
}

/* ============================================================
   TILE EDITOR SETTINGS
============================================================ */

.tile-editor-setting-popup {

    position: absolute;

    right: 20px;
    top: 60px;

    z-index: 3000;

    width: 300px;

    box-sizing: border-box;

    background: rgba(35, 35, 35, 0.98);

    border: 1px solid rgba(255, 255, 255, 0.15);

    border-radius: 10px;

    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.45);

    color: #eee;

    display: none;
}


.tile-editor-setting-popup.active {
    display: block;
}


.tile-editor-setting-title {

    padding: 12px 14px;

    font-size: 14px;
    font-weight: 600;

    border-bottom:
        1px solid rgba(255, 255, 255, 0.1);
}


.tile-editor-setting-body {

    padding: 14px;
}


.tile-editor-setting-row {

    margin-bottom: 16px;
}


.tile-editor-setting-row:last-child {
    margin-bottom: 0;
}


.tile-editor-setting-row label {

    display: block;

    margin-bottom: 7px;

    font-size: 12px;

    color: #aaa;
}


.tile-editor-size-input {

    display: flex;

    align-items: center;

    gap: 6px;
}


.tile-editor-size-input input {

    width: 65px;
    height: 32px;

    box-sizing: border-box;

    padding: 4px 7px;

    border:
        1px solid rgba(255, 255, 255, 0.15);

    border-radius: 5px;

    background: #222;

    color: #eee;

    outline: none;
}


.tile-editor-size-input input:focus {

    border-color: #66ff66;
}


.tile-editor-size-input span {

    font-size: 12px;

    color: #999;
}


.tile-editor-setting-footer {

    display: flex;

    justify-content: flex-end;

    gap: 8px;

    padding: 10px 14px;

    border-top:
        1px solid rgba(255, 255, 255, 0.1);
}


.tile-editor-setting-footer button {

    padding: 6px 14px;

    border: 0;

    border-radius: 5px;

    cursor: pointer;

    background: #444;

    color: #eee;
}


.tile-editor-setting-footer button:hover {

    background: #555;
}


#TileEditorSettingOK {

    background: #3f8f3f;
}


#TileEditorSettingOK:hover {

    background: #4da84d;
}

/* ============================================================
   TILE option SETTINGS
============================================================ */

.tile-option-popup {

    position: absolute;

    left: 12px;
    top: 348px;

    z-index: 3001;

    width: 300px;

    box-sizing: border-box;

    background: rgba(35, 35, 35, 0.98);

    border: 1px solid rgba(255, 255, 255, 0.15);

    border-radius: 10px;

    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.45);

    color: #eee;

    display: none;
}


.tile-option-popup.active {
    display: block;
}


.tile-option-title {

    padding: 12px 14px;

    font-size: 14px;
    font-weight: 600;

    border-bottom:
        1px solid rgba(255, 255, 255, 0.1);
}


.tile-option-body {

    padding: 14px;
}


.tile-option-row {

    margin-bottom: 16px;
}


.tile-option-row:last-child {
    margin-bottom: 0;
}


.tile-option-row label {

    display: block;

    margin-bottom: 7px;

    font-size: 12px;

    color: #aaa;
}


.tile-option-input {

    display: flex;

    align-items: center;

    gap: 6px;
}


.tile-option-input input {

    width: 65px;
    height: 32px;

    box-sizing: border-box;

    padding: 4px 7px;

    border:
        1px solid rgba(255, 255, 255, 0.15);

    border-radius: 5px;

    background: #222;

    color: #eee;

    outline: none;
}


.tile-option-input input:focus {

    border-color: #66ff66;
}


.tile-option-input span {

    font-size: 12px;

    color: #999;
}


.tile-option-footer {

    display: flex;

    justify-content: flex-end;

    gap: 8px;

    padding: 10px 14px;

    border-top:
        1px solid rgba(255, 255, 255, 0.1);
}


.tile-option-footer button {

    padding: 6px 14px;

    border: 0;

    border-radius: 5px;

    cursor: pointer;

    background: #444;

    color: #eee;
}


.tile-option-footer button:hover {

    background: #555;
}


#TileOptionOK {

    background: #3f8f3f;
}


#TileOptionOK:hover {

    background: #4da84d;
}

