:root {
    /* Clean & Vibrant Theme */
    --app-bg: #fdfbf7;
    --sidebar-bg: rgba(255, 248, 240, 0.9);
    --glass-border: rgba(139, 0, 0, 0.1);
    --text-primary: #2c2c2c;
    --text-secondary: #5a5a5a;
    --accent-red: #d63b1d;
    --accent-green: #27c93f;
    --accent-blue: #007aff;
    --accent-gold: #ffb400;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);

    --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-1517245386807-bb43f82c33c4?q=80&w=2670&auto=format&fit=crop');
    /* Community/Teamwork abstract */
    background-size: cover;
    background-position: center;
}

.app-container {
    width: 90vw;
    height: 85vh;
    max-width: 1400px;
    background: rgba(255, 252, 245, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 360px;
    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;
}

.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: 2rem;
    font-weight: 400;
    color: var(--accent-red);
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -5px;
}

.highlight {
    color: var(--text-primary);
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-grow: 1;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Sliders */
.slider-control {
    background: #fff;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

.apple-slider {
    width: 100%;
    -webkit-appearance: none;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    outline: none;
}

.apple-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.1s;
}

.apple-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-card {
    background: #fff;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: monospace;
}

.stat-value.highlight {
    color: var(--accent-red);
}

.stat-sub {
    font-size: 0.7rem;
    color: #999;
    font-family: monospace;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
}

/* Gauge Card */
.gauge-card {
    background: #fff;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-bar-container {
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-red));
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-value-sm {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: right;
}

/* Insight Card */
.insight-card {
    background: #fffdf5;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 189, 46, 0.2);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.insight-icon {
    font-size: 1.5rem;
}

.insight-card p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
}

/* Footer */
.actions-footer {
    margin-top: auto;
}

.action-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(214, 59, 29, 0.2);
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.action-btn:hover {
    background: #b32b12;
    transform: translateY(-1px);
}

/* Main Stage */
.visualizer-stage {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.glass-pane {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.stage-header h2 {
    font-size: 1.5rem;
    color: var(--accent-red);
    font-family: var(--font-title);
}

.view-toggles {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: 8px;
}

.view-btn {
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.view-btn.active {
    background: #fff;
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Visualization Container */
.visualization-container {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

.view-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.view-layer.active {
    opacity: 1;
    pointer-events: auto;
}

/* Map View */
.resident-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 12px;
    padding: 20px;
}

.resident-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e0e0e0;
    transition: all 0.5s ease;
    position: relative;
}

/* Activist (P) */
.resident-dot.activist {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(214, 59, 29, 0.4);
}

/* Participant (A) */
.resident-dot.participant {
    transform: scale(1.2);
}

.resident-dot.participant::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.map-legend {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.dot-legend {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-legend.gray {
    background: #e0e0e0;
}

.dot-legend.red {
    background: var(--accent-red);
}

.dot-legend.green-halo {
    width: 10px;
    height: 10px;
    background: transparent;
    border: 2px solid var(--accent-green);
}

/* Venn View */
.venn-diagram {
    position: relative;
    width: 400px;
    height: 300px;
}

.venn-circle {
    position: absolute;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.5s ease;
}

.circle-p {
    width: 200px;
    height: 200px;
    top: 50px;
    left: 50px;
    background: rgba(214, 59, 29, 0.1);
    border: 2px solid var(--accent-red);
}

.circle-a {
    width: 200px;
    height: 200px;
    top: 50px;
    right: 50px;
    background: rgba(39, 201, 63, 0.1);
    border: 2px solid var(--accent-green);
}

.venn-label {
    position: absolute;
    top: -30px;
    font-weight: 700;
    color: var(--text-primary);
}

.venn-intersection {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.venn-label-sm {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
}