#maker-view {
    display: none;
    padding: 0;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 20000;
    background: #0a0a0a;
}

#maker-view.visible {
    display: block; /* Use block, position relative for children */
}

.maker-logo {
    position: absolute;
    top: 15px;
    left: 20px;
    font-family: var(--font-title);
    font-size: clamp(1.2rem, 5vw, 2rem); /* Scalable logo size */
    font-weight: 900;
    color: var(--color-gold);
    text-shadow:
        0 0 10px rgba(255, 215, 0, 0.6),
        0 0 20px rgba(255, 215, 0, 0.4);
    letter-spacing: 3px;
    z-index: 20001;
    pointer-events: none;
    text-transform: uppercase;
}

#maker-view.hidden {
    display: none !important;
}

/* Preview Layer (Background) */
#maker-canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 10; /* Increased to ensure it's above potential overlays but below drawer */
    transition: padding-bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    background: #050505; /* Solid dark background */
}

#maker-canvas {
    position: relative;
    height: 100%;
    width: auto;
    max-height: 100%;
    max-width: 100%;
    aspect-ratio: 135 / 240;
    background: rgba(255,255,255,0.02);
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    transform: translateZ(0);
}

.maker-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: filter 0.1s linear;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.is-text-layer {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    line-height: 1.2;
    z-index: 50;
    /* Adjust relative to other layers later if needed */
}

/* Blend coloring logic */
.mode-blend .maker-layer-base,
.mode-blend .maker-layer-tint {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.mode-blend .maker-layer-tint {
    pointer-events: none;
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.maker-layer img {
    width: 100%;
    height: 100%;
    display: block;
}

/* The Dynamic Drawer */
.maker-drawer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 35px 35px 0 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s ease;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.8);
}

/* Mobile Drawer Heights */
@media (max-width: 768px) {
    .maker-drawer.state-collapsed { height: 120px; }
    .maker-drawer.state-half { height: 45vh; }
    .maker-drawer.state-full { height: 85vh; }
    
    /* Push preview up based on drawer state */
    .state-collapsed ~ #maker-canvas-container { padding-bottom: 120px; }
    .state-half ~ #maker-canvas-container { padding-bottom: 45vh; }
    .state-full ~ #maker-canvas-container { padding-bottom: 85vh; opacity: 0.3; pointer-events: none; }
}

.drawer-header {
    flex: 0 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(to bottom, rgba(20,20,20,0.9), rgba(20,20,20,0.5));
    border-radius: 35px 35px 0 0;
}

.drawer-drag-zone {
    width: 100%;
    height: 40px; /* Larger area for easy dragging */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 10;
}

.drawer-handle-bar {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.maker-cat-nav {
    display: flex;
    gap: 15px;
    padding: 5px 20px 15px;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.maker-cat-nav::-webkit-scrollbar {
    display: none;
}

.cat-nav-item {
    flex: 0 0 54px;
    height: 54px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.4);
    position: relative;
    user-select: none;
}

.maker-actions {
    position: absolute;
    top: 25px;
    right: 25px;
    display: flex;
    gap: 15px;
    z-index: 5000; /* Extremely high to be above drawer/canvas */
}

.cat-lock-btn {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.cat-lock-btn.locked {
    background: #BE473B;
    border-color: rgba(255, 215, 0, 0.3);
}

.cat-lock-btn.unlocked {
    background: #2e7d32;
    border-color: rgba(255, 255, 255, 0.3);
}

.cat-nav-item.active {
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.cat-nav-item img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Category Content Area */
.maker-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px 20px;
}

.items-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 15px;
    padding-bottom: 80px; /* Space for footer button */
}

/* Vertical Asset Thumb */
.asset-thumb {
    aspect-ratio: 1;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s ease;
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.asset-thumb:hover {
    background: rgba(255, 255, 255, 0.08);
}

.asset-thumb.active {
    border-color: var(--accent);
    background: rgba(255, 215, 0, 0.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.text-thumb-preview {
    font-size: 1.5rem;
    font-weight: 900;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

/* Text Input Styling */
.text-input-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 5px;
}

.text-input-row label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 1px;
    opacity: 0.8;
}

.maker-text-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 12px 15px;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}

.maker-text-input:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.1);
}

/* HSB Color Dashboard */
.color-dashboard {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: auto;
    /* Push to base */
}

.color-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.color-main-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0 5px;
}

.cat-actions-row {
    display: flex;
    gap: 6px;
    margin-top: 5px;
}

.cat-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    padding: 6px;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cat-action-btn:hover:not(.disabled) {
    background: rgba(255, 215, 0, 0.2);
    transform: scale(1.1);
}

.cat-action-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(1);
    border-color: rgba(255, 255, 255, 0.1);
}

.hex-label {
    font-family: monospace;
    font-size: 0.7rem;
    opacity: 0.8;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
    border: 1px solid rgba(255, 215, 0, 0.2);
    text-transform: uppercase;
}

.maker-color-picker {
    width: 42px;
    height: 42px;
    border: none;
    background: none;
    cursor: pointer;
}

.maker-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.maker-color-picker::-webkit-color-swatch {
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
}

.hsb-sliders {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hsb-slider-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hsb-slider-item label {
    font-size: 0.65rem;
    text-transform: uppercase;
    opacity: 0.5;
    min-width: 70px;
    letter-spacing: 1px;
}

.hsb-slider-item input[type="range"] {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    accent-color: var(--accent);
}

.hsb-slider-item span {
    font-size: 0.75rem;
    font-family: monospace;
    min-width: 35px;
    text-align: right;
    color: var(--accent);
}

/* Actions Bar */
.maker-global-actions {
    display: flex;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.maker-action-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 15px;
}

/* Control Groups & Items */
.maker-control-group {
    display: none;
    flex-direction: column;
    height: 100%;
}

.maker-control-group.active {
    display: flex;
}

/* Vertical Items Grid */
.items-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    padding: 5px;
    overflow-y: auto;
    flex: 1;
    min-height: 200px; /* Ensure it takes space */
}

.asset-thumb {
    aspect-ratio: 1/1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.asset-thumb img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.asset-thumb:active {
    transform: scale(0.95);
}

.asset-thumb.active {
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.1);
}

.asset-thumb.active::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--accent);
    color: #000;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Color Dashboard */
.color-dashboard {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 15px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.color-row {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.color-main-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.maker-color-picker {
    -webkit-appearance: none;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: none;
    padding: 0;
}

.maker-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.maker-color-picker::-webkit-color-swatch {
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

.hsb-sliders {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.hsb-slider-item {
    display: grid;
    grid-template-columns: 80px 1fr 40px;
    align-items: center;
    gap: 10px;
}

.hsb-slider-item label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
}

.hsb-slider-item span {
    font-size: 0.7rem;
    color: var(--accent);
    text-align: right;
    font-family: monospace;
}

input[type="range"] {
    -webkit-appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* Footer & Actions */
.maker-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    background: rgba(10, 10, 10, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.action-btn {
    flex: 1;
    height: 46px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.action-btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .color-dashboard {
        display: none;
    }
    .mode-color-active .color-dashboard {
        display: flex;
    }
    .mode-color-active .items-grid-container {
        display: none;
    }
}

/* Desktop Adjustments */
@media (min-width: 769px) {
    .preview-layer {
        left: 0;
        width: calc(100% - 400px);
        height: 100%;
        padding: 40px;
    }

    .maker-drawer {
        left: auto;
        right: 0;
        top: 0;
        width: 400px;
        height: 100%;
        border-top: none;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0;
    }

    .drawer-handle-bar { display: none; }

    .color-dashboard {
        display: flex !important;
    }
    .items-grid-container {
        display: grid !important;
    }
    #maker-toggle-color { display: none; }
}
