:root {
    --accent: #9A342D;
    --accent-dark: #7a2820;
    --accent-light: rgba(154, 52, 45, 0.08);
    --accent-cream: #F1D1A2;
    --accent-cream-light: #fdf6ed;
    --accent-gold: #C5A028;

    --bg-page: #f7f4f0;
    --bg-panel: #ffffff;
    --bg-panel-hover: #fdf6ed;
    --bg-dark: #f0ebe4;
    --text-main: #1a1a1a;
    --text-muted: #5c5c5c;
    --border-color: #ddd5c8;

    --blue: var(--accent);
    --pink: var(--accent-dark);
    --yellow: var(--accent-gold);
    --green: #3d7a3d;
    --teal: var(--accent);

    --shadow: 0 2px 12px rgba(154, 52, 45, 0.08);
    --shadow-glow: 0 0 12px rgba(154, 52, 45, 0.15);

    --font-serif: 'EB Garamond', 'Times New Roman', Garamond, serif;
    --font-sans: 'Source Sans 3', Arial, Calibri, sans-serif;

    --pwr-red: var(--accent);
    --pwr-red-dark: var(--accent-dark);
    --pwr-red-light: var(--accent-light);
    --pwr-cream: var(--accent-cream);
    --pwr-cream-light: var(--accent-cream-light);
    --pwr-gold: var(--accent-gold);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

.accent-line,
.pwr-line {
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 70%, var(--accent-gold) 100%);
    border-radius: 2px;
    margin: 0.6rem 0;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 290px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.04);
}

.logo {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.logo h2 {
    font-family: var(--font-serif);
    color: var(--accent);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.25;
}

.logo p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.nav-links {
    list-style: none;
}

.nav-links li {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-size: 0.92rem;
}

.nav-links li:hover {
    background-color: var(--pwr-red-light);
    color: var(--pwr-red);
}

.nav-links li.active {
    background-color: var(--pwr-red-light);
    color: var(--pwr-red);
    border-left-color: var(--pwr-red);
    font-weight: 600;
}

.content {
    margin-left: 290px;
    flex: 1;
    padding: 2.5rem 3rem;
    max-width: 1200px;
}

.topic-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.topic-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

h1 {
    font-family: var(--font-serif);
    font-size: 2.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--pwr-red);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
    font-style: italic;
    font-family: var(--font-serif);
}

.math-box {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.theorem-box {
    border-left: 4px solid var(--pwr-red);
    background: linear-gradient(135deg, var(--bg-panel) 0%, var(--pwr-cream-light) 100%);
}

.math-formula {
    margin-top: 1rem;
    font-size: 1.2rem;
    text-align: center;
}

.interactive-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 1000px) {
    .interactive-area {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
    }

    .content {
        margin-left: 0;
    }

    .app-container {
        flex-direction: column;
    }
}

.simulation-panel,
.explanation-panel {
    background-color: var(--bg-panel);
    border-radius: 4px;
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.simulation-panel h3,
.explanation-panel h3 {
    margin-bottom: 1rem;
    color: var(--pwr-red);
    font-family: var(--font-serif);
    font-weight: 600;
    border-bottom: 2px solid var(--pwr-cream);
    padding-bottom: 0.5rem;
}

.explanation-panel ul,
.explanation-panel ol {
    margin-left: 1.5rem;
    margin-top: 1rem;
}

.explanation-panel li {
    margin-bottom: 0.8rem;
}

.controls {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 3px;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-sans);
    transition: all 0.2s ease;
}

.btn.primary {
    background-color: var(--pwr-red);
    color: #fff;
    box-shadow: 0 2px 8px rgba(154, 52, 45, 0.25);
}

.btn.primary:hover {
    background-color: var(--pwr-red-dark);
    box-shadow: 0 4px 12px rgba(154, 52, 45, 0.35);
}

.btn.secondary {
    background-color: transparent;
    color: var(--pwr-red);
    border: 1px solid var(--pwr-red);
}

.btn.secondary:hover {
    background-color: var(--pwr-red-light);
}

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

.results-dashboard {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-card {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
}

.stat-card span {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.stat-card strong {
    font-size: 1.4rem;
    font-weight: 600;
    font-family: var(--font-serif);
    color: var(--pwr-red);
}

.stat-card.highlight {
    border-color: var(--pwr-red);
    background-color: var(--pwr-red-light);
}

.stat-card.highlight strong {
    color: var(--pwr-red-dark);
}

.dice-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
    min-height: 80px;
}

.dice {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #fff, var(--bg-dark));
    border: 2px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--pwr-red);
    box-shadow: var(--shadow);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dice.rolling {
    animation: shake 0.4s infinite;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-10deg); }
    20% { transform: translate(-3px, 0px) rotate(10deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(10deg); }
    50% { transform: translate(-1px, 2px) rotate(-10deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-10deg); }
    80% { transform: translate(-1px, -1px) rotate(10deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-10deg); }
}

.dice.highlight {
    border-color: var(--pwr-red);
    box-shadow: 0 0 12px rgba(154, 52, 45, 0.35);
    color: var(--pwr-red-dark);
}

.dice.k4 {
    border-radius: 5px 5px 20px 20px;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    width: 70px;
    height: 60px;
    align-items: flex-end;
    padding-bottom: 5px;
    font-size: 1.5rem;
}

.dice.k10 {
    border-radius: 30px;
}

.canvas-container {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

canvas {
    max-width: 100%;
}

.venn-diagram-container {
    position: relative;
    width: 300px;
    height: 200px;
    margin: 0 auto;
}

.venn-circle {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    top: 30px;
    opacity: 0.85;
}

.circle-a {
    background-color: rgba(154, 52, 45, 0.12);
    border: 2px solid var(--pwr-red);
    left: 20px;
}

.circle-b {
    background-color: rgba(197, 160, 40, 0.15);
    border: 2px solid var(--pwr-gold);
    right: 20px;
}

.venn-label {
    position: absolute;
    top: -25px;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--pwr-red);
}

.venn-elements {
    font-family: var(--font-serif);
    font-size: 0.9rem;
}

.venn-intersection {
    position: absolute;
    left: 50%;
    top: 100px;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: var(--pwr-red-dark);
    z-index: 10;
}

.venn-outside {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.bayes-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 1rem 0 2rem;
}

.tree-node {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    position: relative;
    z-index: 2;
    font-size: 0.9rem;
}

.tree-branches {
    display: flex;
    width: 100%;
    justify-content: space-around;
    position: relative;
    margin-top: 2rem;
}

.tree-branches::before {
    content: '';
    position: absolute;
    top: -2rem;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--pwr-red);
    z-index: 1;
}

.branch-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.branch-path::before {
    content: '';
    position: absolute;
    top: -2rem;
    width: 2px;
    height: 2rem;
    background: var(--pwr-red);
    z-index: 1;
}

.path-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.active-node {
    border-color: var(--pwr-red);
    box-shadow: 0 0 10px rgba(154, 52, 45, 0.25);
    color: var(--pwr-red);
    background: var(--pwr-red-light);
}

.sick-node.active-node {
    border-color: #c0392b;
    box-shadow: 0 0 10px rgba(192, 57, 43, 0.3);
    color: #c0392b;
}

.healthy-node.active-node {
    border-color: var(--green);
    box-shadow: 0 0 10px rgba(61, 122, 61, 0.3);
    color: var(--green);
}

.path-label.sub {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--pwr-gold);
    font-weight: 600;
}

.population-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 0.5rem 0 1rem;
    font-size: 0.9rem;
}

.stat-sick strong { color: #c0392b; }
.stat-healthy strong { color: var(--green); }

.stat-positive {
    display: none;
    color: #2980b9;
    font-weight: 600;
}

.stat-positive.visible {
    display: inline;
}

.t2-legend {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.t2-legend .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}

.t2-legend .dot.sick { background: #c0392b; }
.t2-legend .dot.healthy { background: var(--green); }
.t2-legend .dot.positive {
    background: transparent;
    border: 2px solid #2980b9;
    width: 12px;
    height: 12px;
}

.t2-results {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    margin-top: 1.5rem;
}

.t2-results.visible {
    display: grid;
}

.text-sick { color: #c0392b; }
.text-healthy { color: var(--green); }

.insight-note {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--pwr-cream-light);
    border-left: 3px solid var(--pwr-gold);
    border-radius: 0 4px 4px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
}

.chart-note {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}
