:root {
    /* Theme Colors */
    --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;
    --success-green: #27c93f;
    --danger-red: #ff3b30;
    --true-color: #27c93f;
    --false-color: #ff6b6b;

    /* Shadows */
    --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;
    --font-mono: 'Times New Roman', 'Courier New', monospace;
}

* {
    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-1509228468518-180dd4864904?q=80&w=2574&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
}

.app-container {
    width: 92vw;
    height: 92vh;
    max-width: 1800px;
    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: 350px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.3rem;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.window-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.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.9rem;
    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.3rem;
    flex-grow: 1;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Inputs ===== */
.apple-select, .apple-textarea, .apple-input {
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid rgba(139, 0, 0, 0.2);
    background: #fff;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.apple-select:hover, .apple-textarea:hover, .apple-input:hover {
    border-color: var(--accent-red);
}

.apple-textarea {
    resize: vertical;
    font-family: var(--font-mono);
}

.apple-textarea:focus, .apple-input:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(214, 59, 29, 0.1);
}

/* ===== Domain Input ===== */
.domain-input {
    display: flex;
    gap: 0.5rem;
}

.domain-input .apple-input {
    flex: 1;
}

.small-btn {
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--accent-red);
    background: var(--accent-red);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.small-btn:hover {
    background: var(--accent-hover);
}

.current-domain {
    min-height: 40px;
}

.domain-display {
    background: rgba(214, 59, 29, 0.05);
    padding: 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(214, 59, 29, 0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.domain-label {
    font-weight: 700;
    color: var(--accent-red);
}

.domain-values {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.domain-size {
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ===== Predicate Assignments ===== */
.assignment-container {
    max-height: 150px;
    overflow-y: auto;
}

.predicate-assignment {
    background: rgba(255, 255, 255, 0.6);
    padding: 0.6rem;
    border-radius: 8px;
    margin-bottom: 0.6rem;
    border: 1px solid rgba(139, 0, 0, 0.1);
}

.assignment-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-red);
    margin-bottom: 0.5rem;
}

.assignment-checkboxes {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.no-predicates {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.8rem;
}

/* ===== Buttons ===== */
.apple-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: var(--font-family);
}

.action-btn {
    background: var(--accent-red);
    color: white;
    width: 100%;
    box-shadow: var(--shadow-md);
}

.action-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.danger-btn {
    background: rgba(139, 0, 0, 0.1);
    color: var(--text-primary);
    width: 100%;
}

.danger-btn:hover {
    background: rgba(139, 0, 0, 0.2);
}

.apple-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== Range Slider ===== */
input[type=range] {
    appearance: none;
    width: 100%;
    background: transparent;
}

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.1);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(139, 0, 0, 0.1);
    border-radius: 2px;
}

/* ===== Info Panel ===== */
.info-panel {
    background: rgba(255, 255, 255, 0.6);
    padding: 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text-primary);
    border: 1px solid rgba(139, 0, 0, 0.1);
}

#statusText {
    font-weight: 700;
    color: var(--accent-red);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.stats-display {
    display: flex;
    gap: 14px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    color: var(--accent-red);
    font-weight: 700;
    font-size: 0.95rem;
}

.actions-footer {
    display: flex;
    gap: 10px;
}

/* ===== Main Stage ===== */
.visualizer-stage {
    flex-grow: 1;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.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: 1.5rem;
    overflow-y: auto;
}

.visualization-container {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}

/* ===== Sections ===== */
.section {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    font-family: var(--font-title);
    font-size: 1.4rem;
    color: var(--accent-red);
    margin-bottom: 1rem;
    text-align: center;
    letter-spacing: 0.05em;
}

/* ===== Formula Display ===== */
.formula-display {
    background: linear-gradient(135deg, rgba(214, 59, 29, 0.05) 0%, rgba(255, 180, 0, 0.05) 100%);
    padding: 1.5rem;
    border-radius: 14px;
    border: 2px solid var(--accent-red);
    box-shadow: var(--shadow-md);
}

.formula-box {
    text-align: center;
    margin-bottom: 1rem;
}

.formula-text {
    font-family: var(--font-mono);
    font-size: 2rem;
    color: var(--accent-red);
    font-weight: 700;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.6rem 1.5rem;
    border-radius: 10px;
    display: inline-block;
}

.formula-info {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.95rem;
}

.info-row.context {
    color: var(--text-secondary);
    font-style: italic;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(139, 0, 0, 0.1);
}

.info-label {
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 50px;
}

.info-value {
    color: var(--text-primary);
}

.info-value.type-tautology {
    color: var(--success-green);
    font-weight: 700;
}

.info-value.type-contradiction {
    color: var(--false-color);
    font-weight: 700;
}

.info-value.type-satisfiable {
    color: var(--accent-gold);
    font-weight: 700;
}

/* ===== Interpretation Table ===== */
.interpretation-explanation {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.interpretation-table-container {
    overflow-x: auto;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    padding: 1rem;
}

.interpretation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.interpretation-table th {
    background: var(--accent-red);
    color: #fff;
    padding: 0.6rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.interpretation-table th.domain-header {
    background: var(--accent-gold);
    font-size: 0.75rem;
}

.interpretation-table td {
    padding: 0.5rem;
    text-align: center;
    border: 1px solid rgba(139, 0, 0, 0.1);
}

.interpretation-table tbody tr {
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease;
}

.interpretation-table tbody tr.visible {
    opacity: 1;
    transform: translateX(0);
}

.interpretation-table tbody tr.true-row {
    background: rgba(39, 201, 63, 0.1);
}

.interpretation-table tbody tr.false-row {
    background: rgba(255, 107, 107, 0.1);
}

.index-cell {
    font-weight: 700;
    color: var(--accent-red);
}

.value-cell.true {
    color: var(--true-color);
    font-weight: 700;
}

.value-cell.false {
    color: var(--false-color);
}

.truth-cell {
    font-weight: 700;
    font-size: 0.9rem;
}

.truth-cell.true {
    color: var(--true-color);
}

.truth-cell.false {
    color: var(--false-color);
}

/* ===== Classification Cards ===== */
.classification-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.classification-card {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 14px;
    padding: 1.3rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.classification-card.active {
    border-color: var(--accent-red);
    box-shadow: var(--shadow-md);
    transform: scale(1.05);
}

.classification-card.tautology.active {
    border-color: var(--success-green);
    background: rgba(39, 201, 63, 0.05);
}

.classification-card.contradiction.active {
    border-color: var(--false-color);
    background: rgba(255, 107, 107, 0.05);
}

.classification-card.satisfiable.active {
    border-color: var(--accent-gold);
    background: rgba(255, 180, 0, 0.05);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.card-icon {
    font-size: 2rem;
}

.card-header h3 {
    font-size: 1.1rem;
    color: var(--accent-red);
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    line-height: 1.5;
}

.card-example {
    background: rgba(139, 0, 0, 0.05);
    padding: 0.6rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    margin-bottom: 1rem;
    border-left: 3px solid var(--accent-red);
}

.card-result {
    min-height: 50px;
}

.result-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.result-badge.yes {
    background: var(--success-green);
    color: #fff;
}

.result-badge.no {
    background: rgba(139, 0, 0, 0.1);
    color: var(--text-secondary);
}

.result-detail {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-top: 0.5rem;
}

/* ===== Truth Chart ===== */
.chart-container {
    background: rgba(255, 255, 255, 0.8);
    padding: 2rem;
    border-radius: 14px;
    border: 1px solid rgba(139, 0, 0, 0.15);
}

.chart-bars {
    display: flex;
    justify-content: center;
    gap: 4rem;
    margin-bottom: 2rem;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.chart-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-bar-wrapper {
    width: 80px;
    height: 250px;
    background: rgba(139, 0, 0, 0.05);
    border-radius: 10px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.chart-bar {
    width: 100%;
    border-radius: 10px 10px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 0.5rem;
    transition: height 0.5s ease;
    height: 0;
}

.chart-bar.animated {
    animation: barGrow 1s ease forwards;
}

.chart-bar.true-bar {
    background: linear-gradient(180deg, var(--true-color), rgba(39, 201, 63, 0.6));
}

.chart-bar.false-bar {
    background: linear-gradient(180deg, var(--false-color), rgba(255, 107, 107, 0.6));
}

.bar-value {
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
}

.chart-percent {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-red);
}

.chart-summary {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 2px solid rgba(139, 0, 0, 0.1);
}

.chart-summary p {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.chart-summary strong {
    color: var(--accent-red);
    font-size: 1.2rem;
}

/* ===== Philosophy Section ===== */
.philosophy-box {
    background: linear-gradient(135deg, rgba(214, 59, 29, 0.08) 0%, rgba(255, 180, 0, 0.08) 100%);
    padding: 2rem;
    border-radius: 14px;
    border: 2px solid var(--accent-gold);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
}

.philosophy-box.visible {
    opacity: 1;
    transform: translateY(0);
}

.philosophy-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.philosophy-icon {
    font-size: 2.5rem;
}

.philosophy-header h3 {
    font-family: var(--font-title);
    font-size: 1.5rem;
    color: var(--accent-red);
}

.philosophy-body {
    margin-bottom: 1.5rem;
}

.philosophy-text {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    text-indent: 2em;
}

.philosophy-footer {
    display: flex;
    justify-content: flex-end;
}

.insight-tag {
    padding: 0.5rem 1.2rem;
    background: var(--accent-red);
    color: #fff;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(139, 0, 0, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-red);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

/* ===== Responsive ===== */
@media (max-width: 1400px) {
    .classification-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1200px) {
    .app-container {
        flex-direction: column;
        height: 95vh;
    }

    .sidebar {
        width: 100%;
        max-height: 35vh;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .visualizer-stage {
        padding: 1rem;
    }
}
