

#section-analytics {
    display: none;
    padding: 2rem;
    overflow-y: auto;
    background: var(--bg-primary);
}

#section-analytics.active-section {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.analytics-header {
    text-align: center;
    margin-bottom: 2rem;
}

.analytics-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.analytics-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.analytics-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all var(--transition);
}

.analytics-card:hover {
    border-color: var(--text-muted);
}

.analytics-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.card-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.complexity-card {
    grid-column: span 1;
}

.complexity-chart {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    height: 250px;
    min-height: 250px;
    position: relative;
}

.complexity-chart canvas {
    width: 100% !important;
    height: 100% !important;
}

.complexity-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.benchmark-chart-card {
    grid-column: span 1;
}

.benchmark-chart {
    height: 200px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 0.5rem;
}

.benchmark-chart canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-note {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.info-card {
    grid-column: span 1;
}

.algo-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.algo-selector label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.algo-info-content {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1.25rem;
}

.algo-info-content .info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.algo-info-content .info-row:last-child {
    border-bottom: none;
}

.algo-info-content .info-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.algo-info-content .info-value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.85rem;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.algo-info-content .algo-description {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.stats-card {
    grid-column: span 1;
}

.session-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.export-card {
    grid-column: span 1;
}

.export-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.export-options .btn {
    flex: 1;
}

.export-note {
    text-align: center;
    color: var(--text-muted);
}

.export-note small {
    font-size: 0.75rem;
}

.complexity-chart,
.benchmark-chart {
    width: 100%;
    min-height: 200px;
    aspect-ratio: 16 / 9;
}


.usage-chart-card {
    grid-column: span 1;
}

.usage-chart {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1rem;
    height: 200px;
    min-height: 200px;
    position: relative;
}

.usage-chart canvas {
    width: 100% !important;
    height: 100% !important;
}


.trend-chart-card {
    grid-column: span 1;
}

.trend-chart {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1rem;
    height: 200px;
    min-height: 200px;
    position: relative;
}

.trend-chart canvas {
    width: 100% !important;
    height: 100% !important;
}


.analytics-timeline-wrap {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.analytics-timeline-wrap::-webkit-scrollbar {
    width: 4px;
}

.analytics-timeline-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.analytics-timeline-wrap::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.timeline-entry {
    display: flex;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.timeline-entry:last-child {
    border-bottom: none;
}

.timeline-entry:hover {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding-left: 0.5rem;
    margin-left: -0.5rem;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    background: var(--primary-color, #4a90d9);
    border-radius: 50%;
    margin-top: 0.4rem;
}

.timeline-content {
    flex: 1;
    min-width: 0;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.timeline-algo {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.timeline-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.timeline-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.timeline-stats span {
    font-size: 0.73rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.timeline-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}


.bests-card {
    grid-column: span 1;
}

.bests-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.best-card {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s ease;
}

.best-card:hover {
    border-color: var(--primary-color, #4a90d9);
}

.best-algo {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.best-metric {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2ecc71;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.best-details {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.best-when {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.bests-empty {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}


.recommendation-card {
    grid-column: span 1;
}

.rec-card {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.rec-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.rec-badge {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.rec-algo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.rec-reason {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.rec-alts-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.rec-alts {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.rec-alt {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.78rem;
}

.rec-alt-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.rec-alt-reason {
    color: var(--text-muted);
}

.rec-empty {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}


.toast-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.toast-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: inherit;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.toast-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.toast-action-primary {
    background: var(--primary-color, #4a90d9);
    border-color: transparent;
    color: #fff;
}

.toast-action-primary:hover {
    filter: brightness(1.15);
}

.toast-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    color: inherit;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

.toast-pin {
    position: absolute;
    top: 0.35rem;
    left: 0.35rem;
    font-size: 0.6rem;
    opacity: 0.5;
}

@media (max-width: 768px) and (orientation: portrait), (max-width: 480px) {

    #section-analytics {
        padding: 0.75rem !important;
        padding-bottom: 80px !important;
    }

    #section-analytics.active-section {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .analytics-header {
        margin-bottom: 1rem;
    }

    .analytics-header h2 {
        font-size: 1.1rem;
    }

    .analytics-header p {
        font-size: 0.75rem;
    }

    .analytics-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .analytics-card {
        grid-column: 1 / -1 !important;
        padding: 1rem;
    }

    .analytics-card h3 {
        font-size: 0.9rem;
    }

    .card-description {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
    }

    
    .complexity-chart,
    .benchmark-chart,
    .usage-chart,
    .trend-chart {
        height: 180px !important;
        min-height: 0 !important;
        aspect-ratio: auto !important;
        width: 100%;
    }

    .complexity-legend {
        gap: 0.5rem;
        font-size: 0.65rem;
    }

    .session-stats {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .stat-item {
        padding: 0.75rem 0.5rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    
    .export-options {
        flex-direction: column;
        gap: 0.5rem;
    }

    
    .analytics-timeline-wrap {
        max-height: 250px;
    }

    .timeline-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
    }

    .timeline-stats {
        gap: 0.5rem;
    }

    
    .bests-grid {
        grid-template-columns: 1fr !important;
    }

    
    .algo-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .algo-info-content .info-row {
        flex-direction: column;
        gap: 0.15rem;
        padding: 0.4rem 0;
    }

    
    .upload-area {
        padding: 1rem !important;
    }

    .insights-container {
        gap: 1rem !important;
    }

    
    #insights-advanced-settings summary {
        font-size: 0.8rem !important;
    }

    
}


#section-step {
    display: none;
    padding: 1.5rem;
    overflow-y: auto;
}

#section-step.active-section {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.step-header {
    text-align: center;
    margin-bottom: 1rem;
}

.step-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.step-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.step-controls {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    justify-content: space-between;
}

.step-config {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.step-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.step-info {
    background: var(--bg-tertiary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.step-counter {
    font-size: 1.25rem;
    font-weight: 600;
}

.step-description {
    flex: 1;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.step-stats {
    display: flex;
    gap: 1.5rem;
}




.step-split-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
    align-items: stretch;
    flex: 1 1 0;
    min-height: 0;
}

#section-step {
    --step-code-width: 320px;
}

.step-vis-pane {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.step-code-pane {
    flex: 0 0 var(--step-code-width);
    width: var(--step-code-width);
    min-width: 260px;
    max-width: min(60vw, 760px);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    min-height: 0;
}

.step-code-resizer {
    width: 12px;
    cursor: col-resize;
    border-radius: 999px;
    align-self: stretch;
    background: var(--border-color);
    transition: background 0.2s ease, transform 0.2s ease;
    flex: 0 0 auto;
    position: relative;
}

.step-code-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 24px;
    background: var(--text-muted);
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.step-code-resizer:hover,
.step-code-resizer:focus-visible {
    background: var(--bar-compare);
}

.step-code-resizer:hover::after,
.step-code-resizer:focus-visible::after {
    background: var(--bg-primary);
    opacity: 1;
}


.pseudocode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.pseudocode-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pseudocode-complexity {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--bar-compare);
    background: rgba(245, 200, 66, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.pseudocode-container {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    line-height: 1.8;
}

.pseudocode-line {
    display: flex;
    padding: 0.15rem 1rem;
    transition: background 0.2s, border-color 0.2s;
    border-left: 3px solid transparent;
}

.pseudocode-line.active {
    background: rgba(245, 200, 66, 0.15);
    border-left-color: var(--bar-compare);
}

.pseudocode-line.executed {
    opacity: 0.6;
}

.pseudocode-line.active.executed {
    opacity: 1;
}

.line-number {
    width: 28px;
    color: var(--text-muted);
    user-select: none;
    text-align: right;
    margin-right: 1rem;
    flex-shrink: 0;
}

.line-content {
    flex: 1;
    color: var(--text-primary);
    white-space: pre;
}

.line-content .keyword {
    color: #c678dd;
}

.line-content .function {
    color: #61afef;
}

.line-content .variable {
    color: #e5c07b;
}

.line-content .comment {
    color: var(--text-muted);
    font-style: italic;
}

.line-content .operator {
    color: #56b6c2;
}


.line-content .number {
    color: #d19a66;
}

.line-content .string {
    color: #98c379;
}

.line-content .type {
    color: #e5c07b;
}

.line-content .builtin {
    color: #e06c75;
}

.line-content .punctuation {
    color: #abb2bf;
}

[data-theme="light"] .line-content .keyword {
    color: #a626a4;
}

[data-theme="light"] .line-content .function {
    color: #4078f2;
}

[data-theme="light"] .line-content .variable {
    color: #8a5700;
}

[data-theme="light"] .line-content .comment {
    color: #a0a1a7;
}

[data-theme="light"] .line-content .operator {
    color: #0184bc;
}

[data-theme="light"] .line-content .number {
    color: #986801;
}

[data-theme="light"] .line-content .string {
    color: #50a14f;
}

[data-theme="light"] .line-content .type {
    color: #8a5700;
}

[data-theme="light"] .line-content .builtin {
    color: #e45649;
}

.pseudocode-footer {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.code-legend {
    display: flex;
    gap: 1.5rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.code-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.code-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.code-dot.active {
    background: var(--bar-compare);
}

.code-dot.executed {
    background: var(--text-muted);
    opacity: 0.5;
}

@media (max-width: 1100px) {
    .step-split-container {
        flex-wrap: wrap;
    }

    .step-code-resizer {
        display: none;
    }

    .step-code-pane {
        flex: 1 1 100%;
        width: auto;
        min-width: 0;
        max-width: 100%;
        max-height: 300px;
        order: 2;
    }

    .step-vis-pane {
        flex: 1 1 100%;
        order: 1;
    }

    .step-visualizer {
        height: 300px;
        min-height: 300px;
    }
}


.step-visualizer {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    flex: 1 1 0;
    min-height: 350px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1.5rem;
    gap: 4px;
    margin-bottom: 1rem;
}

.step-visualizer .bar {
    flex: 1;
    min-width: 8px;
    max-width: 60px;
    background: var(--bar-default);
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
    position: relative;
}

.step-visualizer .bar.show-value::before {
    content: none;
    display: none;
}

.step-visualizer .bar.compare {
    background: var(--bar-compare) !important;
}

.step-visualizer .bar.swap {
    background: var(--bar-swap) !important;
}

.step-visualizer .bar.sorted {
    background: var(--bar-sorted) !important;
}

.step-visualizer .bar::after {
    content: attr(data-value);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    padding: 2px 4px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.2s;
}

.step-visualizer .bar:hover::after {
    opacity: 1;
}


.step-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.step-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.step-legend .legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.legend-color.comparing {
    background: var(--bar-compare);
}

.legend-color.swapping {
    background: var(--bar-swap);
}

.legend-color.sorted {
    background: var(--bar-sorted);
}


.step-bookmarks {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.step-bookmarks h4 {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.bookmark-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 0.6rem;
    font-weight: 700;
}



.bookmark-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.8rem;
}

.bookmark-step {
    font-weight: 600;
    color: var(--bar-compare);
    min-width: 60px;
}

.bookmark-desc {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bookmark-goto,
.bookmark-remove {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}

.bookmark-remove {
    color: var(--text-muted);
}

.bookmark-remove:hover {
    color: var(--bar-swap);
}


@media (max-width: 768px) and (orientation: portrait),
(max-width: 480px) {

    
    #section-step {
        padding: 0.75rem !important;
    }

    .step-header h2 {
        font-size: 1.1rem;
    }

    .step-header p {
        font-size: 0.75rem;
    }

    .step-controls {
        padding: 0.75rem;
        gap: 0.75rem;
        flex-direction: column;
    }

    .step-config {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .step-config .control-group {
        width: 100%;
    }

    .step-actions {
        width: 100%;
        justify-content: stretch;
    }

    .step-actions .btn {
        flex: 1;
        min-height: 40px;
    }

    .step-info {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        text-align: center;
    }

    .step-counter {
        font-size: 1rem;
    }

    .step-stats {
        gap: 0.75rem;
        font-size: 0.8rem;
    }

    .step-split-container {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        gap: 0.75rem;
    }

    .step-vis-pane {
        order: 1;
        min-height: 200px;
    }

    .step-visualizer {
        height: 200px !important;
        min-height: 200px !important;
    }

    .step-code-pane {
        order: 2;
        flex: none !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        max-height: 250px !important;
    }

    .step-code-resizer {
        display: none !important;
    }


}

.visualizer-3d #visualizer-container,
.visualizer-3d .step-visualizer,
.visualizer-3d .compare-visualizer {
    perspective: 1000px;
    transform-style: preserve-3d;
}

.visualizer-3d .bar {
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-10deg) rotateY(-15deg);
    background: linear-gradient(180deg,
            var(--bar-default) 0%,
            color-mix(in srgb, var(--bar-default) 70%, black) 100%);
    border-radius: 2px 2px 0 0;
}

.visualizer-3d .bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 100%;
    width: 12px;
    height: 100%;
    background: linear-gradient(90deg,
            color-mix(in srgb, var(--bar-default) 60%, black) 0%,
            color-mix(in srgb, var(--bar-default) 40%, black) 100%);
    transform: skewY(-45deg);
    transform-origin: top left;
}

.visualizer-3d .bar::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    height: 12px;
    background: linear-gradient(180deg,
            color-mix(in srgb, var(--bar-default) 90%, white) 0%,
            var(--bar-default) 100%);
    transform: skewX(-45deg);
    transform-origin: bottom left;
}

.visualizer-3d .bar.compare {
    background: linear-gradient(180deg,
            var(--bar-compare) 0%,
            color-mix(in srgb, var(--bar-compare) 70%, black) 100%);
}

.visualizer-3d .bar.compare::before {
    background: linear-gradient(90deg,
            color-mix(in srgb, var(--bar-compare) 60%, black) 0%,
            color-mix(in srgb, var(--bar-compare) 40%, black) 100%);
}

.visualizer-3d .bar.compare::after {
    background: linear-gradient(180deg,
            color-mix(in srgb, var(--bar-compare) 90%, white) 0%,
            var(--bar-compare) 100%);
}

.visualizer-3d .bar.swap {
    background: linear-gradient(180deg,
            var(--bar-swap) 0%,
            color-mix(in srgb, var(--bar-swap) 70%, black) 100%);
}

.visualizer-3d .bar.swap::before {
    background: linear-gradient(90deg,
            color-mix(in srgb, var(--bar-swap) 60%, black) 0%,
            color-mix(in srgb, var(--bar-swap) 40%, black) 100%);
}

.visualizer-3d .bar.swap::after {
    background: linear-gradient(180deg,
            color-mix(in srgb, var(--bar-swap) 90%, white) 0%,
            var(--bar-swap) 100%);
}

.visualizer-3d .bar.sorted {
    background: linear-gradient(180deg,
            var(--bar-sorted) 0%,
            color-mix(in srgb, var(--bar-sorted) 70%, black) 100%);
}

.visualizer-3d .bar.sorted::before {
    background: linear-gradient(90deg,
            color-mix(in srgb, var(--bar-sorted) 60%, black) 0%,
            color-mix(in srgb, var(--bar-sorted) 40%, black) 100%);
}

.visualizer-3d .bar.sorted::after {
    background: linear-gradient(180deg,
            color-mix(in srgb, var(--bar-sorted) 90%, white) 0%,
            var(--bar-sorted) 100%);
}

.visualizer-3d #visualizer-container,
.visualizer-3d .step-visualizer {
    padding: 20px 30px 10px 10px;
}

.shared-by-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.shared-by-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.shared-by-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(139, 92, 246, 0.5);
}

.shared-by-content span {
    color: var(--text-primary);
    font-size: 0.9rem;
}

.shared-by-content strong {
    color: var(--text-primary);
}

.shared-by-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.shared-by-close:hover {
    color: var(--text-primary);
}

body[data-domain="pathfinding"] main {
    padding: 0 1rem 2rem;
}

body[data-domain="pathfinding"] .advanced-content[data-open="true"] {
    display: flex;
}

body[data-domain="pathfinding"] .advanced-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

body[data-domain="pathfinding"] .grid-legend {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding: 0.5rem 0;
    flex-wrap: wrap;
}

body[data-domain="pathfinding"] .legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

body[data-domain="pathfinding"] .legend-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
}

body[data-domain="pathfinding"] .legend-start {
    background: #2ecc71;
}

body[data-domain="pathfinding"] .legend-end {
    background: #e74c3c;
}

body[data-domain="pathfinding"] .legend-wall {
    background: #1a1a2e;
}

body[data-domain="pathfinding"][data-theme="light"] .legend-wall,
[data-theme="light"] body[data-domain="pathfinding"] .legend-wall {
    background: #2c3e50;
}

body[data-domain="pathfinding"] .legend-weight {
    background: #9b59b6;
}

body[data-domain="pathfinding"] .legend-visited {
    background: rgba(74, 144, 217, 0.5);
}

body[data-domain="pathfinding"] .legend-weight-visited {
    background: rgba(142, 68, 173, 0.55);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

body[data-domain="pathfinding"] .legend-weight-visited::after {
    content: '';
    width: 7px;
    height: 7px;
    background: rgba(255, 255, 255, 0.55);
    transform: rotate(45deg);
    position: absolute;
}

body[data-domain="pathfinding"] .legend-path {
    background: #f5c842;
}

body[data-domain="pathfinding"] .grid-container {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: auto;
    background: var(--bg-secondary);
    user-select: none;
    min-height: 400px;
    height: calc(100vh - 340px);
    box-sizing: border-box;
}

body[data-domain="pathfinding"] .grid-container canvas,
body[data-domain="pathfinding"] .step-grid-wrap canvas {
    display: block;
    cursor: pointer;
    border-radius: 2px;
}

body[data-domain="pathfinding"] .step-split-container {
    display: flex;
    flex: 1;
    gap: 0;
    min-height: 0;
}

body[data-domain="pathfinding"] .step-vis-pane {
    flex: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

body[data-domain="pathfinding"] .step-grid-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: auto;
    background: var(--bg-secondary);
    user-select: none;
    min-height: 300px;
    height: calc(100vh - 400px);
    box-sizing: border-box;
}

body[data-domain="pathfinding"] .compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1rem;
    flex: 1;
    width: 100%;
}

body[data-domain="pathfinding"] .compare-panel {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary);
    height: auto;
    padding: 0;
}

body[data-domain="pathfinding"] .compare-panel:hover {
    transform: none;
    box-shadow: none;
}

body[data-domain="pathfinding"] .compare-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

body[data-domain="pathfinding"] .compare-panel-header select {
    appearance: auto;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.4rem;
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
}

body[data-domain="pathfinding"] .compare-panel-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}

body[data-domain="pathfinding"] .compare-panel-stats span {
    color: var(--text-primary);
    font-weight: 600;
}

body[data-domain="pathfinding"] .compare-panel-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    min-height: 260px;
    user-select: none;
    overflow: hidden;
    padding: 0.5rem;
    background: var(--bg-primary);
}

body[data-domain="pathfinding"] .compare-panel-grid canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

@media (max-width: 768px) {
    body[data-domain="pathfinding"] .grid-container {
        min-height: 320px;
        height: calc(100vh - 280px);
    }

    body[data-domain="pathfinding"] .step-grid-wrap {
        min-height: 240px;
        height: calc(100vh - 330px);
    }

    body[data-domain="pathfinding"] .compare-grid {
        grid-template-columns: 1fr;
    }
}


.grid-editor-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.grid-editor-fullscreen.open {
  opacity: 1;
  pointer-events: auto;
}

.grid-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.grid-editor-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.grid-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: rgba(13, 17, 23, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
  flex-shrink: 0;
  z-index: 2;
}

.grid-editor-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.grid-editor-close-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.grid-editor-close-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: rotate(90deg);
}

.grid-editor-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.grid-editor-brush-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.grid-editor-brush-pills {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 3px;
}

.grid-editor-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.3rem 0.7rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.grid-editor-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.grid-editor-pill.active {
  background: rgba(74, 144, 217, 0.2);
  color: #7bb8f0;
  box-shadow: 0 0 0 1px rgba(74, 144, 217, 0.35);
}

.grid-editor-pill-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.grid-editor-weight-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.grid-editor-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.78rem;
  white-space: nowrap;
  font-weight: 500;
}

.grid-editor-number-input {
  width: 3.8rem;
  padding: 0.25rem 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease;
}

.grid-editor-number-input:focus {
  border-color: rgba(74, 144, 217, 0.5);
}

.grid-editor-checkbox {
  accent-color: #4a90d9;
  cursor: pointer;
}

.grid-editor-toggle-label {
  cursor: pointer;
}

.grid-editor-maze-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.grid-editor-select {
  appearance: auto;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  padding: 0.25rem 0.4rem;
}

.grid-editor-toolbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.grid-editor-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.grid-editor-actions {
  display: flex;
  gap: 0.5rem;
}

.grid-editor-canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: auto;
  min-height: 0;
  background-image:
    radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.02) 1px, transparent 0);
  background-size: 28px 28px;
}

.grid-editor-canvas-area canvas {
  background: var(--bg-primary);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 16px 48px rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  cursor: crosshair;
  transition: box-shadow 0.2s ease;
}

.grid-editor-canvas-area canvas:hover {
  box-shadow:
    0 0 0 1px rgba(74, 144, 217, 0.2),
    0 16px 48px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .grid-editor-backdrop {
  background: rgba(255, 255, 255, 0.45);
}

[data-theme="light"] .grid-editor-toolbar {
  background: rgba(245, 246, 248, 0.96);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .grid-editor-close-btn {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .grid-editor-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .grid-editor-brush-pills {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .grid-editor-pill:hover {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .grid-editor-pill.active {
  background: rgba(52, 152, 219, 0.12);
  color: #2471a3;
  box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.3);
}

[data-theme="light"] .grid-editor-pill-swatch {
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .grid-editor-number-input {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

[data-theme="light"] .grid-editor-maze-group {
  border-left-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .grid-editor-select {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

[data-theme="light"] .grid-editor-canvas-area {
  background-image:
    radial-gradient(circle at 2px 2px, rgba(0, 0, 0, 0.025) 1px, transparent 0);
}

[data-theme="light"] .grid-editor-canvas-area canvas {
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.08),
    0 12px 40px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .grid-editor-canvas-area canvas:hover {
  box-shadow:
    0 0 0 1px rgba(52, 152, 219, 0.2),
    0 12px 40px rgba(0, 0, 0, 0.15);
}

@media (max-width: 900px) {
  .grid-editor-toolbar {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .grid-editor-hint {
    display: none;
  }

  .grid-editor-toolbar-right {
    margin-left: 0;
  }

  .grid-editor-canvas-area {
    padding: 0.75rem;
  }
}

@media (max-width: 600px) {
  .grid-editor-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    padding: 0.5rem;
  }

  .grid-editor-toolbar-left,
  .grid-editor-brush-group,
  .grid-editor-maze-group,
  .grid-editor-toolbar-right {
    justify-content: center;
  }

  .grid-editor-maze-group {
    padding-left: 0;
    border-left: none;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .grid-editor-toolbar-right {
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  .grid-editor-actions {
    justify-content: center;
    width: 100%;
  }

  .grid-editor-canvas-area {
    padding: 0.5rem;
  }
}