/* Shared appearance controls. Theme rules apply only to screens, preserving print colors. */
.header-controls {
    display:flex;
    align-items:center;
    gap:8px;
    order:2;
    flex-shrink:0;
}

.main-nav {
    gap:24px;
}

.main-nav .navigation {
    order:1;
    margin-left:auto;
}

.theme-toggle {
    position:relative;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:44px;
    height:44px;
    min-width:44px;
    min-height:44px;
    padding:0;
    border:0;
    border-radius:6px;
    background:transparent;
    color:var(--ink);
}

/* A compact 36px face keeps the native button's 44px touch target. */
.theme-toggle::before {
    content:"";
    position:absolute;
    inset:4px;
    border:1px solid var(--line);
    border-radius:6px;
    pointer-events:none;
}

.theme-toggle svg {
    position:relative;
    width:18px;
    height:18px;
    flex-shrink:0;
}

.theme-icon-sun,
[data-theme="dark"] .theme-icon-moon {
    display:none;
}

[data-theme="dark"] .theme-icon-sun {
    display:block;
}

@media(max-width:1100px) {
    .main-nav {
        gap:0;
    }
    .header-controls {
        margin-left:auto;
    }
    .main-nav .navigation {
        order:3;
        margin-left:0;
    }
}

@media(max-width:420px) {
    .nav-toggle-label {
        display:none;
    }
    .nav-toggle {
        justify-content:center;
        min-width:44px;
        min-height:44px;
        padding:9px;
    }
}

@media screen {
    :root {
        color-scheme:light;
        --theme-surface:#fff;
        --theme-soft:#edf1e5;
        --theme-table-heading:#f6f7f2;
        --theme-accent:#133b30;
        --theme-quiet:#506b32;
        --theme-header:rgba(248,248,243,.97);
        --theme-focus:#648929;
        --theme-button-bg:#133b30;
        --theme-button-ink:#fff;
        --theme-button-hover:#235640;
        --theme-field:#fdfefa;
        --theme-field-border:#c8d0c0;
        --theme-success-bg:#e9f4d9;
        --theme-success-ink:#17362e;
        --theme-success-border:#b8d190;
        --theme-error-bg:#fff1eb;
        --theme-error-ink:#813c21;
        --theme-error-border:#e4b9a4;
        --theme-error-text:#a02e1a;
        --theme-bronze-bg:#f2e2d1;
        --theme-bronze-border:#d9bea1;
        --theme-silver-bg:#e6ebe7;
        --theme-silver-border:#c9d1ca;
        --theme-gold-bg:#f1e6b2;
        --theme-gold-border:#ddcd87;
        --theme-connector:#91a575;
        --theme-tag:rgba(255,255,255,.3);
        --theme-image-top:rgba(248,248,243,.82);
        --theme-image-bottom:rgba(248,248,243,.96);
        --theme-floating:rgba(248,248,243,.94);
        --theme-hover:#e6edda;
        --theme-dot:#8b9b85;
        --theme-badge-mono-filter:none;
    }

    :root[data-theme="dark"] {
        color-scheme:dark;
        --ink:#e7eee7;
        --muted:#b5c4b9;
        --paper:#101b17;
        --tint:#16261e;
        --line:#3f5547;
        --theme-surface:#1a2b22;
        --theme-soft:#22382b;
        --theme-table-heading:#1e3027;
        --theme-accent:#c6e6a0;
        --theme-quiet:#b2d285;
        --theme-header:rgba(16,27,23,.97);
        --theme-focus:#d5ee88;
        --theme-button-bg:#d5ee88;
        --theme-button-ink:#17362e;
        --theme-button-hover:#e5f7b0;
        --theme-field:#12221a;
        --theme-field-border:#667f6b;
        --theme-success-bg:#253b23;
        --theme-success-ink:#d7eec0;
        --theme-success-border:#6c8c54;
        --theme-error-bg:#3b261f;
        --theme-error-ink:#ffd0bc;
        --theme-error-border:#ad755f;
        --theme-error-text:#ffb9a4;
        --theme-bronze-bg:#3d3023;
        --theme-bronze-border:#927750;
        --theme-silver-bg:#293830;
        --theme-silver-border:#708677;
        --theme-gold-bg:#3b361e;
        --theme-gold-border:#96864f;
        --theme-connector:#8ead78;
        --theme-tag:rgba(255,255,255,.035);
        --theme-image-top:rgba(16,27,23,.93);
        --theme-image-bottom:rgba(16,27,23,.98);
        --theme-floating:rgba(16,27,23,.96);
        --theme-hover:#2d4533;
        --theme-dot:#92aa8a;
        --theme-badge-mono-filter:invert(1);
    }

    /* System preference also works when scripts are disabled or unavailable. */
    @media(prefers-color-scheme:dark) {
        :root:not([data-theme]) {
            color-scheme:dark;
            --ink:#e7eee7;
            --muted:#b5c4b9;
            --paper:#101b17;
            --tint:#16261e;
            --line:#3f5547;
            --theme-surface:#1a2b22;
            --theme-soft:#22382b;
            --theme-table-heading:#1e3027;
            --theme-accent:#c6e6a0;
            --theme-quiet:#b2d285;
            --theme-header:rgba(16,27,23,.97);
            --theme-focus:#d5ee88;
            --theme-button-bg:#d5ee88;
            --theme-button-ink:#17362e;
            --theme-button-hover:#e5f7b0;
            --theme-field:#12221a;
            --theme-field-border:#667f6b;
            --theme-success-bg:#253b23;
            --theme-success-ink:#d7eec0;
            --theme-success-border:#6c8c54;
            --theme-error-bg:#3b261f;
            --theme-error-ink:#ffd0bc;
            --theme-error-border:#ad755f;
            --theme-error-text:#ffb9a4;
            --theme-bronze-bg:#3d3023;
            --theme-bronze-border:#927750;
            --theme-silver-bg:#293830;
            --theme-silver-border:#708677;
            --theme-gold-bg:#3b361e;
            --theme-gold-border:#96864f;
            --theme-connector:#8ead78;
            --theme-tag:rgba(255,255,255,.035);
            --theme-image-top:rgba(16,27,23,.93);
            --theme-image-bottom:rgba(16,27,23,.98);
            --theme-floating:rgba(16,27,23,.96);
            --theme-hover:#2d4533;
            --theme-dot:#92aa8a;
            --theme-badge-mono-filter:invert(1);
        }
    }

    :focus-visible {
        outline-color:var(--theme-focus);
    }

    .site-header {
        background:var(--theme-header);
    }

    .theme-toggle:hover::before {
        background:var(--theme-hover);
        border-color:var(--theme-accent);
    }

    .eyebrow,.button-secondary,.nav-toggle,.diagram-label,
    .visual-topline,.visual-index,.expertise-topline,
    .expertise-slide-link,.expertise-controls button,
    .deployment-table tbody th,.reference-stage:not(:last-child)::after,
    .navigation>a[aria-current=page]:not(.button),.navigation>a:hover {
        color:var(--theme-accent);
    }

    .button-secondary {
        border-color:var(--theme-accent);
    }

    .navigation>a[aria-current=page]:not(.button):after {
        background:var(--theme-accent);
    }

    .hero-copy h1 em,.card-number,
    .service-number,.service-nav a>span:first-child,
    .service-deliverables li:before,.contact-details .eyebrow,
    .expertise-caption .expertise-caption-index,
    .model-consumers .reference-stage-label {
        color:var(--theme-quiet);
    }

    .status-dot {
        background:var(--theme-quiet);
    }

    .button-primary {
        background:var(--theme-button-bg);
        color:var(--theme-button-ink);
    }

    .button-primary:hover {
        background:var(--theme-button-hover);
    }

    .navigation>.nav-cta:hover {
        color:var(--theme-button-ink);
    }

    .section-dark {
        color:#f8f8f3;
    }

    /* The credentials band stays dark in both screen themes. */
    .certifications-section {
        --theme-badge-mono-filter:invert(1);
    }

    .section-dark .eyebrow {
        color:var(--lime);
    }

    .section-dark .button-primary {
        color:var(--forest);
        background:var(--lime);
    }

    .section-dark .button-primary:hover {
        background:#e5f7b0;
    }

    .skip-link,.diagram-node-link {
        color:#17362e;
    }

    .service-card,.content-card,.diagram-node-satellite,
    .reference-stage,.model-consumers>div,.deployment-table td,
    .ai-context-sources>div {
        background:var(--theme-surface);
    }

    .service-card:hover {
        border-color:var(--theme-accent);
    }

    .tag-list li {
        background:var(--theme-tag);
    }

    .section-dark .tag-list li {
        background:transparent;
    }

    .faq-list,.faq-item,.service-nav a,.diagram-note,.engagement-steps li {
        border-color:var(--line);
    }

    .reference-stage-bronze {
        background:var(--theme-bronze-bg);
        border-color:var(--theme-bronze-border);
    }

    .reference-stage-silver {
        background:var(--theme-silver-bg);
        border-color:var(--theme-silver-border);
    }

    .reference-stage-gold {
        background:var(--theme-gold-bg);
        border-color:var(--theme-gold-border);
    }

    .reference-stage-semantic {
        background:var(--forest);
        border-color:var(--forest);
        color:#fff;
    }

    .reference-foundation,.ai-data-foundation,.deployment-table caption {
        background:var(--theme-soft);
        border-color:var(--line);
    }

    .deployment-table thead {
        background:var(--theme-table-heading);
    }

    .model-product::after,.model-consumers::before,
    .model-consumers>div::before,.ai-context-sources>div::before,
    .ai-context-sources>div::after,.diagram-connector,
    .diagram-column:not(:last-child):after,
    .architecture-flow li:not(:last-child):after {
        background:var(--theme-connector);
    }

    .model-consumers,.ai-context-sources {
        border-color:var(--theme-connector);
    }

    .form-control {
        background:var(--theme-field);
        border-color:var(--theme-field-border);
    }

    .form-control::placeholder {
        color:var(--muted);
        opacity:1;
    }

    .form-control:focus {
        outline-color:var(--theme-focus);
        border-color:var(--theme-focus);
    }

    .form-feedback-success {
        background:var(--theme-success-bg);
        color:var(--theme-success-ink);
        border-color:var(--theme-success-border);
    }

    .form-feedback-error {
        background:var(--theme-error-bg);
        color:var(--theme-error-ink);
        border-color:var(--theme-error-border);
    }

    .field-error {
        color:var(--theme-error-text);
    }

    .input-validation-error {
        border-color:var(--theme-error-text);
    }

    /* Keep the third-party verification widget in its own native light scheme. */
    .g-recaptcha {
        color-scheme:light;
    }

    .hero-visual,.about-image {
        background:var(--theme-surface);
    }

    .visual-caption {
        background:var(--paper);
        border-color:var(--line);
    }

    .expertise-topline {
        text-shadow:none;
    }

    .expertise-controls button:hover {
        background:var(--theme-hover);
    }

    .expertise-rotation {
        background:transparent;
    }

    .expertise-dots button>span {
        background:var(--theme-dot);
    }

    .expertise-dots button[aria-current=true]>span {
        background:var(--theme-accent);
    }
}

@media print {
    .section-dark .flow-step,.section-dark .tag-list li,
    .section-dark .architecture-boundary,.section-dark .architecture-foundation,
    .section-dark .text-link {
        color:#17362e;
    }
    .header-controls {
        display:none!important;
    }
}
