:root {
    --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;
    --circuit-wire: #4a5568;
    --gate-color: #3b82f6;
    --signal-active: #10b981;
    --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: linear-gradient(135deg, #2c1810, #1a0e0a);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    width: 90vw;
    height: 85vh;
    max-width: 1500px;
    margin: 7.5vh auto;
    background: rgba(255, 252, 245, 0.92);
    backdrop-filter: blur(20px);
    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);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1rem;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.window-controls {
    display: flex;
    gap: 0.5rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.dot.red {
    background: linear-gradient(135deg, #ff5f57, #ff3b30);
}

.dot.yellow {
    background: linear-gradient(135deg, #ffbd2e, #ffaa00);
}

.dot.green {
    background: linear-gradient(135deg, #28ca42, #27c93f);
}

h1 {
    font-family: var(--font-title);
    font-size: 1.6rem;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.9;
    font-style: italic;
}

.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);
    letter-spacing: 0.02em;
}

.step-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.step-btn {
    padding: 0.7rem 0.6rem;
    background: rgba(255, 255, 255, 0.6);
    border: 2px solid rgba(139, 0, 0, 0.15);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.step-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--accent-red);
    transform: translateY(-1px);
}

.step-btn.active {
    background: var(--accent-red);
    color: white;
    border-color: var(--accent-red);
}

.step-btn.completed {
    background: var(--signal-active);
    color: white;
    border-color: var(--signal-active);
}

.info-panel {
    background: rgba(255, 255, 255, 0.5);
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(139, 0, 0, 0.1);
}

.info-panel p {
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
}

.info-panel strong {
    color: var(--accent-red);
    margin-right: 0.3rem;
}

.expression-display {
    background: rgba(255, 255, 255, 0.7);
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid var(--accent-red);
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.6;
    color: var(--text-primary);
    transition: all 0.3s ease-in-out;
}

.result-display {
    background: rgba(255, 255, 255, 0.5);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(139, 0, 0, 0.1);
    min-height: 60px;
    font-size: 0.85rem;
    line-height: 1.6;
}

.info-box {
    background: linear-gradient(135deg, rgba(214, 59, 29, 0.05), rgba(255, 180, 0, 0.05));
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid rgba(214, 59, 29, 0.2);
}

.info-box h3 {
    font-size: 0.9rem;
    margin-bottom: 0.7rem;
    color: var(--accent-red);
}

.info-box p {
    font-size: 0.75rem;
    line-height: 1.5;
    margin-bottom: 0.4rem;
}

.actions-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.apple-btn {
    flex: 1;
    min-width: 100px;
    padding: 0.7rem;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.action-btn {
    background: var(--accent-red);
    color: white;
}

.action-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.danger-btn {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger-red);
    border: 2px solid var(--danger-red);
}

.danger-btn:hover {
    background: var(--danger-red);
    color: white;
}

.apple-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.visualizer-stage {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    overflow-y: auto;
}

.glass-pane {
    width: 100%;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
}

.graph-title {
    text-align: center;
}

.graph-title h2 {
    font-family: var(--font-title);
    font-size: 1.8rem;
    color: var(--accent-red);
    margin-bottom: 0.3rem;
}

.graph-title p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.quote-banner {
    background: linear-gradient(90deg, rgba(214, 59, 29, 0.1), transparent);
    border-left: 3px solid var(--accent-red);
    padding: 0.8rem 1rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.quote-icon {
    font-size: 1.5rem;
}

.quote-text {
    font-family: var(--font-title);
    font-size: 1rem;
    color: var(--text-primary);
    flex: 1;
}

.quote-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.visualization-container {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 350px;
}

#circuitSvg {
    max-width: 100%;
    height: auto;
}

#circuitGroup {
    transition: opacity 0.3s ease-in-out;
}

.wire {
    stroke: var(--circuit-wire);
    stroke-width: 2.5;
    fill: none;
    transition: all 0.3s;
}

.wire.active {
    stroke: var(--signal-active);
    stroke-width: 3;
}

.logic-gate {
    cursor: pointer;
    transition: all 0.3s;
}

.gate-body {
    fill: var(--gate-color);
    stroke: white;
    stroke-width: 2.5;
}

.gate-label {
    fill: white;
    font-size: 14px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.input-label,
.output-label {
    fill: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
}

.simplification-steps {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 1.5rem;
    transition: opacity 0.3s ease-in-out;
}

.simplification-steps h3 {
    color: var(--accent-red);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

#stepsContent {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--accent-red);
}

.step-item h4 {
    color: var(--accent-red);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.step-item .expression {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 0.5rem;
    background: rgba(214, 59, 29, 0.05);
    border-radius: 4px;
    margin: 0.5rem 0;
}

.comparison-panel {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 1.5rem;
    transition: opacity 0.3s ease-in-out;
}

.comparison-panel h3 {
    color: var(--accent-red);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.comparison-item {
    background: white;
    padding: 1.2rem;
    border-radius: 10px;
    text-align: center;
    border: 2px solid #ccc;
}

.comparison-item.optimized {
    border-color: var(--signal-active);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(16, 185, 129, 0.1));
}

.comparison-item h4 {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
}

.comparison-item p {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.old-value {
    color: var(--danger-red);
}

.new-value {
    color: var(--signal-active);
}

.comparison-arrow {
    font-size: 2rem;
    color: var(--accent-red);
    font-weight: 700;
}

.benefit-box {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid var(--signal-active);
}

.benefit-box p {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.benefit-box strong {
    color: var(--signal-active);
}

.ideology-content-box {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.05), rgba(255, 180, 0, 0.05));
    border: 1px solid rgba(214, 59, 29, 0.2);
    border-radius: 12px;
    padding: 1.2rem;
}

.ideology-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.red-star {
    color: var(--accent-red);
    font-size: 1.2rem;
}

.ideology-header h3 {
    color: var(--accent-red);
    font-family: var(--font-title);
    font-size: 1.2rem;
}

.ideology-text {
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.social-analogy {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(139, 0, 0, 0.1);
}

.social-analogy label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.social-analogy p {
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-primary);
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.sidebar::-webkit-scrollbar,
.visualizer-stage::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.visualizer-stage::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar::-webkit-scrollbar-thumb,
.visualizer-stage::-webkit-scrollbar-thumb {
    background: var(--accent-red);
    border-radius: 3px;
}