:root {
            --primary: #4f46e5;
            --primary-light: #818cf8;
            --primary-dark: #3730a3;
            --accent: #06b6d4;
            --accent-light: #67e8f9;
            --success: #10b981;
            --warning: #f59e0b;
            --error: #ef4444;
            --text: #1e293b;
            --text-secondary: #64748b;
            --text-light: #94a3b8;
            --surface: #ffffff;
            --surface-alt: #f8fafc;
            --surface-hover: #f1f5f9;
            --border: #e2e8f0;
            --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
            --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
            --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
            --shadow-xl: 0 24px 48px rgba(0,0,0,0.15);
            --radius-sm: 8px;
            --radius-md: 12px;
            --radius-lg: 16px;
            --radius-xl: 24px;
        }

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

        html { scroll-behavior: smooth; scroll-padding-top: 80px; }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            line-height: 1.7;
            color: var(--text);
            background: #f0f2f5;
            overflow-x: hidden;
        }

        /* ── Navigation ── */
        .nav {
            position: sticky; top: 64px; left: 0; right: 0; z-index: 10;
            background: rgba(255,255,255,0.92);
            backdrop-filter: blur(16px);
            border-bottom: 1px solid var(--border);
            box-shadow: var(--shadow-sm);
        }
        .nav-inner {
            max-width: 1200px; margin: 0 auto;
            display: flex; align-items: center; justify-content: space-between;
            padding: 0 2rem; height: 64px;
        }
        .nav-brand {
            font-weight: 700; font-size: 1.1rem;
            background: linear-gradient(135deg, var(--primary), var(--accent));
            -webkit-background-clip: text; -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        .nav-links { display: flex; gap: 0.25rem; flex-wrap: wrap; }
        .nav-links a {
            text-decoration: none; color: var(--text-secondary);
            font-size: 0.82rem; font-weight: 500;
            padding: 0.4rem 0.75rem; border-radius: var(--radius-sm);
            transition: all 0.2s;
        }
        .nav-links a:hover, .nav-links a.active {
            color: var(--primary); background: rgba(79,70,229,0.08);
        }

        /* ── Layout ── */
        .container { max-width: 1100px; margin: 0 auto; padding: 80px 1.5rem 3rem; }

        /* ── Hero ── */
        .hero {
            text-align: center; padding: 4rem 2rem 3rem;
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 40%, #06b6d4 100%);
            border-radius: var(--radius-xl);
            margin-bottom: 2.5rem;
            position: relative; overflow: hidden;
        }
        .hero::before {
            content: ''; position: absolute; inset: 0;
            background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.15) 0%, transparent 60%),
                        radial-gradient(circle at 80% 30%, rgba(255,255,255,0.1) 0%, transparent 50%);
        }
        .hero h1 {
            font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; color: #fff;
            position: relative; margin-bottom: 0.75rem;
        }
        .hero p { color: rgba(255,255,255,0.85); font-size: 1.1rem; position: relative; max-width: 600px; margin: 0 auto; }

        /* ── Cards ── */
        .card {
            background: var(--surface); border-radius: var(--radius-lg);
            box-shadow: var(--shadow-md); padding: 2.5rem;
            margin-bottom: 2rem; border: 1px solid var(--border);
            transition: box-shadow 0.3s;
        }
        .card:hover { box-shadow: var(--shadow-lg); }

        h2 {
            font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 700;
            color: var(--primary-dark); margin-bottom: 1.25rem;
            display: flex; align-items: center; gap: 0.6rem;
        }
        h2 .icon {
            width: 40px; height: 40px; border-radius: 10px;
            display: flex; align-items: center; justify-content: center;
            font-size: 1.3rem; flex-shrink: 0;
        }
        .icon-blue { background: #eff6ff; }
        .icon-red { background: #fef2f2; }
        .icon-green { background: #f0fdf4; }
        .icon-purple { background: #faf5ff; }

        h3 {
            font-size: 1.25rem; font-weight: 600;
            color: var(--primary); margin-bottom: 1rem;
        }
        h4 { font-size: 1.05rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }

        /* ── Content Blocks ── */
        .formula-box {
            background: linear-gradient(135deg, #eef2ff, #e0e7ff);
            padding: 1.5rem 2rem; border-radius: var(--radius-md);
            border-left: 4px solid var(--primary);
            text-align: center; margin: 1.5rem 0;
            font-size: 1.15rem; font-weight: 500;
        }
        .formula-box p:first-child { font-size: 1.25rem; font-weight: 600; }
        .formula-box p:last-child { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem; }

        .example-box {
            background: #fffbeb; border-left: 4px solid var(--warning);
            padding: 1.25rem 1.5rem; border-radius: var(--radius-sm);
            margin: 1.25rem 0;
        }
        .example-box strong { color: #92400e; }

        .info-box {
            background: #f0fdf4; border-left: 4px solid var(--success);
            padding: 1.25rem 1.5rem; border-radius: var(--radius-sm);
            margin: 1.25rem 0;
        }

        .warning-box {
            background: #fef2f2; border-left: 4px solid var(--error);
            padding: 1.25rem 1.5rem; border-radius: var(--radius-sm);
            margin: 1.25rem 0;
        }

        .learning-outcomes {
            background: #eff6ff; border: 1px solid #bfdbfe;
            padding: 1.25rem 1.5rem; border-radius: var(--radius-md);
            margin-bottom: 1.5rem;
        }
        .learning-outcomes h4 { color: var(--primary-dark); }
        .learning-outcomes ul { padding-left: 1.5rem; margin-top: 0.5rem; }
        .learning-outcomes li { margin-bottom: 0.4rem; color: var(--text); }

        .explanation {
            font-style: italic; color: var(--text-secondary);
            padding: 0.75rem 1rem; background: rgba(100,116,139,0.06);
            border-radius: var(--radius-sm); border-left: 3px solid var(--accent);
            margin: 1rem 0;
        }

        /* ── Simulations ── */
        .sim-container {
            margin: 1.5rem 0; padding: 1.5rem;
            background: var(--surface-alt); border-radius: var(--radius-md);
            border: 1px solid var(--border);
        }
        .sim-container h3 { display: flex; align-items: center; gap: 0.5rem; }
        .sim-canvas-wrap {
            display: flex; justify-content: center;
            margin: 1rem 0; overflow: hidden; border-radius: var(--radius-sm);
        }
        .sim-canvas-wrap canvas {
            border-radius: var(--radius-sm); border: 1px solid var(--border);
            max-width: 100%; height: auto;
        }
        .sim-controls {
            display: flex; flex-wrap: wrap; gap: 0.6rem;
            margin: 1rem 0; align-items: center;
        }
        .sim-controls label { font-size: 0.85rem; font-weight: 500; }

        /* Material buttons for float/sink */
        .material-btn {
            border: 2px solid transparent; border-radius: var(--radius-sm);
            padding: 0.5rem 1rem; font-size: 0.82rem; font-weight: 600;
            cursor: pointer; transition: all 0.2s;
            color: #fff; text-transform: none; letter-spacing: 0;
            display: inline-flex; flex-direction: column; align-items: center;
            min-width: 80px; box-shadow: var(--shadow-sm);
        }
        .material-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
        .material-btn:active { transform: translateY(0); }
        .material-btn span { font-size: 0.7rem; opacity: 0.85; font-weight: 400; }

        .btn-primary {
            background: linear-gradient(135deg, var(--primary), #7c3aed);
            color: #fff; border: none; border-radius: var(--radius-sm);
            padding: 0.65rem 1.5rem; font-size: 0.9rem; font-weight: 600;
            cursor: pointer; transition: all 0.2s; box-shadow: var(--shadow-sm);
            text-transform: none; letter-spacing: 0;
        }
        .btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
        .btn-primary:active { transform: translateY(0); }

        .btn-secondary {
            background: var(--surface); color: var(--text);
            border: 1px solid var(--border); border-radius: var(--radius-sm);
            padding: 0.65rem 1.5rem; font-size: 0.9rem; font-weight: 500;
            cursor: pointer; transition: all 0.2s;
            text-transform: none; letter-spacing: 0; box-shadow: none;
        }
        .btn-secondary:hover { background: var(--surface-hover); }

        /* ── Slider ── */
        .slider-group {
            display: flex; align-items: center; gap: 0.75rem;
            flex-wrap: wrap;
        }
        .slider-group label { min-width: 120px; font-size: 0.85rem; font-weight: 500; }
        input[type="range"] {
            -webkit-appearance: none; appearance: none;
            width: 200px; height: 6px; border-radius: 3px;
            background: #e2e8f0; outline: none; border: none; padding: 0;
        }
        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none; width: 18px; height: 18px;
            border-radius: 50%; background: var(--primary);
            cursor: pointer; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
        }
        .slider-value {
            background: var(--primary); color: #fff;
            padding: 0.2rem 0.6rem; border-radius: var(--radius-sm);
            font-size: 0.8rem; font-weight: 600; min-width: 60px; text-align: center;
        }

        /* ── Calculators ── */
        .calc-grid {
            display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 1rem; margin-bottom: 1rem;
        }
        .calc-field { display: flex; flex-direction: column; gap: 0.4rem; }
        .calc-field label {
            font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
            letter-spacing: 0.04em; color: var(--text-secondary);
        }
        .calc-field input, .calc-field select {
            padding: 0.7rem 1rem; border: 2px solid var(--border);
            border-radius: var(--radius-sm); font-size: 0.95rem;
            transition: border-color 0.2s; background: var(--surface);
            font-family: inherit;
        }
        .calc-field input:focus, .calc-field select:focus {
            outline: none; border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
        }
        .calc-result {
            margin-top: 1rem; padding: 1.25rem;
            background: linear-gradient(135deg, #f0fdf4, #dcfce7);
            border: 1px solid #bbf7d0; border-radius: var(--radius-md);
            line-height: 1.8;
        }

        /* ── Quiz ── */
        .quiz-box {
            background: linear-gradient(135deg, #faf5ff, #f3e8ff);
            border: 1px solid #e9d5ff; border-radius: var(--radius-md);
            padding: 2rem;
        }
        .quiz-q {
            background: var(--surface); border-radius: var(--radius-sm);
            padding: 1.25rem; margin-bottom: 1.25rem;
            box-shadow: var(--shadow-sm); transition: transform 0.2s;
        }
        .quiz-q:hover { transform: translateX(3px); }
        .quiz-q p { font-weight: 600; margin-bottom: 0.75rem; }
        .quiz-q label {
            display: block; padding: 0.4rem 0; cursor: pointer;
            font-weight: 400; text-transform: none; letter-spacing: 0;
            transition: color 0.2s; font-size: 0.95rem;
        }
        .quiz-q label:hover { color: var(--primary); }
        .quiz-q input[type="radio"] {
            margin-right: 0.5rem; accent-color: var(--primary);
            transform: scale(1.15);
        }

        /* ── Practical Investigation ── */
        .materials-box {
            background: var(--surface-alt); border: 1px solid var(--border);
            padding: 1.25rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem;
        }
        .materials-box ul { padding-left: 1.5rem; margin-top: 0.5rem; }
        .materials-box li { margin-bottom: 0.3rem; }

        .step {
            display: flex; gap: 1rem; align-items: flex-start;
            padding: 0.75rem 1rem; margin: 0.5rem 0;
            background: rgba(255,255,255,0.6); border-radius: var(--radius-sm);
            transition: all 0.2s;
        }
        .step:hover { background: rgba(255,255,255,0.9); transform: translateX(4px); }
        .step-num {
            width: 30px; height: 30px; border-radius: 50%;
            background: linear-gradient(135deg, var(--primary), #7c3aed);
            color: #fff; display: flex; align-items: center; justify-content: center;
            font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
        }

        /* ── Density Reference Table ── */
        .density-table {
            width: 100%; border-collapse: collapse; margin: 1rem 0;
            font-size: 0.9rem;
        }
        .density-table th {
            background: var(--primary); color: #fff;
            padding: 0.6rem 1rem; text-align: left; font-weight: 600;
        }
        .density-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
        .density-table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
        .density-table td {
            padding: 0.5rem 1rem; border-bottom: 1px solid var(--border);
        }
        .density-table tr:hover td { background: #f8fafc; }
        .density-table .swatch {
            display: inline-block; width: 14px; height: 14px;
            border-radius: 3px; margin-right: 0.5rem; vertical-align: middle;
        }

        /* ── SVG diagrams ── */
        .diagram-wrap {
            display: flex; justify-content: center; margin: 1.5rem 0;
        }
        .diagram-wrap svg {
            max-width: 100%; height: auto; background: #fafafa;
            border-radius: var(--radius-md); padding: 1rem;
            border: 1px solid var(--border);
        }

        /* ── Readout panel ── */
        .readout {
            display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 0.75rem; margin: 1rem 0;
        }
        .readout-item {
            background: var(--surface); border: 1px solid var(--border);
            border-radius: var(--radius-sm); padding: 0.75rem 1rem; text-align: center;
        }
        .readout-item .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); font-weight: 600; }
        .readout-item .value { font-size: 1.3rem; font-weight: 700; color: var(--primary); margin-top: 0.15rem; }
        .readout-item .unit { font-size: 0.75rem; color: var(--text-light); }

        /* ── Back to top ── */
        .back-to-top {
            position: fixed; bottom: 2rem; right: 2rem; z-index: 999;
            width: 44px; height: 44px; border-radius: 50%;
            background: var(--primary); color: #fff; border: none;
            font-size: 1.2rem; cursor: pointer; box-shadow: var(--shadow-md);
            display: none; align-items: center; justify-content: center;
            transition: all 0.3s; text-transform: none; padding: 0; letter-spacing: 0;
        }
        .back-to-top:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
        .back-to-top.visible { display: flex; }

        /* ── Responsive ── */
        @media (max-width: 768px) {
            .container { padding: 72px 1rem 2rem; }
            .card { padding: 1.5rem; }
            .hero { padding: 3rem 1.5rem 2rem; }
            .nav-links a { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
            input[type="range"] { width: 140px; }
            .step { flex-direction: column; align-items: center; text-align: center; }
            .readout { grid-template-columns: repeat(2, 1fr); }
        }
        @media (max-width: 480px) {
            .nav-links { display: none; }
            .container { padding: 72px 0.75rem 2rem; }
            .card { padding: 1.25rem; }
        }
