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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
}

#container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

#canvas-container {
    flex: 1;
    position: relative;
}

canvas {
    display: block;
}

#sidebar {
    width: 384px;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(12px);
    border-left: 1px solid #374151;
    padding: 1rem;
    overflow-y: auto;
    color: white;
}

#sidebar::-webkit-scrollbar {
    width: 8px;
}

#sidebar::-webkit-scrollbar-track {
    background: #1F2937;
}

#sidebar::-webkit-scrollbar-thumb {
    background: #4B5563;
    border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: #6B7280;
}

h1 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #8B5CF6, #EC4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.section {
    margin-bottom: 1rem;
}

.dimension-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.875rem;
}

.btn-dimension {
    background: #374151;
    color: #D1D5DB;
}

.btn-dimension:hover {
    background: #4B5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-dimension.active {
    background: linear-gradient(to right, #8B5CF6, #EC4899);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn-primary {
    background: #10B981;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-secondary {
    background: #6366F1;
    color: white;
    width: 100%;
}

.btn-secondary:hover {
    background: #4F46E5;
    transform: translateY(-1px);
}

.btn-danger {
    background: #EF4444;
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
    transform: translateY(-1px);
}

.btn-remove {
    padding: 0.5rem 0.75rem;
    background: #EF4444;
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: #DC2626;
}

.equation-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.color-indicator {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

input[type="text"] {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: #1F2937;
    color: white;
    border: 1px solid #4B5563;
    border-radius: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    transition: all 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #374151;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(to right, #8B5CF6, #EC4899);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(to right, #8B5CF6, #EC4899);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: rgba(75, 85, 99, 0.3);
}

.time-control {
    background: #1F2937;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #374151;
}

.intersections-box {
    background: #1F2937;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #374151;
}

.intersection-list {
    max-height: 160px;
    overflow-y: auto;
    font-size: 0.875rem;
}

.intersection-item {
    background: #374151;
    padding: 0.5rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
    color: #D1D5DB;
}

.help-box {
    background: #1F2937;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    color: #9CA3AF;
    border: 1px solid #374151;
}

.help-box div {
    margin-bottom: 0.25rem;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #9CA3AF;
    margin-top: 0.25rem;
}

.value-tag {
    color: #8B5CF6;
    font-weight: 600;
}

.math-keyboard {
    background: #1F2937;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #374151;
}

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

.keyboard-row:last-child {
    margin-bottom: 0;
}

.keyboard-row button {
    padding: 0.5rem;
    background: #374151;
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.keyboard-row button:hover {
    background: #4B5563;
    transform: scale(1.05);
}

.keyboard-row button:active {
    transform: scale(0.95);
}

.color-preview {
    height: 30px;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    background: linear-gradient(to right, 
        hsl(0, 70%, 60%), 
        hsl(60, 70%, 60%),
        hsl(120, 70%, 60%),
        hsl(180, 70%, 60%),
        hsl(240, 70%, 60%),
        hsl(300, 70%, 60%),
        hsl(360, 70%, 60%)
    );
    border: 1px solid #4B5563;
}
