* {
    box-sizing: border-box;
    font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}
body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.card {
    max-width: 1500px;
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid #334155;
    border-radius: 32px;
    padding: 24px 28px 32px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.8), 0 0 0 1px #1e293b inset;
}
h1 {
    margin: 0 0 12px 0;
    font-weight: 600;
    font-size: 2.1rem;
    letter-spacing: -0.02em;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
}
h1 span {
    background: #2563eb;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 40px;
    color: white;
    margin-left: 8px;
}
.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px 24px;
    margin-bottom: 28px;
    background: #1e293b70;
    padding: 12px 20px;
    border-radius: 60px;
    backdrop-filter: blur(4px);
    border: 1px solid #475569;
}
.select-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.select-group label {
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.9rem;
}
select, input {
    background: #0f172a;
    border: 1px solid #475569;
    color: #f1f5f9;
    padding: 8px 16px;
    border-radius: 40px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.15s;
}
select:hover, input:hover {
    background: #1e293b;
    border-color: #3b82f6;
}
.slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #0f172a80;
    padding: 4px 16px;
    border-radius: 40px;
    border: 1px solid #475569;
}
.slider-group label {
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.9rem;
}
.slider-group input {
    width: 140px;
    padding: 0;
    accent-color: #3b82f6;
}
.slider-group span {
    color: #a5f3fc;
    min-width: 45px;
    text-align: right;
}
button {
    background: #3b82f6;
    border: none;
    color: white;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 40px;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 8px #1e3a8a40;
    transition: 0.15s;
    border: 1px solid #60a5fa;
    letter-spacing: 0.3px;
}
button.secondary {
    background: #334155;
    border-color: #64748b;
    box-shadow: none;
}
button:hover {
    background: #2563eb;
    transform: scale(0.98);
}
button.secondary:hover {
    background: #475569;
}
button:disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(0.5);
}
.visualization-panel {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.bar-container {
    flex: 2;
    min-width: 380px;
    background: #0b1120cc;
    border-radius: 24px;
    padding: 20px 10px 10px 10px;
    border: 1px solid #334155;
    box-shadow: inset 0 2px 5px #00000030, 0 8px 20px #00000040;
    overflow: hidden; /* Prevent any overflow */
}
#chart {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 360px;
    width: 100%;
    padding: 0 6px;
    position: relative;
}
.bar {
    background: #38bdf8;
    flex-shrink: 1; /* Allow bars to shrink */
    min-width: 1px; /* Allow very thin bars */
    border-radius: 8px 8px 4px 4px;
    transition: height 0.12s ease, background 0.1s, transform 0s;
    box-shadow: 0 -2px 8px #7dd3fc80;
    border: 1px solid #bae6fd60;
    position: relative;
    margin: 0 0.5px; /* Tiny gap that scales */
}
.bar.comparing {
    background: #fbbf24 !important;
    box-shadow: 0 -4px 12px #fde68a !important;
    border-color: #fcd34d !important;
}
.bar.pivot {
    background: #a78bfa !important;
    box-shadow: 0 -4px 12px #c4b5fd !important;
    border-color: #ddd6fe !important;
}
.bar.executed {
    background: #ef4444 !important;
    box-shadow: 0 -4px 14px #fca5a5 !important;
    border-color: #fecaca !important;
    animation: shake 0.3s ease-in-out;
}
.bar.procrastinating {
    background: #f59e0b !important;
    box-shadow: 0 -4px 14px #fbbf24 !important;
    animation: pulse 1s ease-in-out infinite;
}
.bar.merging {
    background: #10b981 !important;
    box-shadow: 0 -4px 12px #34d399 !important;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.code-panel {
    flex: 1.2;
    min-width: 360px;
    background: #0f172a;
    border-radius: 24px;
    padding: 20px 16px;
    border: 1px solid #334155;
    box-shadow: inset 0 1px 4px #00000060, 0 8px 18px #00000050;
    display: flex;
    flex-direction: column;
}
.code-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
    color: #94a3b8;
    font-weight: 500;
    padding: 0 6px;
}
pre {
    margin: 0;
    flex: 1;
    background: #02061780;
    padding: 18px 16px;
    border-radius: 18px;
    overflow-x: auto;
    border: 1px solid #1e293b;
    font-size: 0.95rem;
    line-height: 1.7;
    counter-reset: line;
    max-height: 400px;
    overflow-y: auto;
}
code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: #cbd5e1;
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
}
.code-line {
    display: block;
    counter-increment: line;
    padding: 2px 12px 2px 8px;
    border-radius: 8px;
    transition: background 0.08s;
}
.code-line::before {
    content: counter(line);
    display: inline-block;
    width: 30px;
    color: #64748b;
    text-align: right;
    margin-right: 18px;
    font-size: 0.85rem;
    user-select: none;
}
.code-line.highlight {
    background: #1e3a8a;
    color: #f8fafc;
    font-weight: 500;
    box-shadow: 0 0 0 1px #3b82f6 inset;
}
.code-line.highlight::before {
    color: #93c5fd;
}
.stats {
    display: flex;
    gap: 28px;
    margin-top: 16px;
    color: #a5b4fc;
    font-weight: 500;
    padding-left: 8px;
    flex-wrap: wrap;
}
.timer {
    background: #1e293b;
    padding: 4px 12px;
    border-radius: 20px;
    color: #4ade80;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}
.warning-badge {
    background: #ef4444;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-left: 8px;
}