:root {
    /* Chinese Culture Theme */
    --app-bg: #fdfbf7;
    --sidebar-bg: rgba(255, 248, 240, 0.8);
    --glass-border: rgba(214, 59, 29, 0.2);
    --text-primary: #8b0000;
    --text-secondary: #a05a5a;
    --accent-red: #d63b1d;
    --accent-gold: #ffb400;
    --accent-hover: #b32b12;
    --danger-red: #ff3b30;

    /* Graph Concept Colors */
    --path-color: #d63b1d;
    --circuit-color: #ff8c42;
    --component-color: #2d8f2d;

    /* 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: 90vh;
    max-width: 1600px;
    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: 340px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
    flex-shrink: 0;
    overflow-y: auto;
}

.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;
}

/* ===== Concept Buttons ===== */
.concept-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.concept-btn {
    padding: 0.85rem 0.5rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1.5px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.3;
    font-family: var(--font-family);
}

.concept-btn .concept-sub {
    display: block;
    font-size: 0.65rem;
    font-weight: 400;
    margin-top: 4px;
    color: var(--text-secondary);
}

.concept-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    background: rgba(255, 255, 255, 0.7);
}

.concept-btn.active {
    background: #fff;
    border-color: var(--accent-red);
    box-shadow: var(--shadow-md);
}

/* ===== Select & Controls ===== */
.apple-select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
}

.apple-select:hover {
    border-color: var(--accent-red);
    background: rgba(255, 255, 255, 0.8);
}

.apple-select:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(214, 59, 29, 0.1);
}

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;
}

.speed-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

#speedValue {
    font-weight: 600;
    color: var(--accent-gold);
}

/* ===== Info Panel ===== */
.info-panel {
    background: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
    border: 1px solid rgba(139, 0, 0, 0.1);
}

.info-panel p {
    margin-bottom: 8px;
    line-height: 1.5;
}

.stats-display {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-gold);
}

/* ===== 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);
}

.action-btn {
    background: var(--accent-red);
    color: white;
    width: 100%;
    box-shadow: var(--shadow-md);
}

.action-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.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);
}

.actions-footer {
    display: flex;
    gap: 10px;
}

/* ===== 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: 2rem;
    overflow-y: auto;
}

.visualization-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ===== Section ===== */
.section {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.section:hover {
    background: rgba(255, 255, 255, 0.75);
    box-shadow: var(--shadow-sm);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--accent-red);
    text-align: center;
    font-family: var(--font-title);
    letter-spacing: 0.05em;
}

/* ===== Concepts Overview ===== */
.concepts-overview {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.concept-category {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    border: 2px solid var(--glass-border);
}

.concept-category h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent-red);
    margin-bottom: 1.25rem;
    text-align: center;
    font-family: var(--font-title);
}

.concept-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}

.definition-card {
    background: rgba(255, 255, 255, 0.8);
    border: 1.5px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.3s ease;
}

.definition-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-red);
}

.wide-card {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--glass-border);
}

.card-icon {
    font-size: 1.8rem;
    color: var(--accent-red);
}

.card-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.definition {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.formula {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    text-align: center;
    padding: 0.75rem;
    background: rgba(139, 0, 0, 0.05);
    border-radius: 8px;
    color: var(--text-primary);
    border: 1px solid rgba(139, 0, 0, 0.1);
}

.example {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    padding: 0.5rem;
    background: rgba(255, 184, 0, 0.1);
    border-radius: 6px;
}

.properties {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.property-item {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    background: rgba(45, 143, 45, 0.1);
    border: 1px solid rgba(45, 143, 45, 0.3);
    border-radius: 6px;
    color: var(--component-color);
}

/* ===== Case Display ===== */
.case-description {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    border-left: 4px solid var(--accent-red);
}

.desc-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.desc-text h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-red);
    margin-bottom: 0.75rem;
}

.historical-context {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
    text-align: justify;
}

/* ===== Graph SVG ===== */
#graphCanvas {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    min-height: 500px;
}

.graph-svg {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.edge-line {
    stroke: rgba(139, 0, 0, 0.3);
    stroke-width: 2;
    fill: none;
    transition: all 0.3s ease;
}

.edge-arrow {
    fill: rgba(139, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.edge-line.active-edge {
    stroke: var(--accent-red);
    stroke-width: 3;
}

.edge-arrow.active-edge {
    fill: var(--accent-red);
}

.edge-label {
    font-size: 11px;
    fill: var(--text-secondary);
    font-weight: 600;
}

.vertex-circle {
    fill: #fff;
    stroke: var(--accent-red);
    stroke-width: 2.5;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(139, 0, 0, 0.15));
}

.vertex-name {
    font-size: 13px;
    font-weight: 700;
    fill: var(--text-primary);
    pointer-events: none;
}

.vertex-label {
    font-size: 10px;
    fill: var(--text-secondary);
    font-style: italic;
}

.vertex-group.current-vertex .vertex-circle {
    fill: var(--accent-gold);
    stroke: var(--accent-gold);
    transform: scale(1.2);
    transform-origin: center;
}

.vertex-group.visited-vertex .vertex-circle {
    fill: var(--accent-red);
    stroke: var(--accent-red);
}

.vertex-group.visited-vertex .vertex-name {
    fill: white;
}

.vertex-group.component-0 .vertex-circle {
    fill: rgba(214, 59, 29, 0.2);
    stroke: var(--accent-red);
    stroke-width: 3;
}

.vertex-group.component-1 .vertex-circle {
    fill: rgba(139, 58, 139, 0.2);
    stroke: #8b3a8b;
    stroke-width: 3;
}

/* ===== Path Tracing ===== */
#tracingContent {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.path-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.7);
    border: 1.5px solid var(--glass-border);
    border-radius: 12px;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 0.5s ease forwards;
}

@keyframes slideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-number {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-red);
    border-radius: 50%;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.step-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.step-vertex {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.step-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.step-arrow {
    font-size: 1.5rem;
    color: var(--accent-gold);
    font-weight: 700;
}

.circuit-completion {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.25rem;
    background: rgba(45, 143, 45, 0.15);
    border: 2px solid var(--component-color);
    border-radius: 12px;
    margin-top: 1rem;
}

.completion-icon {
    font-size: 2rem;
    color: var(--component-color);
}

.completion-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--component-color);
}

/* ===== Component Display ===== */
.component-display {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 1.25rem;
    opacity: 0;
    transform: translateX(-20px);
    animation: slideIn 0.5s ease forwards;
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.component-display h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-red);
    margin-bottom: 1rem;
}

.component-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    gap: 0.5rem;
}

.info-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 100px;
}

.info-value {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* ===== Property Analysis ===== */
.property-analysis-box {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
}

.property-item {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}

.property-icon {
    font-size: 2.5rem;
    color: var(--component-color);
    flex-shrink: 0;
}

.property-content {
    flex: 1;
}

.property-content h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-red);
    margin-bottom: 1rem;
}

.property-content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0.5rem;
}

.property-content strong {
    color: var(--text-primary);
}

.component-detail {
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(255, 184, 0, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--accent-gold);
}

.component-detail h5 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-gold);
    margin-bottom: 0.75rem;
}

/* ===== Philosophy ===== */
.philosophy-box {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-left: 4px solid var(--accent-gold);
    border-radius: 12px;
}

.philosophy-icon {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 1rem;
}

.philosophy-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.8;
    text-align: justify;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 90vh;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .concept-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .concept-cards {
        grid-template-columns: 1fr;
    }

    #graphCanvas {
        min-height: 400px;
    }

    .graph-svg {
        max-width: 100%;
        height: auto;
    }
}

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

    .glass-pane {
        padding: 1rem;
    }

    #tracingContent {
        flex-direction: column;
        align-items: stretch;
    }

    .path-step {
        width: 100%;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(139, 0, 0, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(214, 59, 29, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(214, 59, 29, 0.5);
}
