

header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem clamp(0.75rem, 1.5vw, 1.5rem);
    position: relative;
    z-index: 100;
    transition: background-color var(--transition), border-color var(--transition);
}

.header-content {
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.75rem 1rem;
}

.header-branding {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 0 1 auto;
    min-width: 0;
}

.tabs {
    flex: 1 1 0;
    min-width: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 0 0 auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
    min-height: 36px;
    min-width: 0;
    margin-left: auto;
}

h1 {
    flex: 0 0 auto;
    font-weight: 600;
    font-size: 1.5rem;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.domain-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: clamp(11rem, 15vw, 13rem);
    min-width: 11rem;
}

.domain-switcher::after {
    content: '▾';
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

.domain-switcher .domain-switch-select {
    width: 100%;
    min-width: 0;
    appearance: none;
    -webkit-appearance: none;
    padding: 0.7rem 2.3rem 0.7rem 0.95rem;
    border: 1px solid color-mix(in srgb, var(--border-color) 72%, transparent);
    border-radius: 999px;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--bg-tertiary) 82%, white 4%), color-mix(in srgb, var(--bg-secondary) 92%, black 4%));
    box-shadow:
        0 12px 32px color-mix(in srgb, var(--shadow) 75%, transparent),
        inset 0 1px 0 color-mix(in srgb, white 18%, transparent);
    backdrop-filter: blur(18px);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), color var(--transition);
}

.domain-switcher .domain-switch-select:hover,
.domain-switcher .domain-switch-select:focus {
    border-color: var(--text-muted);
    box-shadow:
        0 12px 32px color-mix(in srgb, var(--shadow) 75%, transparent),
        inset 0 1px 0 color-mix(in srgb, white 18%, transparent),
        0 0 0 1px color-mix(in srgb, var(--text-primary) 12%, transparent);
}

.domain-switcher .domain-switch-select option {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

[data-domain-tabs="pathfinding"] .tab-glider {
    opacity: 1;
}

body[data-domain="pathfinding"] .swipe-hint,
body[data-domain="pathfinding"] #mobile-nav,
body[data-domain="pathfinding"] #mobile-fab,
body[data-domain="pathfinding"] #mobile-more-menu,
body[data-domain="pathfinding"] .mobile-more-overlay {
    display: none !important;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.theme-toggle-btn {
    width: 48px;
    height: 26px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 13px;
    cursor: pointer;
    position: relative;
    transition: all var(--transition);
}

.theme-toggle-btn::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--text-primary);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform var(--transition);
}

[data-theme="light"] .theme-toggle-btn::after {
    transform: translateX(22px);
}

.theme-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    line-height: 1;
}


.account-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 var(--account-slot-width, 176px);
    min-width: var(--account-slot-width, 176px);
    min-height: 36px;
}

.account-slot[data-auth-state="guest"] .auth-buttons,
.account-slot[data-auth-state="user"] .user-profile {
    visibility: visible;
    pointer-events: auto;
}

.account-slot[data-auth-state="guest"] .user-profile,
.account-slot[data-auth-state="user"] .auth-buttons {
    visibility: hidden;
    pointer-events: none;
}



.docs-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all var(--transition);
    line-height: 1;
}

.docs-link:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}


.pwa-install-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    background: none;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    line-height: 1;
}

.pwa-install-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}


.auth-buttons {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.auth-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all var(--transition);
    line-height: 1;
    white-space: nowrap;
}

.auth-link:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}


.user-profile {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-tertiary);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: border-color var(--transition);
}

.profile-avatar:hover {
    border-color: var(--text-muted);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #444, #666);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 200px;
    box-shadow: 0 4px 20px var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-profile.open .profile-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-info {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

@media (max-width: 1180px) {
    .header-content {
        flex-wrap: wrap;
    }

    .header-branding {
        width: 100%;
        justify-content: space-between;
    }

}

@media (max-width: 768px) {
    .header-branding {
        flex-direction: column;
        align-items: stretch;
    }

    .domain-switcher {
        width: 100%;
    }

}

.profile-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.profile-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.profile-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.25rem 0;
}

.dropdown-item {
    width: 100%;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tabs {
    display: flex;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    position: relative;
    isolation: isolate;
    min-height: 46px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    width: 100%;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-glider {
    position: absolute;
    top: 4px;
    left: 0;
    height: calc(100% - 8px);
    background: var(--bg-primary);
    border-radius: 6px;
    z-index: 1;
    transition: none;
    box-shadow: 0 1px 3px var(--shadow);
    pointer-events: none;
}

.tabs.glider-ready .tab-glider {
    transition: transform 0.25s cubic-bezier(0.2, 0, 0.2, 1), width 0.25s cubic-bezier(0.2, 0, 0.2, 1);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.15s ease;
    position: relative;
    z-index: 2;
    flex: 1 1 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    white-space: nowrap;
    text-align: center;
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    background: transparent;
    color: var(--text-primary);
}

.tab-btn.is-unavailable,
.tab-btn[aria-disabled="true"] {
    color: var(--text-muted);
    opacity: 0.5;
    cursor: not-allowed;
}

.tab-btn.is-unavailable:hover,
.tab-btn[aria-disabled="true"]:hover {
    color: var(--text-muted);
}

.tab-btn.hover-preview {
    color: var(--text-primary);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.tab-btn:focus-visible {
    outline: 2px solid var(--bar-compare);
    outline-offset: -2px;
}

#section-visualizer {
    display: none;
    position: relative;
    background: var(--bg-primary);
}

.toolbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    justify-content: center;
    width: fit-content;
    max-width: 100%;
    align-self: center;
}

.stats span {
    color: var(--text-primary);
    font-weight: 500;
}

.select-wrapper select {
    min-width: 180px;
}


.advanced-options {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.advanced-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all var(--transition);
}

.advanced-toggle:hover {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.toggle-icon {
    transition: transform 0.2s ease;
}

.advanced-options.open .toggle-icon {
    transform: rotate(180deg);
}

.advanced-content {
    display: none;
    padding: 1rem 2rem 1.25rem;
    gap: 2rem;
    flex-wrap: wrap;
    border-top: 1px solid var(--border-color);
}

.advanced-options.open .advanced-content {
    display: flex;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.option-group select {
    min-width: 140px;
}

.option-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--bar-sorted);
}

.save-load-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.save-load-buttons {
    display: flex;
    gap: 0.5rem;
}

.save-load-buttons .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}


.custom-array-group {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem !important;
}

.custom-array-group>label {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.custom-array-group>label small {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.8;
}

.custom-array-wrapper {
    display: flex;
    gap: 0.5rem;
}

.custom-array-wrapper input[type="text"] {
    flex: 1;
    min-width: 180px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    outline: none;
    transition: all var(--transition);
}

.custom-array-wrapper input[type="text"]:focus {
    border-color: var(--text-muted);
}

.custom-array-wrapper input[type="text"]::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.custom-array-upload {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.custom-array-upload .btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.upload-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.7;
}


.custom-array-mini {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-array-config label,
.custom-array-bench label {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

.custom-array-config label small,
.custom-array-bench label small {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.8;
}

.custom-status {
    font-size: 0.7rem;
    color: var(--bar-sorted);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.custom-status.error {
    color: var(--bar-swap);
}

.custom-status.loaded {
    color: var(--bar-sorted);
}

.compare-custom-indicator {
    background: var(--bg-tertiary);
    border: 1px solid var(--bar-sorted);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--bar-sorted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}


.stats-panel {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    background: var(--bg-secondary);
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    display: flex;
    gap: 2rem;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    z-index: 10;
    transition: all var(--transition);
}

.stats-panel span {
    color: var(--text-primary);
    font-weight: 600;
}


#visualizer-container {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
    padding: 2.5rem 4rem 0;
    min-height: clamp(300px, 46vh, 560px);
    aspect-ratio: 16 / 7;
    overflow: visible;
    
    transition: opacity 0.25s ease-in-out;
}

#visualizer-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#visualizer-container.mode-switching {
    opacity: 0;
}


.bar {
    flex: 1;
    min-width: 1px;
    background: var(--bar-default);
    margin: 0;
    border-radius: 1px 1px 0 0;
    transition: height 0.08s ease-out, background-color 0.1s;
    opacity: 0.85;
    position: relative;
}

.bar.compare {
    background: var(--bar-compare) !important;
    opacity: 1;
}

.bar.swap {
    background: var(--bar-swap) !important;
    opacity: 1;
}

.bar.sorted {
    background: var(--bar-sorted) !important;
    opacity: 1;
}

.bar.show-value::before {
    content: attr(data-value);
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%) rotate(-90deg);
    transform-origin: center center;
    font-size: 0.6rem;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.7);
    white-space: nowrap;
    pointer-events: none;
}


.progress-container {
    width: 100%;
    max-width: calc(100% - 8rem);
    margin: 0.5rem 4rem;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    position: relative;
    display: none;
}

.progress-container.active {
    display: block;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--text-primary);
    border-radius: 2px;
    
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
    position: absolute;
    right: 0;
    top: -18px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Consolas', monospace;
}


.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0;
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(-100px) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}


.keyboard-hints {
    position: fixed;
    bottom: 6rem;
    
    right: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    z-index: 100;
    opacity: 0.7;
    transform: translateX(0);
    transition: opacity var(--transition), transform 0.3s ease-in-out;
}

.keyboard-hints.hidden {
    transform: translateX(calc(100% + 2rem));
    opacity: 0;
    pointer-events: none;
}

.keyboard-hints:hover {
    opacity: 1;
}

.keyboard-hints kbd {
    display: inline-block;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.15rem 0.4rem;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.65rem;
    margin-right: 0.25rem;
}

.keyboard-shortcuts-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.keyboard-shortcuts-card {
    position: relative;
    width: min(96vw, 940px);
    max-height: 86vh;
    overflow: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.4rem 1.2rem 1.25rem;
}

.keyboard-shortcuts-card h2 {
    margin: 0 0 0.45rem;
    color: var(--text-primary);
    font-size: 1.08rem;
}

.keyboard-shortcuts-note {
    margin: 0 0 1rem;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.keyboard-shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem 1.1rem;
}

.keyboard-shortcuts-grid section {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.8rem 0.75rem;
    background: var(--bg-tertiary);
}

.keyboard-shortcuts-grid h3 {
    margin: 0 0 0.55rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 650;
}

.keyboard-shortcuts-close {
    position: absolute;
    top: 0.55rem;
    right: 0.75rem;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.keyboard-shortcuts-close:hover {
    color: var(--text-primary);
}

.keyboard-shortcuts-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.35rem;
}

.keyboard-shortcuts-list li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    flex-wrap: wrap;
}

.keyboard-shortcuts-list kbd {
    min-width: 2.2rem;
    text-align: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.12rem 0.36rem;
    font-family: 'SF Mono', 'Consolas', monospace;
    color: var(--text-primary);
    font-size: 0.7rem;
}

@media (max-width: 768px) and (orientation: portrait), (max-width: 480px) {

    #section-visualizer {
        padding: 0 !important;
        display: flex;
        flex-direction: column;
    }

    
    .toolbar {
        padding: 0.6rem 0.75rem !important;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
    }

    .toolbar .controls {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.6rem !important;
    }

    .toolbar .slider-stack {
        display: flex;
        flex-direction: row;
        gap: 0.6rem;
        width: fit-content;
        max-width: 100%;
        margin-inline: auto;
        justify-content: center;
        align-items: center;
    }

    .toolbar .slider-stack .control-group {
        flex: 0 1 auto;
        width: min(44vw, 220px);
        min-width: 0;
    }

    .toolbar .slider-stack .control-group label {
        text-align: center;
        white-space: nowrap;
    }

    .toolbar .control-group {
        width: 100%;
    }

    .toolbar .control-group label {
        font-size: 0.75rem;
    }

    .toolbar .select-wrapper {
        width: 100%;
    }

    .toolbar .select-wrapper select {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .toolbar input[type="range"] {
        width: 100%;
    }

    .toolbar .separator {
        display: none !important;
    }

    .toolbar .stats {
        font-size: 0.7rem;
        padding: 0.4rem 0.5rem;
        background: var(--bg-tertiary);
        border-radius: 6px;
        text-align: center;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.5;
        max-width: 100%;
        flex-wrap: wrap;
        gap: 0.25rem 0.5rem;
    }

    
    .toolbar .control-group:last-child {
        flex-direction: row !important;
        gap: 0.4rem !important;
    }

    .toolbar .control-group:last-child .btn {
        flex: 1;
        min-height: 40px;
        font-size: 0.85rem;
    }

    
    .advanced-options {
        display: block !important;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
    }

    .advanced-toggle {
        padding: 0.6rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    .advanced-content {
        padding: 0.5rem 0.75rem 0.75rem !important;
    }

    .advanced-content .option-group {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    .advanced-content .option-group:last-child {
        border-bottom: none;
    }

    .advanced-content .option-group label {
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .advanced-content .option-group select {
        max-width: 55%;
    }

    .advanced-content .save-load-group {
        flex-wrap: wrap;
    }

    .advanced-content .save-load-buttons {
        gap: 0.4rem;
    }

    .advanced-content .custom-array-group {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .advanced-content .custom-array-wrapper {
        width: 100%;
    }

    .advanced-content .custom-array-wrapper input {
        width: 100%;
    }

    #visualizer-container {
        flex: 1;
        padding: 0.5rem 0.5rem 5rem !important;
        min-height: 45vh;
    }

    .progress-container {
        max-width: 100%;
        margin: 0.25rem 0.5rem;
    }

    #main-scrubber-wrap {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 68px;
        z-index: 150;
    }

    
}


#section-compare {
    display: none;
    padding: 2rem;
    overflow-y: auto;
    background: var(--bg-primary);
}

#section-compare.active-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.compare-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.compare-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.compare-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.compare-controls {
    display: flex;
    gap: 2rem;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    background: var(--bg-secondary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.compare-config {
    display: flex;
    gap: 1.5rem;
}

.compare-actions {
    display: flex;
    gap: 0.75rem;
}

.race-count {
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.race-count span {
    color: var(--bar-compare);
    font-weight: 600;
}

.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    width: 100%;
    margin-top: 1rem;
    padding-bottom: 2rem;
}

.compare-grid.compare-layout-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.compare-grid.compare-layout-columns {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.compare-grid.compare-layout-stack {
    grid-template-columns: 1fr;
}

.compare-grid.compare-layout-spotlight {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.compare-grid.compare-layout-spotlight .compare-panel:first-child {
    grid-column: 1 / -1;
    height: 340px;
}

.compare-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    height: 280px;
    position: relative;
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1),
                box-shadow 0.25s cubic-bezier(0.2, 0, 0, 1),
                opacity 0.2s;
    overflow: hidden;
}

.compare-grid.compare-layout-stack .compare-panel {
    height: 220px;
}

.compare-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}


.compare-panel .panel-header.drag-handle {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
}

.compare-panel .panel-header.drag-handle:active {
    cursor: grabbing;
}


.compare-panel.drag-source {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}


.drag-ghost {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25),
                0 0 0 2px var(--accent);
    transform: scale(1.03);
    overflow: hidden;
    background: var(--bg-secondary);
    
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.drag-ghost.drag-ghost-visible {
    opacity: 0.88;
}


.drag-placeholder {
    border-radius: 12px;
    border: 2px dotted var(--accent) !important;
    background: var(--bg-secondary) !important;
    opacity: 0;
    pointer-events: none;
    box-sizing: border-box;
    
    transition: opacity 0.35s ease !important;
    overflow: hidden;
}

.drag-placeholder.drag-placeholder-visible {
    opacity: 0.35;
}


.drag-placeholder .compare-visualizer,
.drag-placeholder .panel-stats,
.drag-placeholder .panel-status,
.drag-placeholder .race-canvas {
    visibility: hidden;
}

.drag-placeholder .panel-header {
    opacity: 0.6;
    pointer-events: none;
}

.compare-panel .remove-panel {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    opacity: 0.6;
    transition: all 0.2s;
}

.compare-panel .remove-panel:hover {
    opacity: 1;
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.compare-panel.winner {
    border-color: var(--bar-sorted);
    box-shadow: 0 0 20px rgba(46, 204, 113, 0.3);
}

.compare-panel.rank-1 {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.compare-panel.rank-2 {
    border-color: #c0c0c0;
    box-shadow: 0 0 10px rgba(192, 192, 192, 0.3);
}

.compare-panel.rank-3 {
    border-color: #cd7f32;
    box-shadow: 0 0 10px rgba(205, 127, 50, 0.3);
}

.panel-rank {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid var(--border-color);
}

.rank-1 .panel-rank {
    border-color: #ffd700;
    color: #ffd700;
}

.rank-2 .panel-rank {
    border-color: #c0c0c0;
    color: #c0c0c0;
}

.rank-3 .panel-rank {
    border-color: #cd7f32;
    color: #cd7f32;
}


.leaderboard {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    margin-top: 1rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.leaderboard h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--text-primary);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-table th {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

.leaderboard-table td {
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.leaderboard-table td:first-child {
    font-weight: 700;
    color: var(--text-primary);
}

.leaderboard-table td:nth-child(2) {
    font-family: inherit;
    color: var(--text-primary);
}

.leaderboard-table .winner-row {
    background: rgba(46, 204, 113, 0.1);
}

.leaderboard-table .winner-row td {
    color: var(--bar-sorted);
    font-weight: 600;
}

.leaderboard-table .winner-row td:first-child::before {
    content: '#1 ';
}

.compare-result.has-leaderboard {
    background: transparent;
    padding: 0;
}

.val-time {
    color: var(--accent) !important;
    font-weight: 600;
}


.panel-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 0.5rem;
}

.drag-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 4px 1rem 6px;
    margin: 0 -1rem;
    cursor: grab;
    touch-action: none;
    -webkit-touch-callout: none;
}

.drag-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.45;
    transition: opacity 0.2s ease;
    touch-action: none;
}

.panel-header:hover .drag-dots span,
.panel-header:active .drag-dots span {
    opacity: 0.8;
}

.panel-header:active .drag-dots {
    cursor: grabbing;
}

.panel-header-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: space-between;
    align-items: center;
    padding-right: 1.5rem;
    touch-action: none;
}

.algo-select {
    flex: 1;
    min-width: 140px;
    font-size: 0.85rem;
    padding: 0.4rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
}

.panel-stats {
    display: flex;
    gap: 0.75rem;
    font-size: 0.7rem;
}

.panel-stats .stat {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}


.compare-visualizer {
    flex: 1 1 0;
    min-height: 0;
    display: block;
    position: relative;
    overflow: hidden;
}

.compare-visualizer canvas.race-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.compare-visualizer .bar {
    flex: 1 1 0;
    min-width: 0;
    background: var(--bar-default);
    margin: 0;
    border-radius: 0;
    opacity: 0.8;
    transition: height 0.05s ease-out, background-color 0.1s;

    box-shadow: 1px 0 0 0 var(--bar-default);
}

.compare-visualizer .bar.compare {
    background: var(--bar-compare) !important;
    box-shadow: 1px 0 0 0 var(--bar-compare);
    opacity: 1;
    z-index: 10;
}

.compare-visualizer .bar.swap {
    background: var(--bar-swap) !important;
    box-shadow: 1px 0 0 0 var(--bar-swap);
    opacity: 1;
    z-index: 10;
}

.compare-visualizer .bar.sorted {
    background: var(--bar-sorted) !important;
    box-shadow: 1px 0 0 0 var(--bar-sorted);
    opacity: 1;
}

.compare-divider {
    width: 2px;
    background: var(--border-color);
    margin: 0 0.5rem;
}

.panel-status {
    text-align: center;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.panel-status.running {
    color: var(--bar-compare);
}

.panel-status.done {
    color: var(--bar-sorted);
}

.compare-result {
    margin-top: 1.5rem;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);
}

.compare-result.winner-1 {
    border-color: var(--bar-sorted);
    color: var(--bar-sorted);
}

.compare-result.winner-2 {
    border-color: var(--bar-sorted);
    color: var(--bar-sorted);
}

.remove-panel-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.remove-panel-btn:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}


.race-leaderboard {
    margin-top: 1.5rem;
    width: 100%;
    max-width: 600px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.race-leaderboard h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    transition: transform 0.2s;
}

.leaderboard-item:hover {
    transform: translateX(4px);
}

.leaderboard-rank {
    font-weight: 700;
    font-size: 1.25rem;
    min-width: 2rem;
}

.leaderboard-item:nth-child(1) .leaderboard-rank {
    color: #ffd700;
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
    color: #c0c0c0;
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
    color: #cd7f32;
}

.leaderboard-name {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

.leaderboard-time {
    font-family: 'SF Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-muted);
}


.race-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    min-width: 120px;
    justify-content: center;
}

#race-elapsed {
    color: var(--bar-compare);
}


.custom-array-group {
    margin-top: 0.5rem;
}

.custom-array-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.custom-array-wrapper input[type="text"] {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.custom-array-wrapper input[type="text"]::placeholder {
    color: var(--text-muted);
}

@media (max-width: 768px) and (orientation: portrait), (max-width: 480px) {

    .compare-header h2 {
        font-size: 1.1rem;
    }

    .compare-header p {
        font-size: 0.75rem;
    }

    .compare-controls {
        flex-direction: column !important;
        padding: 0.75rem !important;
        gap: 0.75rem !important;
    }

    .compare-config {
        flex-direction: column !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }

    .compare-config .control-group {
        width: 100%;
    }

    .compare-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: stretch;
    }

    .compare-actions .btn {
        flex: 1;
        min-width: 0;
        min-height: 40px;
    }

    .compare-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    .compare-panel {
        height: 200px;
    }

    .race-count {
        font-size: 0.85rem;
    }

    .leaderboard {
        padding: 0.75rem;
    }

    .leaderboard-table {
        font-size: 0.75rem;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.4rem 0.5rem;
    }

    
}


#section-custom {
    display: none;
    padding: 0 2rem 2rem 2rem;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    overflow: auto;
    min-height: 0;
    --custom-primary-width: minmax(360px, 1fr);
    --custom-resizer-width: 12px;
    --custom-console-height: 120px;
    --custom-row-top-height: 1fr;
    --custom-row-resizer-height: 12px;
}

#section-custom.active-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: auto;
}

.custom-bottom-resizer {
    width: 100%;
    height: 12px;
    flex-shrink: 0;
    border-radius: 12px;
    background: var(--border-color);
    cursor: row-resize;
    position: relative;
    transition: background 0.2s ease;
    margin-top: 0.5rem;
}

.custom-bottom-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 2px;
    background: var(--text-muted);
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.custom-bottom-resizer:hover,
.custom-bottom-resizer:focus-visible {
    background: var(--bar-compare);
}

.custom-bottom-resizer:hover::after,
.custom-bottom-resizer:focus-visible::after {
    background: var(--bg-primary);
    opacity: 1;
}

.custom-header {
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.custom-workspace {
    display: grid;
    grid-template-columns: var(--custom-primary-width, minmax(360px, 1fr)) var(--custom-resizer-width, 12px) 1fr;
    grid-template-rows: var(--custom-row-top-height, 1fr) var(--custom-row-resizer-height, 12px) minmax(200px, 1fr);
    grid-template-areas:
        "primary resizer secondary"
        "primary resizer row-resizer"
        "primary resizer tertiary";
    column-gap: 1.25rem;
    row-gap: 1rem;
    flex: 1;
    height: var(--custom-workspace-height, auto);
    min-height: 0;
    position: relative;
    overflow: auto;
}

@media (max-width: 900px) {
    .custom-workspace {
        grid-template-columns: 1fr;
        grid-template-rows:
            var(--custom-mobile-primary-height, auto)
            12px
            var(--custom-mobile-secondary-height, auto)
            12px
            var(--custom-mobile-tertiary-height, auto);
        grid-template-areas:
            "primary"
            "resizer"
            "secondary"
            "row-resizer"
            "tertiary";
        column-gap: 0;
    }

    .custom-pane-resizer {
        width: 100%;
        height: 12px;
        cursor: row-resize;
        border-radius: 12px;
    }

    .custom-pane-resizer::after {
        width: 28px;
        height: 2px;
    }

    .custom-row-resizer {
        width: 100%;
        height: 12px;
    }
}

[data-slot="primary"] {
    grid-area: primary;
}

[data-slot="secondary"] {
    grid-area: secondary;
}

[data-slot="tertiary"] {
    grid-area: tertiary;
}

.custom-row-resizer {
    grid-area: row-resizer;
    height: var(--custom-row-resizer-height, 12px);
    border-radius: 12px;
    background: var(--border-color);
    cursor: row-resize;
    position: relative;
    align-self: stretch;
    transition: background 0.2s ease;
}

.custom-row-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 2px;
    background: var(--text-muted);
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.custom-row-resizer:hover,
.custom-row-resizer:focus-visible {
    background: var(--bar-compare);
}

.custom-row-resizer:hover::after,
.custom-row-resizer:focus-visible::after {
    background: var(--bg-primary);
    opacity: 1;
}

.custom-pane-resizer {
    grid-area: resizer;
    width: var(--custom-resizer-width, 12px);
    border-radius: 999px;
    background: var(--border-color);
    cursor: col-resize;
    position: relative;
    align-self: stretch;
    transition: background 0.2s ease;
}

.custom-pane-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 28px;
    background: var(--text-muted);
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.custom-pane-resizer:hover,
.custom-pane-resizer:focus-visible {
    background: var(--bar-compare);
}

.custom-pane-resizer:hover::after,
.custom-pane-resizer:focus-visible::after {
    background: var(--bg-primary);
    opacity: 1;
}

.custom-panel {
    position: relative;
}

.custom-panel-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0.15rem 0.4rem;
    margin-right: 0.5rem;
    border-radius: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: grab;
    user-select: none;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.custom-panel-handle:active {
    cursor: grabbing;
    background: var(--bg-tertiary);
}

.custom-panel.custom-dragging {
    opacity: 0.6;
}

.custom-drop-target {
    outline: 2px dashed var(--bar-compare);
    outline-offset: 4px;
}

.editor-pane {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: auto;
    box-shadow: var(--shadow-sm);
}

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.editor-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.editor-wrapper {
    flex: 1;
    position: relative;
    background: #0d1117;
    overflow: hidden;
}


.code-highlight-pre {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 1rem;
    border: none;
    background: transparent;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    tab-size: 4;
    -moz-tab-size: 4;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: auto;
    color: #e6edf3;
    pointer-events: none;
    box-sizing: border-box;
    z-index: 0;
}

.code-highlight-pre code {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    tab-size: inherit;
    -moz-tab-size: inherit;
    white-space: inherit;
    word-wrap: inherit;
    display: block;
}


.code-highlight-pre .hl-kw {
    color: #ff7b72;
}

.code-highlight-pre .hl-bi {
    color: #ffa657;
}

.code-highlight-pre .hl-fn {
    color: #d2a8ff;
}

.code-highlight-pre .hl-st {
    color: #a5d6ff;
}

.code-highlight-pre .hl-nu {
    color: #79c0ff;
}

.code-highlight-pre .hl-cm {
    color: #8b949e;
    font-style: italic;
}

.code-highlight-pre .hl-op {
    color: #ff7b72;
}

.code-highlight-pre .hl-ty {
    color: #ffa657;
}

.code-highlight-pre .hl-api {
    color: #7ee787;
    font-weight: 600;
}


.code-highlight-pre [data-ln] {
    display: block;
    border-left: 3px solid transparent;
    padding-left: 6px;
    margin-left: -9px;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.code-highlight-pre .hl-exec-line {
    border-radius: 2px;
}

.code-highlight-pre .hl-exec-cmp {
    background: rgba(255, 213, 79, 0.12);
    border-left-color: #ffd54f;
}

.code-highlight-pre .hl-exec-swap {
    background: rgba(255, 107, 107, 0.14);
    border-left-color: #ff6b6b;
}

.code-highlight-pre .hl-exec-set {
    background: rgba(0, 229, 255, 0.10);
    border-left-color: #00e5ff;
}


#custom-code-editor,
#pf-custom-code-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 1rem;
    border: none;
    resize: none;
    background: transparent;
    color: #e6edf3;
    caret-color: #e6edf3;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    tab-size: 4;
    -moz-tab-size: 4;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: auto;
    outline: none;
    box-sizing: border-box;
    z-index: 1;
}


.editor-wrapper.hl-active #custom-code-editor,
.editor-wrapper.hl-active #pf-custom-code-editor {
    color: transparent;
}

.editor-help {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
}

.editor-help code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    color: var(--text-primary);
}

.visualizer-pane {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    min-height: 0;
    overflow: auto;
}

.console-pane {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
    min-height: 0;
    align-self: stretch;
    overflow: auto;
}

.custom-console {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.custom-controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.custom-stats {
    display: flex;
    gap: 1.5rem;
    margin-left: auto;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.custom-stats b {
    color: var(--text-primary);
}

.custom-vis-box {
    flex: 1;
    min-height: 200px;
    background: var(--bg-main);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 10px;
}

.custom-console-resizer {
    height: 12px;
    cursor: row-resize;
    border-radius: 999px;
    background: var(--border-color);
    transition: background 0.2s ease, transform 0.2s ease;
    position: relative;
}

.custom-console-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 2px;
    background: var(--text-muted);
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.custom-console-resizer:hover,
.custom-console-resizer:focus-visible {
    background: var(--bar-compare);
}

.custom-console-resizer:hover::after,
.custom-console-resizer:focus-visible::after {
    background: var(--bg-primary);
    opacity: 1;
}

#custom-scrubber-wrap {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    width: auto;
    margin: 0;
    z-index: 40;
}

.custom-console {
    margin-top: 0.5rem;
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.custom-console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.console-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn.small.static {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
}

.btn.small.static:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.custom-console-body {
    background: #0d1117;
    flex: 1 1 auto;
    min-height: 80px;
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    transition: height 0.3s ease;
}

.custom-console-body.collapsed {
    height: 0;
    border-bottom: none;
    overflow: hidden;
}

.console-output {
    list-style: none;
    padding: 0;
    margin: 0;
}

.console-msg {
    padding: 0.2rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    word-break: break-word;
    white-space: pre-wrap;
    color: #e6edf3;
}

.console-error {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.console-warn {
    color: #f1c40f;
    background: rgba(241, 196, 15, 0.1);
}

.console-log {
    color: #e6edf3;
}

@media (max-width: 768px) and (orientation: portrait), (max-width: 480px) {

    #section-custom {
        padding: 0.5rem !important;
        overflow: auto !important;
    }

    #section-custom.active-section {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .custom-header {
        margin-bottom: 0.5rem;
    }

    .custom-header h2 {
        font-size: 1rem !important;
    }

    .custom-header p {
        font-size: 0.75rem;
    }

    .custom-workspace {
        grid-template-columns: 1fr !important;
        grid-template-rows:
            var(--custom-mobile-primary-height, auto)
            12px
            var(--custom-mobile-secondary-height, auto)
            12px
            var(--custom-mobile-tertiary-height, auto) !important;
        grid-template-areas:
            "primary"
            "resizer"
            "secondary"
            "row-resizer"
            "tertiary" !important;
        gap: 0.5rem;
        min-height: 0 !important;
        overflow: auto;
    }

    .custom-pane-resizer {
        width: 100% !important;
        height: 12px !important;
        cursor: row-resize !important;
        border-radius: 12px;
    }

    .custom-pane-resizer::after {
        width: 28px !important;
        height: 2px !important;
    }

    .custom-row-resizer {
        width: 100% !important;
        height: 12px !important;
    }

    
    .editor-pane {
        min-height: 0;
        max-height: none;
        overflow: visible;
    }

    .editor-wrapper {
        min-height: 200px;
        height: 250px;
    }

    #custom-code-editor,
    #pf-custom-code-editor {
        font-size: 12px !important;
    }

    .code-highlight-pre {
        font-size: 12px !important;
    }

    .editor-toolbar {
        flex-wrap: wrap;
        gap: 0.4rem;
        padding: 0.4rem !important;
    }

    .editor-actions {
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
    }

    .editor-actions .btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    
    .custom-vis-pane {
        min-height: 0;
    }

    .custom-controls {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-auto-rows: auto;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.5rem !important;
    }

    .custom-controls .control-group {
        grid-column: span 3;
        width: 100%;
    }

    .custom-controls .btn {
        width: 100%;
        min-height: 40px;
    }

    .custom-stats {
        grid-column: span 3;
        margin-left: 0;
        gap: 0.75rem;
        font-size: 0.75rem;
        justify-content: center;
        flex-wrap: wrap;
        text-align: center;
    }

    .custom-vis-box {
        min-height: 150px;
        height: 200px;
    }

    #custom-scrubber-wrap {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.5rem;
        z-index: 60;
    }

    .visualizer-pane {
        --custom-console-height: 100px;
    }

    
    #blockly-tab,
    #blockly-builder {
        min-height: 250px;
    }

    
}



.profile-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.profile-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.profile-btn-icon {
    font-size: 1rem;
    line-height: 1;
}


.profile-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: profileFadeIn 0.2s ease;
}

@keyframes profileFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}


.profile-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: min(680px, 92vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: profileSlideUp 0.25s ease;
}

@keyframes profileSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.profile-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.profile-modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.profile-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 4px;
    transition: all 0.15s;
    line-height: 1;
}

.profile-modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.profile-modal-body {
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}


.profile-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


.profile-selector-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.profile-select {
    flex: 1;
    min-width: 140px;
}


.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
}

.preset-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    color: var(--text-secondary);
}

.preset-swatch:hover {
    border-color: var(--text-muted);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.preset-colors {
    display: flex;
    gap: 3px;
    width: 100%;
}

.preset-colors span {
    flex: 1;
    height: 20px;
    border-radius: 3px;
}

.preset-name {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.65rem;
}

.color-picker-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.2s;
}

.color-picker-item:hover {
    border-color: var(--text-muted);
}

.color-picker-item input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    background: none;
    padding: 0;
    flex-shrink: 0;
}

.color-picker-item input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-item input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.color-picker-item input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: 50%;
}

.color-label {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.color-hex {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
}


.viz-defaults-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.viz-defaults-grid label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.viz-defaults-grid label span:first-child {
    min-width: 120px;
    flex-shrink: 0;
}

.viz-defaults-grid input[type="range"] {
    flex: 1;
    max-width: 200px;
}

.viz-defaults-grid label.toggle-label {
    cursor: pointer;
    transition: color 0.15s;
}

.viz-defaults-grid label.toggle-label:hover {
    color: var(--text-primary);
}

.viz-defaults-grid label.toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--bar-sorted);
    cursor: pointer;
}


.algo-toggle-actions {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.algo-toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.35rem;
}

.algo-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.algo-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.algo-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--bar-sorted);
    cursor: pointer;
    flex-shrink: 0;
}

.algo-toggle[data-category="simple"] span::before {
    content: '\25CB  ';
    color: var(--bar-default);
    font-size: 0.6em;
}

.algo-toggle[data-category="efficient"] span::before {
    content: '\25C6  ';
    color: var(--bar-sorted);
    font-size: 0.6em;
}

.algo-toggle[data-category="linear"] span::before {
    content: '\25B2  ';
    color: var(--bar-compare);
    font-size: 0.6em;
}

.algo-toggle[data-category="novelty"] span::before {
    content: '\2605  ';
    color: var(--bar-swap);
    font-size: 0.6em;
}


.profile-section-footer {
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}


.profile-modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    padding: 0 0.75rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.profile-modal-tabs::-webkit-scrollbar {
    display: none;
}

.pmodal-tab {
    padding: 0.6rem 0.85rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pmodal-tab:hover {
    color: var(--text-secondary);
}

.pmodal-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}


.profile-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 0 0 12px 12px;
}

.profile-modal-footer-left,
.profile-modal-footer-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}


.profile-modal .btn.primary {
    background: var(--text-primary);
    color: var(--bg-primary);
    border: 1px solid var(--text-primary);
    padding: 0.45rem 1.25rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.02em;
}

.profile-modal .btn.primary:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.profile-modal .btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.45rem 1rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-modal .btn.secondary:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.profile-modal .btn.small {
    padding: 0.3rem 0.65rem;
    font-size: 0.72rem;
}

.profile-modal .btn.stop {
    background: transparent;
    color: #e74c3c;
    border: 1px solid #e74c3c55;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-modal .btn.stop:hover {
    background: rgba(231, 76, 60, 0.1);
    border-color: #e74c3c;
}


.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.setting-row:hover {
    background: var(--bg-tertiary);
}

.setting-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.setting-input {
    min-width: 140px;
    max-width: 200px;
    padding: 0.35rem 0.5rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.setting-range {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    justify-content: flex-end;
    max-width: 260px;
}

.setting-range input[type="range"] {
    flex: 1;
    max-width: 160px;
}

.setting-range-val {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 45px;
    text-align: right;
}


.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    transition: all 0.25s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.25s ease;
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--bar-sorted);
    border-color: var(--bar-sorted);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(16px);
    background: #fff;
}


.profile-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-style: italic;
}


.algo-category {
    margin-bottom: 0.65rem;
}

.algo-category-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--border-color);
}


.profile-info-grid {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.profile-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-radius: 4px;
}

.profile-info-row:nth-child(odd) {
    background: var(--bg-tertiary);
}

.profile-info-row code {
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
    background: var(--bg-primary);
    border-radius: 3px;
    color: var(--text-muted);
}


@media (max-width: 600px) {
    .profile-modal {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .color-grid {
        grid-template-columns: 1fr 1fr;
    }

    .preset-grid {
        grid-template-columns: 1fr 1fr;
    }

    .algo-toggle-grid {
        grid-template-columns: 1fr;
    }

    .profile-modal-footer {
        flex-direction: column;
        gap: 0.5rem;
        border-radius: 0;
    }

    .setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .setting-range {
        width: 100%;
        max-width: 100%;
    }
}


@media (max-width: 768px) and (orientation: portrait),
(max-width: 480px) {

    
    body {
        overflow-y: auto;
        overflow-x: hidden;
        max-width: 100vw;
        
        padding-bottom: 60px;
    }

    
    .tabs {
        display: none !important;
    }

    .tab-glider {
        display: none !important;
    }

    .swipe-hint {
        display: none !important;
    }

    .keyboard-hints {
        display: none !important;
    }

    .docs-link {
        display: none !important;
    }

    .pwa-install-btn {
        display: none !important;
    }

    .theme-toggle {
        display: none !important;
    }

    .profile-btn {
        display: none !important;
    }

    .separator {
        display: none !important;
    }

    
    header {
        padding: 0.6rem 1rem;
        position: sticky;
        top: 0;
        z-index: 200;
        max-width: 100%;
        overflow: hidden;
    }

    .header-content {
        gap: 0.5rem;
        flex-wrap: nowrap;
    }

    h1 {
        font-size: 1.1rem !important;
        white-space: nowrap;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .auth-link {
        font-size: 0.7rem;
        padding: 0.35rem 0.6rem;
    }

    .profile-avatar {
        width: 30px;
        height: 30px;
    }

    
    main {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: visible;
        overflow-x: hidden;
        padding: 0;
        max-width: 100%;
    }

    
    section[id^="section-"] {
        padding: 0.75rem !important;
        max-width: 100%;
        overflow-x: hidden;
    }

    
    main>section[id^="section-"] {
        display: none !important;
        opacity: 1;
        transform: none !important;
        transition: none !important;
    }

    
    main>section[id^="section-"].active-section {
        display: flex !important;
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: auto;
        flex: 1 !important;
        flex-direction: column;
    }

    body.page-scroll-benchmark {
        overflow-y: auto !important;
    }

    main.page-scroll-benchmark {
        overflow: visible !important;
        flex: 1 !important;
    }

    body.page-scroll-benchmark main>section#section-benchmark.active-section {
        overflow-y: visible !important;
        -webkit-overflow-scrolling: auto !important;
        flex: 1 !important;
    }

    
    .mobile-nav {
        display: flex !important;
    }

    
    
    .mobile-fab {
        display: none !important;
    }

    
    .btn {
        min-height: 40px;
        font-size: 0.85rem;
    }

    select,
    input[type="number"] {
        min-height: 40px;
        font-size: 0.9rem;
        min-width: 0;
        max-width: 100%;
    }

    input[type="range"] {
        height: 8px;
        padding: 0;
        margin: 12px 0;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
        margin-top: -9px;
    }

    input[type="range"]::-moz-range-thumb {
        width: 26px;
        height: 26px;
    }

    .time-travel-scrubber input[type="range"]::-webkit-slider-thumb {
        margin-top: -7px;
    }

    
    .profile-dropdown {
        position: fixed;
        top: auto;
        bottom: 70px;
        right: 0.5rem;
        left: 0.5rem;
        min-width: auto;
        max-width: none;
    }

    
    .toast-container {
        bottom: 72px !important;
    }
}


.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 500;
    align-items: stretch;
    justify-content: space-around;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.25);
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.6rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease;
    padding: 0.25rem 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.mobile-nav-item span {
    letter-spacing: 0.02em;
}

.mobile-nav-item.active {
    color: var(--text-primary);
}

.mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 0 0 2px 2px;
}


.mobile-more-menu {
    display: none;
    position: fixed;
    bottom: 60px;
    right: 0;
    left: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 499;
    padding: 0.5rem 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
    animation: mobile-menu-slide-up 0.2s ease-out;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

@keyframes mobile-menu-slide-up {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-more-menu.open {
    display: flex;
    flex-direction: column;
}

.mobile-more-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-more-item:active {
    background: var(--bg-tertiary);
}

.mobile-more-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}


.mobile-fab {
    display: none;
    position: fixed;
    bottom: 76px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 300;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-fab:active {
    transform: scale(0.92);
}

.mobile-fab.stop {
    background: #e74c3c;
    color: #fff;
}

.mobile-fab svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}


.mobile-fab[data-visible="false"] {
    display: none !important;
}


.mobile-more-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 498;
}

.mobile-more-overlay.active {
    display: block;
}



@keyframes vt-slide-out {
    to {
        transform: translateX(-8%);
        opacity: 0;
    }
}

@keyframes vt-slide-in {
    from {
        transform: translateX(8%);
        opacity: 0;
    }
}

::view-transition-old(root) {
    animation: 0.3s cubic-bezier(0.4, 0, 0.2, 1) both vt-slide-out;
}

::view-transition-new(root) {
    animation: 0.3s cubic-bezier(0.4, 0, 0.2, 1) both vt-slide-in;
}



main>section[id^="section-"] {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

main>section[id^="section-"].active-section.vt-enter {
    opacity: 1;
    transform: translateY(0);
}



@media (prefers-reduced-motion: reduce) {

    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none !important;
    }

    main>section[id^="section-"] {
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}