/* Theme selector and cross-theme polish for the NEU staging build. */
.portal-header {
    overflow: visible;
    position: relative;
    z-index: 40;
}

.portal-panel {
    position: relative;
    z-index: 1;
}
.portal-tools {
    min-width: 246px;
    display: grid;
    gap: 8px;
    justify-items: stretch;
}

.theme-switcher {
    position: relative;
    justify-self: stretch;
}

.theme-toggle {
    width: 100%;
    min-height: 52px;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 12px;
    gap: 9px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(50, 226, 194, 0.14), rgba(98, 197, 255, 0.08)), rgba(4, 17, 25, 0.58);
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible,
.theme-switcher.is-open .theme-toggle {
    border-color: var(--line-strong);
    background: linear-gradient(135deg, rgba(50, 226, 194, 0.24), rgba(98, 197, 255, 0.14)), rgba(5, 22, 31, 0.72);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.theme-toggle::after {
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    transform: rotate(45deg) translateY(-2px);
    content: "";
    transition: transform 160ms ease;
}

.theme-switcher.is-open .theme-toggle::after {
    transform: rotate(225deg) translate(-2px, -2px);
}

.theme-palette-icon {
    width: 32px;
    aspect-ratio: 1;
    position: relative;
    display: grid;
    place-items: center;
    border: 1px solid rgba(188, 239, 246, 0.16);
    border-radius: 10px;
    background: conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--accent-3), var(--warn), var(--accent));
    box-shadow: inset 0 0 0 3px rgba(4, 17, 25, 0.28);
}

.theme-palette-icon span {
    width: 9px;
    aspect-ratio: 1;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
}

.theme-toggle-copy {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.theme-toggle-kicker {
    color: var(--muted-2);
    font-size: 0.66rem;
    line-height: 1;
    font-weight: 950;
    text-transform: uppercase;
}

.theme-current-label {
    color: var(--ink);
    font-size: 0.91rem;
    line-height: 1.15;
    font-weight: 950;
}

.theme-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 80;
    width: min(300px, calc(100vw - 24px));
    max-height: min(74vh, 520px);
    overflow-y: auto;
    display: grid;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-strong);
    box-shadow: var(--shadow-soft);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-5px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.theme-switcher.is-open .theme-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.theme-menu button {
    width: 100%;
    min-height: 56px;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 9px;
    align-items: center;
    padding: 9px;
    border: 1px solid rgba(188, 239, 246, 0.13);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.055);
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.theme-menu button:hover,
.theme-menu button:focus-visible,
.theme-menu button.is-active {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.theme-menu button span:last-child {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.theme-menu strong {
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1.16;
}

.theme-menu small {
    color: var(--muted-2);
    font-size: 0.72rem;
    line-height: 1.2;
    font-weight: 800;
}

.theme-dot {
    width: 24px;
    aspect-ratio: 1;
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.48);
    border-radius: 999px;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.12);
}

.theme-dot-default { background: linear-gradient(135deg, #32e2c2 0 48%, #09131b 49%); }
.theme-dot-dark { background: linear-gradient(135deg, #a98cff 0 48%, #050509 49%); }
.theme-dot-graphite { background: linear-gradient(135deg, #a8c3d1 0 48%, #101316 49%); }
.theme-dot-light { background: linear-gradient(135deg, #008fa7 0 48%, #f8fbfc 49%); }
.theme-dot-ocean { background: linear-gradient(135deg, #55d9ed 0 48%, #5b8cff 49%); }
.theme-dot-forest { background: linear-gradient(135deg, #5ce095 0 48%, #0a1c12 49%); }
.theme-dot-sunset { background: linear-gradient(135deg, #ff9b63 0 48%, #ffd166 49%); }
.theme-dot-rose { background: linear-gradient(135deg, #ff79c2 0 48%, #b99cff 49%); }

html[data-theme="light"] .portal-header,
html[data-theme="light"] .portal-panel,
html[data-theme="light"] .footer-redesign,
html[data-theme="light"] .ota-header,
html[data-theme="light"] .ota-row,
html[data-theme="light"] .ota-result,
html[data-theme="light"] .zip-inline-panel,
html[data-theme="light"] .legal-document-panel,
html[data-theme="light"] .view-header,
html[data-theme="light"] .donation-view,
html[data-theme="light"] .section-head,
html[data-theme="light"] .text-reader,
html[data-theme="light"] .gate-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(242, 248, 250, 0.9)),
        var(--panel);
    box-shadow: var(--shadow-soft);
}

html[data-theme="light"] .portal-signal,
html[data-theme="light"] .portal-nav,
html[data-theme="light"] .nav-buttons,
html[data-theme="light"] .item-actions,
html[data-theme="light"] .theme-switcher,
html[data-theme="light"] .footer-link-deck a,
html[data-theme="light"] .traffic-row,
html[data-theme="light"] .latest-upload-item,
html[data-theme="light"] .path-trail a,
html[data-theme="light"] .path-current,
html[data-theme="light"] .folder-stats span,
html[data-theme="light"] .badge-14d,
html[data-theme="light"] .file-info span,
html[data-theme="light"] .metric-tile,
html[data-theme="light"] .checksum-card,
html[data-theme="light"] .zip-file,
html[data-theme="light"] .zip-browser-summary span,
html[data-theme="light"] .ota-help,
html[data-theme="light"] .ota-code,
html[data-theme="light"] .ota-select,
html[data-theme="light"] .gate-form input {
    background: rgba(255, 255, 255, 0.68);
}

html[data-theme="light"] .portal-title h1,
html[data-theme="light"] .portal-meta strong,
html[data-theme="light"] .latest-upload-head h2,
html[data-theme="light"] .latest-upload-main strong,
html[data-theme="light"] .item-name,
html[data-theme="light"] .stats-summary strong,
html[data-theme="light"] .stat-card h2,
html[data-theme="light"] .traffic-console-head strong,
html[data-theme="light"] .footer-link-deck span,
html[data-theme="light"] .donation-note,
html[data-theme="light"] .donation-card h2,
html[data-theme="light"] .view-header h2,
html[data-theme="light"] .legal-document-panel h2,
html[data-theme="light"] .legal-document-panel h3,
html[data-theme="light"] .legal-document-panel strong,
html[data-theme="light"] .ota-header h2,
html[data-theme="light"] .ota-panel-head h3,
html[data-theme="light"] .ota-help summary,
html[data-theme="light"] .zip-inline-head h2,
html[data-theme="light"] .zip-entry-copy strong,
html[data-theme="light"] .text-reader-head strong,
html[data-theme="light"] .checksum-card h2,
html[data-theme="light"] .gate-card h1,
html[data-theme="light"] .section-head h1,
html[data-theme="light"] .section-head h2,
html[data-theme="light"] .metric-tile strong {
    color: #102232;
}

html[data-theme="light"] .portal-nav a,
html[data-theme="light"] .legal-tabs a,
html[data-theme="light"] .nav-btn,
html[data-theme="light"] .pagination a,
html[data-theme="light"] .support-btn,
html[data-theme="light"] .btn-changelog,
html[data-theme="light"] .btn-zip-browse,
html[data-theme="light"] .all-stats-link,
html[data-theme="light"] .footer-support-cta,
html[data-theme="light"] .path-trail a,
html[data-theme="light"] .folder-toggle,
html[data-theme="light"] a.zip-download,
html[data-theme="light"] .ota-btn.ghost,
html[data-theme="light"] .ota-mini-btn,
html[data-theme="light"] .primary-action {
    color: #102b39;
    background: linear-gradient(135deg, rgba(0, 143, 167, 0.13), rgba(59, 113, 214, 0.1)), rgba(255, 255, 255, 0.84);
}

html[data-theme="light"] .item,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .donation-card,
html[data-theme="light"] .footer-support-copy,
html[data-theme="light"] .footer-link-deck,
html[data-theme="light"] .traffic-console,
html[data-theme="light"] .community-simple,
html[data-theme="light"] .ota-package-panel,
html[data-theme="light"] .ota-extract-panel {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.86), transparent 38%),
        var(--card);
}

html[data-theme="light"] .badge-14d,
html[data-theme="light"] .file-info span,
html[data-theme="light"] .folder-stats span,
html[data-theme="light"] .traffic-main,
html[data-theme="light"] .traffic-mirror,
html[data-theme="light"] .legal-document-panel,
html[data-theme="light"] .path-current,
html[data-theme="light"] .zip-file,
html[data-theme="light"] .zip-size,
html[data-theme="light"] .ota-help,
html[data-theme="light"] .ota-code span,
html[data-theme="light"] .ota-version-name,
html[data-theme="light"] .text-reader pre,
html[data-theme="light"] .checksum-code {
    color: #203744;
}

html[data-theme="light"] .item-icon,
html[data-theme="light"] .portal-mark,
html[data-theme="light"] .zip-entry-icon {
    background: rgba(255, 255, 255, 0.74);
}

html[data-theme="light"] .text-reader pre {
    background: rgba(255, 255, 255, 0.78);
}

html[data-theme="light"] .inline-alert.is-danger,
html[data-theme="light"] .ota-error,
html[data-theme="light"] .ota-alert-danger {
    color: #8a1f31;
}

@media (max-width: 760px) {
    .portal-brand {
        grid-template-columns: 48px minmax(0, 1fr);
        align-items: center;
    }

    .portal-tools {
        grid-column: 2;
        width: min(172px, 100%);
        min-width: 0;
        justify-self: end;
        margin-top: -3px;
    }

    .portal-tools .portal-meta {
        display: none;
    }

    .theme-toggle {
        min-height: 42px;
        grid-template-columns: 28px minmax(0, 1fr) 10px;
        gap: 8px;
        padding: 6px 9px;
        border-radius: 13px;
        background: linear-gradient(135deg, rgba(50, 226, 194, 0.24), rgba(98, 197, 255, 0.13)), rgba(4, 17, 25, 0.68);
    }

    .theme-toggle-kicker {
        font-size: 0.61rem;
    }

    .theme-current-label {
        font-size: 0.84rem;
    }

    .theme-palette-icon {
        width: 28px;
        border-radius: 9px;
    }

    .theme-menu {
        right: 0;
        left: auto;
        width: min(286px, calc(100vw - 24px));
    }
}

@media (max-width: 430px) {
    .portal-tools {
        width: min(154px, 100%);
    }

    .theme-toggle {
        min-height: 40px;
        grid-template-columns: 26px minmax(0, 1fr) 9px;
        gap: 7px;
        padding: 6px 8px;
    }

    .theme-palette-icon {
        width: 26px;
    }

    .theme-current-label {
        font-size: 0.8rem;
    }

    .theme-menu button {
        min-height: 52px;
    }
}

/* Stronger visual separation for non-default themes. */
html[data-theme="dark"] .portal-header,
html[data-theme="dark"] .portal-panel,
html[data-theme="dark"] .footer-redesign,
html[data-theme="dark"] .ota-result {
    background:
        linear-gradient(135deg, rgba(169, 140, 255, 0.1), transparent 36%),
        linear-gradient(180deg, rgba(10, 10, 18, 0.98), rgba(4, 4, 8, 0.98));
}

html[data-theme="dark"] .portal-signal,
html[data-theme="dark"] .portal-nav,
html[data-theme="dark"] .portal-meta,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .latest-upload-strip,
html[data-theme="dark"] .footer-support-copy,
html[data-theme="dark"] .footer-link-deck,
html[data-theme="dark"] .traffic-console,
html[data-theme="dark"] .community-simple,
html[data-theme="dark"] .ota-package-panel,
html[data-theme="dark"] .ota-extract-panel {
    background: rgba(8, 8, 15, 0.82);
    border-color: rgba(172, 146, 255, 0.18);
}

html[data-theme="dark"] .item,
html[data-theme="dark"] .latest-upload-item,
html[data-theme="dark"] .footer-link-deck a,
html[data-theme="dark"] .traffic-row {
    background: rgba(18, 18, 31, 0.86);
}

html[data-theme="ocean"] .portal-header,
html[data-theme="ocean"] .portal-panel,
html[data-theme="ocean"] .footer-redesign,
html[data-theme="ocean"] .ota-result {
    background:
        radial-gradient(circle at 12% 0, rgba(0, 240, 200, 0.16), transparent 30%),
        linear-gradient(135deg, rgba(51, 199, 255, 0.18), transparent 42%),
        linear-gradient(180deg, rgba(5, 45, 78, 0.98), rgba(3, 27, 49, 0.98));
}

html[data-theme="ocean"] .portal-signal,
html[data-theme="ocean"] .portal-nav,
html[data-theme="ocean"] .portal-meta,
html[data-theme="ocean"] .theme-toggle,
html[data-theme="ocean"] .latest-upload-strip,
html[data-theme="ocean"] .footer-support-copy,
html[data-theme="ocean"] .footer-link-deck,
html[data-theme="ocean"] .traffic-console,
html[data-theme="ocean"] .community-simple,
html[data-theme="ocean"] .ota-package-panel,
html[data-theme="ocean"] .ota-extract-panel {
    background: rgba(5, 52, 88, 0.78);
    border-color: rgba(87, 206, 255, 0.24);
}

html[data-theme="ocean"] .item,
html[data-theme="ocean"] .latest-upload-item,
html[data-theme="ocean"] .footer-link-deck a,
html[data-theme="ocean"] .traffic-row {
    background: rgba(8, 67, 106, 0.82);
}

/* Light theme contrast fixes. */
html[data-theme="light"] .portal-meta,
html[data-theme="light"] .theme-toggle,
html[data-theme="light"] .theme-menu,
html[data-theme="light"] .theme-menu button,
html[data-theme="light"] .latest-upload-strip,
html[data-theme="light"] .latest-upload-item,
html[data-theme="light"] .footer-support-copy,
html[data-theme="light"] .footer-link-deck,
html[data-theme="light"] .footer-link-deck a,
html[data-theme="light"] .traffic-console,
html[data-theme="light"] .community-simple,
html[data-theme="light"] .ota-package-panel,
html[data-theme="light"] .ota-extract-panel {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(35, 72, 90, 0.18);
}

html[data-theme="light"] .theme-toggle:hover,
html[data-theme="light"] .theme-toggle:focus-visible,
html[data-theme="light"] .theme-switcher.is-open .theme-toggle,
html[data-theme="light"] .theme-menu button:hover,
html[data-theme="light"] .theme-menu button:focus-visible,
html[data-theme="light"] .theme-menu button.is-active,
html[data-theme="light"] .latest-upload-item:hover,
html[data-theme="light"] .latest-upload-item:focus-visible,
html[data-theme="light"] .footer-link-deck a:hover,
html[data-theme="light"] .footer-link-deck a:focus-visible,
html[data-theme="light"] .footer-support-cta:hover,
html[data-theme="light"] .footer-support-cta:focus-visible {
    color: #0f2634;
    background: linear-gradient(135deg, rgba(0, 143, 167, 0.16), rgba(59, 113, 214, 0.12)), rgba(241, 249, 252, 0.96);
    border-color: rgba(0, 126, 150, 0.38);
}

html[data-theme="light"] .theme-toggle-kicker,
html[data-theme="light"] .theme-menu small,
html[data-theme="light"] .portal-meta span,
html[data-theme="light"] .latest-upload-folder,
html[data-theme="light"] .footer-link-deck small,
html[data-theme="light"] .footer-note,
html[data-theme="light"] .ota-eyebrow {
    color: #4a6575;
}

html[data-theme="light"] .theme-current-label,
html[data-theme="light"] .theme-menu strong,
html[data-theme="light"] .portal-meta strong,
html[data-theme="light"] .latest-upload-main strong,
html[data-theme="light"] .footer-link-deck span,
html[data-theme="light"] .donation-note,
html[data-theme="light"] .ota-panel-head h3,
html[data-theme="light"] .ota-version-name {
    color: #102232;
}

html[data-theme="light"] .footer-note a,
html[data-theme="light"] .footer-note a:visited {
    color: #006f8a;
    text-decoration-color: rgba(0, 111, 138, 0.42);
}

html[data-theme="light"] .footer-note a:hover,
html[data-theme="light"] .footer-note a:focus-visible {
    color: #004c63;
    background: rgba(0, 143, 167, 0.1);
}

html[data-theme="light"] .footer-support-cta {
    color: #0d5f55;
    background: rgba(0, 143, 167, 0.11);
    border-color: rgba(0, 143, 167, 0.3);
}

html[data-theme="light"] .ota-chip {
    color: #0d4f45;
    background: rgba(0, 143, 167, 0.1);
    border-color: rgba(0, 126, 150, 0.28);
}

html[data-theme="light"] .ota-chip-warning {
    color: #6f4300;
    background: rgba(180, 111, 0, 0.1);
    border-color: rgba(180, 111, 0, 0.28);
}

/* Light theme ZIP/package action contrast fixes. */
html[data-theme="light"] .item-file-card .item-actions,
html[data-theme="light"] .item-actions {
    background: rgba(246, 251, 253, 0.94);
    border-color: rgba(35, 72, 90, 0.18);
}

html[data-theme="light"] .item-link-label {
    color: #0f2634;
    background: linear-gradient(135deg, rgba(0, 143, 167, 0.14), rgba(59, 113, 214, 0.1)), rgba(255, 255, 255, 0.86);
    border-color: rgba(0, 126, 150, 0.3);
}

html[data-theme="light"] .btn-zip-browse,
html[data-theme="light"] .btn-changelog,
html[data-theme="light"] a.zip-download {
    color: #0f4e48;
    background: rgba(0, 143, 167, 0.12);
    border-color: rgba(0, 126, 150, 0.3);
}

html[data-theme="light"] .btn-zip-browse:hover,
html[data-theme="light"] .btn-zip-browse:focus-visible,
html[data-theme="light"] .btn-changelog:hover,
html[data-theme="light"] .btn-changelog:focus-visible,
html[data-theme="light"] a.zip-download:hover,
html[data-theme="light"] a.zip-download:focus-visible {
    color: #082f2b;
    background: rgba(0, 143, 167, 0.2);
    border-color: rgba(0, 111, 138, 0.45);
}

html[data-theme="light"] .btn-arb {
    color: #8a1f31;
    background: rgba(180, 35, 60, 0.11);
    border-color: rgba(180, 35, 60, 0.34);
}

html[data-theme="light"] .btn-arb:hover,
html[data-theme="light"] .btn-arb:focus-visible {
    color: #641222;
    background: rgba(180, 35, 60, 0.18);
    border-color: rgba(180, 35, 60, 0.48);
}

/* Light theme folder info and download metric contrast fixes. */
html[data-theme="light"] .info-box {
    color: #183242;
    background: linear-gradient(135deg, rgba(255, 226, 160, 0.42), rgba(0, 143, 167, 0.09)), rgba(255, 255, 255, 0.92);
    border-color: rgba(138, 90, 0, 0.26);
    box-shadow: 0 10px 24px rgba(45, 74, 91, 0.1);
}

html[data-theme="light"] .info-box strong {
    color: #102232;
}

html[data-theme="light"] .orangefox-link,
html[data-theme="light"] .orangefox-link:visited {
    color: #006f8a;
    text-decoration-color: rgba(0, 111, 138, 0.42);
}

html[data-theme="light"] .orangefox-link:hover,
html[data-theme="light"] .orangefox-link:focus-visible {
    color: #004c63;
    background: rgba(0, 143, 167, 0.1);
}

html[data-theme="light"] .folder-stats span,
html[data-theme="light"] .badge-14d,
html[data-theme="light"] .file-info span,
html[data-theme="light"] .zip-size {
    color: #203744;
    background: rgba(247, 252, 254, 0.94);
    border-color: rgba(35, 72, 90, 0.26);
    box-shadow: inset 0 0 0 1px rgba(0, 143, 167, 0.06);
}

html[data-theme="light"] .folder-stats .folder-stat-primary,
html[data-theme="light"] .folder-badge .badge-14d:first-child,
html[data-theme="light"] .badge-14d {
    color: #0d4f45;
    background: rgba(0, 143, 167, 0.12);
    border-color: rgba(0, 126, 150, 0.34);
}

html[data-theme="light"] .file-info strong,
html[data-theme="light"] .folder-stats strong,
html[data-theme="light"] .folder-stats .folder-stat-primary small {
    color: #006f8a;
}

/* Light theme bandwidth monitor contrast fixes. */
html[data-theme="light"] .traffic-console {
    background: linear-gradient(135deg, rgba(0, 143, 167, 0.09), rgba(59, 113, 214, 0.06)), rgba(255, 255, 255, 0.92);
    border-color: rgba(35, 72, 90, 0.24);
    box-shadow: 0 10px 24px rgba(45, 74, 91, 0.1);
}

html[data-theme="light"] .traffic-row {
    background: rgba(247, 252, 254, 0.95);
    border-color: rgba(35, 72, 90, 0.28);
    box-shadow: inset 0 0 0 1px rgba(0, 143, 167, 0.06);
}

html[data-theme="light"] .traffic-label,
html[data-theme="light"] .traffic-console-head p {
    color: #4a6575;
}

html[data-theme="light"] .traffic-main {
    color: #102232;
}

html[data-theme="light"] .traffic-mirror {
    color: #315061;
}

html[data-theme="light"] .traffic-note {
    color: #8a1f31;
    background: rgba(180, 35, 60, 0.1);
    border-color: rgba(180, 35, 60, 0.32);
}

/* Light theme donation contact contrast fixes. */
html[data-theme="light"] .donation-card .contact {
    color: #315061;
}

html[data-theme="light"] .donation-card .contact a,
html[data-theme="light"] .donation-card .contact a:visited {
    color: #006f8a;
    font-weight: 950;
    text-decoration-color: rgba(0, 111, 138, 0.42);
}

html[data-theme="light"] .donation-card .contact a:hover,
html[data-theme="light"] .donation-card .contact a:focus-visible {
    color: #004c63;
    background: rgba(0, 143, 167, 0.1);
}

/* Subtle card separation for themes with low surface contrast. */
html[data-theme="light"] .item,
html[data-theme="light"] .stat-card {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.92), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 249, 252, 0.96));
    border-color: rgba(35, 72, 90, 0.24);
    box-shadow:
        0 14px 28px rgba(45, 74, 91, 0.11),
        0 0 0 1px rgba(0, 143, 167, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] .item:hover,
html[data-theme="light"] .stat-card:hover {
    border-color: rgba(0, 126, 150, 0.42);
    box-shadow:
        0 18px 34px rgba(45, 74, 91, 0.16),
        0 0 0 1px rgba(0, 143, 167, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

html[data-theme="light"] .item::before,
html[data-theme="light"] .stat-card::before {
    opacity: 0.9;
}

html[data-theme="dark"] .item,
html[data-theme="dark"] .stat-card {
    border-color: rgba(205, 207, 232, 0.18);
    box-shadow:
        0 16px 32px rgba(0, 0, 0, 0.42),
        0 0 0 1px rgba(172, 146, 255, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .item:hover,
html[data-theme="dark"] .stat-card:hover {
    border-color: rgba(172, 146, 255, 0.45);
    box-shadow:
        0 22px 42px rgba(0, 0, 0, 0.54),
        0 0 0 1px rgba(172, 146, 255, 0.16);
}

/* Stronger card separation after visual review. */
html[data-theme="light"] .item,
html[data-theme="light"] .stat-card {
    background:
        linear-gradient(135deg, rgba(232, 247, 251, 0.7), rgba(255, 255, 255, 0.18) 44%),
        linear-gradient(180deg, #ffffff, #eef7fa);
    border-color: rgba(23, 84, 105, 0.38);
    box-shadow:
        0 16px 30px rgba(45, 74, 91, 0.18),
        0 2px 0 rgba(255, 255, 255, 0.92) inset,
        0 0 0 1px rgba(0, 111, 138, 0.16);
}

html[data-theme="light"] .item::before,
html[data-theme="light"] .stat-card::before {
    height: 4px;
    opacity: 1;
    background: linear-gradient(90deg, rgba(0, 143, 167, 0.78), rgba(59, 113, 214, 0.52), rgba(0, 143, 167, 0.06));
}

html[data-theme="light"] .item:hover,
html[data-theme="light"] .stat-card:hover {
    border-color: rgba(0, 111, 138, 0.58);
    background:
        linear-gradient(135deg, rgba(218, 243, 249, 0.86), rgba(255, 255, 255, 0.26) 44%),
        linear-gradient(180deg, #ffffff, #e8f4f8);
    box-shadow:
        0 20px 38px rgba(45, 74, 91, 0.24),
        0 2px 0 rgba(255, 255, 255, 0.95) inset,
        0 0 0 1px rgba(0, 111, 138, 0.24);
}

html[data-theme="dark"] .item,
html[data-theme="dark"] .stat-card {
    background:
        linear-gradient(135deg, rgba(169, 140, 255, 0.1), transparent 42%),
        linear-gradient(180deg, rgba(24, 24, 39, 0.96), rgba(13, 13, 23, 0.96));
    border-color: rgba(205, 207, 232, 0.28);
    box-shadow:
        0 18px 34px rgba(0, 0, 0, 0.56),
        0 0 0 1px rgba(172, 146, 255, 0.13),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .item::before,
html[data-theme="dark"] .stat-card::before {
    opacity: 1;
    background: linear-gradient(90deg, rgba(169, 140, 255, 0.82), rgba(98, 214, 255, 0.48), transparent 78%);
}

html[data-theme="dark"] .item:hover,
html[data-theme="dark"] .stat-card:hover {
    border-color: rgba(172, 146, 255, 0.62);
    box-shadow:
        0 24px 46px rgba(0, 0, 0, 0.66),
        0 0 0 1px rgba(172, 146, 255, 0.26);
}

/* Extra theme surface tuning. */
html[data-theme="graphite"] .portal-header,
html[data-theme="graphite"] .portal-panel,
html[data-theme="graphite"] .footer-redesign,
html[data-theme="graphite"] .ota-result {
    background:
        linear-gradient(135deg, rgba(168, 195, 209, 0.09), transparent 38%),
        linear-gradient(180deg, rgba(24, 29, 34, 0.98), rgba(14, 17, 20, 0.98));
}

html[data-theme="graphite"] .portal-signal,
html[data-theme="graphite"] .portal-nav,
html[data-theme="graphite"] .portal-meta,
html[data-theme="graphite"] .theme-toggle,
html[data-theme="graphite"] .latest-upload-strip,
html[data-theme="graphite"] .footer-support-copy,
html[data-theme="graphite"] .footer-link-deck,
html[data-theme="graphite"] .traffic-console,
html[data-theme="graphite"] .community-simple,
html[data-theme="graphite"] .ota-package-panel,
html[data-theme="graphite"] .ota-extract-panel {
    background: rgba(23, 29, 34, 0.82);
    border-color: rgba(156, 184, 198, 0.2);
}

html[data-theme="graphite"] .item,
html[data-theme="graphite"] .latest-upload-item,
html[data-theme="graphite"] .footer-link-deck a,
html[data-theme="graphite"] .traffic-row {
    background: rgba(31, 38, 44, 0.86);
}

html[data-theme="sunset"] .portal-header,
html[data-theme="sunset"] .portal-panel,
html[data-theme="sunset"] .footer-redesign,
html[data-theme="sunset"] .ota-result {
    background:
        radial-gradient(circle at 12% 0, rgba(255, 209, 102, 0.14), transparent 30%),
        linear-gradient(135deg, rgba(255, 111, 168, 0.1), transparent 42%),
        linear-gradient(180deg, rgba(55, 27, 18, 0.98), rgba(28, 13, 9, 0.98));
}

html[data-theme="sunset"] .portal-signal,
html[data-theme="sunset"] .portal-nav,
html[data-theme="sunset"] .portal-meta,
html[data-theme="sunset"] .theme-toggle,
html[data-theme="sunset"] .latest-upload-strip,
html[data-theme="sunset"] .footer-support-copy,
html[data-theme="sunset"] .footer-link-deck,
html[data-theme="sunset"] .traffic-console,
html[data-theme="sunset"] .community-simple,
html[data-theme="sunset"] .ota-package-panel,
html[data-theme="sunset"] .ota-extract-panel {
    background: rgba(62, 31, 20, 0.78);
    border-color: rgba(255, 152, 92, 0.24);
}

html[data-theme="sunset"] .item,
html[data-theme="sunset"] .latest-upload-item,
html[data-theme="sunset"] .footer-link-deck a,
html[data-theme="sunset"] .traffic-row {
    background: rgba(72, 36, 23, 0.84);
}

html[data-theme="rose"] .portal-header,
html[data-theme="rose"] .portal-panel,
html[data-theme="rose"] .footer-redesign,
html[data-theme="rose"] .ota-result {
    background:
        radial-gradient(circle at 12% 0, rgba(185, 156, 255, 0.15), transparent 30%),
        linear-gradient(135deg, rgba(255, 121, 194, 0.14), transparent 42%),
        linear-gradient(180deg, rgba(52, 24, 47, 0.98), rgba(27, 12, 24, 0.98));
}

html[data-theme="rose"] .portal-signal,
html[data-theme="rose"] .portal-nav,
html[data-theme="rose"] .portal-meta,
html[data-theme="rose"] .theme-toggle,
html[data-theme="rose"] .latest-upload-strip,
html[data-theme="rose"] .footer-support-copy,
html[data-theme="rose"] .footer-link-deck,
html[data-theme="rose"] .traffic-console,
html[data-theme="rose"] .community-simple,
html[data-theme="rose"] .ota-package-panel,
html[data-theme="rose"] .ota-extract-panel {
    background: rgba(58, 27, 52, 0.8);
    border-color: rgba(255, 121, 194, 0.24);
}

html[data-theme="rose"] .item,
html[data-theme="rose"] .latest-upload-item,
html[data-theme="rose"] .footer-link-deck a,
html[data-theme="rose"] .traffic-row {
    background: rgba(68, 31, 60, 0.84);
}

/* Theme-aware primary header navigation. */
html[data-theme="default"] .portal-nav {
    background: linear-gradient(90deg, rgba(50, 226, 194, 0.08), rgba(98, 197, 255, 0.06)), rgba(3, 15, 23, 0.5);
}

html[data-theme="default"] .portal-nav a {
    background: linear-gradient(135deg, rgba(50, 226, 194, 0.2), rgba(98, 197, 255, 0.13)), rgba(8, 28, 39, 0.92);
    border-color: rgba(83, 226, 214, 0.22);
}

html[data-theme="default"] .portal-nav a:hover,
html[data-theme="default"] .portal-nav a:focus-visible,
html[data-theme="default"] .portal-nav a.is-active {
    background: linear-gradient(135deg, rgba(50, 226, 194, 0.46), rgba(98, 197, 255, 0.3)), rgba(12, 42, 55, 0.98);
    border-color: rgba(83, 226, 214, 0.46);
}

html[data-theme="light"] .portal-nav {
    background: linear-gradient(90deg, rgba(0, 143, 167, 0.09), rgba(59, 113, 214, 0.06)), rgba(255, 255, 255, 0.74);
    border-top-color: rgba(35, 72, 90, 0.18);
}

html[data-theme="light"] .portal-nav a {
    color: #102b39;
    background: linear-gradient(135deg, rgba(0, 143, 167, 0.13), rgba(59, 113, 214, 0.09)), rgba(255, 255, 255, 0.92);
    border-color: rgba(0, 126, 150, 0.24);
    box-shadow: 0 8px 18px rgba(45, 74, 91, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] .portal-nav a:hover,
html[data-theme="light"] .portal-nav a:focus-visible,
html[data-theme="light"] .portal-nav a.is-active {
    color: #072733;
    background: linear-gradient(135deg, rgba(0, 143, 167, 0.28), rgba(59, 113, 214, 0.18)), rgba(242, 250, 252, 0.98);
    border-color: rgba(0, 111, 138, 0.46);
    box-shadow: 0 12px 24px rgba(45, 74, 91, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

html[data-theme="dark"] .portal-nav {
    background: linear-gradient(90deg, rgba(169, 140, 255, 0.09), rgba(255, 143, 203, 0.05)), rgba(5, 5, 10, 0.62);
}

html[data-theme="dark"] .portal-nav a {
    background: linear-gradient(135deg, rgba(169, 140, 255, 0.2), rgba(98, 214, 255, 0.08)), rgba(14, 14, 25, 0.94);
    border-color: rgba(172, 146, 255, 0.26);
}

html[data-theme="dark"] .portal-nav a:hover,
html[data-theme="dark"] .portal-nav a:focus-visible,
html[data-theme="dark"] .portal-nav a.is-active {
    background: linear-gradient(135deg, rgba(169, 140, 255, 0.46), rgba(255, 143, 203, 0.18)), rgba(20, 18, 34, 0.99);
    border-color: rgba(172, 146, 255, 0.58);
}

html[data-theme="graphite"] .portal-nav {
    background: linear-gradient(90deg, rgba(168, 195, 209, 0.08), rgba(125, 211, 199, 0.05)), rgba(13, 17, 20, 0.58);
}

html[data-theme="graphite"] .portal-nav a {
    background: linear-gradient(135deg, rgba(168, 195, 209, 0.18), rgba(125, 211, 199, 0.08)), rgba(25, 31, 36, 0.94);
    border-color: rgba(156, 184, 198, 0.28);
}

html[data-theme="graphite"] .portal-nav a:hover,
html[data-theme="graphite"] .portal-nav a:focus-visible,
html[data-theme="graphite"] .portal-nav a.is-active {
    background: linear-gradient(135deg, rgba(168, 195, 209, 0.38), rgba(125, 211, 199, 0.18)), rgba(34, 42, 48, 0.99);
    border-color: rgba(156, 184, 198, 0.54);
}

html[data-theme="ocean"] .portal-nav {
    background: linear-gradient(90deg, rgba(51, 199, 255, 0.12), rgba(0, 240, 200, 0.07)), rgba(3, 30, 52, 0.62);
}

html[data-theme="ocean"] .portal-nav a {
    background: linear-gradient(135deg, rgba(51, 199, 255, 0.22), rgba(0, 240, 200, 0.11)), rgba(7, 48, 80, 0.94);
    border-color: rgba(87, 206, 255, 0.3);
}

html[data-theme="ocean"] .portal-nav a:hover,
html[data-theme="ocean"] .portal-nav a:focus-visible,
html[data-theme="ocean"] .portal-nav a.is-active {
    background: linear-gradient(135deg, rgba(51, 199, 255, 0.46), rgba(0, 240, 200, 0.24)), rgba(7, 68, 105, 0.99);
    border-color: rgba(87, 206, 255, 0.58);
}

html[data-theme="forest"] .portal-nav {
    background: linear-gradient(90deg, rgba(92, 224, 149, 0.1), rgba(208, 214, 106, 0.06)), rgba(5, 24, 14, 0.6);
}

html[data-theme="forest"] .portal-nav a {
    background: linear-gradient(135deg, rgba(92, 224, 149, 0.2), rgba(208, 214, 106, 0.1)), rgba(12, 43, 27, 0.94);
    border-color: rgba(92, 224, 149, 0.28);
}

html[data-theme="forest"] .portal-nav a:hover,
html[data-theme="forest"] .portal-nav a:focus-visible,
html[data-theme="forest"] .portal-nav a.is-active {
    background: linear-gradient(135deg, rgba(92, 224, 149, 0.44), rgba(208, 214, 106, 0.22)), rgba(16, 58, 36, 0.99);
    border-color: rgba(92, 224, 149, 0.56);
}

html[data-theme="sunset"] .portal-nav {
    background: linear-gradient(90deg, rgba(255, 155, 99, 0.12), rgba(255, 111, 168, 0.07)), rgba(35, 15, 10, 0.62);
}

html[data-theme="sunset"] .portal-nav a {
    background: linear-gradient(135deg, rgba(255, 155, 99, 0.22), rgba(255, 209, 102, 0.12)), rgba(62, 30, 19, 0.94);
    border-color: rgba(255, 152, 92, 0.31);
}

html[data-theme="sunset"] .portal-nav a:hover,
html[data-theme="sunset"] .portal-nav a:focus-visible,
html[data-theme="sunset"] .portal-nav a.is-active {
    background: linear-gradient(135deg, rgba(255, 155, 99, 0.48), rgba(255, 111, 168, 0.22)), rgba(82, 39, 24, 0.99);
    border-color: rgba(255, 152, 92, 0.6);
}

html[data-theme="rose"] .portal-nav {
    background: linear-gradient(90deg, rgba(255, 121, 194, 0.12), rgba(185, 156, 255, 0.07)), rgba(32, 13, 28, 0.62);
}

html[data-theme="rose"] .portal-nav a {
    background: linear-gradient(135deg, rgba(255, 121, 194, 0.22), rgba(185, 156, 255, 0.12)), rgba(56, 25, 50, 0.94);
    border-color: rgba(255, 121, 194, 0.3);
}

html[data-theme="rose"] .portal-nav a:hover,
html[data-theme="rose"] .portal-nav a:focus-visible,
html[data-theme="rose"] .portal-nav a.is-active {
    background: linear-gradient(135deg, rgba(255, 121, 194, 0.48), rgba(185, 156, 255, 0.24)), rgba(76, 33, 67, 0.99);
    border-color: rgba(255, 121, 194, 0.6);
}
