:root {
    --primary: #EF4444;
    --primary-hover: #DC2626;
    --secondary: #F87171;
    --accent: #FECACA;

    --bg-dark: #0F172A;
    --bg-panel: #1E293B;
    --bg-input: #334155;

    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border: #334155;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --font-sans: 'Inter', system-ui, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 340px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.brand {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.brand .logo {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.tabs {
    display: flex;
    padding: 1rem 1.5rem 0;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.75rem 0;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-main);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.editor-view {
    display: none;
    padding: 1.5rem;
    flex-grow: 1;
    overflow-y: auto;
}

.editor-view.active {
    display: block;
    animation: fade 0.3s ease;
}

@keyframes fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Bezier UI */
.canvas-container {
    margin-bottom: 1.5rem;
    background: var(--bg-dark);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    justify-content: center;
    position: relative;
    padding: 1rem;
}

canvas {
    width: 260px;
    height: 260px;
    cursor: crosshair;
}

.coord-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.coord-item label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.25rem;
    text-align: center;
}

.num-input,
.select-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid transparent;
    color: white;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font-sans);
    text-align: center;
    transition: all 0.2s;
}

.num-input:focus,
.select-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-dark);
}

.w-24 {
    width: 100px;
}

.presets h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.preset-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-chip {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-chip:hover {
    border-color: var(--secondary);
    color: white;
}

/* Spring UI */
.info-box {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--primary);
    padding: 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.slider-group {
    margin-bottom: 1.5rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.slider-header span {
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

/* Export Box */
.export-box {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-dark);
}

.export-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    padding: 4px;
    display: flex;
    align-items: center;
}

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

#css-code {
    display: block;
    background: var(--bg-panel);
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: monospace;
}

/* Workspace */
.workspace {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    position: relative;
    min-width: 0;
}

.toolbar {
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 2rem;
    align-items: flex-end;
    background: var(--bg-panel);
}

.tool-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
}

.push-right {
    margin-left: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Demonstration Area */
.demonstration {
    padding: 2.5rem;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.track-wrap {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.track-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.track-info h3 {
    font-size: 1rem;
    font-weight: 600;
}

.badge {
    background: var(--bg-input);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    color: var(--secondary);
    font-family: monospace;
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.lane {
    height: 60px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border);
    position: relative;
    padding: 0 20px;
    display: flex;
    align-items: center;
}

.ruler {
    position: absolute;
    left: 30px;
    right: 30px;
    height: 2px;
    background: rgba(255, 255, 255, 0.05);
}

.block {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    position: absolute;
    left: 20px;
    z-index: 2;
    transform: translateX(0);
}

.current-block {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.compare-block {
    background: var(--bg-input);
    border: 2px solid var(--text-muted);
}

/* Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.gallery-item h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.75rem;
}

.box-preview {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-grid {
    background-image: linear-gradient(45deg, var(--bg-input) 25%, transparent 25%), linear-gradient(-45deg, var(--bg-input) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--bg-input) 75%), linear-gradient(-45deg, transparent 75%, var(--bg-input) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.gallery-target {
    width: 60px;
    height: 60px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

#tg-opacity {
    opacity: 1;
}

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transform: translateY(150%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.toast.show {
    transform: translateY(0);
}