:root {
    --primary: #ff8a4d;
    --bg: #120d0d;
    --card: rgba(24, 14, 14, 0.92);
    --panel: rgba(18, 11, 11, 0.98);
    --border: rgba(255, 180, 128, 0.18);
    --border-strong: rgba(255, 180, 128, 0.34);
    --text: #f6f1ee;
    --muted: #c8b6ae;
    --sidebar-width: 360px;
    --toolbar-height: 56px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--primary) 16%, transparent) 0%, transparent 38%),
        linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%),
        var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

.app-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

body[data-dashboard-sidebar-externalized="true"] .color-panel {
    display: none;
}

/* REAL LEFT STICKY SIDEBAR WITH ITS OWN SCROLLVIEW */
.color-panel {
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    height: 100vh;
    padding: 22px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--panel);
    border-right: 1px solid var(--border);
    box-shadow: 12px 0 34px rgba(0, 0, 0, 0.22);
    position: sticky;
    top: 0;
    left: 0;
    z-index: 20;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.color-panel::-webkit-scrollbar {
    width: 10px;
}

.color-panel::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}

.sidebar-header {
    margin-bottom: 22px;
}

.sidebar-header h1 {
    margin: 0;
    font-size: 1.55rem;
    line-height: 1;
    font-weight: 900;
    letter-spacing: -0.05em;
}

.sidebar-header h1 span {
    color: var(--primary);
}

.sidebar-header p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.4;
}

/* FULL STRETCHED PREVIEW AREA: NO OUTER MARGIN, NO CARD GUTTER */
.preview-area {
    flex: 1 1 auto;
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #070707;
}

.preview-toolbar {
    flex: 0 0 var(--toolbar-height);
    height: var(--toolbar-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    margin: 0;
    background: rgba(255, 255, 255, 0.035);
    border-bottom: 1px solid var(--border);
}

input[type="file"] {
    color: var(--muted);
    max-width: 100%;
}

.canvas-container {
    flex: 1 1 auto;
    width: 100%;
    height: calc(100vh - var(--toolbar-height));
    min-height: 0;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background-color: #070707;
    background-image:
        linear-gradient(45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.025) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.025) 75%);
    background-size: 32px 32px;
    background-position: 0 0, 0 16px, 16px -16px, -16px 0;
}

canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    image-rendering: pixelated;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.7);
    cursor: crosshair;
}

.tool-box {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.tool-box label {
    display: block;
    margin-bottom: 10px;
    color: var(--primary);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

select,
input[type="range"] {
    width: 100%;
}

select {
    min-height: 40px;
    margin-bottom: 16px;
    padding: 9px 10px;
    color: var(--text);
    background: rgba(8, 10, 16, 0.86);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
}

select:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

input[type="range"] {
    accent-color: var(--primary);
    cursor: pointer;
}

.range-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.72rem;
}

.palette-section {
    margin-bottom: 20px;
}

.palette-section h3 {
    margin: 0 0 12px;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: 6px;
    min-height: 44px;
    max-height: 34vh;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.color-swatch {
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: var(--text);
    z-index: 5;
}

.color-swatch.active {
    border: 2px solid var(--text);
    box-shadow: 0 0 12px color-mix(in srgb, var(--primary) 66%, transparent);
}

.btn {
    width: 100%;
    min-height: 42px;
    padding: 11px 12px;
    color: #fff;
    background: var(--primary);
    border: 0;
    border-radius: 10px;
    font-size: 0.86rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease;
}

.btn:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.btn-secondary {
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.09);
}

.badge {
    float: right;
    padding: 2px 7px;
    color: #fff;
    background: var(--primary);
    border-radius: 999px;
    font-size: 0.68rem;
}

input[type="color"] {
    width: 100%;
    height: 42px;
    margin-bottom: 10px;
    padding: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
}

@media (max-width: 760px) {
    :root {
        --sidebar-width: 300px;
    }

    .color-panel {
        padding: 16px;
    }

    .sidebar-header h1 {
        font-size: 1.25rem;
    }
}
