:root {
    --ed-bg: #1e1e1e;
    --ed-panel: #323232;
    --ed-panel-2: #3f3f3f;
    --ed-panel-3: #454545;
    --ed-line: #222222;
    --ed-line-soft: #4a4a4a;
    --ed-ink: #d4d4d4;
    --ed-ink-bright: #f0f0f0;
    --ed-ink-dim: #8f8f8f;
    --ed-accent: #1473e6;
    --ed-accent-hover: #2f87f0;
    --ed-canvas-bg: #131313;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--ed-bg);
    color: var(--ed-ink);
    margin: 0;
}

.home-hero { background: var(--ed-bg); color: var(--ed-ink); }
.home-hero .text-secondary { color: var(--ed-ink-dim) !important; }

/* ---- layout ---- */
.ed {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 13px;
}

/* ---- menu bar ---- */
.ed-menubar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    height: 34px;
    background: var(--ed-panel);
    border-bottom: 1px solid var(--ed-line);
}

.ed-logo {
    color: var(--ed-ink-bright);
    font-weight: 700;
    letter-spacing: .2px;
    margin-right: 10px;
    font-size: 13px;
}

.ed-menu-btn {
    background: transparent;
    border: none;
    color: var(--ed-ink);
    padding: 6px 10px;
    font-size: 12.5px;
    border-radius: 3px;
    cursor: pointer;
}
.ed-menu-btn:hover, .ed-menu-btn:focus, .ed-menu-btn.show { background: var(--ed-panel-3); color: var(--ed-ink-bright); }
.ed-menu-btn::after { display: none; }

.dropdown-menu-dark {
    --bs-dropdown-bg: #2b2b2b;
    --bs-dropdown-border-color: var(--ed-line-soft);
    --bs-dropdown-link-color: var(--ed-ink);
    --bs-dropdown-link-hover-bg: var(--ed-accent);
    --bs-dropdown-link-hover-color: #fff;
    --bs-dropdown-divider-bg: var(--ed-line-soft);
    font-size: 12.5px;
    min-width: 12rem;
}
.dropdown-item { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.ed-menu-key { color: var(--ed-ink-dim); font-size: 11px; margin-left: 12px; }
.dropdown-item:hover .ed-menu-key { color: rgba(255,255,255,.75); }

.ed-menubar-right { margin-left: auto; display: flex; gap: 2px; }

.ed-icon-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--ed-ink);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.ed-icon-btn svg { width: 15px; height: 15px; }
.ed-icon-btn:hover { background: var(--ed-panel-3); color: var(--ed-ink-bright); }

/* ---- options bar (horizontal, tool-context sensitive) ---- */
.ed-optionsbar {
    flex: 0 0 auto;
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 0 14px;
    background: var(--ed-panel);
    border-bottom: 1px solid var(--ed-line);
    overflow-x: auto;
}

.ed-opt-group { display: none; align-items: center; gap: 8px; white-space: nowrap; }
.ed-opt-group.visible { display: flex; }
.ed-opt-group label { font-size: 11.5px; color: var(--ed-ink-dim); text-transform: uppercase; letter-spacing: .3px; }
.ed-opt-group input[type="range"] { width: 110px; accent-color: var(--ed-accent); }
.ed-opt-group input[type="color"] {
    width: 30px;
    height: 26px;
    border: 1px solid var(--ed-line-soft);
    border-radius: 4px;
    background: none;
    padding: 0;
    cursor: pointer;
}
.ed-opt-group input[type="number"] {
    width: 64px;
    background: var(--ed-panel-2);
    border: 1px solid var(--ed-line-soft);
    color: var(--ed-ink);
    border-radius: 4px;
    padding: 4px 6px;
}
.ed-opt-group span { font-size: 12px; color: var(--ed-ink-dim); min-width: 26px; }
.ed-opt-hint { font-size: 12px; color: var(--ed-ink-dim); font-style: italic; }

.ed-opt-btn {
    background: var(--ed-panel-2);
    border: 1px solid var(--ed-line-soft);
    color: var(--ed-ink);
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ed-opt-btn:hover { background: var(--ed-panel-3); }
.ed-opt-btn-primary { background: var(--ed-accent); border-color: var(--ed-accent); color: #fff; }
.ed-opt-btn-primary:hover { background: var(--ed-accent-hover); }

.ed-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

/* ---- left tool strip ---- */
.ed-tools {
    width: 44px;
    flex: 0 0 auto;
    background: var(--ed-panel);
    border-right: 1px solid var(--ed-line);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 3px;
}

.ed-tool {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--ed-ink);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ed-tool svg { width: 17px; height: 17px; }
.ed-tool:hover { background: var(--ed-panel-3); }
.ed-tool.active { background: var(--ed-accent); color: #fff; }

.ed-swatch-wrap { margin-top: auto; padding-top: 10px; }
.ed-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 2px solid var(--ed-line-soft);
    box-shadow: 0 0 0 1px #000;
    cursor: pointer;
}

/* ---- canvas area ---- */
.ed-canvas-area {
    flex: 1 1 auto;
    position: relative;
    background: var(--ed-canvas-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ed-canvas-viewport {
    overflow: auto;
    width: 100%;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.ed-canvas-stack {
    position: relative;
    background-image:
        linear-gradient(45deg, #2b2c2f 25%, transparent 25%),
        linear-gradient(-45deg, #2b2c2f 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2b2c2f 75%),
        linear-gradient(-45deg, transparent 75%, #2b2c2f 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #232427;
    box-shadow: 0 0 0 1px #000, 0 8px 24px rgba(0,0,0,.5);
    flex: 0 0 auto;
}

.ed-canvas-stack canvas {
    position: absolute;
    top: 0;
    left: 0;
    image-rendering: pixelated;
}

.ed-statusbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: var(--ed-panel);
    border-top: 1px solid var(--ed-line);
    font-size: 12px;
}

.ed-statusbar button {
    background: none;
    border: none;
    color: var(--ed-ink);
    min-width: 20px;
    height: 20px;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 3px;
    font-size: 12px;
}
.ed-statusbar button:hover { background: var(--ed-panel-3); color: var(--ed-ink-bright); }
.ed-statusbar-sep { width: 1px; height: 16px; background: var(--ed-line-soft); margin: 0 6px; }
.ed-statusbar-docinfo { color: var(--ed-ink-dim); }

.ed-brush-cursor {
    position: absolute;
    top: 0;
    left: 0;
    border: 1px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.6);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 5;
}

/* ---- right panel ---- */
.ed-panel-right {
    width: 260px;
    flex: 0 0 auto;
    background: var(--ed-panel);
    border-left: 1px solid var(--ed-line);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.ed-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ed-ink-bright);
    border-bottom: 1px solid var(--ed-line);
}

.ed-panel-head-actions { display: flex; gap: 4px; }
.ed-panel-head-actions button {
    width: 22px;
    height: 22px;
    border: none;
    background: var(--ed-panel-2);
    color: var(--ed-ink);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
}
.ed-panel-head-actions button:hover { background: var(--ed-accent); color: #fff; }

.ed-layer-props {
    padding: 10px 12px;
    border-bottom: 1px solid var(--ed-line);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ed-layer-props select {
    background: var(--ed-panel-2);
    color: var(--ed-ink);
    border: 1px solid var(--ed-line-soft);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12px;
}

.ed-opacity { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ed-ink-dim); }
.ed-opacity input { flex: 1; accent-color: var(--ed-accent); }

.ed-layer-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ed-layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
}

.ed-layer-item:hover { background: var(--ed-panel-2); }
.ed-layer-item.active { background: rgba(20,115,230,.22); border-color: var(--ed-accent); }

.ed-layer-item .thumb {
    width: 32px;
    height: 32px;
    border-radius: 3px;
    background: #444 repeating-conic-gradient(#3a3a3a 0% 25%, #444 0% 50%) 0 0/8px 8px;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid var(--ed-line-soft);
}
.ed-layer-item .thumb img { width: 100%; height: 100%; object-fit: contain; }

.ed-layer-item .name {
    flex: 1;
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ed-ink);
}
.ed-layer-item.active .name { color: var(--ed-ink-bright); }

.ed-layer-item .vis {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--ed-ink-dim);
    cursor: pointer;
}
.ed-layer-item .vis.off { opacity: .3; }

.ed-layer-rename-input {
    flex: 1;
    font-size: 12.5px;
    background: var(--ed-panel-2);
    color: var(--ed-ink);
    border: 1px solid var(--ed-accent);
    border-radius: 4px;
    padding: 1px 4px;
    min-width: 0;
}

/* ---- canvas size modal anchor grid ---- */
.ed-anchor-grid {
    display: grid;
    grid-template-columns: repeat(3, 28px);
    grid-template-rows: repeat(3, 28px);
    gap: 3px;
    background: var(--ed-panel-2);
    padding: 8px;
    border-radius: 4px;
    width: fit-content;
}
.ed-anchor-cell {
    width: 28px;
    height: 28px;
    background: var(--ed-panel-3);
    border: 1px solid var(--ed-line-soft);
    cursor: pointer;
    border-radius: 2px;
}
.ed-anchor-cell:hover { background: var(--ed-accent-hover); }
.ed-anchor-cell.active { background: var(--ed-accent); border-color: var(--ed-accent); }
