:root {
    --bg: #050816;
    --panel: #0f172a;
    --accent: #38bdf8;
    --accent-soft: rgba(56, 189, 248, 0.15);
    --text: #e5e7eb;
    --muted: #9ca3af;
    --danger: #f97373;
    --radius-lg: 16px;
    --radius-full: 999px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    sans-serif;
    background: radial-gradient(circle at top, #1f2937 0, #020617 45%, #000 100%);
    color: var(--text);
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 24px;
}

.app {
    width: 100%;
    max-width: 1120px;
    margin: auto;
    display: grid;
    grid-template-columns: 2.2fr 1.2fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
    }
}

.card {
    background: linear-gradient(145deg, #020617 0, #0b1120 50%, #020617 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.9);
    padding: 20px 20px 16px;
    backdrop-filter: blur(16px);
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.title-group h1 {
    font-size: 1.35rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.title-pill {
    font-size: 0.7rem;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(56, 189, 248, 0.4);
    background: rgba(15, 23, 42, 0.9);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.subtitle {
    margin: 4px 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.pill-badge {
    font-size: 0.72rem;
    padding: 6px 10px;
    border-radius: var(--radius-full);
    background: rgba(22, 163, 74, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #bbf7d0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.pill-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.8);
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.select {
    position: relative;
    display: inline-flex;
    align-items: center;
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 7px 28px 7px 10px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.95);
    color: var(--text);
    font-size: 0.82rem;
    cursor: pointer;
}

.select::after {
    content: "▾";
    position: absolute;
    right: 10px;
    font-size: 0.6rem;
    color: var(--muted);
    pointer-events: none;
}

button {
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    padding: 7px 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: radial-gradient(circle at top left, #38bdf8, #0ea5e9 55%, #0369a1);
    color: #0b1120;
    font-weight: 500;
    box-shadow: 0 10px 22px rgba(56, 189, 248, 0.35);
    transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
}

button.secondary {
    background: rgba(15, 23, 42, 0.95);
    color: var(--text);
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: none;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

button:not(:disabled):hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    color: var(--muted);
    flex: 1;
    min-width: 180px;
}

.slider-group label {
    white-space: nowrap;
}

input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.tags-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.tag {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.9);
}

.metrics-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 10px;
}

.metric {
    padding: 4px 8px;
    border-radius: var(--radius-full);
    background: rgba(15, 23, 42, 0.9);
    border: 1px dashed rgba(148, 163, 184, 0.4);
}

#visualizationContainer {
    position: relative;
    height: 320px;
    padding: 10px;
    border-radius: 14px;
    background: radial-gradient(circle at top left, #1f2937, #020617 60%, #000);
    border: 1px solid rgba(31, 41, 55, 0.8);
    overflow: hidden;
}

#bars {
    position: absolute;
    inset: 16px 8px 10px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
}

.bar {
    flex: 1;
    border-radius: 6px 6px 0 0;
    background: linear-gradient(to top, #0ea5e9, #38bdf8);
    box-shadow: 0 6px 14px rgba(56, 189, 248, 0.45);
    transition: transform 0.08s linear, height 0.08s linear,
    background 0.08s linear, box-shadow 0.08s linear;
}

.bar.compare {
    background: linear-gradient(to top, #facc15, #fde047);
    box-shadow: 0 6px 14px rgba(234, 179, 8, 0.55);
}

.bar.swap {
    background: linear-gradient(to top, #f97373, #fecaca);
    box-shadow: 0 6px 14px rgba(248, 113, 113, 0.65);
    transform: translateY(-4px);
}

.bar.sorted {
    background: linear-gradient(to top, #22c55e, #bbf7d0);
    box-shadow: 0 6px 14px rgba(34, 197, 94, 0.65);
}

.watermark {
    position: absolute;
    bottom: 10px;
    right: 16px;
    font-size: 0.7rem;
    color: rgba(148, 163, 184, 0.55);
    pointer-events: none;
}

.side-panel-title {
    font-size: 0.95rem;
    margin: 0 0 6px;
}

.algo-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(56, 189, 248, 0.4);
    background: rgba(15, 23, 42, 0.9);
    margin-bottom: 6px;
}

.algo-badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.9);
}

.algo-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--muted);
    margin: 8px 0 10px;
}

.algo-meta span {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    border: 1px dashed rgba(148, 163, 184, 0.4);
}

.algo-description {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.4;
    margin-bottom: 10px;
}

.code-block {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.7rem;
    background: #020617;
    border-radius: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(15, 23, 42, 0.9);
    color: #e5e7eb;
    max-height: 170px;
    overflow: auto;
    white-space: pre;
}

.hint {
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--muted);
}

.hint strong {
    color: var(--accent);
    font-weight: 500;
}
