:root {
    --main-bg: #f8fafc;
    --canvas-bg: #f9f9f9;
    --text-main: #1e293b;
    --membrane-fill: #f1f5f9;
    --membrane-stroke: #475569;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--main-bg);
    color: var(--text-main);
    margin: 0;
    padding: 1vmin;
    min-height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

header {
    background: #fff;
    padding: 0.5rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    border-radius: 12px;
}

h1 {
    font-size: clamp(16px, 2vw, 20px);
    margin: 0;
    color: #0f172a;
}

h3 {
    font-size: 1rem;
    margin: 5px 0;
    text-align: center;
}

#global-settings {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

#comparison-container {
    display: flex;
    flex-direction: row;
    gap: 10px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.simulator-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

/* Scoped variables for Mitosis */
.simulator-section.mitosis {
    --btn-color: #10b981;
    --btn-hover: #059669;
    --instruction-bg: #dcfce7;
    --instruction-text: #14532d;
    --pair-highlight-opacity: 0.15;
}

/* Scoped variables for Meiosis */
.simulator-section.meiosis {
    --btn-color: #3b82f6;
    --btn-hover: #2563eb;
    --instruction-bg: #fef9c3;
    --instruction-text: #854d0e;
}

.canvas-container {
    width: 100%;
    aspect-ratio: 4/3;
    background-color: var(--canvas-bg);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    border: 1px solid #f1f5f9;
}

svg {
    width: 100%;
    height: 100%;
    display: block;
}

.instruction-box {
    width: 100%;
    background-color: var(--instruction-bg);
    color: var(--instruction-text);
    padding: 8px;
    border-radius: 6px;
    margin-top: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.3;
    text-align: center;
    box-sizing: border-box;
    min-height: 2.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.controls {
    margin-top: 10px;
    display: flex;
    gap: 6px;
    width: 100%;
}

.control-btn {
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    background-color: var(--btn-color);
    color: white;
    font-weight: bold;
    transition: all 0.2s;
    flex: 1;
}

.control-btn:hover:not(:disabled) {
    background-color: var(--btn-hover);
    transform: translateY(-1px);
}

.control-btn:disabled {
    background-color: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
}

/* Switch logic */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #3b82f6; }
input:checked + .slider:before { transform: translateX(20px); }

/* Mutation classes */
.cell-membrane { transition: d 1.5s cubic-bezier(0.4, 0, 0.2, 1); fill: var(--membrane-fill); stroke: var(--membrane-stroke); stroke-width: 4px; }
.nucleus { transition: all 0.4s ease; fill: rgba(56, 189, 248, 0.1); stroke: #0ea5e9; stroke-width: 3px; transform-origin: 400px 300px; }
.nucleus-side { fill: rgba(56, 189, 248, 0.1); stroke: #0ea5e9; stroke-width: 3px; }

/* Specialization for Comparison Layout */
@media (max-width: 1000px) {
    #comparison-container { flex-direction: column; }
    .instruction-box { min-height: 2rem; }
}

/* Highlight style */
.highlight-rect {
    fill: none;
    stroke-width: 25px;
    stroke-linecap: round;
    transition: all 0.5s;
    pointer-events: none;
}

.highlighted-pair .highlight-rect {
    stroke: rgba(234, 179, 8, 0.25); /* Gold glow */
}

.chromosome {
    transition: transform 1.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
    cursor: pointer;
}
.dragging, .dragging * { transition: none !important; }
.hide-alleles .gene-text, .hide-alleles .locus-marker { display: none; }

.sister-left,
.sister-right {
    transition: transform 1.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
    transform-origin: 0 0;
}

/* Focus Mode and Selection */
.focus-active .chromosome {
    filter: brightness(0.4) grayscale(0.8);
    opacity: 0.3;
}

.focus-active .chromosome.selected {
    filter: brightness(1.1) drop-shadow(0 0 10px gold);
    opacity: 1;
}

.focus-active .chromosome.selected .chrom-body {
    animation: chrom-glow 2s infinite ease-in-out;
}

@keyframes chrom-glow {
    0% { filter: drop-shadow(0 0 2px gold); }
    50% { filter: drop-shadow(0 0 12px gold); }
    100% { filter: drop-shadow(0 0 2px gold); }
}

.nucleus-side {
    transition: opacity 1s ease 1s; /* Fade in after chromosomes move (1.5s total move) */
    fill: rgba(56, 189, 248, 0.1);
    stroke: #0ea5e9;
    stroke-width: 3px;
}

/* Nucleus origins for scaling/rotation if needed */
.mitosis .nucleus-left { transform-origin: 200px 300px; }
.mitosis .nucleus-right { transform-origin: 600px 300px; }
.meiosis .nuc-tl { transform-origin: 200px 160px; }
.meiosis .nuc-bl { transform-origin: 200px 440px; }
.meiosis .nuc-tr { transform-origin: 600px 160px; }
.meiosis .nuc-br { transform-origin: 600px 440px; }

.gene-text {
    text-anchor: middle;
    dominant-baseline: middle;
    font-weight: 900;
    font-size: 16px;
    fill: #111;
    stroke: #fff;
    stroke-width: 3px;
    paint-order: stroke;
}

.no-transition, .no-transition * {
    transition: none !important;
    animation: none !important;
}
