:root {
    /* Red Culture Theme */
    --app-bg: #fdfbf7;
    --sidebar-bg: rgba(255, 248, 240, 0.8);
    --glass-border: rgba(214, 59, 29, 0.2);
    --text-primary: #8b0000;
    /* Dark Red */
    --text-secondary: #a05a5a;
    --accent-red: #d63b1d;
    /* Revolutionary Red */
    --accent-gold: #ffb400;
    /* Star Gold */
    --accent-hover: #b32b12;
    --danger-red: #ff3b30;

    /* Graph Colors */
    --node-default: #fff8f0;
    --node-border: #d63b1d;
    --node-visited: #d63b1d;
    /* Red for visited/liberated */
    --node-current: #ffb400;
    /* Gold for current focus */
    --node-queue: #ff8c75;
    /* Light Red for queue */
    --node-start: #8b0000;
    /* Dark Red for start */

    --edge-default: rgba(139, 0, 0, 0.2);
    --edge-visited: #d63b1d;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(139, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(139, 0, 0, 0.12);
    --shadow-lg: 0 20px 40px rgba(139, 0, 0, 0.15);

    --font-family: "Noto Serif SC", "Outfit", serif;
    --font-title: "Ma Shan Zheng", cursive;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--app-bg);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url('https://images.unsplash.com/photo-1533038590840-1cde6e668a91?q=80&w=2574&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
}

.app-container {
    width: 90vw;
    height: 85vh;
    max-width: 1400px;
    background: rgba(255, 252, 245, 0.85);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 2rem;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.window-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red {
    background: #ff5f56;
    border: 1px solid #e0443e;
}

.dot.yellow {
    background: #ffbd2e;
    border: 1px solid #dea123;
}

.dot.green {
    background: #27c93f;
    border: 1px solid #1aab29;
}

h1 {
    font-family: var(--font-title);
    font-size: 2rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -5px;
}

.highlight {
    color: var(--accent-red);
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-grow: 1;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Buttons */
.apple-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: var(--font-family);
    gap: 8px;
}

.primary-btn {
    background: #fff;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    background: var(--accent-red);
    color: #fff;
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.action-btn {
    background: var(--accent-red);
    color: white;
    width: 100%;
    box-shadow: var(--shadow-md);
}

.action-btn:hover {
    background: var(--accent-hover);
}

.danger-btn {
    background: rgba(139, 0, 0, 0.1);
    color: var(--text-primary);
    width: 100%;
}

.danger-btn:hover {
    background: rgba(139, 0, 0, 0.2);
}

.apple-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Range Slider */
input[type=range] {
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--accent-red);
    cursor: pointer;
    margin-top: -8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid #fff;
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(139, 0, 0, 0.1);
    border-radius: 2px;
}

/* Info Panel */
.info-panel {
    background: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-primary);
    border: 1px solid rgba(139, 0, 0, 0.1);
}

#statusText {
    font-weight: 700;
    color: var(--accent-red);
    margin-bottom: 8px;
}

.queue-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.queue-display span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

#queueList {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    min-height: 24px;
}

.queue-item {
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--node-queue);
    color: #fff;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* Main Stage */
.visualizer-stage {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
}

.glass-pane {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 0;
    position: relative;
    overflow: hidden;
}

/* SVG Elements */
svg {
    display: block;
    cursor: grab;
}

svg:active {
    cursor: grabbing;
}

/* Nodes */
.node-circle {
    fill: var(--node-default);
    stroke: var(--node-border);
    stroke-width: 2px;
    transition: fill 0.3s ease, stroke 0.3s ease;
    cursor: pointer;
    filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.1));
}

.node-text {
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 700;
    fill: var(--text-primary);
    pointer-events: none;
    user-select: none;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Edges */
.edge-line {
    stroke: var(--edge-default);
    stroke-width: 2px;
    transition: stroke 0.3s ease;
}

.edge-text-bg {
    fill: rgba(255, 255, 255, 0.8);
}

.edge-text {
    font-size: 10px;
    fill: var(--text-secondary);
    font-weight: 600;
    pointer-events: none;
    user-select: none;
}

/* States */
.node-group.visited .node-circle {
    fill: var(--node-visited);
    stroke: var(--node-visited);
}

.node-group.visited .node-text {
    fill: white;
    text-shadow: none;
}

.node-group.current .node-circle {
    fill: var(--node-current);
    stroke: var(--node-current);
}

.node-group.current .node-text {
    fill: var(--text-primary);
    text-shadow: none;
}

.node-group.queue .node-circle {
    fill: var(--node-queue);
    stroke: var(--node-queue);
}

.node-group.queue .node-text {
    fill: white;
    text-shadow: none;
}

.node-group.start .node-circle {
    fill: var(--node-start);
    stroke: var(--node-start);
}

.node-group.start .node-text {
    fill: white;
    text-shadow: none;
}

.edge-line.visited {
    stroke: var(--edge-visited);
    stroke-width: 3px;
}

.actions-footer {
    display: flex;
    gap: 10px;
}