: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-hover: #b32b12;

    /* 集合配色 */
    --set-a-color: rgba(214, 59, 29, 0.3);
    --set-b-color: rgba(255, 180, 0, 0.3);
    --set-a-stroke: #d63b1d;
    --set-b-stroke: #ffb400;
    --result-color: rgba(139, 0, 0, 0.5);

    /* 元素配色 */
    --element-a: #ff6b6b;
    --element-b: #ffd93d;
    --element-both: #ff8c42;
    --element-result: #8b0000;

    --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(255, 180, 0, 0.05) 100%),
        url('https://images.unsplash.com/photo-1519389950473-47ba0277781c?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.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.5rem;
    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: 1.2rem;
    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;
}

/* ========== 选择器 ========== */
.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);
}

/* ========== 操作按钮组 ========== */
.operation-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.operation-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(214, 59, 29, 0.3);
    background: #fff;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.operation-btn .icon {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-red);
}

.operation-btn:hover {
    background: rgba(214, 59, 29, 0.05);
    border-color: var(--accent-red);
    transform: translateY(-1px);
}

.operation-btn.active {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
    box-shadow: var(--shadow-md);
}

.operation-btn.active .icon {
    color: #fff;
}

/* ========== 滑块 ========== */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.slider-label {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
}

.slider-label span {
    color: var(--accent-red);
    font-weight: 700;
}

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;
    font-size: 0.85rem;
    color: var(--text-primary);
    border: 1px solid rgba(214, 59, 29, 0.1);
    line-height: 1.5;
}

/* ========== 统计面板 ========== */
.stats-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(214, 59, 29, 0.1);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    font-size: 1.1rem;
    color: var(--accent-red);
    font-weight: 700;
}

.highlight-stat {
    background: rgba(214, 59, 29, 0.1);
    border-color: var(--accent-red);
}

.highlight-stat .stat-value {
    font-size: 1.3rem;
}

/* ========== 按钮 ========== */
.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: var(--accent-red);
    color: white;
    box-shadow: var(--shadow-md);
}

.action-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.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: 0;
    position: relative;
    overflow: hidden;
}

/* ========== SVG 元素 ========== */
svg {
    display: block;
}

.set-circle {
    stroke-width: 3px;
    transition: all 0.5s ease;
    opacity: 0.6;
}

.set-a {
    fill: var(--set-a-color);
    stroke: var(--set-a-stroke);
}

.set-b {
    fill: var(--set-b-color);
    stroke: var(--set-b-stroke);
}

.set-label {
    font-family: var(--font-family);
    font-size: 18px;
    font-weight: 700;
    fill: var(--text-primary);
    text-anchor: middle;
}

/* ========== 元素样式 ========== */
.element {
    cursor: pointer;
    transition: all 0.3s ease;
}

.element-circle {
    fill: var(--element-a);
    stroke: #fff;
    stroke-width: 2px;
    filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.2));
}

.element-text {
    font-family: var(--font-family);
    font-size: 11px;
    font-weight: 600;
    fill: #fff;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

.element:hover .element-circle {
    transform: scale(1.1);
    filter: drop-shadow(0px 4px 8px rgba(0, 0, 0, 0.3));
}

.element.in-a .element-circle {
    fill: var(--element-a);
}

.element.in-b .element-circle {
    fill: var(--element-b);
}

.element.in-both .element-circle {
    fill: var(--element-both);
}

.element.highlighted .element-circle {
    fill: var(--element-result);
    stroke: var(--accent-gold);
    stroke-width: 3px;
    filter: url(#glow) drop-shadow(0px 4px 8px rgba(139, 0, 0, 0.4));
}

/* ========== 图例 ========== */
.legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(214, 59, 29, 0.2);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.set-a-color {
    background: var(--element-a);
}

.set-b-color {
    background: var(--element-b);
}

.result-color {
    background: var(--element-result);
}

.legend-item span {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* ========== 动画 ========== */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.element {
    animation: fadeIn 0.3s ease;
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        width: 95vw;
        height: 95vh;
    }

    .sidebar {
        width: 100%;
        max-height: 40vh;
        overflow-y: auto;
    }

    .visualizer-stage {
        padding: 1rem;
    }
}