:root {
    --color-primary: #27D89C;
    --color-secondary: #4AF0B5;
    --color-accent: #78E8C0;
    --color-success: #10b981;
    --color-warning: #D7B56D;
    --color-error: #FF5E73;
    
    --bg-dark: #0B1110;
    --bg-dark-2: #101816;
    --bg-glass: rgba(18, 28, 26, 0.82);
    --bg-glass-light: rgba(16, 24, 22, 0.68);
    
    --text-primary: #F1FFF8;
    --text-secondary: #A2B8B1;
    --text-tertiary: #6D8079;
    
    --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 16px 38px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 28px 64px rgba(0, 0, 0, 0.36);
    --sticky-offset: 18px;
    
    --glow-blue: 0 0 18px rgba(39, 216, 156, 0.16);
    --glow-cyan: 0 0 18px rgba(74, 240, 181, 0.16);
    --glow-purple: 0 0 18px rgba(74, 240, 181, 0.1);
    --border-soft: rgba(74, 240, 181, 0.12);
    --surface-card: #121C1A;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', sans-serif;
    background: #0B1110;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.background-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(39, 216, 156, 0.055) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(74, 240, 181, 0.045) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

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

/* Hero Section */
.hero-section {
    text-align: center;
    margin-bottom: 60px;
    animation: fadeInDown 0.8s ease-out;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #F1FFF8 0%, #4AF0B5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Selector Section */
.selector-section {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 50px;
    animation: fadeInUp 0.8s ease-out 0.1s both;
}

.selector-buttons {
    display: flex;
    gap: 16px;
    background: var(--bg-glass);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    backdrop-filter: blur(10px);
}

.selector-btn {
    position: relative;
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.selector-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.selector-btn.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(6, 182, 212, 0.2) 100%);
    color: var(--text-primary);
    box-shadow: var(--glow-blue), var(--glow-cyan);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.selector-btn.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #06b6d4);
    border-radius: 2px;
    animation: slideIn 0.3s ease-out;
}

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--bg-glass);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Sticky Visualizer */
.visualizer-sticky-parent {
    position: relative;
    z-index: 10;
}

.visualizer-section {
    display: none;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.visualizer-section.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    animation: sectionReveal 0.35s ease-out;
}

.array-container {
    position: sticky;
    top: var(--sticky-offset);
    z-index: 50;
    margin-bottom: 40px;
    padding: 22px;
    background: rgba(15, 23, 42, 0.56);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 18px;
    box-shadow: 0 18px 44px rgba(2, 6, 23, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(18px) saturate(130%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    min-height: 132px;
    display: flex;
    align-items: center;
    transition: box-shadow 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.visualizer-header {
    display: grid;
    grid-template-columns: minmax(240px, max-content) minmax(0, 1fr) max-content;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 40px;
    padding: 24px;
    background: var(--bg-glass);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.visualizer-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
}

.array-definition-panel {
    margin: 0;
    padding: 16px 18px;
    min-height: 84px;
    width: 100%;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.18);
    border-radius: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-sm);
    animation: definitionReveal 0.35s ease-out;
}

.size-control {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.size-input {
    width: 86px;
    padding: 12px 14px;
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
}

.size-input:focus {
    outline: none;
    border-color: var(--color-secondary);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: var(--glow-cyan);
}

.size-error {
    grid-column: 2 / 4;
    display: none;
    color: var(--color-error);
    font-size: 0.9rem;
    animation: slideInDown 0.3s ease;
}

.size-error.show {
    display: block;
}

.array-visualization {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
    justify-content: center;
    transition: gap 0.5s ease;
}

.array-visualization.sorting-active {
    gap: 24px;
}

.array-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 90px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(6, 182, 212, 0.15));
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    color: var(--text-primary);
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: default;
    position: relative;
    overflow: hidden;
}

.array-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0));
    border-radius: 10px;
    pointer-events: none;
}

.array-box-index {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    font-weight: 500;
}

.array-box-value {
    font-size: 1.4rem;
    color: var(--color-secondary);
}

.array-box.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(6, 182, 212, 0.3));
    border-color: rgba(59, 130, 246, 0.6);
    transform: scale(1.1);
    box-shadow: var(--glow-blue), var(--glow-cyan);
}

.array-box.visiting {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.4), rgba(6, 182, 212, 0.4));
    border-color: var(--color-secondary);
    transform: scale(1.08);
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.5);
}

.array-box.sorted {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(16, 185, 129, 0.2));
    border-color: var(--color-success);
}

.array-box.comparing {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(245, 158, 11, 0.2));
    border-color: var(--color-warning);
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.4);
}

.array-box.swapping {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.36), rgba(6, 182, 212, 0.26));
    border-color: var(--color-accent);
    box-shadow: 0 16px 34px rgba(6, 182, 212, 0.2), var(--glow-purple);
    z-index: 4;
}

.array-box.found {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.4), rgba(16, 185, 129, 0.3));
    border-color: var(--color-success);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.6);
    animation: pulse 0.6s ease-in-out;
}

.array-box.pass-complete {
    animation: passComplete 0.7s ease-out;
}

.array-box.already-sorted {
    animation: sortedGlow 0.9s ease-out;
}

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

.array-box.new {
    animation: slideIn 0.3s ease-out;
}

.array-box.remove {
    animation: slideOut 0.3s ease-out forwards;
}

.array-box.focused {
    transform: scale(1.1);
    border-color: var(--color-accent);
    box-shadow: var(--glow-purple);
}

.array-box.moving {
    border-color: var(--color-accent);
    box-shadow: var(--glow-purple);
    transition: transform 0.72s cubic-bezier(0.22, 1, 0.36, 1);
}

.array-box:hover {
    transform: scale(1.05);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: var(--glow-blue);
}

/* Input Section */
.input-section {
    margin-bottom: 40px;
    padding: 30px;
    background: var(--bg-glass);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.input-section h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.inputs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.input-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-field label {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.input-field input {
    padding: 12px;
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.input-field input:focus {
    outline: none;
    border-color: var(--color-secondary);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: var(--glow-cyan);
    transform: translateY(-1px);
}

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

.error-message {
    color: var(--color-error);
    font-size: 0.9rem;
    display: none;
    animation: slideInDown 0.3s ease;
}

.error-message.show {
    display: block;
}

/* Operations Section */
.operations-section {
    margin-bottom: 40px;
    padding: 30px;
    background: var(--bg-glass);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.operations-section h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.operations-buttons {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.operation-btn {
    padding: 14px 32px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(6, 182, 212, 0.2));
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.operation-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2), transparent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.operation-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(6, 182, 212, 0.3));
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: var(--glow-blue), var(--glow-cyan);
    transform: translateY(-2px);
}

.operation-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--glow-blue);
}

.operation-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.operation-btn.running::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 2px solid transparent;
    border-top-color: var(--color-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Search Section */
.search-section {
    margin-bottom: 40px;
    padding: 30px;
    background: var(--bg-glass);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    animation: slideInUp 0.3s ease-out;
}

.search-section.hidden {
    display: none;
}

.search-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-input {
    flex: 1;
    padding: 14px 20px;
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-secondary);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: var(--glow-cyan);
}

.search-action-btn {
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--glow-cyan);
}

.search-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.search-status {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Status Display */
.status-display {
    margin-bottom: 40px;
    padding: 20px;
    background: var(--bg-glass);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
    animation: slideInUp 0.3s ease-out;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease, background 0.3s ease;
}

.status-display.hidden {
    display: none;
}

.status-display.checking {
    border-color: rgba(245, 158, 11, 0.28);
    box-shadow: 0 0 22px rgba(245, 158, 11, 0.14);
}

.status-display.success {
    color: var(--text-primary);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.18);
}

.status-display.failure {
    color: var(--text-primary);
    border-color: rgba(239, 68, 68, 0.42);
    background: rgba(239, 68, 68, 0.12);
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.24);
    border-width: 2px;
    font-weight: 500;
    animation: slideInUp 0.3s ease-out, statusPulse 2s ease-in-out;
}

.status-display.failure::before {
    content: '⚠ ';
    color: rgba(239, 68, 68, 0.8);
    font-weight: 700;
    margin-right: 6px;
}

.status-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    min-height: 20px;
}

/* Info Section */
.info-section {
    padding: 30px;
    background: var(--bg-glass);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.info-section h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.info-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.info-btn {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.info-btn:hover, .info-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: var(--text-primary);
}

.info-panel {
    padding: 24px;
    background: rgba(139, 92, 246, 0.1);
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-radius: 12px;
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1rem;
    animation: slideInUp 0.3s ease-out;
}

.info-panel.hidden {
    display: none;
}

.info-panel.show {
    display: block;
}

/* Coming Soon */
.coming-soon-container {
    text-align: center;
    padding: 80px 40px;
}

.queue-placeholder {
    background: var(--bg-glass);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(14px);
    animation: sectionReveal 0.35s ease-out;
}

/* Queue Visualizer */
.queue-definition-panel {
    margin: 12px 0 0;
    padding: 18px;
    min-height: 98px;
    width: 100%;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.18);
    border-radius: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-sm);
    animation: definitionReveal 0.35s ease-out;
}

.queue-header {
    flex-direction: column;
    align-items: stretch;
}

.queue-operation-card {
    margin-bottom: 40px;
    padding: 30px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.7), rgba(30, 41, 59, 0.46));
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.queue-operation-card:hover {
    transform: translateY(-2px);
    border-color: rgba(6, 182, 212, 0.24);
    box-shadow: var(--shadow-md), var(--glow-cyan);
}

.queue-operation-card h3,
.queue-card-heading h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
}

.queue-card-heading h3 {
    margin-bottom: 0;
}

.queue-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.queue-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.queue-input {
    flex: 1;
    min-width: 0;
    padding: 14px 20px;
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.queue-input:focus {
    outline: none;
    border-color: var(--color-secondary);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: var(--glow-cyan);
}

.queue-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.queue-visualization-panel {
    position: sticky;
    top: var(--sticky-offset);
    z-index: 40;
    margin-bottom: 40px;
    padding: 24px;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.48), rgba(30, 41, 59, 0.3));
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 24px;
    box-shadow: 0 26px 70px rgba(2, 6, 23, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(18px) saturate(130%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    animation: stackPanelReveal 0.45s ease-out;
}

.queue-main-actions,
.queue-view-actions {
    display: grid;
    gap: 20px;
    margin-bottom: 40px;
}

.queue-main-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.queue-view-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.queue-main-actions .queue-operation-card,
.queue-view-actions .queue-operation-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 178px;
    margin-bottom: 0;
}

.queue-visualization-panel.warning {
    border-color: rgba(239, 68, 68, 0.34);
    box-shadow: 0 26px 70px rgba(239, 68, 68, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.queue-capacity {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.52);
    border: 1px solid rgba(6, 182, 212, 0.18);
    border-radius: 14px;
    color: var(--text-secondary);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-sm);
}

.queue-capacity span {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.queue-capacity strong {
    min-width: 72px;
    color: var(--color-secondary);
    font-size: 1.25rem;
    text-align: right;
    text-shadow: 0 0 16px rgba(6, 182, 212, 0.42);
    transition: transform 0.25s ease, color 0.25s ease;
}

.queue-capacity strong.updated {
    transform: scale(1.12);
    color: var(--color-success);
}

.queue-capacity strong.full {
    color: var(--color-warning);
}

.queue-warning-label {
    margin-bottom: 14px;
    padding: 12px 16px;
    border: 1px solid rgba(239, 68, 68, 0.34);
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: #fecaca;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-align: center;
    box-shadow: 0 0 28px rgba(239, 68, 68, 0.18);
    animation: warningLabelReveal 0.28s ease-out;
}

.queue-warning-label.hidden {
    display: none;
}

.queue-stage {
    position: relative;
    min-height: 230px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.queue-chamber {
    position: relative;
    width: min(100%, 880px);
    min-height: 150px;
    padding: 34px 26px;
    border: 2px solid rgba(6, 182, 212, 0.32);
    border-radius: 26px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(15, 23, 42, 0.72), rgba(139, 92, 246, 0.08));
    box-shadow: inset 0 -18px 40px rgba(6, 182, 212, 0.08), 0 0 44px rgba(6, 182, 212, 0.16);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

.queue-chamber.warning {
    border-color: rgba(239, 68, 68, 0.58);
    animation: stackWarningShake 0.72s ease-out;
    box-shadow: inset 0 -18px 40px rgba(239, 68, 68, 0.12), 0 0 58px rgba(239, 68, 68, 0.26);
}

.queue-items {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 92px;
    transition: transform 0.58s cubic-bezier(0.22, 1, 0.36, 1), gap 0.4s ease;
}

.queue-items.shifting-left {
    transform: translateX(-18px);
}

.queue-items.recentering {
    transform: translateX(0) scale(1.01);
}

.queue-item,
.queue-moving-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 72px;
    border-radius: 16px;
    color: var(--text-primary);
    font-weight: 700;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.34), rgba(6, 182, 212, 0.18) 48%, rgba(139, 92, 246, 0.28));
    border: 1px solid rgba(6, 182, 212, 0.36);
    box-shadow: 0 14px 30px rgba(2, 6, 23, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08), var(--glow-blue);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.queue-item.front {
    border-color: rgba(16, 185, 129, 0.52);
}

.queue-item.rear {
    border-color: rgba(245, 158, 11, 0.52);
}

.queue-item.highlight {
    animation: peekPulse 0.9s ease-out;
}

.queue-item.dequeuing {
    animation: queueDequeueOut 0.78s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.queue-item.just-added {
    animation: stackTopGlow 0.85s ease-out;
}

.queue-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    pointer-events: none;
}

.queue-empty-state.hidden {
    display: none;
}

.queue-end-label {
    position: absolute;
    top: 54px;
    z-index: 3;
    color: var(--color-secondary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.queue-front-label {
    left: 24px;
}

.queue-rear-label {
    right: 24px;
}

.queue-motion-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.queue-moving-item {
    position: absolute;
    top: 50%;
    right: 18px;
    transform: translate(120px, -50%);
}

.queue-moving-item.enqueuing {
    animation: queueEnqueueIn 0.86s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.queue-arrow {
    position: absolute;
    top: 50%;
    width: 76px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-secondary));
    filter: drop-shadow(0 0 12px rgba(6, 182, 212, 0.5));
    animation: arrowPulse 0.82s ease-out;
}

.queue-arrow::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 12px;
    height: 12px;
    border-right: 2px solid var(--color-secondary);
    border-bottom: 2px solid var(--color-secondary);
    transform: translateY(-50%) rotate(-45deg);
}

.queue-arrow.enqueue {
    right: 84px;
}

.queue-arrow.dequeue {
    left: 84px;
    transform: rotate(180deg);
}

.coming-soon-container h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.coming-soon-container p {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

/* Stack Visualizer */
.stack-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 30px;
    align-items: start;
}

.stack-controls-panel {
    min-width: 0;
}

.structure-summary {
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 520px;
}

.stack-operation-card {
    margin-bottom: 40px;
    padding: 30px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.7), rgba(30, 41, 59, 0.46));
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.stack-operation-card:hover {
    transform: translateY(-2px);
    border-color: rgba(6, 182, 212, 0.24);
    box-shadow: var(--shadow-md), var(--glow-cyan);
}

.stack-operation-card h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
}

.stack-secondary-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stack-secondary-actions .stack-operation-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 214px;
    margin-bottom: 0;
}

.stack-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.stack-input {
    flex: 1;
    min-width: 0;
    padding: 14px 20px;
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.stack-input:focus {
    outline: none;
    border-color: var(--color-secondary);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: var(--glow-cyan);
}

.stack-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.stack-visualization-panel {
    position: sticky;
    top: var(--sticky-offset);
    z-index: 40;
    min-height: 620px;
    padding: 24px;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.48), rgba(30, 41, 59, 0.3));
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 24px;
    box-shadow: 0 26px 70px rgba(2, 6, 23, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(18px) saturate(130%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    animation: stackPanelReveal 0.45s ease-out;
}

.stack-visualization-panel.warning {
    border-color: rgba(239, 68, 68, 0.34);
    box-shadow: 0 26px 70px rgba(239, 68, 68, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stack-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.52);
    border: 1px solid rgba(6, 182, 212, 0.18);
    border-radius: 14px;
    color: var(--text-secondary);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-sm);
}

.stack-meta-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stack-meta-value {
    min-width: 34px;
    color: var(--color-secondary);
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 0 16px rgba(6, 182, 212, 0.42);
    transition: transform 0.25s ease, color 0.25s ease;
}

.stack-meta-value.updated {
    transform: scale(1.16);
    color: var(--color-success);
}

.stack-meta-value.full {
    min-width: 86px;
    color: var(--color-warning);
    text-shadow: 0 0 16px rgba(245, 158, 11, 0.42);
}

.stack-definition-panel {
    margin: 12px 0 0;
    padding: 18px;
    min-height: 98px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.18);
    border-radius: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-sm);
    animation: definitionReveal 0.35s ease-out;
}

.stack-warning-label {
    margin-bottom: 14px;
    padding: 12px 16px;
    border: 1px solid rgba(239, 68, 68, 0.34);
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: #fecaca;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-align: center;
    box-shadow: 0 0 28px rgba(239, 68, 68, 0.18);
    animation: warningLabelReveal 0.28s ease-out;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.stack-warning-label.hidden {
    display: none;
}

.stack-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 560px;
    overflow: hidden;
}

.stack-shell {
    position: relative;
    width: min(260px, 100%);
    height: 430px;
    padding: 46px 20px 22px;
    border: 2px solid rgba(6, 182, 212, 0.34);
    border-top: 0;
    border-radius: 0 0 28px 28px;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), rgba(15, 23, 42, 0.74));
    box-shadow: inset 0 -24px 44px rgba(6, 182, 212, 0.1), inset 18px 0 36px rgba(139, 92, 246, 0.06), 0 0 44px rgba(6, 182, 212, 0.18);
    transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.stack-shell.reacting {
    transform: translateY(4px) scale(0.992);
    box-shadow: inset 0 -24px 44px rgba(6, 182, 212, 0.13), 0 0 54px rgba(139, 92, 246, 0.22);
}

.stack-shell.peeking {
    box-shadow: inset 0 -24px 44px rgba(6, 182, 212, 0.12), 0 0 58px rgba(16, 185, 129, 0.2);
}

.stack-shell.warning {
    border-color: rgba(239, 68, 68, 0.58);
    animation: stackWarningShake 0.72s ease-out;
    box-shadow: inset 0 -24px 44px rgba(239, 68, 68, 0.12), 0 0 58px rgba(239, 68, 68, 0.28);
}

.stack-ambient-glow {
    position: absolute;
    inset: 16px;
    border-radius: 22px;
    background: radial-gradient(circle at 50% 18%, rgba(6, 182, 212, 0.16), transparent 42%),
                radial-gradient(circle at 50% 88%, rgba(139, 92, 246, 0.14), transparent 46%);
    opacity: 0.9;
    pointer-events: none;
    animation: chamberGlow 4s ease-in-out infinite;
}

.stack-shell::before,
.stack-shell::after {
    content: '';
    position: absolute;
    top: 0;
    width: 28px;
    height: 2px;
    background: rgba(6, 182, 212, 0.38);
    box-shadow: var(--glow-cyan);
}

.stack-shell::before {
    left: 0;
}

.stack-shell::after {
    right: 0;
}

.stack-top-label {
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.stack-items {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column-reverse;
    justify-content: flex-start;
    gap: 14px;
    height: 100%;
}

.stack-item,
.stack-moving-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    border-radius: 14px;
    color: var(--text-primary);
    font-weight: 700;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.34), rgba(6, 182, 212, 0.18) 48%, rgba(139, 92, 246, 0.28));
    border: 1px solid rgba(6, 182, 212, 0.36);
    box-shadow: 0 14px 30px rgba(2, 6, 23, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.08), var(--glow-blue);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.stack-item::before,
.stack-moving-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    transform: translateX(-120%);
    transition: transform 0.5s ease;
}

.stack-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(2, 6, 23, 0.36), var(--glow-cyan);
}

.stack-item:hover::before,
.stack-moving-item.pushing::before {
    transform: translateX(120%);
}

.stack-item {
    animation: stackSettle 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.stack-item.top {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 12px 28px rgba(16, 185, 129, 0.16), var(--glow-cyan);
}

.stack-item.just-added {
    animation: stackTopGlow 0.9s ease-out;
}

.stack-item.peeking {
    animation: peekPulse 0.9s ease-out;
}

.stack-item.popping {
    animation: stackPopOut 0.72s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.stack-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 0.95rem;
    pointer-events: none;
}

.stack-empty-state.hidden {
    display: none;
}

.stack-base {
    margin-top: 18px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.stack-motion-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.stack-moving-item {
    position: absolute;
    top: 44px;
    left: 50%;
    width: 170px;
    transform: translate(-50%, -120px);
}

.stack-moving-item.pushing {
    animation: pushIntoStack 0.82s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.stack-arrow {
    position: absolute;
    left: 50%;
    width: 2px;
    height: 74px;
    background: linear-gradient(180deg, var(--color-secondary), transparent);
    transform: translateX(-50%);
    filter: drop-shadow(0 0 12px rgba(6, 182, 212, 0.5));
}

.stack-arrow::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-right: 2px solid var(--color-secondary);
    border-bottom: 2px solid var(--color-secondary);
    transform: translateX(-50%) rotate(45deg);
}

.stack-arrow.push {
    top: 104px;
    animation: arrowPulse 0.82s ease-out;
}

.stack-arrow.pop {
    top: 46px;
    transform: translateX(-50%) rotate(180deg);
    animation: arrowPulse 0.72s ease-out;
}

.stack-arrow.peek {
    display: none;
}

@keyframes sectionReveal {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes stackPanelReveal {
    from {
        opacity: 0;
        transform: translateX(22px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pushIntoStack {
    0% {
        opacity: 0;
        transform: translate(-50%, -130px) scale(0.94);
    }
    25% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translate(-50%, 62px) scale(1);
    }
}

@keyframes stackSettle {
    from {
        opacity: 0;
        transform: translateY(-24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes stackTopGlow {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    35% {
        transform: translateY(-5px) scale(1.03);
        box-shadow: 0 18px 40px rgba(16, 185, 129, 0.26), var(--glow-cyan);
    }
}

@keyframes peekPulse {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    45% {
        transform: translateY(-10px) scale(1.05);
        border-color: rgba(16, 185, 129, 0.72);
        box-shadow: 0 20px 42px rgba(16, 185, 129, 0.26), var(--glow-cyan);
    }
}

@keyframes stackPopOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    70% {
        opacity: 1;
        transform: translateY(-86px) scale(1.04);
    }
    100% {
        opacity: 0;
        transform: translateY(-128px) scale(0.94);
    }
}

@keyframes chamberGlow {
    0%, 100% {
        opacity: 0.68;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.02);
    }
}

@keyframes stackWarningShake {
    0%, 100% {
        filter: none;
    }
    18% {
        filter: drop-shadow(-4px 0 10px rgba(239, 68, 68, 0.16));
    }
    36% {
        filter: drop-shadow(4px 0 10px rgba(239, 68, 68, 0.16));
    }
    54% {
        filter: drop-shadow(-2px 0 8px rgba(239, 68, 68, 0.14));
    }
    72% {
        filter: drop-shadow(2px 0 8px rgba(239, 68, 68, 0.14));
    }
}

@keyframes stackWarningPulse {
    0%, 100% {
        box-shadow: 0 26px 70px rgba(2, 6, 23, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    }
    45% {
        border-color: rgba(239, 68, 68, 0.38);
        box-shadow: 0 26px 70px rgba(239, 68, 68, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
}

@keyframes arrowPulse {
    0%, 100% {
        opacity: 0;
    }
    25%, 75% {
        opacity: 1;
    }
}

@keyframes definitionReveal {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes warningLabelReveal {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes queueEnqueueIn {
    0% {
        opacity: 0;
        transform: translate(120px, -50%) scale(0.94);
    }
    24% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translate(-28px, -50%) scale(1);
    }
}

@keyframes queueDequeueOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    70% {
        opacity: 1;
        transform: translateX(-86px) scale(1.04);
    }
    100% {
        opacity: 0;
        transform: translateX(-124px) scale(0.94);
    }
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes statusPulse {
    0%, 100% {
        box-shadow: 0 0 24px rgba(239, 68, 68, 0.24);
    }
    50% {
        box-shadow: 0 0 36px rgba(239, 68, 68, 0.36);
    }
}

@keyframes passComplete {
    0%, 100% {
        transform: scale(1);
    }
    45% {
        transform: scale(1.08);
        box-shadow: 0 0 28px rgba(16, 185, 129, 0.45);
    }
}

@keyframes sortedGlow {
    0%, 100% {
        transform: scale(1);
    }
    45% {
        transform: scale(1.06);
        box-shadow: 0 0 32px rgba(16, 185, 129, 0.55);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --sticky-offset: 10px;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .visualizer-header {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 18px;
    }

    .size-error {
        grid-column: 1;
    }

    .array-container {
        min-height: 118px;
        padding: 18px;
    }
    
    .selector-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .operations-buttons {
        justify-content: center;
    }
    
    .array-box {
        width: 60px;
        height: 80px;
    }
    
    .array-box-value {
        font-size: 1.2rem;
    }

    .stack-layout {
        grid-template-columns: 1fr;
    }

    .stack-visualization-panel {
        position: relative;
        top: auto;
        order: -1;
        min-height: auto;
        padding: 18px;
    }

    .stack-stage {
        min-height: 460px;
    }

    .stack-shell {
        height: 350px;
        padding: 40px 16px 18px;
    }

    .stack-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .stack-secondary-actions {
        grid-template-columns: 1fr;
    }

    .queue-visualization-panel {
        padding: 18px;
    }

    .queue-main-actions,
    .queue-view-actions {
        grid-template-columns: 1fr;
    }

    .queue-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .queue-stage {
        min-height: 240px;
    }

    .queue-chamber {
        padding: 32px 18px;
    }

    .queue-items {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    :root {
        --sticky-offset: 6px;
    }

    .hero-title {
        font-size: 2rem;
    }

    .container {
        padding: 20px 10px;
    }

    .array-box {
        width: 50px;
        height: 70px;
    }

    .visualizer-header {
        padding: 14px;
    }

    .visualizer-header h2 {
        font-size: 1.35rem;
    }

    .size-control {
        width: 100%;
        gap: 10px;
        justify-content: center;
    }

    .array-container {
        min-height: 104px;
        padding: 14px;
    }

    .status-display {
        padding: 14px;
        font-size: 0.85rem;
    }

    .array-box-value {
        font-size: 1rem;
    }

    .inputs-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    .stack-operation-card {
        padding: 20px;
    }

    .stack-stage {
        min-height: 410px;
    }

    .stack-shell {
        width: min(220px, 100%);
        height: 310px;
        padding: 36px 14px 16px;
    }

    .stack-item,
    .stack-moving-item {
        min-height: 42px;
    }

    .stack-moving-item {
        width: 150px;
    }

    .queue-operation-card {
        padding: 20px;
    }

    .queue-item,
    .queue-moving-item {
        width: 52px;
        height: 62px;
    }

    .queue-capacity {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Calm premium theme refinement */
.selector-buttons,
.visualizer-header,
.array-container,
.input-section,
.operations-section,
.search-section,
.status-display,
.info-section,
.stack-operation-card,
.queue-operation-card,
.stack-visualization-panel,
.queue-visualization-panel,
.queue-placeholder {
    background: rgba(18, 28, 26, 0.82);
    border-color: var(--border-soft);
    box-shadow: var(--shadow-sm);
}

.array-definition-panel,
.queue-definition-panel,
.stack-definition-panel,
.info-panel {
    background: rgba(16, 24, 22, 0.78);
    border-color: var(--border-soft);
    box-shadow: var(--shadow-sm);
}

.selector-btn.active,
.operation-btn,
.search-action-btn {
    background: rgba(39, 216, 156, 0.14);
    border-color: rgba(74, 240, 181, 0.2);
    box-shadow: none;
}

.selector-btn:hover:not(.active),
.operation-btn:hover:not(:disabled),
.info-btn:hover,
.info-btn.active,
.search-action-btn:hover {
    background: rgba(74, 240, 181, 0.1);
    border-color: rgba(74, 240, 181, 0.28);
    box-shadow: 0 10px 28px rgba(39, 216, 156, 0.08);
}

.selector-btn.active::after {
    background: #27D89C;
}

.input-field input,
.search-input,
.stack-input,
.queue-input,
.size-input {
    background: rgba(11, 17, 16, 0.68);
    border-color: rgba(74, 240, 181, 0.12);
    color: var(--text-primary);
}

.input-field input:focus,
.search-input:focus,
.stack-input:focus,
.queue-input:focus,
.size-input:focus {
    background: rgba(16, 24, 22, 0.92);
    border-color: rgba(74, 240, 181, 0.34);
    box-shadow: 0 0 0 3px rgba(74, 240, 181, 0.08);
}

.array-box,
.stack-item,
.stack-moving-item,
.queue-item,
.queue-moving-item {
    background: rgba(18, 28, 26, 0.92);
    border-color: rgba(74, 240, 181, 0.18);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(241, 255, 248, 0.04);
}

.array-box-value,
.stack-meta-value,
.queue-capacity strong,
.stack-top-label,
.queue-end-label {
    color: var(--color-secondary);
}

.array-box.active,
.array-box.visiting,
.queue-item.highlight,
.stack-item.peeking {
    background: rgba(39, 216, 156, 0.14);
    border-color: rgba(74, 240, 181, 0.34);
    box-shadow: 0 16px 32px rgba(39, 216, 156, 0.12);
}

.array-box.comparing {
    background: rgba(74, 240, 181, 0.1);
    border-color: rgba(74, 240, 181, 0.3);
    box-shadow: 0 16px 32px rgba(74, 240, 181, 0.1);
}

.array-box.swapping,
.array-box.moving {
    background: rgba(215, 181, 109, 0.12);
    border-color: rgba(215, 181, 109, 0.36);
    box-shadow: 0 16px 32px rgba(215, 181, 109, 0.1);
}

.array-box.sorted,
.array-box.found,
.stack-item.top,
.queue-item.front,
.queue-item.rear {
    background: rgba(39, 216, 156, 0.12);
    border-color: rgba(39, 216, 156, 0.34);
    box-shadow: 0 14px 30px rgba(39, 216, 156, 0.1);
}

.stack-shell,
.queue-chamber {
    background: rgba(16, 24, 22, 0.7);
    border-color: rgba(74, 240, 181, 0.16);
    box-shadow: inset 0 -18px 34px rgba(39, 216, 156, 0.04), 0 20px 42px rgba(0, 0, 0, 0.24);
}

.stack-ambient-glow {
    background: radial-gradient(circle at 50% 20%, rgba(74, 240, 181, 0.08), transparent 46%),
                radial-gradient(circle at 50% 90%, rgba(39, 216, 156, 0.06), transparent 50%);
}

.stack-meta,
.queue-capacity {
    background: rgba(11, 17, 16, 0.58);
    border-color: var(--border-soft);
    box-shadow: var(--shadow-sm);
}

.status-display.success {
    background: rgba(39, 216, 156, 0.08);
    border-color: rgba(39, 216, 156, 0.22);
    box-shadow: 0 12px 28px rgba(39, 216, 156, 0.08);
}

.status-display.failure,
.stack-warning-label,
.queue-warning-label {
    background: rgba(255, 94, 115, 0.08);
    border-color: rgba(255, 94, 115, 0.24);
    box-shadow: 0 12px 28px rgba(255, 94, 115, 0.08);
}

.coming-soon-container h2 {
    background: linear-gradient(135deg, #F1FFF8 0%, #4AF0B5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==========================================================
   LINKED LIST VISUALIZER STYLES
   All classes prefixed ll- — zero collision with existing CSS
   ========================================================== */

/* LL Section Header */
.ll-header {
    /* Use default visualizer-header grid layout - no overrides */
}

.ll-definition-panel {
    margin: 0;
    padding: 16px 18px;
    min-height: 84px;
    width: 100%;
    background: rgba(39, 216, 156, 0.08);
    border: 1px solid rgba(39, 216, 156, 0.18);
    border-radius: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-sm);
    animation: definitionReveal 0.35s ease-out;
}

/* LL Sticky Visualization Panel */
.ll-visualization-panel {
    position: sticky;
    top: var(--sticky-offset);
    z-index: 40;
    margin-bottom: 40px;
    padding: 24px;
    background: rgba(18, 28, 26, 0.82);
    border: 1px solid var(--border-soft);
    border-radius: 24px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(18px) saturate(130%);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    animation: sectionReveal 0.35s ease-out;
    transition: background-color 0.35s ease, border-color 0.35s ease;
}

/* Error state: smooth red overlay fade-in via background-color */
.ll-visualization-panel.ll-error-state {
    background: rgba(255, 94, 115, 0.14);
    border-color: rgba(255, 94, 115, 0.2);
}

/* Node Count Meta Row */
.ll-node-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 18px;
    background: rgba(11, 17, 16, 0.58);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

.ll-meta-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.ll-meta-value {
    color: var(--color-secondary);
    font-size: 1.25rem;
    font-weight: 700;
    text-shadow: 0 0 16px rgba(74, 240, 181, 0.42);
    transition: transform 0.25s ease, color 0.25s ease;
}

.ll-meta-value.updated {
    transform: scale(1.12);
    color: var(--color-success);
}

.ll-meta-value.ll-count-full {
    color: var(--color-warning);
    text-shadow: 0 0 16px rgba(215, 181, 109, 0.42);
}

/* Head / Tail Info Row */
.ll-head-tail-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 12px 20px;
    background: rgba(11, 17, 16, 0.52);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
}

.ll-ht-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ll-ht-name {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
}

.ll-ht-arrow {
    color: var(--color-secondary);
    font-size: 1rem;
}

.ll-ht-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-secondary);
    transition: color 0.3s ease;
}

.ll-ht-null {
    color: var(--text-tertiary);
}

.ll-ht-sep {
    color: var(--text-tertiary);
    font-size: 1.4rem;
    line-height: 1;
}

/* LL Stage (scrollable visualization area) */
.ll-stage {
    position: relative;
    min-height: 118px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: visible;
    padding: 8px 6px 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(74, 240, 181, 0.18) transparent;
}

.ll-stage::-webkit-scrollbar {
    height: 4px;
}

.ll-stage::-webkit-scrollbar-thumb {
    background: rgba(74, 240, 181, 0.18);
    border-radius: 2px;
}

/* Horizontal flex row of node-wrappers and connectors */
.ll-node-list {
    display: flex;
    align-items: flex-end;
    flex-wrap: nowrap;
    gap: 0;
    padding-top: 36px; /* room for HEAD/TAIL badge above nodes */
    margin: 0 auto;
}

/* ---- Node Wrapper: pointer label on top, node box below ---- */
.ll-node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

/* Pointer label row above node (HEAD / TAIL / spacer) */
.ll-ptr-label-row {
    height: 26px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 5px;
}

.ll-ptr-badge {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 7px;
    border-radius: 6px;
    white-space: nowrap;
}

.ll-head-badge {
    color: var(--color-secondary);
    background: rgba(74, 240, 181, 0.1);
    border: 1px solid rgba(74, 240, 181, 0.22);
}

.ll-tail-badge {
    color: var(--color-warning);
    background: rgba(215, 181, 109, 0.1);
    border: 1px solid rgba(215, 181, 109, 0.22);
}

/* ---- Node Box: [data | sep | next] ---- */
.ll-node {
    display: flex;
    align-items: stretch;
    height: 62px;
    border: 1.5px solid rgba(74, 240, 181, 0.2);
    border-radius: 10px;
    background: rgba(18, 28, 26, 0.92);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(241, 255, 248, 0.04);
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, background 0.3s ease;
    cursor: default;
    flex-shrink: 0;
}

.ll-node:hover {
    border-color: rgba(74, 240, 181, 0.36);
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28), 0 0 14px rgba(74, 240, 181, 0.1);
}

.ll-node--head {
    border-color: rgba(74, 240, 181, 0.32);
}

.ll-node--tail {
    border-color: rgba(215, 181, 109, 0.32);
}

/* Traversal highlight */
.ll-node--traverse {
    border-color: rgba(74, 240, 181, 0.58) !important;
    background: rgba(39, 216, 156, 0.14) !important;
    box-shadow: 0 0 26px rgba(39, 216, 156, 0.2) !important;
    animation: llNodeTraverse 0.42s ease-out;
}

/* New node (just inserted) */
.ll-node--new {
    animation: llNodeInsert 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Data half */
.ll-node__data {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-secondary);
    padding: 0 8px;
    flex-shrink: 0;
}

/* Vertical separator between data and next */
.ll-node__sep {
    width: 1.5px;
    background: rgba(74, 240, 181, 0.16);
    margin: 10px 0;
    flex-shrink: 0;
}

/* Next pointer half */
.ll-node__next {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-tertiary);
    padding: 0 4px;
    flex-shrink: 0;
}

/* ---- Arrow connector between nodes ---- */
.ll-connector {
    display: flex;
    align-items: center;
    align-self: flex-end;           /* bottom-align with node-wrappers */
    height: 62px;                   /* match node height */
    padding: 0 2px;
    flex-shrink: 0;
}

.ll-connector::before {
    content: '';
    display: block;
    width: 26px;
    height: 2px;
    background: linear-gradient(90deg, rgba(74, 240, 181, 0.35), rgba(74, 240, 181, 0.6));
}

.ll-connector::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 8px solid rgba(74, 240, 181, 0.55);
    margin-left: -1px;
}

/* ---- null connector after last node ---- */
.ll-null-conn {
    display: flex;
    align-items: center;
    align-self: flex-end;
    height: 62px;
    gap: 4px;
    padding: 0 6px;
    flex-shrink: 0;
}

.ll-conn-line {
    width: 20px;
    height: 2px;
    background: linear-gradient(90deg, rgba(74, 240, 181, 0.35), rgba(74, 240, 181, 0.2));
    flex-shrink: 0;
}

.ll-null-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
    padding: 3px 9px;
    border: 1px solid rgba(109, 128, 121, 0.22);
    border-radius: 6px;
    background: rgba(11, 17, 16, 0.58);
    white-space: nowrap;
}

/* Empty State */
.ll-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.ll-empty-state.hidden {
    display: none;
}

.ll-empty-display {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    background: rgba(11, 17, 16, 0.5);
    border: 1px dashed rgba(74, 240, 181, 0.16);
    border-radius: 12px;
}

.ll-pointer-badge {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-tertiary);
}

.ll-pointer-separator {
    color: var(--text-tertiary);
    font-size: 1.2rem;
}

/* ==========================================================
   LL Operation Cards and Inputs
   ========================================================== */

.ll-operations-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.ll-operation-card {
    padding: 28px;
    background: rgba(18, 28, 26, 0.82);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.ll-operation-card:hover {
    transform: translateY(-2px);
    border-color: rgba(74, 240, 181, 0.22);
    box-shadow: var(--shadow-md), 0 0 28px rgba(39, 216, 156, 0.07);
}

.ll-operation-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 18px;
    color: var(--text-primary);
}

/* Input group layouts */
.ll-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.ll-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

/* Inputs */
.ll-input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    background: rgba(11, 17, 16, 0.68);
    border: 2px solid rgba(74, 240, 181, 0.12);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.ll-input:focus {
    outline: none;
    border-color: rgba(74, 240, 181, 0.34);
    background: rgba(16, 24, 22, 0.92);
    box-shadow: 0 0 0 3px rgba(74, 240, 181, 0.08);
}

.ll-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

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

/* Compact index input */
.ll-input-small {
    flex: none;
    width: 80px;
}

/* Learn buttons grid */
.ll-learn-buttons {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* ==========================================================
   LL Animations
   ========================================================== */

/* New node pops in from above with a slight bounce */
@keyframes llNodeInsert {
    0% {
        opacity: 0;
        transform: scale(0.68) translateY(-18px);
    }
    55% {
        opacity: 1;
        transform: scale(1.06) translateY(2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Traversal highlight pulse */
@keyframes llNodeTraverse {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    45% {
        transform: translateY(-6px) scale(1.05);
        box-shadow: 0 16px 34px rgba(39, 216, 156, 0.24);
    }
}

/* Error glow on visualization panel - DEPRECATED: now uses smooth background transition */
/* @keyframes llErrorGlow - removed in favor of background-color transition */

/* Delete button style (delete operations use destructive color) */
.ll-delete-btn {
    background: rgba(255, 94, 115, 0.12) !important;
    border: 1.5px solid rgba(255, 94, 115, 0.24) !important;
    color: var(--color-error) !important;
    transition: all 0.3s ease;
}

.ll-delete-btn:hover {
    background: rgba(255, 94, 115, 0.18) !important;
    border-color: rgba(255, 94, 115, 0.42) !important;
    box-shadow: 0 8px 24px rgba(255, 94, 115, 0.15) !important;
}

.ll-delete-btn:active {
    transform: scale(0.96);
}

.ll-delete-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ==========================================================
   LL Responsive Overrides
   ========================================================== */

@media (max-width: 768px) {
    .ll-operations-grid {
        grid-template-columns: 1fr;
    }

    .ll-visualization-panel {
        padding: 18px;
    }

    .ll-head-tail-display {
        gap: 12px;
    }

    .ll-input-group {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .ll-operations-grid {
        grid-template-columns: 1fr;
    }

    .ll-visualization-panel {
        padding: 14px;
    }

    .ll-node__data {
        width: 42px;
        font-size: 0.95rem;
    }

    .ll-node__next {
        width: 28px;
        font-size: 0.8rem;
    }

    .ll-node {
        height: 52px;
    }

    .ll-connector {
        height: 52px;
    }

    .ll-null-conn {
        height: 52px;
    }

    .ll-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ll-input-small {
        width: 100%;
    }

    .ll-operation-card {
        padding: 18px;
    }

    .ll-head-tail-display {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .ll-ht-sep {
        display: none;
    }
}
