:root {
    /* Emergency Response Theme */
    --app-bg: #1a1a1a;
    --sidebar-bg: rgba(30, 30, 30, 0.9);
    --glass-border: rgba(255, 149, 0, 0.3);
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;

    --accent-orange: #ff9500;
    --accent-red: #ff3b30;
    --accent-green: #27c93f;
    --accent-blue: #007aff;

    --node-center: #ff3b30;
    --node-target: #ff9500;
    --node-visited: #27c93f;
    --node-default: #555;

    --edge-default: rgba(255, 255, 255, 0.15);
    --edge-scanning: #ff9500;
    --edge-path: #27c93f;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.7);

    --font-family: "Outfit", "Noto Serif SC", sans-serif;
    --font-title: "Black Ops One", "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: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('https://images.unsplash.com/photo-1519501025264-65ba15a82390?q=80&w=2564&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
}

.app-container {
    width: 90vw;
    height: 85vh;
    max-width: 1400px;
    background: rgba(30, 30, 30, 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 {
    width: 380px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.2rem;
    flex-shrink: 0;
    overflow-y: auto;
    z-index: 20;
}

.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;
}

.dot.yellow {
    background: #ffbd2e;
}

.dot.green {
    background: #27c93f;
}

h1 {
    font-family: var(--font-title);
    font-size: 1.8rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: -5px;
    letter-spacing: 0.1em;
}

.highlight {
    color: var(--accent-orange);
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-orange);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.apple-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: var(--font-family);
    gap: 8px;
    text-transform: uppercase;
}

.primary-btn {
    background: var(--accent-orange);
    color: white;
    box-shadow: 0 0 15px rgba(255, 149, 0, 0.3);
}

.primary-btn:hover {
    background: #ffaa33;
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(255, 149, 0, 0.5);
}

.danger-btn {
    background: rgba(255, 59, 48, 0.1);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    width: 100%;
}

.danger-btn:hover {
    background: rgba(255, 59, 48, 0.2);
}

.apple-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

input[type=range] {
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--accent-orange);
    cursor: pointer;
    margin-top: -7px;
    box-shadow: 0 0 10px var(--accent-orange);
    border: 2px solid #fff;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.info-panel {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 149, 0, 0.2);
}

#statusText {
    font-weight: 700;
    color: var(--accent-orange);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: monospace;
}

.stat-value.highlight {
    color: var(--accent-orange);
}

/* Distance Table */
.distance-table-container {
    height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

th {
    text-align: left;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    font-weight: 600;
}

td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

tr.active {
    background: rgba(255, 149, 0, 0.15);
}

tr.visited td {
    color: var(--accent-green);
}

.dist-val {
    font-family: monospace;
    font-weight: 700;
}

.info-box {
    background: linear-gradient(135deg, rgba(255, 59, 48, 0.1), rgba(255, 149, 0, 0.1));
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.info-box h3 {
    font-size: 0.9rem;
    color: var(--accent-red);
    margin-bottom: 0.5rem;
    font-family: var(--font-family);
}

.info-box p {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.visualizer-stage {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: #111;
}

.glass-pane {
    width: 100%;
    height: 100%;
    background: rgba(30, 30, 30, 0.6);
    border-radius: 16px;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.rain-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAH0lEQVQoU2NkYGAwZmBgOMsABX8Z0AESCyJ0///7BwA8Hw8B4w75gAAAAABJRU5ErkJggg==') repeat;
    opacity: 0.1;
    animation: rain 0.5s linear infinite;
    pointer-events: none;
}

@keyframes rain {
    from {
        background-position: 0 0;
    }

    to {
        background-position: -20px 20px;
    }
}

.graph-title {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(30, 30, 30, 0.9);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--accent-orange);
    box-shadow: 0 0 15px rgba(255, 149, 0, 0.2);
    z-index: 10;
    pointer-events: none;
}

.graph-title h2 {
    font-family: var(--font-family);
    font-size: 1.2rem;
    color: var(--accent-orange);
    margin: 0;
}

.graph-title p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 4px 0 0 0;
}

.legend {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(30, 30, 30, 0.9);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
    pointer-events: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.center {
    background: var(--node-center);
    box-shadow: 0 0 8px var(--node-center);
}

.legend-dot.target {
    background: var(--node-target);
}

.legend-dot.visited {
    background: var(--node-visited);
}

.legend-line {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.path {
    background: var(--edge-path);
}

.node-popup {
    position: absolute;
    background: rgba(30, 30, 30, 0.95);
    padding: 12px;
    border-radius: 4px;
    border: 1px solid var(--accent-orange);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    max-width: 200px;
}

.node-popup h3 {
    font-size: 0.9rem;
    color: var(--accent-orange);
    margin-bottom: 4px;
}

.node-popup p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Graph Elements */
.edge-line {
    stroke: var(--edge-default);
    stroke-width: 2px;
    transition: all 0.3s ease;
    stroke-linecap: round;
}

.edge-line.scanning {
    stroke: var(--edge-scanning);
    stroke-width: 4px;
    animation: pulse-line 0.5s infinite alternate;
}

.edge-line.path {
    stroke: var(--edge-path);
    stroke-width: 4px;
    stroke-dasharray: 10, 5;
    animation: flow 1s linear infinite;
    filter: drop-shadow(0 0 5px var(--edge-path));
}

@keyframes flow {
    to {
        stroke-dashoffset: -15;
    }
}

@keyframes pulse-line {
    from {
        stroke-opacity: 0.6;
    }

    to {
        stroke-opacity: 1;
    }
}

.edge-label {
    font-family: monospace;
    font-size: 10px;
    fill: var(--text-secondary);
    text-anchor: middle;
    pointer-events: none;
    font-weight: 700;
}

.edge-label-bg {
    fill: rgba(30, 30, 30, 0.9);
}

.node-group {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.node-group:hover {
    transform: scale(1.1);
}

.node-circle {
    fill: var(--node-default);
    stroke: #fff;
    stroke-width: 2px;
    transition: all 0.3s ease;
}

.node-circle.center {
    fill: var(--node-center);
    stroke: var(--node-center);
    stroke-width: 4px;
    stroke-opacity: 0.5;
    animation: pulse-center 2s infinite;
}

@keyframes pulse-center {
    0% {
        stroke-width: 4px;
        stroke-opacity: 0.5;
    }

    50% {
        stroke-width: 10px;
        stroke-opacity: 0;
    }

    100% {
        stroke-width: 4px;
        stroke-opacity: 0.5;
    }
}

.node-circle.target {
    fill: var(--node-target);
}

.node-circle.visited {
    fill: var(--node-visited);
    stroke: var(--node-visited);
}

.node-circle.current {
    stroke: white;
    stroke-width: 4px;
    filter: drop-shadow(0 0 10px white);
}

.node-icon {
    font-size: 16px;
    pointer-events: none;
    user-select: none;
}

.node-text {
    font-family: var(--font-family);
    font-size: 11px;
    fill: var(--text-primary);
    pointer-events: none;
    user-select: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    font-weight: 700;
}

.node-dist {
    font-family: monospace;
    font-size: 10px;
    fill: var(--accent-orange);
    pointer-events: none;
    font-weight: 700;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-orange);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ffaa33;
}