:root {
    /* 思政主题配色 */
    --app-bg: #fdfbf7;
    --sidebar-bg: rgba(255, 248, 240, 0.9);
    --glass-border: rgba(214, 59, 29, 0.2);
    --text-primary: #8b0000;
    --text-secondary: #a05a5a;
    --accent-red: #d63b1d;
    --accent-gold: #ffb400;
    --accent-blue: #4a90e2;
    --accent-green: #27c93f;
    --accent-hover: #b32b12;

    /* 可视化配色 */
    --color-1: #ff6b6b;
    --color-2: #4ecdc4;
    --color-3: #45b7d1;
    --color-4: #f9ca24;
    --color-5: #6c5ce7;
    --color-6: #fd79a8;
    --color-7: #00b894;
    --color-8: #e17055;

    --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", "ZCOOL XiaoWei", 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:
        linear-gradient(135deg, rgba(214, 59, 29, 0.05) 0%, rgba(74, 144, 226, 0.05) 100%),
        url('https://images.unsplash.com/photo-1451187580459-43490279c0fa?q=80&w=2572&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.90);
    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: 340px;
    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;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.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: 1.8rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -5px;
}

.highlight {
    color: var(--accent-red);
}

.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(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========== 原理按钮 ========== */
.principle-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.principle-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 8px;
    border-radius: 12px;
    border: 2px solid rgba(214, 59, 29, 0.2);
    background: #fff;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: var(--font-family);
}

.principle-btn .icon {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-red);
    transition: all 0.25s ease;
}

.principle-btn .text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.25s ease;
}

.principle-btn:hover {
    background: rgba(214, 59, 29, 0.05);
    border-color: var(--accent-red);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.principle-btn.active {
    background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-hover) 100%);
    border-color: var(--accent-red);
    box-shadow: var(--shadow-md);
}

.principle-btn.active .icon,
.principle-btn.active .text {
    color: #fff;
}

/* ========== 选择器 ========== */
.apple-select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--accent-red);
    background: #fff;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.apple-select:hover {
    border-color: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

.apple-select:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(214, 59, 29, 0.1);
}

/* ========== 参数控件 ========== */
.param-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 8px 0;
}

.param-label {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
}

.param-label .value {
    color: var(--accent-red);
    font-weight: 700;
    margin-left: 8px;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--accent-red);
    cursor: pointer;
    margin-top: -7px;
    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.15);
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(214, 59, 29, 0.2);
    border-radius: 2px;
}

/* ========== 信息面板 ========== */
.info-panel {
    background: rgba(255, 255, 255, 0.6);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(214, 59, 29, 0.1);
}

.info-panel h3 {
    font-size: 1rem;
    color: var(--accent-red);
    margin-bottom: 6px;
    font-weight: 700;
}

.info-panel p {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 6px;
}

.info-panel p:last-child {
    margin-bottom: 0;
}

.political-text {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.8rem !important;
}

/* ========== 结果面板 ========== */
.result-panel {
    background: linear-gradient(135deg, rgba(214, 59, 29, 0.1) 0%, rgba(255, 180, 0, 0.1) 100%);
    padding: 12px;
    border-radius: 12px;
    border: 2px solid var(--accent-red);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.formula-display {
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.formula-display span {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
}

.result-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
}

.result-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.result-value {
    font-size: 1.8rem;
    color: var(--accent-red);
    font-weight: 700;
}

/* ========== 按钮 ========== */
.apple-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 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);
    width: 100%;
}

.action-btn {
    background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-hover) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.action-btn:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

.secondary-btn {
    background: #fff;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}

.secondary-btn:hover {
    background: rgba(214, 59, 29, 0.05);
}

.actions-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ========== 可视化主区域 ========== */
.visualizer-stage {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
}

.glass-pane {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    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;
    position: relative;
    overflow: auto;
}

.visualization-area {
    width: 100%;
    height: calc(100% - 80px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

/* ========== 可视化元素 ========== */
.category-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.category-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-red);
    text-align: center;
}

.items-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.item-box {
    padding: 12px 20px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-1) 0%, var(--color-2) 100%);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    cursor: pointer;
}

.item-box:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg);
}

.operation-symbol {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-red);
    text-align: center;
}

.tree-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
}

.tree-level {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.tree-node {
    padding: 10px 16px;
    border-radius: 8px;
    background: #fff;
    border: 2px solid var(--accent-red);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: all 0.3s ease;
}

.tree-node:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.tree-node.highlighted {
    background: var(--accent-red);
    color: #fff;
    box-shadow: 0 0 20px rgba(214, 59, 29, 0.5);
}

/* ========== 图例 ========== */
.legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(214, 59, 29, 0.2);
    max-width: 250px;
}

.legend-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-red);
    margin-bottom: 8px;
}

.legend-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-primary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ========== 动画 ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.item-box,
.tree-node {
    animation: fadeIn 0.4s ease;
}

.result-value {
    animation: pulse 1s ease infinite;
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        width: 95vw;
        height: 95vh;
    }

    .sidebar {
        width: 100%;
        max-height: 50vh;
    }

    .glass-pane {
        padding: 1rem;
    }
}