:root {
    /* Red Culture Theme - Inherited from style.css */
    --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;
    --success-green: #27c93f;
    --warning-orange: #ff9500;

    --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 */
.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: 1rem;
}

.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: 2rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

.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: 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;
}

/* Law Selector */
.law-selector {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

.law-selector::-webkit-scrollbar {
    width: 6px;
}

.law-selector::-webkit-scrollbar-thumb {
    background: var(--accent-red);
    border-radius: 3px;
}

.law-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid rgba(139, 0, 0, 0.1);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.law-btn:hover {
    background: rgba(214, 59, 29, 0.05);
    border-color: var(--accent-red);
}

.law-btn.active {
    background: var(--accent-red);
    color: white;
    border-color: var(--accent-red);
}

.law-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.law-formula {
    font-size: 0.7rem;
    font-family: 'Courier New', monospace;
    opacity: 0.8;
    margin-top: 2px;
}

/* Element Pool */
.element-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(139, 0, 0, 0.1);
}

.element-item {
    padding: 6px 12px;
    background: #fff;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: grab;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(139, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.element-item:hover {
    transform: translateY(-2px);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.hint-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Info Panel */
.info-panel {
    background: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(139, 0, 0, 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;
    line-height: 1.5;
    color: var(--text-primary);
}

/* Buttons */
.actions-footer {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.apple-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    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 {
    padding: 12px 20px;
    background: var(--accent-red);
    color: white;
    box-shadow: var(--shadow-md);
}

.action-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.danger-btn {
    padding: 12px 20px;
    background: rgba(139, 0, 0, 0.1);
    color: var(--text-primary);
}

.danger-btn:hover {
    background: rgba(139, 0, 0, 0.2);
}

/* 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.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);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.stage-header {
    text-align: center;
    margin-bottom: 2rem;
}

.stage-header h2 {
    font-size: 1.8rem;
    color: var(--accent-red);
    margin-bottom: 0.5rem;
    font-family: var(--font-title);
}

.stage-header p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

/* Balance Scale */
.scale-stage {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 40px;
}

.balance-scale {
    width: 600px;
    height: 400px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.scale-beam {
    width: 500px;
    height: 10px;
    background: linear-gradient(to bottom, #d4af37, #b8860b);
    /* Gold */
    border-radius: 5px;
    position: relative;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
    z-index: 2;
}

.scale-pivot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: #8b0000;
    border-radius: 50%;
    z-index: 3;
    border: 2px solid #fff;
}

.pivot-triangle {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 150px solid rgba(139, 0, 0, 0.8);
    z-index: 1;
}

.scale-base {
    width: 200px;
    height: 20px;
    background: rgba(139, 0, 0, 0.8);
    border-radius: 10px 10px 0 0;
    position: absolute;
    bottom: 0;
}

.scale-pan {
    position: absolute;
    top: 5px;
    width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: top center;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.left-pan {
    left: 0;
}

.right-pan {
    right: 0;
}

.pan-chain {
    width: 2px;
    height: 80px;
    background: rgba(139, 0, 0, 0.3);
}

.pan-plate {
    width: 220px;
    min-height: 120px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--accent-gold);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.equation-display {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.pan-content {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.set-slot {
    min-width: 50px;
    height: 50px;
    border: 2px dashed rgba(139, 0, 0, 0.2);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
    padding: 4px;
}

.set-slot.highlight {
    border-color: var(--accent-red);
    background: rgba(214, 59, 29, 0.05);
}

.set-slot.filled {
    border-style: solid;
    border-color: var(--accent-gold);
    background: #fff;
    color: var(--text-primary);
    font-weight: 700;
}

.op-symbol {
    font-weight: 700;
    color: var(--accent-red);
    font-size: 0.9rem;
}

.result-preview {
    width: 100%;
    padding: 6px;
    background: rgba(214, 59, 29, 0.05);
    border-radius: 6px;
    font-size: 0.75rem;
    text-align: center;
    color: var(--text-primary);
    animation: fadeIn 0.5s ease;
}

.result-preview.hidden {
    display: none;
}

/* Verification Badge */
.verification-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 16px 32px;
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
    border: 2px solid var(--accent-gold);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.verification-badge.hidden {
    display: none;
}

.badge-icon {
    font-size: 2rem;
}

.badge-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-red);
    font-family: var(--font-title);
}

@keyframes popIn {
    from {
        transform: translate(-50%, -50%) scale(0);
    }

    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        width: 96vw;
        height: 96vh;
    }

    .sidebar {
        width: 100%;
        max-height: 45vh;
    }

    .balance-scale {
        transform: scale(0.7);
    }
}