:root {
    /* Base Colors - Default Light */
    --primary: #EF4444;
    --primary-hover: #DC2626;
    --accent: #FECACA;
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

[data-theme='dark'] {
    /* Dark Theme Colors */
    --bg-main: #0B0B0C;
    --bg-surface: #1E1E20;
    --bg-surface-hover: #27272A;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;
    --border-color: #334155;
    
    /* Adjusted primary for dark mode */
    --primary: #F87171;
    --primary-hover: #EF4444;
    --accent: #7F1D1D;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Controls */
.sidebar {
    width: 320px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

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

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    transition: color 0.2s, background-color 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-hover);
}

.icon-btn.sm {
    padding: 0.25rem;
}

.theme-toggle {
    padding: 0.5rem;
}

[data-theme='light'] .sun-icon { display: none; }
[data-theme='dark'] .moon-icon { display: none; }

.control-groups {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.control-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="number"], select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

input[type="number"]:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1);
}

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

.input-with-range input[type="number"] {
    width: 4rem;
    text-align: center;
}

.input-with-range input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
}

.toggle-group {
    display: flex;
    background-color: var(--bg-main);
    border-radius: 0.5rem;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
}

.toggle-btn {
    flex: 1;
    padding: 0.375rem 0;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.toggle-btn.active {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Export Section */
.export-section {
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    height: 250px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

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

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

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

.tab-content {
    flex: 1;
    position: relative;
    background-color: var(--bg-main);
}

.panel {
    display: none;
    height: 100%;
    width: 100%;
}

.panel.active {
    display: block;
}

.code-wrapper {
    position: relative;
    height: 100%;
    padding: 1rem;
    overflow: auto;
}

.code-wrapper pre {
    margin: 0;
    font-family: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.code-wrapper .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.375rem;
    border-radius: 0.375rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.code-wrapper:hover .copy-btn {
    opacity: 1;
}

/* Main Preview Area */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    overflow: hidden;
}

.preview-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

.preview-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: 500;
    outline: none;
    text-align: center;
}

.preview-input::placeholder {
    color: var(--text-tertiary);
}

.scale-list {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.scale-item {
    width: 100%;
    max-width: 900px;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: baseline;
    gap: 2rem;
    transition: background-color 0.2s;
}

.scale-item:hover {
    background-color: var(--bg-surface-hover);
    border-radius: 0.5rem;
    padding-left: 1rem;
    padding-right: 1rem;
    margin-left: -1rem;
    margin-right: -1rem;
}

.scale-item.base-size {
    position: relative;
}

.scale-item.base-size::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--primary);
    border-radius: 0 4px 4px 0;
}

.scale-meta {
    width: 120px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.scale-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.scale-value {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-family: 'Fira Code', monospace;
}

.scale-preview {
    flex: 1;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    background-color: var(--text-primary);
    color: var(--bg-surface);
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .preview-area {
        height: 50vh;
    }
}
