:root {
    --primary: #EC4899;
    /* Pink */
    --primary-hover: #db2777;
    --accent: #8B5CF6;
    /* Purple */
    --accent-hover: #7c3aed;
    --background: #111827;
    /* Gray 900 */
    --surface: #1F2937;
    /* Gray 800 */

    --glass-bg: rgba(31, 41, 55, 0.7);
    --glass-border: rgba(236, 72, 153, 0.2);

    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --text-error: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    min-height: 100vh;
}

.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 10% 20%, rgba(236, 72, 153, 0.08), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.08), transparent 40%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.25rem;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

header p {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-top: 0.5rem;
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.workspace-panel {
    display: flex;
    flex-direction: column;
}

/* Utilities */
.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.hidden {
    display: none !important;
}

.full-width {
    width: 100%;
}

.text-error {
    color: var(--text-error) !important;
}

.divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1.5rem 0;
}

.divider-v {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 0.5rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h2 {
    font-size: 1.2rem;
    color: var(--text-main);
    font-weight: 600;
}

h3 {
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 500;
}

/* Toolbars */
.toolbar,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

.primary-btn {
    background: var(--primary);
    color: #fff;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.outline-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
}

.outline-btn:hover {
    border-color: var(--text-main);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.outline-btn.active {
    background: rgba(236, 72, 153, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

/* Toggles */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-switch .slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    transition: 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toggle-switch .slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    background: #fff;
    transition: 0.3s;
}

.toggle-switch input:checked+.slider {
    background: var(--primary);
    border-color: var(--primary);
}

.toggle-switch input:checked+.slider::before {
    transform: translateX(16px);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Canvas */
.canvas-container {
    background: #0f172a;
    /* Slate 900 */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: crosshair;
    aspect-ratio: 3/2;
    max-height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    max-width: 100%;
    /* Let JS handle absolute size, CSS scales it down visually if needed */
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Scrubber */
.slider-full {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    outline: none;
}

.slider-full::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

/* Code Panel */
.small-select {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 4px;
    outline: none;
}

.code-block {
    position: relative;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    min-height: 100px;
}

pre {
    margin: 0;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: #e5e7eb;
    white-space: pre-wrap;
    word-break: break-all;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Info Box */
.info-box {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    padding: 1rem;
}

.info-box ul {
    list-style: none;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.info-box li {
    margin-bottom: 0.4rem;
}

.key {
    display: inline-block;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-family: inherit;
    font-size: 0.8rem;
    color: #fff;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.toast.show {
    opacity: 1;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
}