:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-subtle: #f7f9fc;
    --surface-elevated: rgba(255, 255, 255, .88);
    --heading: #111827;
    --text: #334155;
    --muted: #718096;
    --muted-strong: #526072;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, .1);
    --success: #059669;
    --success-bg: #e8f7f1;
    --info-bg: #eaf3ff;
    --warning: #d97706;
    --warning-bg: #fff7e6;
    --danger: #dc2626;
    --danger-bg: #fff0f0;
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, .055);
    --shadow-card: 0 14px 40px rgba(15, 23, 42, .08);
    --font-display: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --bg: #0b1119;
        --surface: #121a24;
        --surface-subtle: #182230;
        --surface-elevated: rgba(18, 26, 36, .9);
        --heading: #f3f6fa;
        --text: #d2d9e3;
        --muted: #93a1b3;
        --muted-strong: #b7c1ce;
        --border: #263445;
        --border-strong: #3a4a5e;
        --primary: #60a5fa;
        --primary-hover: #93c5fd;
        --primary-soft: rgba(96, 165, 250, .12);
        --success: #34d399;
        --success-bg: rgba(52, 211, 153, .11);
        --info-bg: rgba(96, 165, 250, .11);
        --warning: #fbbf24;
        --warning-bg: rgba(251, 191, 36, .1);
        --danger: #fb7185;
        --danger-bg: rgba(251, 113, 133, .11);
        --shadow-sm: 0 10px 28px rgba(0, 0, 0, .18);
        --shadow-card: 0 18px 48px rgba(0, 0, 0, .25);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1119;
    --surface: #121a24;
    --surface-subtle: #182230;
    --surface-elevated: rgba(18, 26, 36, .9);
    --heading: #f3f6fa;
    --text: #d2d9e3;
    --muted: #93a1b3;
    --muted-strong: #b7c1ce;
    --border: #263445;
    --border-strong: #3a4a5e;
    --primary: #60a5fa;
    --primary-hover: #93c5fd;
    --primary-soft: rgba(96, 165, 250, .12);
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, .11);
    --info-bg: rgba(96, 165, 250, .11);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, .1);
    --danger: #fb7185;
    --danger-bg: rgba(251, 113, 133, .11);
    --shadow-sm: 0 10px 28px rgba(0, 0, 0, .18);
    --shadow-card: 0 18px 48px rgba(0, 0, 0, .25);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding-top: 68px;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: rgba(37, 99, 235, .2);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
}

code,
pre {
    font-family: var(--font-mono);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--heading);
    font-family: var(--font-display);
    font-weight: 700;
}

.container {
    width: min(100% - 32px, 1160px);
}

.content {
    flex: 1 0 auto;
}

.skip-link {
    position: fixed;
    z-index: 1100;
    top: 10px;
    left: 12px;
    padding: 9px 13px;
    border-radius: 8px;
    background: var(--surface);
    color: var(--heading);
    box-shadow: var(--shadow-card);
    transform: translateY(-160%);
    transition: transform .18s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

/* Navigation */
.navbar {
    min-height: 68px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.navbar.bg-dark {
    background: #0f172a !important;
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: 28px;
    color: #fff !important;
    font-size: 17px;
    font-weight: 750;
    letter-spacing: -.015em;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    order: 2;
}

.navbar-collapse {
    order: 3;
}

.theme-toggle {
    width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 10px;
    background: rgba(255, 255, 255, .06);
    color: rgba(255, 255, 255, .78);
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, color .18s ease;
}

.theme-toggle:hover {
    border-color: rgba(255, 255, 255, .3);
    background: rgba(255, 255, 255, .11);
    color: #fff;
}

.theme-toggle:focus-visible {
    outline: 3px solid rgba(96, 165, 250, .3);
    outline-offset: 2px;
}

.theme-toggle-icons,
.theme-icon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
}

.theme-icon {
    display: block;
}

.theme-icon-sun {
    display: none;
}

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

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

.brand-logo {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 11px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}

.navbar-nav {
    gap: 3px;
}

.navbar .nav-link {
    position: relative;
    padding: 8px 11px !important;
    border-radius: 9px;
    color: rgba(255, 255, 255, .68) !important;
    font-size: 14px;
    font-weight: 550;
    transition: color .18s ease, background-color .18s ease;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    background: rgba(255, 255, 255, .08);
    color: #fff !important;
}

.navbar .nav-link.active::after {
    content: "";
    position: absolute;
    right: 11px;
    bottom: 3px;
    left: 11px;
    height: 2px;
    border-radius: 99px;
    background: #60a5fa;
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, .2);
    border-radius: 10px;
    padding: 7px 9px;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .22);
}

/* Shared page hero */
.hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(30px, 5vw, 56px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-card);
}

.hero h1 {
    max-width: 760px;
    margin-top: 7px;
    color: var(--heading);
    font-weight: 760;
    letter-spacing: -.045em;
    line-height: 1.12;
}

.hero > p {
    max-width: 720px;
    color: var(--muted);
    font-size: clamp(15px, 1.8vw, 17px);
}

.page-kicker {
    display: inline-block;
    color: var(--primary);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .15em;
}

/* Cards */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.card-header {
    border-bottom-color: var(--border);
    background: var(--surface-subtle);
    color: var(--heading);
}

.tile-link {
    display: block;
    height: 100%;
    color: inherit;
}

.feature-tile {
    min-height: 100%;
    overflow: hidden;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.feature-tile:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
    box-shadow: var(--shadow-card);
}

.tile-link:focus-visible {
    border-radius: var(--radius);
    outline: 3px solid rgba(37, 99, 235, .32);
    outline-offset: 3px;
}

.tile-illustration {
    height: 72px;
    display: grid;
    place-items: center;
    border-bottom: 1px solid var(--border);
    color: var(--muted-strong);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .14em;
}

.tool-icon {
    width: 29px;
    height: 29px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tile-success .tile-illustration {
    background: var(--success-bg);
}

.tile-info .tile-illustration {
    background: var(--info-bg);
}

.tile-danger .tile-illustration {
    background: var(--danger-bg);
}

.tile-body {
    position: relative;
    padding: 18px 19px 20px;
    text-align: left;
}

.tile-body h3,
.tile-body h2,
.tile-body h6 {
    margin: 0 0 6px;
    color: var(--heading);
    font-size: 16px;
    font-weight: 700;
}

.tile-code {
    display: block;
    width: 100%;
    margin-top: 5px;
    overflow: hidden;
    color: var(--muted-strong);
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Forms and utilities */
.btn {
    min-height: 42px;
    border-radius: 10px;
    font-weight: 650;
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.btn-outline-secondary {
    border-color: var(--border-strong);
    color: var(--muted-strong);
}

.btn-outline-secondary:hover {
    border-color: var(--muted-strong);
    background: var(--surface-subtle);
    color: var(--heading);
}

.form-control,
.form-select,
.input-group-text {
    border-color: var(--border-strong);
    background-color: var(--surface);
    color: var(--text);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    background-color: var(--surface);
    color: var(--text);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.form-control::placeholder {
    color: color-mix(in srgb, var(--muted) 72%, transparent);
}

.alert {
    border-radius: var(--radius-sm);
}

.bs-dropzone {
    padding: clamp(30px, 6vw, 58px);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    text-align: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease, transform .2s ease;
}

.bs-dropzone:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.progress {
    height: 10px;
    margin-top: 20px;
    border-radius: 99px;
    background: var(--surface-subtle);
}

.progress-bar {
    background: var(--primary);
}

/* Documentation */
pre {
    max-width: 100%;
    overflow: auto;
    color: var(--text);
    font-size: 12px;
    line-height: 1.7;
}

.card .tile-body[style] {
    text-align: left !important;
}

.docs-more-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.docs-more-button {
    width: 96px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.35;
    text-align: center;
}

.docs-more-button:focus-visible {
    outline: 3px solid rgba(37, 99, 235, .28);
    outline-offset: 2px;
}

/* Service and case cards keep the existing image-led language */
.service-card {
    height: calc(100% - 24px);
    margin: 12px 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.service-card:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
    box-shadow: var(--shadow-card);
}

.service-card img {
    width: 100%;
    max-width: 200px;
    aspect-ratio: 1;
    border-radius: 14px;
    object-fit: cover;
}

.service-card h2,
.service-card h5 {
    margin: 16px 0 4px;
    font-size: 15px;
}

/* Error and footer */
.error-content {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
}

.site-footer {
    flex: 0 0 auto;
    padding: 30px 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
}

.footer-identity p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.footer-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--heading);
}

.footer-brand:hover {
    color: var(--heading);
}

.footer-brand img {
    width: 32px;
    height: 32px;
    border-radius: 9px;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 18px;
}

.footer-nav a {
    color: var(--muted-strong);
    font-size: 12px;
}

.footer-nav a:hover {
    color: var(--primary);
}

.back-to-top {
    position: fixed;
    z-index: 1030;
    right: 20px;
    bottom: 22px;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--heading);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform .18s ease, opacity .18s ease;
}

.back-to-top:hover {
    transform: translateY(-2px);
}

.back-to-top[hidden] {
    display: none;
}

.text-muted {
    color: var(--muted) !important;
}

.text-body {
    color: var(--text) !important;
}

@media (max-width: 1199.98px) {
    .navbar-collapse {
        margin-top: 10px;
        padding: 8px;
        border: 1px solid rgba(255, 255, 255, .09);
        border-radius: 12px;
        background: rgba(15, 23, 42, .98);
    }

    .navbar .nav-link.active::after {
        top: 9px;
        right: auto;
        bottom: 9px;
        left: 3px;
        width: 2px;
        height: auto;
    }
}

@media (min-width: 1200px) {
    .navbar-collapse {
        order: 2;
    }

    .navbar-actions {
        margin-left: 10px;
        order: 3;
    }
}

@media (max-width: 767.98px) {
    body {
        padding-top: 64px;
    }

    .container {
        width: min(100% - 24px, 1160px);
    }

    .navbar {
        min-height: 64px;
    }

    .hero {
        padding: 28px 22px;
        border-radius: 18px;
    }

    .hero h1 {
        font-size: clamp(31px, 10vw, 45px);
    }

    .tile-illustration {
        height: 64px;
    }

    .docs-more-links {
        width: 100%;
    }

    .footer-layout {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
    }

    .footer-nav {
        justify-content: flex-start;
    }

}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
