:root {
    --bg: #070b17;
    --panel: #0f1731;
    --panel-border: #41599d;
    --text: #ebf1ff;
    --muted: #9db0df;
    --accent: #52f2d2;
    --accent-2: #ff77cb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 10%, rgba(82, 242, 210, 0.14), transparent 30%),
        radial-gradient(circle at 88% 0%, rgba(255, 119, 203, 0.18), transparent 34%),
        linear-gradient(180deg, #070b17 0%, #0d1430 100%);
}

.app {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.3rem 1rem 2.1rem;
}

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.back-link:hover {
    text-decoration: underline;
}

.hero {
    margin: 0.95rem 0 1.1rem;
}

.kicker {
    margin: 0;
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

h1 {
    margin: 0.35rem 0 0.35rem;
    font-size: clamp(1.8rem, 3.3vw, 2.7rem);
}

.subtitle {
    margin: 0;
    max-width: 68ch;
    color: var(--muted);
}

.layout {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(250px, 290px) minmax(320px, 1fr);
    grid-template-areas:
        "controls editor"
        "controls preview";
}

.panel {
    background: linear-gradient(180deg, rgba(15, 23, 49, 0.96), rgba(11, 18, 39, 0.98));
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
    padding: 0.9rem;
}

.panel h2 {
    margin: 0 0 0.7rem;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.control-panel {
    grid-area: controls;
    display: grid;
    gap: 0.85rem;
    align-content: start;
}

.helper {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.35;
}

.palette {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
}

.swatch {
    border: 1px solid rgba(157, 176, 223, 0.45);
    border-radius: 10px;
    background: #111b39;
    color: var(--text);
    text-align: left;
    padding: 0.45rem 0.5rem;
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease;
}

.swatch:hover {
    transform: translateY(-1px);
}

.swatch.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(82, 242, 210, 0.5) inset;
}

.swatch-chip {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    margin-bottom: 0.32rem;
}

.swatch-name {
    font-size: 0.77rem;
    letter-spacing: 0.02em;
}

.actions {
    display: grid;
    gap: 0.42rem;
}

button {
    border: 1px solid #6780c4;
    border-radius: 10px;
    background: linear-gradient(180deg, #35559b, #253c70);
    color: var(--text);
    font-weight: 700;
    font-size: 0.84rem;
    padding: 0.62rem 0.74rem;
    cursor: pointer;
}

button:hover {
    transform: translateY(-1px);
}

button.ghost {
    background: linear-gradient(180deg, #263252, #18223f);
}

button.accent {
    border-color: #87ffe6;
    background: linear-gradient(180deg, #39d8b4, #21957a);
    color: #061512;
}

.stats {
    display: grid;
    gap: 0.45rem;
}

.stats > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(108, 132, 204, 0.5);
    border-radius: 8px;
    background: rgba(18, 27, 54, 0.72);
    padding: 0.45rem 0.55rem;
}

.stats span {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stats strong {
    font-size: 0.98rem;
}

.editor-panel {
    grid-area: editor;
}

.preview-panel {
    grid-area: preview;
}

canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    border: 1px solid #556daf;
    background: #0a1228;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "controls"
            "editor"
            "preview";
    }
}
