:root {
    --primary-color: #00b4d8;
    --primary-hover: #0096b1;
    --bg-color: #fbfbff;
    --text-color: #1a1a1a;
    --text-secondary: #555;
    --card-bg: rgba(255, 255, 255, 0.75);
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* --- Header --- */
/* Header styles moved to global styles.css and .page-header */

.breadcrumb {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    transition: opacity 0.2s;
}

.breadcrumb:hover {
    opacity: 0.7;
}

.subheading {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    margin-bottom: 1rem;
    background: linear-gradient(180deg, #1a1a1a 0%, #434344 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- Lab Card Container --- */
.lab-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 28px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 4rem;
}

/* --- Top Controls --- */
.top-controls {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: flex-end;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.control-group input[type="range"] {
    width: 200px;
    height: 6px;
    background: linear-gradient(to right, var(--primary-color) 0%, var(--primary-color) 50%, #e5e7eb 50%, #e5e7eb 100%);
    border-radius: 10px;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.value-display {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}

.btn-mode,
.btn-reset {
    padding: 0.7rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    font-family: inherit;
}

.btn-mode {
    background: var(--primary-color);
    color: #fff;
}

.btn-mode:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 180, 216, 0.3);
}

.btn-reset {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.btn-reset:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--text-secondary);
}

/* --- Simulator Layout --- */
.simulator-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* --- Simulation Main --- */
.simulation-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- Weight Panel --- */
.weight-panel {
    background: rgba(255, 255, 255, 0.5);
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
}

.weight-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.weight-options {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.weight-item {
    cursor: grab;
    transition: transform 0.2s;
}

.weight-item:active {
    cursor: grabbing;
}

.weight-item:hover {
    transform: scale(1.1);
}

.weight-icon {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.weight-50g {
    background: linear-gradient(135deg, #f59e0b, #f97316);
}

.weight-100g {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.weight-200g {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* --- Canvas Container --- */
.canvas-container {
    position: relative;
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    min-height: 400px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

#beamCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: move;
}

/* --- Stability Indicator --- */
.stability-indicator {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.status-icon {
    font-size: 1.8rem;
    animation: pulse 2s ease-in-out infinite;
}

.status-text {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-color);
}

.stability-indicator.balanced {
    border-color: var(--success-color);
}

.stability-indicator.balanced .status-text {
    color: var(--success-color);
}

.stability-indicator.unbalanced {
    border-color: var(--danger-color);
}

.stability-indicator.unbalanced .status-text {
    color: var(--danger-color);
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* --- Analysis Sidebar --- */
.analysis-sidebar {
    display: flex;
    flex-direction: column;
}

.analysis-panel {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.analysis-panel h3 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.data-card {
    background: #fff;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.data-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.data-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.data-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.net-moment {
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.05), rgba(0, 180, 216, 0.1));
    border: 2px solid var(--primary-color);
}

.formula-card {
    background: #fff;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-top: 1rem;
}

.formula-card h4 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.formula-card p {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

/* --- Instructions --- */
.instructions {
    background: rgba(0, 180, 216, 0.05);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid rgba(0, 180, 216, 0.2);
}

.instructions h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.instructions ol {
    margin-left: 1.5rem;
    line-height: 1.8;
}

.instructions li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.instructions strong {
    color: var(--text-color);
    font-weight: 600;
}

.unit-label {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

/* --- Responsive Design --- */
@media (max-width: 1200px) {
    .simulator-layout {
        grid-template-columns: 1fr;
    }

    .analysis-sidebar {
        order: -1;
    }

    .analysis-panel {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }

    .analysis-panel h3 {
        grid-column: 1 / -1;
    }

    .formula-card {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    header {
        padding: 80px 0 40px;
    }

    .lab-card {
        padding: 1.5rem;
        border-radius: 20px;
    }

    .top-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group input[type="range"] {
        width: 100%;
    }

    .button-group {
        margin-left: 0;
        width: 100%;
    }

    .btn-mode,
    .btn-reset {
        flex: 1;
    }

    .weight-options {
        gap: 1rem;
    }

    .weight-icon {
        width: 60px;
        height: 60px;
        font-size: 0.8rem;
    }

    .stability-indicator {
        top: 1rem;
        right: 1rem;
        padding: 0.75rem 1rem;
    }

    .status-icon {
        font-size: 1.4rem;
    }

    .status-text {
        font-size: 0.9rem;
    }

    .data-value {
        font-size: 1.5rem;
    }

    .canvas-container {
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }

    .lab-card {
        padding: 1rem;
    }

    .instructions {
        padding: 1.5rem;
    }

    .instructions ol {
        margin-left: 1rem;
        font-size: 0.9rem;
    }
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.lab-card {
    animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}