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

:root {
    --primary-color: #9333ea;
    --secondary-color: #667eea;
    --accent-color: #f59e0b;
    --success-color: #16a34a;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    
    --bg-primary: rgba(255, 255, 255, 0.98);
    --bg-secondary: rgba(248, 250, 252, 0.95);
    --bg-tertiary: rgba(241, 245, 249, 0.9);
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-accent: #475569;
    
    --border-light: rgba(226, 232, 240, 0.8);
    --border-medium: rgba(203, 213, 225, 0.9);
    
    --shadow-light: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-heavy: 0 16px 48px rgba(0, 0, 0, 0.16);
    
    --radius-small: 6px;
    --radius-medium: 10px;
    --radius-large: 16px;
    
    --header-height: 120px;
    --canvas-top: 0px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #9333ea 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Intelligent Sticky Header */
.smart-sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 2px solid rgba(102, 126, 234, 0.3);
    z-index: 1000;
    padding: 20px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-medium);
}

.smart-sticky-header.sticky-active {
    background: rgba(0, 0, 0, 0.98);
    border-bottom-color: rgba(102, 126, 234, 0.5);
    box-shadow: var(--shadow-heavy);
}

.header-content {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.smart-sticky-header h1 {
    color: white;
    font-size: 1.6rem;
    font-weight: 800;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.4);
    margin: 0;
    letter-spacing: -0.5px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.speed-control-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.speed-control-group label {
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
}

.speed-control-group select {
    padding: 10px 14px;
    border: 2px solid rgba(55, 65, 81, 0.6);
    border-radius: var(--radius-medium);
    background: rgba(255, 255, 255, 0.95);
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 200px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.speed-control-group select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* Custom Speed Controls */
.custom-speed-controls {
    display: none;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.15);
    padding: 12px 16px;
    border-radius: var(--radius-medium);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.custom-speed-controls input[type="range"] {
    width: 140px;
    margin: 0;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
}

.custom-speed-controls input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 2px solid var(--secondary-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.custom-input {
    width: 90px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 500;
}

.unit-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Manual Step Controls */
.manual-step-controls {
    display: none;
    align-items: center;
    gap: 15px;
    background: rgba(245, 158, 11, 0.15);
    padding: 12px 16px;
    border-radius: var(--radius-medium);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.step-btn {
    background: linear-gradient(135deg, var(--accent-color) 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 12px 18px;
    border-radius: var(--radius-medium);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    letter-spacing: 0.3px;
}

.step-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

.step-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.step-info {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

.step-counter {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.primary-btn, .secondary-btn {
    padding: 12px 18px;
    border: none;
    border-radius: var(--radius-medium);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.3px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.primary-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a6fd8 0%, #7c3aed 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.secondary-btn {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

.secondary-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(107, 114, 128, 0.4);
}

.primary-btn:disabled, .secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Speed Display */
.speed-display {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-medium);
    padding: 10px 16px;
    margin-top: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.speed-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.speed-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    font-weight: 500;
}

.speed-value {
    color: white;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Canvas-Aware Status Overlay */
.canvas-aware-status {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 999;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-large);
    padding: 16px 20px;
    color: white;
    text-align: center;
    min-width: 220px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-medium);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.generation-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.mode-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.mode-badge.setup {
    background: rgba(147, 51, 234, 0.3);
    border: 1px solid rgba(147, 51, 234, 0.6);
    color: #e4d4f4;
}

.mode-badge.generating {
    background: rgba(22, 163, 74, 0.3);
    border: 1px solid rgba(22, 163, 74, 0.6);
    color: #bbf7d0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

.performance-metrics {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Main Layout */
.main-layout {
    margin-top: 160px;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 25px;
    margin-bottom: 30px;
}

.canvas-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Viewport Responsive Container */
.viewport-responsive-container {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-large);
    padding: 25px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-medium);
    text-align: center;
    border: 1px solid var(--border-light);
    overflow: hidden;
}

#sierpinski-canvas {
    border: 3px dashed var(--primary-color);
    border-radius: var(--radius-large);
    cursor: grab;
    touch-action: none;
    max-width: 100%;
    height: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-light);
}

#sierpinski-canvas:active {
    cursor: grabbing;
    transform: scale(0.995);
}

#sierpinski-canvas:hover {
    border-color: var(--secondary-color);
    box-shadow: var(--shadow-medium);
}

/* Smart Configuration Guide */
.configuration-guide {
    position: absolute;
    top: 25px;
    left: 25px;
    right: 25px;
    background: rgba(0, 0, 0, 0.92);
    color: white;
    padding: 20px;
    border-radius: var(--radius-large);
    backdrop-filter: blur(20px);
    z-index: 10;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.guide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.guide-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.3px;
}

.guide-toggle {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: var(--radius-small);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.guide-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.instruction-step {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 10px 0;
    padding: 10px 15px;
    border-radius: var(--radius-medium);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.6;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.instruction-step.active {
    opacity: 1;
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.3);
    transform: translateX(5px);
}

.instruction-step.completed {
    opacity: 0.8;
    background: rgba(22, 163, 74, 0.15);
    border-color: rgba(22, 163, 74, 0.3);
}

.step-number {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.instruction-step.completed .step-number {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

.step-text {
    flex: 1;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.step-status {
    font-size: 1rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* Comprehensive Analysis Panel */
.comprehensive-analysis-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-large);
    padding: 25px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-light);
    max-height: 600px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-light);
}

.analysis-header h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.3px;
}

.panel-controls {
    display: flex;
    gap: 8px;
}

.analysis-toggle, .panel-toggle {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
    padding: 6px 12px;
    border-radius: var(--radius-small);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.analysis-toggle:hover, .panel-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.analysis-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.analysis-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.analysis-section h4 {
    color: var(--text-accent);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 15px;
    letter-spacing: 0.2px;
}

.analysis-placeholder, .stats-placeholder {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 30px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    border: 2px dashed var(--border-medium);
}

/* Step Analysis Grid */
.step-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.metric-card {
    background: var(--bg-secondary);
    padding: 12px 15px;
    border-radius: var(--radius-medium);
    border: 1px solid var(--border-light);
    text-align: center;
    transition: all 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.metric-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.vertex-card {
    border-color: var(--primary-color);
    background: rgba(147, 51, 234, 0.05);
}

.vertex-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.vertex-indicator.vertex-0 { background: #ef4444; }
.vertex-indicator.vertex-1 { background: #22c55e; }
.vertex-indicator.vertex-2 { background: #3b82f6; }

/* Vertex Statistics */
.vertex-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.vertex-stat-card {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: var(--radius-medium);
    border: 1px solid var(--border-light);
}

.vertex-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.vertex-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.vertex-percentage {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.vertex-stat-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.vertex-stat-fill {
    height: 100%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 4px;
}

.vertex-stat-fill.vertex-0 { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.vertex-stat-fill.vertex-1 { background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); }
.vertex-stat-fill.vertex-2 { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }

.vertex-stat-count {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

/* Distance and Pattern Metrics */
.distance-metrics, .emergence-metrics {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.distance-metric, .emergence-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-small);
    border: 1px solid var(--border-light);
}

.metric-bar {
    width: 100%;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}

.metric-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 3px;
}

/* History Visualization Controls */
.history-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.control-item, .option-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-small);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.control-item:hover, .option-item:hover {
    background: var(--bg-tertiary);
    transform: translateY(-1px);
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-medium);
    border-radius: 4px;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.control-item input[type="checkbox"], .option-item input[type="checkbox"] {
    display: none;
}

.control-item input[type="checkbox"]:checked + .checkmark,
.option-item input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.control-item input[type="checkbox"]:checked + .checkmark::after,
.option-item input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Advanced Settings Panel */
.advanced-settings-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-large);
    padding: 25px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-light);
    height: fit-content;
    max-height: 800px;
    overflow-y: auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-light);
}

.panel-header h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.3px;
}

.settings-section {
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-light);
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.settings-section h4 {
    color: var(--text-accent);
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* Preset Grid */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.preset-btn {
    padding: 12px 15px;
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-medium);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.preset-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.preset-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-medium);
}

/* Coordinates Display */
.coordinates-display {
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    padding: 15px;
    margin: 15px 0;
    border: 1px solid var(--border-light);
}

.coord-header {
    font-weight: 600;
    color: var(--text-accent);
    margin-bottom: 12px;
    font-size: 0.9rem;
    letter-spacing: 0.2px;
}

.coordinates-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vertex-coord, .start-point-coord {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: white;
    border-radius: var(--radius-small);
    border: 1px solid var(--border-light);
}

.start-point-coord {
    border-left: 4px solid var(--danger-color);
    background: rgba(239, 68, 68, 0.05);
}

.coord-values {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.3px;
}

.start-indicator {
    font-size: 1rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* Parameter Controls */
.parameter-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.parameter-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.parameter-item label {
    font-weight: 600;
    color: var(--text-accent);
    font-size: 0.9rem;
    letter-spacing: 0.2px;
}

.parameter-item select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-medium);
    background: white;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23475569" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
}

.parameter-item select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

.parameter-item input[type="range"] {
    width: 100%;
    margin: 10px 0;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: var(--border-light);
    outline: none;
    cursor: pointer;
}

.parameter-item input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(147, 51, 234, 0.3);
    transition: all 0.2s ease;
}

.parameter-item input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.4);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 5px;
}

.visual-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

/* Performance Metrics */
.performance-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-small);
    border: 1px solid var(--border-light);
}

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

.metric-value {
    color: var(--text-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Smart Visibility Notice */
.visibility-notice {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 15px 25px;
    border-radius: var(--radius-large);
    z-index: 1000;
    text-align: center;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(239, 68, 68, 0.3);
    box-shadow: var(--shadow-heavy);
    animation: slideUpFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUpFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.notice-content {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.notice-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.notice-text {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.notice-action {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: var(--radius-medium);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.notice-action:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Footer */
footer {
    text-align: center;
    color: white;
    opacity: 0.95;
    margin-top: 30px;
    padding: 25px 0;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
}

footer a {
    color: #fbbf24;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

footer a:hover {
    color: #f59e0b;
    text-decoration: underline;
}

footer p {
    margin-bottom: 8px;
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .main-layout {
        grid-template-columns: 1fr 360px;
        gap: 20px;
    }
}

@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 1fr 340px;
        gap: 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .header-controls {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .advanced-settings-panel, .comprehensive-analysis-panel {
        max-height: none;
    }
    
    .canvas-aware-status {
        position: relative;
        top: 0;
        right: 0;
        margin-bottom: 20px;
    }
    
    .main-layout {
        margin-top: 20px;
    }
    
    .preset-grid {
        grid-template-columns: 1fr;
    }
    
    .step-metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .smart-sticky-header h1 {
        font-size: 1.3rem;
    }
    
    .header-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .speed-control-group {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .action-buttons button {
        width: 100%;
    }
    
    .configuration-guide {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        margin-bottom: 20px;
    }
    
    .step-metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .performance-grid {
        grid-template-columns: 1fr;
    }
    
    .history-controls {
        grid-template-columns: 1fr;
    }
    
    .parameter-item input[type="range"]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .viewport-responsive-container {
        padding: 15px;
    }
    
    .comprehensive-analysis-panel, .advanced-settings-panel {
        padding: 20px;
    }
    
    .notice-content {
        flex-direction: column;
        gap: 10px;
    }
    
    .performance-metrics {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .mode-badge.generating {
        animation: none;
    }
}

@media (prefers-contrast: high) {
    .comprehensive-analysis-panel,
    .viewport-responsive-container,
    .advanced-settings-panel {
        background: rgba(255, 255, 255, 1);
        border: 3px solid #000;
    }
    
    #sierpinski-canvas {
        border: 3px solid #000;
    }
    
    .smart-sticky-header {
        background: rgba(0, 0, 0, 1);
        border-bottom: 3px solid #fff;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: rgba(31, 41, 55, 0.98);
        --bg-secondary: rgba(55, 65, 81, 0.95);
        --bg-tertiary: rgba(75, 85, 99, 0.9);
        
        --text-primary: #f3f4f6;
        --text-secondary: #9ca3af;
        --text-accent: #d1d5db;
        
        --border-light: rgba(75, 85, 99, 0.8);
        --border-medium: rgba(107, 114, 128, 0.9);
    }
    
    .coordinates-display,
    .step-details,
    .metric-card,
    .vertex-stat-card,
    .distance-metric,
    .emergence-metric,
    .control-item,
    .option-item,
    .metric-item {
        background: var(--bg-secondary);
        color: var(--text-primary);
    }
    
    .vertex-coord,
    .start-point-coord {
        background: var(--bg-tertiary);
    }
    
    .parameter-item select,
    .preset-btn {
        background: var(--bg-secondary);
        color: var(--text-primary);
        border-color: var(--border-medium);
    }
    
    .checkmark {
        border-color: var(--border-medium);
    }
}

/* Custom Scrollbar */
.comprehensive-analysis-panel::-webkit-scrollbar,
.advanced-settings-panel::-webkit-scrollbar {
    width: 8px;
}

.comprehensive-analysis-panel::-webkit-scrollbar-track,
.advanced-settings-panel::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.comprehensive-analysis-panel::-webkit-scrollbar-thumb,
.advanced-settings-panel::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.comprehensive-analysis-panel::-webkit-scrollbar-thumb:hover,
.advanced-settings-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Focus styles for accessibility */
button:focus,
select:focus,
input:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* High performance optimizations */
.canvas-section,
.comprehensive-analysis-panel,
.advanced-settings-panel {
    will-change: transform;
}

#sierpinski-canvas {
    will-change: transform;
}

/* Print styles */
@media print {
    .smart-sticky-header,
    .canvas-aware-status,
    .visibility-notice {
        display: none;
    }
    
    .main-layout {
        margin-top: 0;
        grid-template-columns: 1fr;
    }
    
    .comprehensive-analysis-panel,
    .advanced-settings-panel {
        max-height: none;
        overflow: visible;
    }
}