
        /* =====================================================
           FFMI CALCULATOR — scoped styles
           Matches body-fat-estimator / tdee-calculator pattern
           ===================================================== */

        .tool-page {
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .tool-main {
            flex: 1;
            padding: 80px 0 80px;
        }

        /* Header */
        .tool-header {
            text-align: center;
            margin-bottom: 48px;
        }

        .tool-badge {
            display: inline-block;
            padding: 5px 14px;
            border-radius: var(--radius-full);
            font-size: 0.8rem;
            font-weight: 600;
            background: var(--color-text);
            color: var(--color-bg);
            margin-bottom: 16px;
            letter-spacing: 0.01em;
        }

        .tool-header h1 {
            font-family: var(--font-display);
            font-size: 3rem;
            font-weight: 900;
            letter-spacing: -0.035em;
            line-height: 1.08;
            color: var(--color-text);
            margin-bottom: 12px;
        }

        .tool-header p {
            font-size: 1.1rem;
            color: var(--color-text-secondary);
            max-width: 560px;
            margin: 0 auto;
            line-height: 1.65;
        }

        /* Calculator Card */
        .tool-calc-card {
            max-width: 520px;
            margin: 0 auto 64px;
            background: var(--color-bg);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
            padding: 40px;
            box-shadow: var(--shadow-elevated);
        }

        /* Gender toggle */
        .tool-gender-toggle {
            display: flex;
            background: var(--color-surface);
            border-radius: var(--radius-full);
            padding: 4px;
            margin-bottom: 32px;
            border: 1px solid var(--color-border);
        }

        .tool-gender-btn {
            flex: 1;
            padding: 10px 0;
            text-align: center;
            font-family: var(--font-body);
            font-size: 0.95rem;
            font-weight: 600;
            color: var(--color-text-secondary);
            background: transparent;
            border: none;
            border-radius: var(--radius-full);
            cursor: pointer;
            transition: all 0.25s ease;
        }

        .tool-gender-btn.active {
            background: var(--color-text);
            color: var(--color-bg);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
        }

        /* Input groups */
        .tool-input-group {
            margin-bottom: 20px;
        }

        .tool-input-label {
            display: block;
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--color-text);
            margin-bottom: 6px;
            letter-spacing: 0.01em;
        }

        .tool-input-hint {
            font-weight: 400;
            color: var(--color-text-tertiary);
            font-size: 0.8rem;
        }

        .tool-input-row {
            display: flex;
            gap: 10px;
        }

        .tool-input-row .tool-input-field {
            flex: 1;
        }

        .tool-input-field {
            width: 100%;
            padding: 12px 16px;
            font-family: var(--font-body);
            font-size: 1rem;
            font-weight: 500;
            color: var(--color-text);
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            outline: none;
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
            -moz-appearance: textfield;
            appearance: textfield;
        }

        .tool-input-field::-webkit-outer-spin-button,
        .tool-input-field::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }

        .tool-input-field::placeholder {
            color: var(--color-text-tertiary);
            font-weight: 400;
        }

        .tool-input-field:focus {
            border-color: var(--color-text);
            box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.06);
        }

        /* Unit toggle (inline) */
        .tool-unit-toggle {
            display: inline-flex;
            background: var(--color-surface);
            border-radius: var(--radius-full);
            padding: 2px;
            border: 1px solid var(--color-border);
            margin-left: 8px;
            vertical-align: middle;
        }

        .tool-unit-btn {
            padding: 3px 10px;
            font-family: var(--font-body);
            font-size: 0.72rem;
            font-weight: 600;
            color: var(--color-text-tertiary);
            background: transparent;
            border: none;
            border-radius: var(--radius-full);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .tool-unit-btn.active {
            background: var(--color-bg);
            color: var(--color-text);
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
        }

        /* Body fat hint link */
        .tool-bf-help {
            display: block;
            font-size: 0.78rem;
            color: var(--color-text-tertiary);
            margin-top: 6px;
        }

        .tool-bf-help a {
            color: var(--color-text-secondary);
            text-decoration: underline;
            text-underline-offset: 2px;
            font-weight: 500;
        }

        .tool-bf-help a:hover {
            color: var(--color-text);
        }

        /* Calculate button */
        .tool-calc-btn {
            width: 100%;
            padding: 14px 0;
            font-family: var(--font-display);
            font-size: 1.05rem;
            font-weight: 700;
            color: var(--color-bg);
            background: var(--color-text);
            border: none;
            border-radius: var(--radius-sm);
            cursor: pointer;
            transition: transform 0.2s ease, opacity 0.2s ease;
            margin-top: 12px;
        }

        .tool-calc-btn:hover {
            transform: translateY(-1px);
            opacity: 0.9;
        }

        .tool-calc-btn:active {
            transform: translateY(0);
        }

        /* Result */
        .tool-result {
            display: none;
            text-align: center;
            margin-top: 28px;
            padding-top: 28px;
            border-top: 1px solid var(--color-border);
            animation: toolFadeIn 0.5s ease;
        }

        .tool-result.show {
            display: block;
        }

        @keyframes toolFadeIn {
            from { opacity: 0; transform: translateY(12px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        .tool-result-number {
            font-family: var(--font-display);
            font-size: 4.5rem;
            font-weight: 900;
            letter-spacing: -0.04em;
            line-height: 1;
            color: var(--color-text);
            margin-bottom: 4px;
        }

        .tool-result-unit {
            font-size: 1.15rem;
            font-weight: 700;
            color: var(--color-text-secondary);
            letter-spacing: 0.01em;
        }

        .tool-result-category {
            display: inline-block;
            padding: 5px 16px;
            border-radius: var(--radius-full);
            font-size: 0.85rem;
            font-weight: 700;
            margin-top: 10px;
            margin-bottom: 16px;
        }

        /* Category colors — green → blue → orange → red as FFMI climbs */
        .cat-below    { background: #e0f2fe; color: #075985; }
        .cat-average  { background: #e5e7eb; color: #374151; }
        .cat-above    { background: #d1fae5; color: #065f46; }
        .cat-athletic { background: #dbeafe; color: #1e40af; }
        .cat-elite    { background: #fef3c7; color: #92400e; }
        .cat-limit    { background: #ffedd5; color: #9a3412; }
        .cat-beyond   { background: #fee2e2; color: #991b1b; }

        /* Gauge bar — anchored on the natural limit */
        .tool-gauge {
            position: relative;
            height: 12px;
            background: var(--color-surface);
            border-radius: var(--radius-full);
            overflow: visible;
            margin-bottom: 6px;
        }

        .tool-gauge-fill {
            height: 100%;
            border-radius: var(--radius-full);
            transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
            background: linear-gradient(90deg, #60a5fa, #10b981, #f59e0b, #ef4444);
        }

        /* Natural-limit marker */
        .tool-gauge-marker {
            position: absolute;
            top: -6px;
            bottom: -6px;
            width: 2px;
            background: var(--color-text);
            border-radius: 2px;
        }

        .tool-gauge-marker::after {
            content: attr(data-label);
            position: absolute;
            top: -18px;
            left: 50%;
            transform: translateX(-50%);
            font-family: var(--font-body);
            font-size: 0.65rem;
            font-weight: 700;
            color: var(--color-text);
            letter-spacing: 0.04em;
            text-transform: uppercase;
            white-space: nowrap;
        }

        .tool-gauge-labels {
            display: flex;
            justify-content: space-between;
            font-size: 0.7rem;
            color: var(--color-text-tertiary);
            font-weight: 500;
            margin-top: 8px;
            margin-bottom: 18px;
        }

        .tool-result-detail {
            font-size: 0.95rem;
            color: var(--color-text-secondary);
            line-height: 1.65;
            max-width: 420px;
            margin: 0 auto;
        }

        /* Stats row */
        .tool-result-stats {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 14px;
            margin-top: 24px;
            padding-top: 20px;
            border-top: 1px solid var(--color-border);
        }

        .tool-stat {
            text-align: center;
        }

        .tool-stat-value {
            font-family: var(--font-display);
            font-size: 1.35rem;
            font-weight: 800;
            color: var(--color-text);
            letter-spacing: -0.01em;
        }

        .tool-stat-label {
            font-size: 0.72rem;
            color: var(--color-text-tertiary);
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-top: 2px;
        }

        /* =====================================================
           REFERENCE CHART
           ===================================================== */

        .tool-reference {
            max-width: 720px;
            margin: 0 auto 64px;
        }

        .tool-reference h2 {
            font-family: var(--font-display);
            font-size: 1.8rem;
            font-weight: 800;
            letter-spacing: -0.025em;
            color: var(--color-text);
            text-align: center;
            margin-bottom: 8px;
        }

        .tool-reference > p {
            text-align: center;
            color: var(--color-text-secondary);
            font-size: 0.95rem;
            margin-bottom: 32px;
            max-width: 520px;
            margin-left: auto;
            margin-right: auto;
        }

        .tool-ref-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 12px;
        }

        .tool-ref-card {
            display: flex;
            align-items: center;
            gap: 16px;
            padding: 18px 20px;
            background: var(--color-bg);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        .tool-ref-card:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-card);
        }

        .tool-ref-card.ceiling {
            border-color: rgba(17, 17, 17, 0.25);
            background: #fafafa;
        }

        .tool-ref-dot {
            width: 38px;
            height: 38px;
            border-radius: 50%;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.72rem;
            font-weight: 800;
            font-family: var(--font-display);
            color: #fff;
            letter-spacing: -0.01em;
        }

        .tool-ref-info h4 {
            font-family: var(--font-display);
            font-size: 0.95rem;
            font-weight: 700;
            color: var(--color-text);
            margin-bottom: 2px;
        }

        .tool-ref-range {
            font-size: 0.82rem;
            font-weight: 600;
            color: var(--color-text-secondary);
        }

        .tool-ref-desc {
            font-size: 0.8rem;
            color: var(--color-text-tertiary);
            line-height: 1.5;
            margin-top: 2px;
        }

        /* Dot colors */
        .dot-below    { background: #60a5fa; }
        .dot-average  { background: #6b7280; }
        .dot-above    { background: #10b981; }
        .dot-athletic { background: #3b82f6; }
        .dot-elite    { background: #f59e0b; }
        .dot-limit    { background: #f97316; }
        .dot-beyond   { background: #ef4444; }

        /* =====================================================
           FORMULA CARD
           ===================================================== */

        .tool-formula {
            max-width: 620px;
            margin: 0 auto 64px;
            padding: 32px 36px;
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-lg);
        }

        .tool-formula h2 {
            font-family: var(--font-display);
            font-size: 1.4rem;
            font-weight: 800;
            letter-spacing: -0.02em;
            color: var(--color-text);
            margin-bottom: 20px;
            text-align: center;
        }

        .tool-formula-block {
            background: var(--color-bg);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            padding: 18px 22px;
            margin-bottom: 14px;
            font-family: var(--font-display);
            font-weight: 700;
            color: var(--color-text);
            font-size: 0.98rem;
            letter-spacing: -0.01em;
            text-align: center;
        }

        .tool-formula-block .eq-label {
            display: block;
            font-family: var(--font-body);
            font-size: 0.72rem;
            font-weight: 600;
            color: var(--color-text-tertiary);
            text-transform: uppercase;
            letter-spacing: 0.08em;
            margin-bottom: 6px;
        }

        .tool-formula-block em {
            font-style: italic;
            font-weight: 600;
            color: var(--color-text-secondary);
        }

        .tool-formula p {
            font-size: 0.9rem;
            color: var(--color-text-secondary);
            line-height: 1.7;
            margin-top: 16px;
        }

        /* =====================================================
           CTA SECTION
           ===================================================== */

        .tool-cta-section {
            max-width: 620px;
            margin: 0 auto 48px;
            text-align: center;
            padding: 48px 40px;
            background: var(--color-surface);
            border-radius: var(--radius-lg);
            border: 1px solid var(--color-border);
        }

        .tool-cta-icon {
            width: 56px;
            height: 56px;
            margin: 0 auto 20px;
            border-radius: var(--radius-sm);
            background: var(--color-text);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .tool-cta-icon svg {
            width: 26px;
            height: 26px;
            color: #fff;
        }

        .tool-cta-section h2 {
            font-family: var(--font-display);
            font-size: 1.7rem;
            font-weight: 800;
            letter-spacing: -0.025em;
            color: var(--color-text);
            margin-bottom: 12px;
        }

        .tool-cta-section p {
            font-size: 1rem;
            color: var(--color-text-secondary);
            line-height: 1.7;
            max-width: 460px;
            margin: 0 auto 24px;
        }

        .tool-cta-list {
            list-style: none;
            display: inline-flex;
            flex-direction: column;
            gap: 6px;
            text-align: left;
            margin-bottom: 28px;
        }

        .tool-cta-list li {
            font-size: 0.92rem;
            color: var(--color-text-secondary);
            padding-left: 24px;
            position: relative;
        }

        .tool-cta-list li::before {
            content: "✓";
            position: absolute;
            left: 0;
            font-weight: 700;
            color: var(--color-text);
        }

        /* Other tools ribbon */
        .tool-other {
            max-width: 620px;
            margin: 0 auto 24px;
            text-align: center;
        }

        .tool-other h3 {
            font-family: var(--font-display);
            font-weight: 700;
            font-size: 1.05rem;
            margin-bottom: 14px;
            color: var(--color-text);
        }

        .tool-other-links {
            display: flex;
            gap: 10px;
            justify-content: center;
            flex-wrap: wrap;
        }

        .tool-other-links a {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 10px 18px;
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: 999px;
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--color-text);
            text-decoration: none;
            transition: background 0.2s ease, transform 0.2s ease;
        }

        .tool-other-links a:hover {
            background: #ececec;
            transform: translateY(-1px);
        }

        /* Error state */
        .tool-error-msg {
            color: #ef4444;
            font-size: 0.85rem;
            font-weight: 500;
            margin-top: 10px;
            display: none;
            text-align: center;
        }

        .tool-error-msg.show {
            display: block;
        }

        /* =====================================================
           RESPONSIVE
           ===================================================== */

        @media (max-width: 640px) {
            .tool-main {
                padding: 56px 0 80px;
            }

            .tool-header {
                margin-bottom: 32px;
            }

            .tool-header h1 {
                font-size: 1.95rem;
            }

            .tool-header p {
                font-size: 0.95rem;
            }

            .tool-calc-card {
                padding: 24px 20px;
                margin: 0 auto 40px;
            }

            .tool-ref-grid {
                grid-template-columns: 1fr;
            }

            .tool-result-number {
                font-size: 3.2rem;
            }

            .tool-result-stats {
                grid-template-columns: 1fr 1fr 1fr;
                gap: 8px;
            }

            .tool-stat-value {
                font-size: 1.15rem;
            }

            .tool-formula {
                padding: 24px 20px;
            }

            .tool-cta-section {
                padding: 32px 22px;
            }

            .tool-cta-section h2 {
                font-size: 1.35rem;
            }
        }
    