:root {
    /* Unity Purple & Order Blue Theme */
    --app-bg: #fdfbf7;
    --panel-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(108, 92, 231, 0.1);
    --text-primary: #2d3436;
    --text-secondary: #636e72;

    --compat-primary: #6c5ce7;
    /* Purple */
    --compat-light: #a29bfe;
    --compat-bg: rgba(108, 92, 231, 0.05);

    --equiv-primary: #0984e3;
    /* Blue */
    --equiv-light: #74b9ff;
    --equiv-bg: rgba(9, 132, 227, 0.05);

    --accent-gold: #fdcb6e;
    --accent-red: #d63031;

    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 20px rgba(0, 0, 0, 0.08);

    --font-family: "Noto Serif SC", "Outfit", serif;
    --font-mono: "JetBrains Mono", monospace;
    --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-1557683316-973673baf926?q=80&w=2629&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    transition: background-image 0.5s ease;
}

.app-container {
    width: 95vw;
    height: 90vh;
    max-width: 1600px;
    background: rgba(255, 252, 245, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.main-header {
    padding: 1.2rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.6);
}

.header-content h1 {
    font-family: var(--font-title);
    font-size: 2rem;
    font-weight: 400;
    color: var(--compat-primary);
    transition: color 0.3s;
}

.header-content h1.equiv-mode {
    color: var(--equiv-primary);
}

.highlight {
    color: var(--accent-gold);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -5px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mode-toggle {
    display: flex;
    background: #fff;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.toggle-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.02);
}

.toggle-btn.active {
    opacity: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toggle-btn[data-mode="compatibility"].active {
    background: var(--compat-primary);
    color: white;
}

.toggle-btn[data-mode="equivalence"].active {
    background: var(--equiv-primary);
    color: white;
}

.btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.btn-text .main {
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-text .sub {
    font-size: 0.7rem;
    opacity: 0.8;
}

.apple-btn {
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.apple-btn:hover {
    background: #f5f5f5;
    transform: scale(1.05);
}

/* Main Stage */
.main-stage {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2px;
    background: rgba(0, 0, 0, 0.02);
    overflow: hidden;
}

.graph-panel,
.analysis-panel {
    background: var(--panel-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.panel-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.5);
}

.panel-header h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.panel-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* Graph */
.graph-container {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.graph-container:active {
    cursor: grabbing;
}

.graph-svg {
    width: 100%;
    height: 100%;
}

.node-circle {
    stroke: #fff;
    stroke-width: 2px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.node-circle:hover {
    stroke: var(--accent-gold);
    stroke-width: 3px;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.2));
}

.node-label {
    font-size: 12px;
    font-family: var(--font-family);
    fill: var(--text-primary);
    pointer-events: none;
    text-anchor: middle;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.link {
    stroke-opacity: 0.4;
    transition: all 0.5s ease;
}

.link.compat {
    stroke: var(--compat-primary);
}

.link.equiv {
    stroke: var(--equiv-primary);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.85rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 100;
    max-width: 200px;
}

.tooltip h4 {
    color: var(--text-primary);
    margin-bottom: 4px;
}

.tooltip p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 2px;
}

/* Legend */
.legend-bar {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.6);
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Analysis Panel */
.analysis-panel {
    padding: 20px;
    gap: 20px;
    overflow-y: auto;
}

.property-card,
.insight-card,
.stats-box {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.property-card {
    border-top: 4px solid var(--compat-primary);
}

.property-card.equiv {
    border-top-color: var(--equiv-primary);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.card-icon {
    font-size: 1.5rem;
}

.card-header h4 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.math-box {
    background: rgba(0, 0, 0, 0.03);
    padding: 10px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 16px;
}

.check-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

.check-item.satisfied {
    opacity: 1;
    color: var(--text-primary);
    font-weight: 600;
}

.check-icon {
    font-weight: bold;
}

.satisfied .check-icon {
    color: #00b894;
}

.check-item:not(.satisfied) .check-icon {
    color: #d63031;
}

/* Insight */
.insight-card {
    background: linear-gradient(135deg, #fffdf5 0%, #fff 100%);
    border: 1px solid var(--accent-gold);
}

.insight-card h4 {
    color: #e17055;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.insight-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Stats */
.stats-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}