@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --top-bar-height: clamp(58px, 3vw + 42px, 78px);
    --brand-orange: var(--accent);
    --body-bg: var(--bg-primary);
    --success: var(--text-color-green);
    --warning: var(--text-color-yellow);
    --danger: var(--text-color-red);
    --heading-h1: var(--text-primary);
    --heading-h2: var(--text-secondary);
    --heading-h3: var(--text-subtle);
    --heading-cta: var(--accent);
    --heading-legal: var(--text-muted);
    --bg-app: var(--bg-primary);
    --bg-surface: var(--bg-panel);
    --bg-elevated: var(--surface-layer-hover);
    --border-subtle: var(--border-color);
    --border-strong: var(--border-color-strong);
    --text-disabled: var(--text-muted-soft);
    --metric-meta-label-color: var(--text-secondary);
    --metric-chip-text-color: var(--text-secondary);
    --metric-resolution-chip-bg: var(--surface-layer-hover);
    --metric-resolution-chip-border: color-mix(in srgb, var(--border-strong) 75%, transparent);
    --metric-resolution-label-opacity: 0.9;
    --section-gap: 1.6rem;
    --section-divider-offset: -0.8rem;
    --section-divider-color: color-mix(in srgb, var(--border-color) 85%, transparent);
    --section-divider-line: linear-gradient(90deg, transparent, var(--section-divider-color), transparent);
    --surface-primary-radius: 12px;
    --surface-primary-border: color-mix(in srgb, var(--border-color) 65%, transparent);
    --surface-primary-shadow: 0 12px 26px var(--shadow-soft);
    --surface-secondary-radius: var(--surface-primary-radius);
    --surface-secondary-border: color-mix(in srgb, var(--border-color) 45%, transparent);
    --surface-secondary-bg: var(--surface-layer);
    --badge-bg: var(--accent-soft);
    --badge-text: var(--accent-strong);
    --badge-border: var(--accent-border);
    --tier-tag-bg-0: var(--surface-layer-chip);
    --tier-tag-border-0: color-mix(in srgb, var(--border-strong) 80%, transparent);
    --tier-tag-text-0: var(--text-secondary);
    --tier-tag-bg-1: var(--surface-layer-chip);
    --tier-tag-border-1: var(--accent-border);
    --tier-tag-text-1: var(--text-secondary);
    --tier-tag-bg-2: var(--surface-layer-chip);
    --tier-tag-border-2: var(--accent-border-strong);
    --tier-tag-text-2: var(--text-secondary);
    --canvas-haze-cool: color-mix(in srgb, var(--gradient-radial-start) 24%, transparent);
    --canvas-haze-warm: color-mix(in srgb, var(--accent) 4%, transparent);
    --canvas-haze-neutral: color-mix(in srgb, var(--gradient-radial-mid) 28%, transparent);
    --canvas-haze-opacity: 0.4;
    --canvas-haze-blur: 64px;
    --canvas-noise-opacity: 0.09;
    --token-card-bg: color-mix(in srgb, var(--body-bg) 88%, #000000);
    --token-card-border: color-mix(in srgb, var(--border-color) 55%, transparent);
    --token-card-shadow: 0 16px 26px color-mix(in srgb, var(--shadow-soft) 70%, transparent);
    --token-card-inset: inset 0 0 0 1px color-mix(in srgb, var(--text-primary) 8%, transparent);
    --token-card-radius: var(--surface-primary-radius);
    --tier-card-bg: color-mix(in srgb, var(--body-bg) 92%, #000000);
    --tier-card-border: color-mix(in srgb, var(--text-muted) 14%, transparent);
    --tier-card-shadow: 0 2px 6px color-mix(in srgb, var(--shadow-soft) 55%, transparent);
    --tier-card-shadow-hover: 0 3px 8px color-mix(in srgb, var(--shadow-soft) 65%, transparent);
    --tier-card-radius: var(--surface-primary-radius);
    --overlay: rgba(0, 0, 0, 0.60);
    --modal-bg: rgba(15, 22, 35, 0.92);
    --modal-border: rgba(255, 255, 255, 0.08);
    --modal-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
    --modal-header-border: rgba(255, 255, 255, 0.06);
    --field-bg: rgba(10, 16, 28, 0.85);
    --field-border: rgba(255, 255, 255, 0.10);
    --field-border-hover: rgba(255, 255, 255, 0.16);
    --focus-ring: rgba(255, 255, 255, 0.18);
    --btn-primary-bg: #ff8c00;
    --btn-primary-fg: #101420;
    --btn-primary-bg-hover: #ff9b1f;
    --btn-primary-bg-active: #ff7a00;
    --btn-primary-disabled-bg: rgba(255, 140, 0, 0.6);
    --btn-primary-disabled-fg: rgba(16, 20, 32, 0.78);
    --btn-secondary-bg: transparent;
    --btn-secondary-border: rgba(255, 255, 255, 0.16);
    --btn-secondary-border-hover: rgba(255, 255, 255, 0.24);
    --btn-secondary-fg: rgba(255, 255, 255, 0.92);
    --btn-secondary-bg-hover: rgba(255, 255, 255, 0.06);
    --btn-tertiary-bg: transparent;
    --btn-tertiary-bg-hover: rgba(255, 255, 255, 0.05);
    --btn-tertiary-fg: rgba(255, 255, 255, 0.70);
    --btn-tertiary-fg-hover: rgba(255, 255, 255, 0.88);
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
    --canvas-haze-cool: color-mix(in srgb, var(--gradient-radial-mid) 45%, transparent);
    --canvas-haze-warm: color-mix(in srgb, #e7d9c5 28%, transparent);
    --canvas-haze-neutral: color-mix(in srgb, var(--body-bg) 70%, var(--gradient-radial-start));
    --canvas-haze-opacity: 0.85;
    --canvas-haze-blur: 22px;
    --canvas-noise-opacity: 0.07;
    --section-divider-color: color-mix(in srgb, var(--border-color) 100%, transparent);
    --token-card-bg: color-mix(in srgb, var(--body-bg) 84%, #0f172a);
    --token-card-border: color-mix(in srgb, var(--border-color) 85%, transparent);
    --token-card-shadow: 0 12px 20px var(--shadow-soft);
    --token-card-inset: inset 0 1px 0 color-mix(in srgb, #ffffff 55%, transparent);
    --tier-card-bg: color-mix(in srgb, var(--body-bg) 96%, #0f172a);
    --tier-card-border: color-mix(in srgb, var(--text-muted) 18%, transparent);
    --tier-card-shadow: 0 2px 6px color-mix(in srgb, var(--shadow-soft) 55%, transparent);
    --tier-card-shadow-hover: 0 3px 8px color-mix(in srgb, var(--shadow-soft) 65%, transparent);
    --overlay: rgba(0, 0, 0, 0.35);
    --modal-bg: #ffffff;
    --modal-border: rgba(15, 23, 42, 0.12);
    --modal-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
    --modal-header-border: rgba(15, 23, 42, 0.08);
    --field-bg: rgba(248, 250, 252, 0.96);
    --field-border: rgba(15, 23, 42, 0.14);
    --field-border-hover: rgba(15, 23, 42, 0.22);
    --focus-ring: rgba(15, 23, 42, 0.16);
    --btn-primary-bg: #ff8c00;
    --btn-primary-fg: #101420;
    --btn-primary-bg-hover: #ff9b1f;
    --btn-primary-bg-active: #f57f00;
    --btn-primary-disabled-bg: rgba(255, 140, 0, 0.55);
    --btn-primary-disabled-fg: rgba(16, 20, 32, 0.72);
    --btn-secondary-bg: transparent;
    --btn-secondary-border: rgba(15, 23, 42, 0.18);
    --btn-secondary-border-hover: rgba(15, 23, 42, 0.28);
    --btn-secondary-fg: rgba(15, 23, 42, 0.84);
    --btn-secondary-bg-hover: rgba(15, 23, 42, 0.06);
    --btn-tertiary-bg: transparent;
    --btn-tertiary-bg-hover: rgba(15, 23, 42, 0.04);
    --btn-tertiary-fg: rgba(15, 23, 42, 0.66);
    --btn-tertiary-fg-hover: rgba(15, 23, 42, 0.82);
    --metric-meta-label-color: var(--text-muted);
    --metric-chip-text-color: var(--text-secondary);
    --metric-resolution-chip-bg: color-mix(in srgb, var(--surface-layer-pill) 85%, var(--bg-surface));
    --metric-resolution-chip-border: color-mix(in srgb, var(--border-subtle) 65%, transparent);
    --metric-resolution-label-opacity: 0.8;
}

/* General Typography and Colors */
body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--body-bg);
    background-repeat: no-repeat;
    position: relative;
    isolation: isolate;
    margin: 0;
    padding: 0;
    padding-top: var(--top-bar-height);
    transition: background-color 0.2s ease, color 0.2s ease;
}

body::before {
    content: "";
    position: fixed;
    top: var(--top-bar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(
            140% 120% at -15% -10%,
            var(--canvas-haze-cool) 0%,
            color-mix(in srgb, var(--canvas-haze-cool) 55%, transparent) 38%,
            transparent 72%
        ),
        radial-gradient(
            140% 120% at 115% -5%,
            var(--canvas-haze-warm) 0%,
            color-mix(in srgb, var(--canvas-haze-warm) 55%, transparent) 40%,
            transparent 74%
        ),
        radial-gradient(
            160% 140% at 50% 120%,
            color-mix(in srgb, var(--canvas-haze-neutral) 55%, transparent) 0%,
            transparent 78%
        );
    background-size: 130% 130%;
    background-position: center;
    opacity: var(--canvas-haze-opacity);
    filter: blur(var(--canvas-haze-blur));
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: "";
    position: fixed;
    top: var(--top-bar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
    background-size: 180px 180px;
    opacity: var(--canvas-noise-opacity);
    mix-blend-mode: soft-light;
    pointer-events: none;
    z-index: 0;
}

body > * {
    position: relative;
    z-index: 1;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    text-align: left;
    color: var(--heading-h1);
}

h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-top: 1rem;
    text-align: left;
    color: var(--heading-h2);
}

h3 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--heading-h3);
}

.h1 {
    color: var(--heading-h1);
    font-weight: 800;
}

.h2 {
    color: var(--heading-h2);
    font-weight: 600;
}

.h3 {
    color: var(--heading-h3);
    font-weight: 600;
}

p, ol {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    font-size: 1rem;
}

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

a:hover,
a:focus-visible {
    color: var(--accent-strong);
    text-decoration: underline;
}

/* General Section Styling */
.container {
    max-width: 800px;           /* Ensure consistent width for content */
    margin: 0 auto;
    padding: 20px;
}

.info {
    text-align: center;          /* Center-align title and description */
}

/* Title Styling */
.main {
    margin-bottom: 15px;          /* Add space between title and description */
}

.title {
    font-size: 2.5rem;
    color: var(--heading-h1);
    font-weight: 800;
    margin: 0;
    padding: 0;
}

.version {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0;
    padding: 0;
}

/* Description Styling */
.description {
    margin-top: 10px;
    text-align: left; /* Center-align description text */
}

.description h2 {
    margin-bottom: 10px;
}

.description p {
    line-height: 1.6;
    margin: 0;
}

/* Section Styling */
section {
    margin-top: var(--section-gap);
    text-align: left;         /* Left-align content for additional sections */
}

section + section {
    position: relative;
}

section + section::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: var(--section-divider-offset);
    height: 1px;
    background: var(--section-divider-line);
}

section h3 {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--heading-h3);
}

.cta-heading {
    color: var(--heading-cta);
    font-weight: 700;
}

.inline-highlight {
    color: var(--accent);
    font-weight: 600;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--badge-bg);
    color: var(--badge-text);
    border: 1px solid var(--badge-border);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

section p {
    line-height: 1.6;
}

section .muted-section {
    color: var(--heading-legal);
    font-size: 0.85em;         /* 85% of the parent's font size */
    /* font-style: italic;       /* Optional for emphasis */
}

section .muted-section h3 {
    color: var(--heading-legal);
}

section .muted-section p {
    font-size: 1em;         /* Set to force the font size in .muted-section (above) */
}

/* Footer Styling */
footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

footer p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    text-align: center;
}

/* Bootstrap theme overrides */
body .bg-dark {
    background-color: var(--surface-layer-strong) !important;
    color: var(--text-primary) !important;
}

body .bg-secondary {
    background-color: var(--surface-layer) !important;
    color: var(--text-primary) !important;
}

body .bg-light {
    background-color: var(--surface-layer-soft) !important;
    color: var(--text-primary) !important;
}

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

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

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

body .shadow-sm {
    box-shadow: 0 0.125rem 0.25rem var(--shadow-soft) !important;
}

body .table {
    color: var(--text-primary);
    background-color: transparent;
}

body .table th,
body .table td {
    border-color: var(--border-color);
}

body .table thead th {
    color: var(--text-muted);
    border-bottom-color: var(--border-color);
}

body .table-striped tbody tr:nth-of-type(odd) {
    background-color: color-mix(in srgb, var(--surface-layer) 70%, transparent);
}

body .table-hover tbody tr:hover {
    background-color: var(--surface-layer-hover);
    color: var(--text-primary);
}

body .table-light,
body .table-light > th,
body .table-light > td {
    background-color: var(--surface-layer);
    color: var(--text-primary);
}

/* Navigation Bar */
.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--paper-color);
    padding: 10px 20px;
    box-shadow: 0 2px 4px var(--shadow-soft);
    border-bottom: 1px solid var(--border-color);
}

.nav-container .logo {
    font-size: 1.8em;
    font-family: 'Georgia', serif;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: bold;
}

.nav-container .logo:hover {
    text-decoration: underline;
}

.nav-links {
    display: flex;
    gap: 15px;
    margin-left: 30px;
    list-style: none;
}

.nav-links a {
    color: var(--text-primary);
    font-size: 1em;
    text-decoration: none;
    font-weight: bold;
}

.nav-links a:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

/* Navbar Logo */
.navbar-brand {
    display: flex;
    align-items: center;
    font-family: 'sans-serif';
    font-weight: bold;
    font-size: 1.3em;
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.logo-text {
    color: var(--text-primary);
}

.logo-text:hover {
    color: var(--accent-strong);
}

/* Flash message container styling */
.flash-container {
    position: absolute;
    top: calc(var(--top-bar-height) + 12px);
    right: 20px; /* Right-align messages */
    z-index: 1050; /* Ensure it appears above other elements */
    width: 300px;
}

/* Flash message styling */
.flash-message {
    display: none;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
    font-size: 14px;
    box-shadow: 0 2px 4px var(--shadow-soft);
    text-align: center;
    transition: opacity 0.5s ease;
}

/* Success message */
.flash-message.success {
    background-color: color-mix(in srgb, var(--success) 18%, var(--paper-color));
    color: color-mix(in srgb, var(--success) 70%, var(--text-primary));
    border: 1px solid color-mix(in srgb, var(--success) 45%, transparent);
}

/* Info message */
.flash-message.info {
    background-color: color-mix(in srgb, var(--brand-surface) 50%, var(--paper-color));
    color: var(--text-primary);
    border: 1px solid var(--brand-border-strong);
}

/* Danger message */
.flash-message.danger {
    background-color: color-mix(in srgb, var(--danger) 18%, var(--paper-color));
    color: color-mix(in srgb, var(--danger) 70%, var(--text-primary));
    border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
}


/* Buttons Styling */
.btn-primary {
    background-color: var(--accent);
    color: var(--text-inverse);
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    display: inline-block;
    text-align: center;
}

.btn-primary:hover {
    background-color: var(--accent-strong);
}

/* Authentication Links */
.auth-links {
    display: flex;
    gap: 15px;
}

.auth-links .auth-link {
    color: var(--text-contrast);
    font-size: 1em;
    font-weight: bold;
    text-decoration: none;
    padding: 5px 10px;
    border: 1px solid var(--border-color-grey);
    border-radius: 4px;
    background-color: var(--surface-overlay);
}

.auth-links .auth-link:hover {
    background-color: var(--hover-background-color);
    color: var(--text-primary);
    border-color: var(--accent-border);
    text-decoration: none;
}

/* Form Section */
.form-section {
    margin: 2rem auto;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.card {
    background-color: var(--paper-color);
    border: 1px solid var(--surface-primary-border);
    border-radius: var(--surface-primary-radius);
    box-shadow: var(--surface-primary-shadow);
    width: 100%;
    max-width: 800px; /* Match Swagger's layout width */
    padding: 20px;
    margin: 0 auto;
}

.card-body {
    padding: 20px;
    text-align: center;
}

.token-page .card {
    background-color: var(--token-card-bg);
    border: 1px solid var(--token-card-border);
    border-radius: var(--token-card-radius);
    box-shadow: var(--token-card-shadow), var(--token-card-inset);
}

/* Token Display */
#token-form {
    margin: 0 auto 14px;
    padding: 12px 14px;
    border: 1px solid var(--surface-secondary-border);
    border-radius: var(--surface-secondary-radius);
    background-color: var(--surface-secondary-bg);
}

#token-form .btn-primary,
#token-form .btn-primary:visited {
    color: #f8fafc;
}

.token-page #token-form .btn-primary,
.token-page #token-form .btn-primary:visited {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: var(--text-inverse);
    border-radius: calc(var(--token-card-radius) - 2px);
    box-shadow: none;
}

.token-page #token-form .btn-primary:hover,
.token-page #token-form .btn-primary:focus-visible {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: var(--text-inverse);
}

.token-page #token-form .btn-primary:focus-visible {
    outline: 2px solid var(--accent-border-strong);
    outline-offset: 2px;
}

.token-display {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--surface-secondary-bg);
    border: 1px solid var(--surface-secondary-border);
    border-radius: var(--surface-secondary-radius);
    text-align: center;
}

.token-display p {
    margin: 0;
    font-size: 1rem;
    text-align: center;
}

#copy-button {
    padding: 5px 10px; /* Reduce vertical and horizontal padding */
    font-size: 0.9em; /* Slightly smaller font size */
    background-color: var(--surface-overlay);
    border: 1px solid var(--border-color-grey);
    color: var(--text-contrast);
    border-radius: 4px; /* Slightly rounded corners */
    cursor: pointer; /* Pointer cursor on hover */
    transition: background-color 0.2s ease; /* Smooth transition for hover effect */
    margin-left: 8px;
}

#copy-button:hover {
    background-color: var(--hover-background-color);
    border-color: var(--border-color-grey);
    color: var(--text-primary);
}


/* Tier Section Styling */
.tier-section {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
    margin-top: var(--section-gap);
    margin-bottom: var(--section-gap);
}

/* Individual Tier Card Styling */
.tier-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--surface-primary-radius);
    box-shadow: none;
    width: 100%;
    padding: 1rem 1.125rem;
    margin: 0;
    text-align: left;
    height: 100%;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.tier-card:hover,
.tier-card-link:focus-visible .tier-card {
    background: var(--bg-surface);
    box-shadow: 0 4px 8px color-mix(in srgb, var(--shadow-soft) 25%, transparent);
    border-color: color-mix(in srgb, var(--border-strong) 70%, var(--border-subtle));
}

.tier-header {
    font-size: 1.4rem; /* Slightly smaller than h2 */
    font-weight: 600;
    color: var(--heading-h3);
    margin-bottom: 10px;
    text-align: center;
}

.tier-details{
    display:flex;
    flex-direction:column;
    gap:.75rem;
    margin-top:.75rem;
}

.tier-detail{
    display:flex;
    flex-direction:column;
    gap:.2rem;
}

.tier-detail-label{
    font-size:.74rem;
    font-weight:600;
    color: var(--metric-meta-label-color);
    white-space:nowrap;
}

.tier-detail-value{
    font-size:.96rem;
    font-weight:600;
    color: var(--text-secondary);
    line-height:1.35;
}

.tier-card-link {
    color: inherit; /* Ensures the text color remains unchanged */
    display: flex;
    text-decoration: none;
}

.tier-card-link:hover {
    text-decoration: none;
}




/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-wrap: wrap;
    }

    h1 {
        font-size: 2rem;
    }

    .card {
        padding: 15px;
    }

    .btn-primary {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .tier-section {
        grid-template-columns: 1fr;
    }
}



/* Code Block Styling */
/* Specific styling for the API Demo page */
.api-demo-page .container {
    max-width: 100%; /* Allow full width */
    padding: 0 20px; /* Add horizontal padding */
}

/* System status page */
.system-status-page main.container {
    max-width: 1200px;
}

.system-status-page .card {
    max-width: 100%;
}

.system-status-page .card-body {
    text-align: left;
}

.system-status-page .system-status-card__header {
    background: var(--surface-layer);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.system-status-page .card-body p {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

.system-status-page .system-status-table th,
.system-status-page .system-status-table td {
    white-space: nowrap;
}

.system-status-page .system-status-meta div {
    line-height: 1.25;
}

@media (max-width: 767.98px) {
    .system-status-page main.container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

pre {
    margin: 0.75rem 0 0;
    padding: 12px 14px;
    background: var(--surface-overlay);
    border: 1px solid var(--border-color-grey);
    border-radius: 10px;
    color: var(--text-contrast);
    overflow-x: auto;
}

pre code {
    color: inherit;
}

.api-demo-page .codecard {
    width: 90%; /* Use 90% of the viewport width */
    max-width: 1200px; /* Limit maximum width */
    margin: 20px auto; /* Center the codecard */
}

.codecard {
    background: var(--paper-color);
    border: 1px solid var(--surface-primary-border);
    border-radius: var(--surface-primary-radius);
    box-shadow: var(--surface-primary-shadow);
}

.codecard-body {
    padding: clamp(18px, 3vw, 28px);
}

.codecard-title {
    color: var(--heading-h1);
}

.codecard-text {
    color: var(--text-muted);
    text-align: left;
}

.api-demo-page .codecard-title,
.api-demo-page .codecard-text {
    text-align: left !important;
    margin-left: 0;
    margin-right: 0;
}

.code-container pre {
    margin: 0;
    padding: 16px 18px;
    background: var(--surface-overlay);
    border: 1px solid var(--border-color-grey);
    border-radius: 12px;
    color: var(--text-contrast);
    overflow-x: auto;
}

.code-container code {
    color: inherit;
}

.code-container .hljs {
    background: transparent;
    color: var(--text-primary);
}

.code-container .hljs-keyword,
.code-container .hljs-selector-tag,
.code-container .hljs-title {
    color: var(--accent);
}

.code-container .hljs-string,
.code-container .hljs-number,
.code-container .hljs-literal {
    color: var(--text-primary);
}

.code-container .hljs-comment {
    color: var(--text-muted);
}

/* --- Metric Docs Styling ---  */
/* ---------------- Metric Detail (permalink) ---------------- */
.doc table { border-collapse: separate; border-spacing: 14px 6px; width: 100%; }
.doc th:first-child, .doc td:first-child { white-space: nowrap; width: 28%; padding-right: 1.25rem; }
.doc code {
  background: var(--surface-layer);
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
  border: 1px solid var(--border-color);
}

/* ---------------- Metric Index (catalog) ------------------- */
.metrics-sticky{
  position: sticky;
  top: var(--top-bar-height);
  width: min(800px, 100%);
  margin: 0 auto var(--metrics-sticky-gap);
  z-index: 25;
  box-sizing: border-box;
  --metrics-sticky-gap: 12px;
  padding: 1rem 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  backdrop-filter: blur(8px);
}

.metrics-sticky h1{
  margin-top: 0;
  font-size: 1.9rem;
  line-height: 1.1;
}

.metrics-toolbar{
  display:flex; gap:.5rem; align-items:center;
  padding:.35rem 0 0;
}
.metrics-toolbar input[type="text"]{ flex:1; max-width:540px; }
.metrics-toolbar .results{ margin-left:auto; color: var(--text-muted); font-size:.9rem; }
.metrics-toolbar input[type="text"],
.metrics-toolbar select{
  background: var(--surface-overlay);
  color: var(--text-primary);
  border: 1px solid var(--border-color-grey);
  border-radius:8px;
  height: 38px;
  padding: 0 .65rem;
}
.metrics-toolbar input[type="text"]::placeholder{
  color: var(--text-muted);
}

.group-header{
  margin:1.2rem 0 .6rem;
  padding-bottom:.35rem;
  position: relative;
  color: var(--heading-h2); font-weight:600;
}

.group-header::after{
  content:"";
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  height:1px;
  background: var(--section-divider-line);
}
.group-header .count{ color: var(--text-muted); font-weight:600; font-size:.9rem; margin-left:.35rem; }

.metrics-grid{
  list-style:none; margin:0; padding:0;
  display:grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap:1rem;
}

.metric-card{
  background: var(--bg-surface);
  border:1px solid var(--border-subtle);
  border-radius:var(--surface-primary-radius);
  box-shadow:none;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.metric-card:hover,
.metric-card:focus-within{
  background: var(--bg-surface);
  box-shadow:0 4px 8px color-mix(in srgb, var(--shadow-soft) 25%, transparent);
  border-color: color-mix(in srgb, var(--border-strong) 70%, var(--border-subtle));
}
.metric-card:focus-within{
  border-color: var(--border-strong);
}

.metric-inner{ padding:1rem 1.125rem; }
.metric-head{
  --metric-cta-width: 88px;
  display:flex; align-items:stretch; gap:1rem;
}
.metric-head-main{
  display:flex; flex-direction:column; gap:.3rem;
  flex:1 1 auto;
  min-width:0;
}
.metric-head-actions{
  display:flex; flex-direction:column; align-items:flex-end; justify-content:flex-end;
  gap:.65rem;
  padding-top:.1rem;
  margin-left:auto;
  flex:0 0 var(--metric-cta-width);
  width:var(--metric-cta-width);
  min-width:var(--metric-cta-width);
  flex-shrink:0;
}
.metric-title{
  flex:1 1 auto;
  font-weight:600; font-size:1.12rem; color: var(--text-primary);
  text-decoration:none;
  line-height:1.3;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: manual;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  text-overflow: ellipsis;
  line-clamp:2;
}
.metric-title:hover{ text-decoration:none; }

.metric-pill{
  display:inline-flex; align-items:center; gap:.25rem;
  padding:.12rem .5rem; border-radius:6px;
  border:1px solid var(--metric-resolution-chip-border);
  background: var(--metric-resolution-chip-bg);
  color: var(--metric-chip-text-color);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:.72rem; font-weight:600; line-height:1.1;
}
.metric-pill:hover{
  border-color: color-mix(in srgb, var(--border-strong) 75%, var(--border-subtle));
  background: var(--surface-layer-pill);
}
.metric-slug{
  display:block;
  color: var(--text-secondary);
  width:100%;
  max-width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:clip;
}
 .metric-tier-text{
  white-space:nowrap;
  font-weight:500;
  color: var(--text-secondary);
  opacity:.85;
  font-size:.74rem;
}
 .metric-tier-text.tier-1{
  opacity:.9;
}
 .metric-tier-text.tier-2{
  opacity:.95;
}

/* Meta layout container */
.metric-meta{
  display:flex; flex-direction:column;
  gap:.45rem; margin-top:.75rem;
  font-size:.92rem; color: var(--text-muted);
}

.meta-row{ display:flex; align-items:baseline; gap:.5rem; min-height:1.2rem; }
.meta-label{
  font-size:.74rem; font-weight:500; color: var(--metric-meta-label-color);
}
.meta-value{
  font-weight:500; color: var(--text-secondary); opacity:.92;
}

.meta-group{ gap:.35rem; overflow:hidden; }
.meta-group .meta-label{
  color: var(--text-secondary);
  font-weight:600;
}
.meta-group .meta-value{
  font-weight:700;
  color: var(--text-secondary);
  opacity:1;
}
.meta-group-text{
  flex:1 1 auto;
  min-width:0;                 /* critical for ellipsis in flex */
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
}

.meta-split{ justify-content:space-between; }
.meta-tier{ margin-left:1rem; white-space:nowrap; }

.meta-chips{
  display:flex; flex-wrap:wrap; gap:.35rem;
}
.metric-chip{
  color: var(--metric-chip-text-color);
  border-radius:4px;
}

.meta-resolutions .meta-label{
  color: var(--metric-meta-label-color);
  opacity: var(--metric-resolution-label-opacity);
}
.meta-resolutions .metric-pill{
  color: var(--metric-chip-text-color);
  background: var(--metric-resolution-chip-bg);
  border-color: var(--metric-resolution-chip-border);
}

@media (max-width: 640px) {
  .metrics-sticky{
    padding: .85rem .9rem;
    --metrics-sticky-gap: 10px;
  }
  .metrics-sticky h1{
    font-size: 1.6rem;
  }
  .metrics-grid{
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap:.75rem;
  }
  .metric-inner{
    padding:.9rem 1rem;
  }
  .metric-head{
    --metric-cta-width: 78px;
    gap:.75rem;
  }
  .metrics-toolbar{
    flex-wrap:wrap;
    gap:.6rem;
  }
  .metrics-toolbar input[type="text"]{
    flex:1 1 100%;
    max-width:none;
  }
  .metrics-toolbar select{
    flex:0 0 auto;
    width: 140px;
  }
  .metrics-toolbar .results{
    margin-left:auto;
    width:auto;
    flex:1 1 auto;
    text-align:right;
  }
}

/* ---------------- Buttons ---------------- */
.btn{
  border:1px solid var(--border-color);
  background: var(--surface-layer);
  padding:.32rem .6rem;
  border-radius:8px;
  cursor:pointer;
  text-decoration:none;
  color: var(--text-primary);                 /* readable base text */
  line-height:1.15;
}
.btn:hover{ background: var(--hover-background-color); color: var(--text-primary); }

.btn-primary,
.btn-primary:visited{
  color: var(--text-inverse) !important;                 /* pin readable text */
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover,
.btn-primary:focus{
  color: var(--text-inverse) !important;                 /* stay readable on hover/focus */
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.btn-primary:active{
  color: var(--text-inverse) !important;
  background: color-mix(in srgb, var(--accent-strong) 85%, var(--accent));
  border-color: var(--accent-strong);
}
.btn:focus-visible{
  outline:2px solid var(--accent-border-strong);
  outline-offset:2px;
}

/* smaller, right-aligned Open button */
.open-btn,
.open-btn:visited,
.open-btn:hover,
.open-btn:focus,
.open-btn:active{
  font-size:.85rem;           /* smaller text */
  padding:.24rem .56rem;      /* tighter box */
  border-radius:6px;
  margin-left:auto;           /* ensure right-align in flex row */
  color: #f8fafc !important;
  font-weight: 700;
}

/* no underlines for links inside cards */
.metrics-grid .metric-card a,
.metrics-grid .metric-card a:hover,
.metrics-grid .metric-card a:focus { text-decoration:none; }

/* Top Bar */
.top-bar-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 500;
    background: var(--nav-glass-gradient);
    box-shadow: 0 18px 36px var(--shadow-soft);
    height: var(--top-bar-height);
}

.top-bar {
    position: relative;
    z-index: 130;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    background: var(--nav-glass-gradient);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 18px 36px var(--shadow-soft);
    column-gap: clamp(8px, 2vw, 28px);
    padding: clamp(10px, 1.2vw + 6px, 14px) clamp(16px, 4vw, 40px);
    min-height: var(--top-bar-height);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.top-brand {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 200px;
    flex: 1 1 250px;
    overflow: hidden;
}

.top-brand__logo {
    display: block;
    height: clamp(28px, 2vw + 16px, 44px);
    width: auto;
    max-width: min(280px, 40vw);
    object-fit: contain;
}

.top-brand__logo--light {
    display: none;
}

html[data-theme="light"] .top-brand__logo--light {
    display: block;
}

html[data-theme="light"] .top-brand__logo--dark {
    display: none;
}

.top-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 1.2vw, 16px);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(980px, calc(100% - 320px));
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1vw, 18px);
    margin-left: auto;
}

.top-primary-actions {
    display: flex;
    align-items: center;
    gap: clamp(10px, 1vw, 18px);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.top-link {
    text-decoration: none;
    color: var(--text-contrast);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    letter-spacing: 0.02em;
    padding: 6px 0;
    position: relative;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.top-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 100%;
    height: 2px;
    background: var(--chip-gradient);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.top-link:hover::after,
.top-link:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
}

.top-link:hover,
.top-link:focus-visible {
    color: var(--accent-strong);
    text-decoration: none;
}

.top-link .link-text {
    font-family: inherit;
    font-weight: inherit;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.theme-toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
    color: var(--text-contrast);
    font-family: inherit;
    background: var(--surface-overlay);
    border: 1px solid var(--border-color-grey);
    position: relative;
    padding: 0;
    width: 40px;
    height: 36px;
    border-radius: 12px;
    transition: border 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle-button:focus-visible {
    outline: 2px solid var(--accent-border-strong);
    outline-offset: 3px;
}

.theme-toggle-slider {
    display: none;
}

.theme-toggle-icon {
    font-size: 0.95rem;
    opacity: 0.9;
    transition: opacity 0.2s ease, color 0.2s ease;
    font-family: inherit;
}

.theme-toggle-icon--moon {
    color: currentColor;
}

.theme-toggle-icon--sun {
    color: currentColor;
}

html[data-theme="light"] .theme-toggle-icon--sun {
    opacity: 0.95;
    display: inline-flex;
}

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

html:not([data-theme="light"]) .theme-toggle-icon--moon {
    opacity: 0.95;
    display: inline-flex;
}

html:not([data-theme="light"]) .theme-toggle-icon--sun {
    display: none;
}

.topbar-auth-button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 36px;
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--border-color-grey);
    background: var(--surface-overlay);
    color: var(--text-contrast);
    cursor: pointer;
    transition: border 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.topbar-auth-button .topbar-auth-label:not(.visually-hidden) {
    display: block;
    width: 100%;
    text-align: center;
    font-weight: 700;
    font-size: 0.72rem;
    line-height: 1.05;
    word-break: keep-all;
}

.topbar-auth-button--logged-in {
    position: relative;
}

.topbar-user-tooltip {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color-grey);
    background: var(--surface-overlay);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.topbar-auth-button--logged-in:hover .topbar-user-tooltip,
.topbar-auth-button--logged-in:focus-visible .topbar-user-tooltip {
    opacity: 1;
    transform: translateY(0);
}

.topbar-auth-button:hover,
.topbar-auth-button:focus-visible,
.theme-toggle-button:hover,
.theme-toggle-button:focus-visible {
    background: var(--hover-background-color);
    outline: none;
    box-shadow: 0 8px 14px var(--shadow-soft);
}

.topbar-auth-icon {
    position: relative;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-auth-icon-mask {
    width: 18px;
    height: 18px;
    display: block;
    background-color: currentColor;
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: contain;
    -webkit-mask-position: center;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size: contain;
}

.topbar-auth-icon-mask--user {
    mask-image: url("../icons/lucide-user.svg");
    -webkit-mask-image: url("../icons/lucide-user.svg");
}

.topbar-auth-icon-mask--circle-user {
    mask-image: url("../icons/lucide-circle-user.svg");
    -webkit-mask-image: url("../icons/lucide-circle-user.svg");
}

.topbar-auth-icon-mask--key {
    mask-image: url("../icons/lucide-key-round.svg");
    -webkit-mask-image: url("../icons/lucide-key-round.svg");
}

.topbar-auth-icon-mask--user-plus {
    mask-image: url("../icons/lucide-user-plus.svg");
    -webkit-mask-image: url("../icons/lucide-user-plus.svg");
}

.topbar-auth-badge {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 10px;
    height: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--surface-overlay);
    border: 1px solid var(--border-color-grey);
    box-shadow: 0 6px 10px var(--shadow-soft);
    color: var(--text-contrast);
}

.topbar-auth-icon-mask--badge {
    width: 8px;
    height: 8px;
}

.topbar-action-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color-white);
    padding: 4px 0;
}

html[data-theme="light"] .topbar-action-link {
    color: var(--text-contrast);
}

.topbar-action-link:hover,
.topbar-action-link:focus-visible {
    color: var(--accent-strong);
    text-decoration: none;
}

.topbar-menu-button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color-grey);
    background: var(--surface-overlay);
    gap: 4px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.topbar-menu-button .hamburger-line {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: var(--text-contrast);
}

.topbar-menu-button:hover {
    background: var(--hover-background-color);
    border-color: var(--accent-soft);
}

.topbar-menu-button:focus-visible {
    outline: 2px solid var(--accent-border-strong);
    outline-offset: 2px;
}

.topbar-menu-backdrop {
    position: fixed;
    inset: 0;
    background: var(--surface-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 690;
    cursor: pointer;
}

.topbar-menu-backdrop--visible {
    opacity: 1;
    pointer-events: auto;
}

.topbar-menu-sheet {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(320px, 80vw);
    background: var(--paper-color);
    box-shadow: -8px 0 32px var(--shadow-soft);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 700;
    display: flex;
    flex-direction: column;
    padding: 26px 22px;
    overflow-y: auto;
}

.topbar-menu-sheet--open {
    transform: translateX(0);
}

.topbar-menu-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.ui-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--border-color-grey);
    background: var(--surface-overlay);
    color: var(--text-color-lightgrey);
    cursor: pointer;
    line-height: 1;
    box-shadow: none;
}

.ui-close-button:hover,
.ui-close-button:focus-visible {
    background: var(--hover-background-color);
    color: var(--text-color-white);
}

.topbar-menu-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.topbar-menu-links .top-link {
    font-size: 1rem;
}

.topbar-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.topbar-menu-theme {
    display: flex;
    justify-content: flex-start;
    width: 100%;
}

.topbar-menu-theme .theme-toggle-button {
    padding-left: 0;
}

.topbar-menu-auth {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.topbar-menu-auth-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color-grey);
    background: var(--surface-overlay);
    color: var(--text-contrast);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.topbar-menu-auth-button:hover,
.topbar-menu-auth-button:focus-visible {
    background: var(--hover-background-color);
    border-color: var(--accent-soft);
    color: var(--accent-strong);
}

.topbar-menu-divider {
    width: 100%;
    height: 1px;
    background: var(--border-color-grey);
    opacity: 0.6;
    margin: 4px 0 12px;
}

.status-line {
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-contrast);
}

.topbar-menu-contact {
    margin-top: 12px;
}

.topbar-menu-contact-link {
    color: inherit;
    font: inherit;
    text-decoration: none;
}

.topbar-menu-contact-link:hover,
.topbar-menu-contact-link:focus-visible {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

@media (max-width: 1100px) {
    .top-links {
        display: none;
    }
}

@media (max-width: 1024px) {
    .top-primary-actions {
        display: none;
    }
}

@media (min-width: 1025px) {
    .topbar-menu-actions {
        display: none;
    }
}

@media (max-width: 600px) {
    .top-bar {
        padding: clamp(8px, 2vw + 6px, 12px) clamp(12px, 6vw, 24px);
    }

    .top-brand {
        min-width: 150px;
    }

    .top-brand__logo {
        max-width: min(220px, 55vw);
    }

    .topbar-menu-button {
        width: 34px;
        height: 30px;
        flex: 0 0 auto;
    }
}

/* Modal theming */
.modal-backdrop {
    background-color: var(--overlay);
}

.modal-backdrop.show {
    opacity: 1;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .modal-backdrop {
        backdrop-filter: saturate(0.88) blur(1.5px);
        -webkit-backdrop-filter: saturate(0.88) blur(1.5px);
    }
}

.modal-dialog {
    width: min(92vw, 560px);
    max-width: 560px;
    margin: 1.5rem auto;
}

@media (max-width: 900px) and (orientation: landscape) {
    .modal-dialog {
        width: min(96vw, 760px);
        max-width: 96vw;
        margin: 0.75rem auto;
    }
}

@media (min-width: 992px) {
    .modal-dialog {
        width: min(88vw, 720px);
        max-width: 720px;
    }
}

.modal-content {
    background: var(--modal-bg);
    color: var(--text-primary);
    border: 1px solid var(--modal-border);
    box-shadow: var(--modal-shadow);
    border-radius: 16px;
}

.modal-header,
.modal-footer {
    border-color: var(--modal-header-border);
    background: transparent;
}

.modal-footer {
    gap: 0.6rem;
}

.modal-title {
    color: var(--text-primary);
    font-weight: 600;
}

.modal .close {
    color: var(--text-muted);
    opacity: 0.9;
    text-shadow: none;
    border-radius: 999px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.modal .close:hover {
    color: var(--text-primary);
    opacity: 1;
    background: var(--btn-tertiary-bg-hover);
    border-color: var(--modal-border);
}

.modal .close:focus-visible {
    color: var(--text-primary);
    opacity: 1;
    background: var(--btn-tertiary-bg-hover);
    border-color: var(--modal-border);
    box-shadow: 0 0 0 2px var(--focus-ring);
    outline: none;
}

.modal label {
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 500;
}

.modal .form-control {
    background: var(--field-bg);
    color: var(--text-primary);
    border: 1px solid var(--field-border);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.modal .form-control:hover {
    border-color: var(--field-border-hover);
}

.modal .form-control:focus {
    border-color: var(--field-border-hover);
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.modal .form-control::placeholder {
    color: var(--text-muted);
}

.modal .btn {
    border-radius: 10px;
    font-weight: 500;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease,
        border-color 0.15s ease, color 0.15s ease;
}

.modal .btn-primary {
    background: var(--btn-primary-bg);
    border: 1px solid transparent;
    color: var(--btn-primary-fg);
    font-weight: 600;
    box-shadow: 0 10px 22px color-mix(in srgb, var(--btn-primary-bg) 28%, transparent);
}

.modal .btn-primary:hover,
.modal .btn-primary:focus-visible {
    background: var(--btn-primary-bg-hover);
    color: var(--btn-primary-fg);
    transform: translateY(-1px);
    box-shadow: 0 12px 24px color-mix(in srgb, var(--btn-primary-bg) 32%, transparent);
    outline: none;
}

.modal .btn-primary:active {
    background: var(--btn-primary-bg-active);
    transform: translateY(0);
}

.modal .btn-primary:disabled,
.modal .btn-primary.disabled {
    background: var(--btn-primary-disabled-bg);
    color: var(--btn-primary-disabled-fg);
    opacity: 0.85;
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

.modal .btn-link {
    background: var(--btn-secondary-bg);
    border: 1px solid var(--btn-secondary-border);
    color: var(--btn-secondary-fg);
    text-decoration: none;
}

.modal .btn-link:hover,
.modal .btn-link:focus-visible {
    background: var(--btn-secondary-bg-hover);
    border-color: var(--btn-secondary-border-hover);
    color: var(--btn-secondary-fg);
    transform: translateY(-1px);
    outline: none;
}

.modal .btn-secondary {
    background: var(--btn-tertiary-bg);
    border: 1px solid transparent;
    color: var(--btn-tertiary-fg);
    text-decoration: none;
}

.modal .btn-secondary:hover,
.modal .btn-secondary:focus-visible {
    background: var(--btn-tertiary-bg-hover);
    color: var(--btn-tertiary-fg-hover);
    transform: translateY(-1px);
    outline: none;
}

.modal .btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--focus-ring);
}

.modal .btn:active {
    transform: translateY(0);
}

.modal .btn:disabled,
.modal .btn.disabled {
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    text-decoration: none;
}
