:root {
    --bg: #0c0f22;
    --panel: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.10);
    --text: #eef2ff;
    --muted: #a7b0c7;
    --brand: #ff3040;
    --btn: #1a2149;
    --btnHover: #243169;
    --chip: #1f2444;
    --chipBorder: #2b3260;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
    background: radial-gradient(1200px 700px at 20% -10%, #1b2157 0%, #0e122d 60%, #090b1a 100%);
    background-attachment: fixed;
}

.app {
    max-width: 1100px;
    margin: 14px auto 64px;
    padding: 0 12px;
}

header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

header .badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff6a75, #ff3040);
    display: grid;
    place-items: center;
    box-shadow: var(--shadow);
}

header h1 {
    margin: 0;
    font-size: 1.1rem;
}

header p {
    margin: 4px 0 0;
    font-size: .9rem;
    color: var(--muted)
}

/* Mobile-first: single column, tools first */
.grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}

aside.panel.controls {
    order: 0;
}

main.panel.preview {
    order: 1;
}

/* Desktop: two columns */
@media (min-width: 980px) {
    .grid {
        grid-template-columns: 360px 1fr;
        align-items: start;
    }
}

.panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .02));
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.controls {
    padding: 12px;
}

@media (min-width: 980px) {
    .controls {
        position: sticky;
        top: 10px;
    }
}

.group {
    background: rgba(0, 0, 0, .16);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.group h3 {
    margin: 0 0 10px;
    font-size: .95rem;
    font-family: Poppins, Inter, sans-serif;
    letter-spacing: .2px;
}

label {
    display: block;
    font-size: .85rem;
    color: var(--muted);
    margin-bottom: 6px;
}

input[type="text"],
textarea,
select,
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(10, 12, 28, .6);
    color: var(--text);
    outline: none;
    font-size: .95rem;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

input[type="file"] {
    width: 100%;
}

input[type="color"] {
    width: 44px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .2);
    background: transparent;
}

input[type="range"] {
    width: 100%;
    accent-color: #3b82f6;
}

.row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn {
    border: 1px solid rgba(255, 255, 255, .1);
    background: var(--btn);
    color: #fff;
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, transform .05s;
}

.btn:hover {
    background: var(--btnHover)
}

.btn:active {
    transform: translateY(1px)
}

.btn.primary {
    background: linear-gradient(180deg, #2a3aa0, #1b2358)
}

.chip-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--chip);
    border: 1px solid var(--chipBorder);
    font-size: .88rem;
    line-height: 1;
    height: 32px;
}

.chip .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .25) inset;
}

.chip .x {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    cursor: pointer;
}

.preview {
    padding: 10px;
}

.canvas-wrap {
    position: relative;
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #0b0d1a;
    box-shadow: var(--shadow);
}

canvas {
    width: 100%;
    height: auto;
    display: block;
}

.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.note {
    color: var(--muted);
    font-size: .85rem;
    margin-top: 8px;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.switch input {
    display: none;
}

.toggle {
    width: 40px;
    height: 24px;
    border-radius: 999px;
    background: #2a2f55;
    border: 1px solid rgba(255, 255, 255, .15);
    position: relative;
}

.toggle::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    transition: transform .2s, background .2s;
}

.switch input:checked+.toggle {
    background: linear-gradient(180deg, #34d399, #0ea5e9);
}

.switch input:checked+.toggle::after {
    transform: translate(16px, -50%);
    background: #0b102e;
}