:root {
    --primary: #0984E3;
    --primary-hover: #076CBF;
    --secondary: #74B9FF;
    --accent: #FD79A8;
    --bg: #0A141E;
    --surface: #102030;
    --surface-hover: #162C41;
    --text-primary: #FFFFFF;
    --text-secondary: #8BA8C6;
    --border: rgba(116, 185, 255, 0.2);
    --border-focus: rgba(116, 185, 255, 0.6);
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 85% 10%, rgba(9, 132, 227, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 15% 90%, rgba(253, 121, 168, 0.05) 0%, transparent 40%);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    padding: 1rem;
}

.app-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 2rem);
    gap: 1.5rem;
}

/* Glassmorphism Helpers */
.glass-panel {
    background: rgba(16, 32, 48, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Header */
.header {
    text-align: left;
    padding: 0.5rem 1rem;
}

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

.accent-text {
    color: var(--accent);
    font-style: italic;
}

.header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
}

/* Controls Panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1.5rem;
    gap: 1.5rem;
}

.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 1rem;
    margin-bottom: 0.5rem;
}

.panel-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.preset-select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.preset-select:focus {
    border-color: var(--border-focus);
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-section h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary);
    font-weight: 600;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

/* Toggles & Inputs */
.toggle-group {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.25rem;
    gap: 0.25rem;
}

.grid-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(9, 132, 227, 0.4);
}

.range-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.1);
    height: 6px;
    border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--secondary);
    margin-top: -5px;
    box-shadow: 0 0 10px rgba(116, 185, 255, 0.4);
    transition: var(--transition);
}

.range-val {
    font-size: 0.85rem;
    font-family: monospace;
    color: var(--text-primary);
    min-width: 4ch;
    text-align: right;
}

/* Code Output */
.code-section {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

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

.copy-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: #a6e22e;
    /* Code green like token */
    line-height: 1.4;
}

.token-prop {
    color: #66D9EF;
}

.token-val {
    color: #E6DB74;
}

.token-class {
    color: var(--accent);
}

/* Preview Area */
.preview-panel {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1rem;
    overflow: hidden;
}

.preview-controls {
    display: flex;
    gap: 0.5rem;
}

.icon-btn,
.device-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
}

.icon-btn:hover,
.device-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.device-toggles {
    display: flex;
    gap: 0.25rem;
    margin-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding-left: 1rem;
}

.device-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.preview-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 2rem;
    overflow: hidden;
    transition: all 400ms ease;
    min-height: 0;
}

.preview-wrapper.device-mobile {
    padding: 1rem;
}

/* The actual scroll container */
.scroll-container {
    width: 100%;
    height: 100%;
    background: var(--surface-hover);
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: auto;
    display: flex;
    gap: 20px;

    /* These will be overridden by JS */
    scroll-snap-type: x mandatory;
    padding: 20px;
}

/* Modifiers based on direction/preset via JS inline styles, default is row */
.scroll-container.is-y {
    flex-direction: column;
}

.scroll-container.is-both {
    flex-wrap: wrap;
    align-content: flex-start;
}

.scroll-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.scroll-container::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 5px;
}

/* Snap Items */
.snap-item {
    flex: 0 0 calc(100% - 40px);
    min-height: calc(100% - 40px);
    background: linear-gradient(135deg, var(--surface) 0%, rgba(9, 132, 227, 0.2) 100%);
    border: 2px solid var(--border);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);

    /* Will be overridden by JS */
    scroll-snap-align: center;
    scroll-snap-stop: normal;
}

/* Specific item styles for visual flair */
.snap-item:nth-child(4n+1) {
    background: linear-gradient(135deg, var(--surface) 0%, rgba(9, 132, 227, 0.3) 100%);
}

.snap-item:nth-child(4n+2) {
    background: linear-gradient(135deg, var(--surface) 0%, rgba(116, 185, 255, 0.3) 100%);
}

.snap-item:nth-child(4n+3) {
    background: linear-gradient(135deg, var(--surface) 0%, rgba(253, 121, 168, 0.2) 100%);
}

.snap-item:nth-child(4n+4) {
    background: linear-gradient(135deg, var(--surface) 0%, rgba(160, 185, 174, 0.2) 100%);
}


/* Mobile Mockup Styles */
.preview-wrapper.device-mobile .scroll-container {
    width: 375px;
    height: 667px;
    border-width: 12px;
    border-radius: 36px;
    border-color: #000;
    background: var(--bg);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 20px 40px rgba(0, 0, 0, 0.6);
}

.preview-wrapper.device-mobile .snap-item {
    flex: 0 0 calc(100% - 20px);
    min-height: calc(50% - 20px);
    /* Smaller items for mobile to show scrolling better */
}

/* Matrix layout helper */
.scroll-container.preset-matrix {
    display: grid;
    grid-template-columns: repeat(3, 100%);
    grid-template-rows: repeat(3, 100%);
    gap: 0;
    padding: 0;
}

.scroll-container.preset-matrix .snap-item {
    width: 100%;
    height: 100%;
    min-height: auto;
    border-radius: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface-hover);
    color: var(--secondary);
    padding: 0.75rem 1.5rem;
    border-radius: 24px;
    font-weight: 500;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    opacity: 0;
    transition: all 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Responsive Root */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 500px;
        overflow-y: auto;
    }
}