:root {
    /* Red 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;

    /* Structure Colors */
    --color-semigroup: #10b981;
    --color-subsemigroup: #8b5cf6;
    --color-monoid: #f59e0b;
    --color-group: #4ecdc4;
    --edge-relation: rgba(214, 59, 29, 0.3);

    --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: 85vh;
    max-width: 1400px;
    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 {
    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: 1rem;
}

.window-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 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.75rem;
    color: var(--text-primary);
    letter-spacing: 1px;
    margin: 0;
}

.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: 1rem;
    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;
}

/* Structure Buttons */
.structure-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.structure-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(139, 0, 0, 0.15);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-family);
}

.structure-btn:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--accent-red);
    transform: translateX(3px);
}

.structure-btn.active {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
    box-shadow: var(--shadow-md);
}

.structure-btn .icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
}

.structure-btn.active .icon {
    background: rgba(255, 255, 255, 0.2);
}

.btn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.btn-text strong {
    font-size: 0.95rem;
}

.btn-text small {
    font-size: 0.7rem;
    opacity: 0.7;
}

/* Properties Panel */
.properties-panel {
    background: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prop-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.4;
    transition: all 0.3s;
}

.prop-item.active {
    opacity: 1;
    color: var(--text-primary);
}

.prop-check {
    color: var(--color-semigroup);
    font-weight: bold;
    font-size: 1rem;
}

.prop-item.active .prop-check {
    color: var(--accent-red);
}

/* Examples List */
.examples-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.example-card {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(139, 0, 0, 0.1);
    transition: all 0.2s;
}

.example-card:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--accent-gold);
}

.ex-icon {
    font-size: 1.5rem;
    min-width: 30px;
}

.ex-content strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--accent-red);
}

.ex-content p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Info Box */
.info-box {
    background: linear-gradient(135deg, rgba(214, 59, 29, 0.05), rgba(255, 180, 0, 0.05));
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(214, 59, 29, 0.2);
}

.info-box h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--accent-red);
    font-family: var(--font-family);
}

.info-box p {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.info-box p:last-child {
    margin-bottom: 0;
}

/* Actions Footer */
.actions-footer {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
}

.apple-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.apple-btn:active {
    transform: scale(0.98);
}

.action-btn {
    background: var(--accent-red);
    color: #fff;
}

.action-btn:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

.danger-btn {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger-red);
    border: 1px solid var(--danger-red);
}

.danger-btn:hover {
    background: var(--danger-red);
    color: #fff;
}

/* Visualizer 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);
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.graph-title {
    text-align: center;
    margin-bottom: 1rem;
}

.graph-title h2 {
    font-family: var(--font-title);
    font-size: 1.8rem;
    color: var(--accent-red);
    margin-bottom: 0.25rem;
}

.graph-title p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Quote Banner */
.quote-banner {
    background: linear-gradient(90deg, rgba(214, 59, 29, 0.1), transparent);
    border-left: 3px solid var(--accent-red);
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.quote-icon {
    font-size: 1.2rem;
    margin-bottom: 6px;
}

.quote-text {
    font-family: var(--font-title);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.quote-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}

/* SVG Diagram */
#structureSvg {
    flex: 1;
    display: block;
    margin-bottom: 1rem;
}

.structure-node {
    cursor: pointer;
    transition: all 0.3s;
}

.structure-node .node-bg {
    transition: all 0.3s;
}

.structure-node:hover .node-bg {
    stroke-width: 3;
    filter: brightness(1.1);
}

.node-label {
    font-size: 14px;
    fill: var(--text-primary);
    text-anchor: middle;
    pointer-events: none;
    font-family: var(--font-family);
    font-weight: 600;
}

.node-sublabel {
    font-size: 10px;
    fill: var(--text-secondary);
    text-anchor: middle;
    pointer-events: none;
}

.relation-line {
    stroke: var(--edge-relation);
    stroke-width: 2;
    fill: none;
    opacity: 0.5;
    transition: all 0.3s;
}

.relation-line.active {
    opacity: 1;
    stroke-width: 3;
    stroke: var(--accent-red);
}

.relation-label {
    font-size: 12px;
    fill: var(--accent-red);
    font-family: var(--font-family);
}

/* Ideology Content Box */
.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: 1rem;
}

.ideology-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.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 p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.social-analogy {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(139, 0, 0, 0.1);
}

.social-analogy label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.social-analogy p {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--accent-red);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}