:root {
    /* Cooperation Theme */
    --app-bg: #fdfbf7;
    --sidebar-bg: rgba(255, 248, 240, 0.95);
    --glass-border: rgba(139, 0, 0, 0.1);
    --text-primary: #2c2c2c;
    --text-secondary: #5a5a5a;
    --accent-red: #d63b1d;
    /* West/Target */
    --accent-blue: #007aff;
    /* East/Source */
    --accent-gold: #c5a059;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px 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-1451187580459-43490279c0fa?q=80&w=2672&auto=format&fit=crop');
    /* Network/Connection abstract */
    background-size: cover;
    background-position: center;
}

.app-container {
    width: 90vw;
    height: 85vh;
    max-width: 1400px;
    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;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 380px;
    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;
}

.dot.yellow {
    background: #ffbd2e;
}

.dot.green {
    background: #27c93f;
}

h1 {
    font-family: var(--font-title);
    font-size: 2rem;
    font-weight: 400;
    color: var(--accent-red);
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -5px;
}

.highlight {
    color: var(--text-primary);
}

.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;
}

/* Sets Display */
.sets-display {
    display: flex;
    gap: 10px;
}

.set-card {
    flex: 1;
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.set-a {
    border-top: 3px solid var(--accent-blue);
}

.set-b {
    border-top: 3px solid var(--accent-red);
}

.set-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.set-members {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.member-tag {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-family: var(--font-mono);
}

/* Matrix View */
.matrix-container {
    display: grid;
    /* Grid template set by JS */
    gap: 4px;
    background: #f0f0f0;
    padding: 8px;
    border-radius: 8px;
    justify-content: center;
}

.matrix-cell {
    width: 30px;
    height: 30px;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #ccc;
    border-radius: 4px;
    transition: all 0.2s;
    cursor: pointer;
}

.matrix-cell:hover {
    background: #e0e0e0;
}

.matrix-cell.active {
    background: var(--accent-gold);
    color: #fff;
    font-weight: 700;
}

.matrix-header {
    font-weight: 700;
    font-size: 0.7rem;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
}

.matrix-legend {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Insight Card */
.insight-card {
    background: #fffdf5;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(197, 160, 89, 0.2);
    border-left: 4px solid var(--accent-gold);
}

.insight-card h3 {
    font-size: 1.1rem;
    color: var(--accent-red);
    margin-bottom: 8px;
    font-family: var(--font-title);
}

.insight-card p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Footer */
.actions-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.secondary-btn {
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.secondary-btn:hover {
    background: #f5f5f5;
}

/* 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.8);
    border-radius: 16px;
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.stage-header {
    text-align: center;
    margin-bottom: 1rem;
}

.stage-header h2 {
    font-size: 2rem;
    color: var(--accent-red);
    font-family: var(--font-title);
}

.stage-header p {
    font-size: 1rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    letter-spacing: 1px;
}

/* Graph Container */
.graph-container {
    flex-grow: 1;
    position: relative;
    display: flex;
    justify-content: space-between;
    padding: 0 100px;
    align-items: center;
}

.graph-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    /* Let clicks pass through to lines if needed, but lines need pointer-events: auto */
}

.column {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    height: 80%;
    z-index: 10;
}

.node {
    width: 120px;
    padding: 10px;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    position: relative;
    transition: all 0.3s;
}

.col-a .node {
    border-left: 4px solid var(--accent-blue);
}

.col-b .node {
    border-right: 4px solid var(--accent-red);
    flex-direction: row-reverse;
}

.node:hover {
    transform: scale(1.05);
    z-index: 20;
}

.node-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.col-a .node-dot {
    background: var(--accent-blue);
}

.col-b .node-dot {
    background: var(--accent-red);
}

/* Lines */
.relation-line {
    stroke: #e0e0e0;
    stroke-width: 2;
    fill: none;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s;
}

.relation-line:hover {
    stroke: #ccc;
    stroke-width: 4;
}

.relation-line.active {
    stroke: url(#gradLine);
    stroke-width: 3;
    marker-end: url(#arrowhead);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.relation-line.hidden {
    opacity: 0;
    pointer-events: none;
}

.relation-line.faint {
    opacity: 0.1;
    stroke-dasharray: 5, 5;
}