:root {
    --primary: #4a90e2;
    --primary-light: #60a5fa;
    --primary-dark: #3b82f6;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-dim: #94a3b8;
}

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

body {
    font-family: 'Outfit', 'Noto Sans TC', sans-serif;
    background: radial-gradient(circle at top right, #1e293b, var(--bg-dark));
    color: #f8fafc;
    min-height: 100vh;
    padding: 1.5rem;
    overflow-x: hidden;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 0.4rem;
}

/* Dashboard Grid - 4 Columns */
.dashboard-grid {
    display: grid;
    grid-template-columns: 240px 1fr 1fr 1.2fr;
    gap: 1.5rem;
    max-width: 1800px;
    margin: 0 auto;
    align-items: start;
}

.ui-col {
    position: sticky;
    top: 1.5rem;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.view-section {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.2rem;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* Macro Section */
.view-section.macro {
    text-align: center;
}

.view-section.macro h3 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.blob-display {
    width: 240px;
    height: 240px;
    margin: 0 auto 1.5rem;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.08), transparent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.1);
}

.blob-sprite { transform: scale(5.2); }

.empty-state .placeholder-text {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-style: italic;
}

.genotype-selector {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.genotype-selector button {
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.genotype-selector button.active {
    background: var(--primary);
    border-color: var(--primary-light);
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.4);
}

/* Micro Section */
.view-section.micro {
    text-align: center;
    background: rgba(0,0,0,0.25);
}

.meiosis-svg {
    max-height: 280px;
    width: 100%;
    margin-top: 1rem;
}

/* Interaction & Anim */
.chromosome-interactive { transition: all 0.8s cubic-bezier(0.25, 1, 0.5, 1); }
.sister-chromatid { transition: all 0.8s cubic-bezier(0.25, 1, 0.5, 1); cursor: default; }
.cell-membrane { transition: all 0.6s ease; fill: transparent; stroke: rgba(255,255,255,0.15); stroke-width: 2; }

/* Cell-based selection styles */
.gamete-cell-interactive {
    cursor: pointer;
    transition: all 0.3s;
    fill: rgba(255,255,255,0.02);
    stroke: rgba(255,255,255,0.1);
    stroke-width: 1.5;
}

.gamete-cell-interactive:hover {
    fill: rgba(74, 144, 226, 0.1);
    stroke: rgba(255,255,255,0.3);
}

.gamete-cell-selected {
    stroke: var(--primary-light) !important;
    stroke-width: 4 !important;
    fill: rgba(74, 144, 226, 0.15) !important;
    filter: drop-shadow(0 0 8px var(--primary));
}

.selected-gamete { 
    filter: brightness(1.5) drop-shadow(0 0 12px var(--primary-light)); 
}

.cell-membrane { fill: transparent; stroke: rgba(255,255,255,0.15); stroke-width: 2; }
.nucleus { 
    fill: rgba(74, 144, 226, 0.05); 
    stroke: rgba(255,255,255,0.25); 
    stroke-dasharray: 4,4; 
    transform-origin: 200px 150px; /* Center for 400x300 SVG */
    transition: all 0.6s ease;
}

.gene-text {
    paint-order: stroke;
    stroke: #000;
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: #fff !important;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white; border: none; padding: 0.8rem 1.4rem; border-radius: 12px;
    font-weight: 600; cursor: pointer; transition: all 0.2s; width: 100%;
}
.primary-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4); }

.secondary-btn {
    background: transparent; color: var(--text-dim); border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem; border-radius: 10px; cursor: pointer; font-size: 0.85rem;
}

.stage-info { 
    font-size: 0.9rem; 
    color: var(--primary-light); 
    margin-bottom: 0.8rem; 
    height: 3.2rem; /* Fixed height to prevent jittering */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden; /* Prevent text expansion from pushing buttons */
    line-height: 1.2;
}

.meiosis-step-tools { margin-top: 1rem; }
.step-nav { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 1rem;
    background: rgba(0,0,0,0.2);
    padding: 0.5rem;
    border-radius: 12px;
    height: 50px; /* Stable height */
}

#meiosis-step-label { font-weight: 600; color: #fff; min-width: 80px; text-align: center; }

.icon-btn {
    background: var(--primary); 
    border: none; 
    color: white; 
    cursor: pointer; 
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.icon-btn:hover:not(:disabled) { transform: scale(1.1); background: var(--primary-light); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.step-label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #fff;
    min-width: 80px;
    text-align: center;
}

.zygote-chromo {
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hidden { display: none !important; }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.4); }
    70% { box-shadow: 0 0 0 12px rgba(74, 144, 226, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 144, 226, 0); }
}

/* Blob States */
.blob-body { fill: #f0e199; transition: fill 0.5s; }
.phenotype-aa .blob-body { fill: #a0d8ef; }
.gene-label { font-size: 0.75rem; font-weight: bold; color: rgba(255,255,255,0.8); }

/* Timeline Styles */
.timeline-container {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    height: 380px; /* Fixed total height for timeline area */
    overflow-y: auto;
    gap: 1rem;
    padding-right: 5px;
}

.timeline-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: all 0.4s ease;
}

.timeline-group.collapsed .timeline-item {
    display: none;
}

.timeline-header {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--primary-light);
    text-transform: uppercase;
    border-bottom: 2px solid var(--glass-border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.5rem;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timeline-item {
    font-size: 0.82rem;
    padding: 0.5rem 0.8rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-dim);
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    text-align: left;
}

.timeline-item.active {
    background: rgba(74, 144, 226, 0.15);
    color: #fff;
    border-left-color: var(--primary);
    font-weight: 600;
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.1);
}

.timeline-item.dimmed-item {
    opacity: 0.25;
    pointer-events: none;
}

.timeline-group.dimmed {
    opacity: 0.4;
}

.action-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    min-height: 160px; /* Force consistent button area height */
    justify-content: flex-start;
}

/* Unify button containers */
.meiosis-step-tools { 
    margin: 0; 
}
.step-nav { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 1.2rem;
    background: rgba(0,0,0,0.3);
    padding: 0.6rem;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    height: 52px;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .center-col { grid-column: 1 / span 2; grid-row: 2; }
}
