/*
   Career Quest responsive polish
   Loaded after style.css so the original visual design stays intact.
*/

:root {
    --cq-page-padding: clamp(14px, 3vw, 24px);
    --cq-safe-top: env(safe-area-inset-top, 0px);
    --cq-safe-right: env(safe-area-inset-right, 0px);
    --cq-safe-bottom: env(safe-area-inset-bottom, 0px);
    --cq-safe-left: env(safe-area-inset-left, 0px);
    --cq-touch-size: 48px;
    --cq-panel: rgba(15, 23, 42, 0.94);
    --cq-panel-light: rgba(248, 250, 252, 0.97);
    --cq-border: rgba(255, 255, 255, 0.13);
    --cq-shadow: 0 18px 45px rgba(2, 6, 23, 0.28);
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding-right: max(var(--cq-page-padding), var(--cq-safe-right));
    padding-bottom: max(24px, var(--cq-safe-bottom));
    padding-left: max(var(--cq-page-padding), var(--cq-safe-left));
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
.btn,
.option-btn,
.nav-links a,
.mobile-menu-toggle,
.theme-toggle,
.app-back-button,
.app-home-button {
    touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #60a5fa;
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 5000;
    padding: 12px 16px;
    border-radius: 10px;
    color: white;
    background: #2563eb;
    text-decoration: none;
    transform: translateY(-150%);
    transition: transform 0.18s ease;
}

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

.site-main {
    min-height: 60vh;
}

/* Navigation */

.navbar {
    isolation: isolate;
    gap: 18px;
}

.nav-brand-link {
    color: inherit;
    text-decoration: none;
    flex: 0 0 auto;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.mobile-menu-toggle {
    display: none;
    min-height: 42px;
    padding: 9px 13px;
    border: 1px solid var(--cq-border);
    border-radius: 12px;
    color: inherit;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 700;
    cursor: pointer;
}

.theme-toggle {
    position: static;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    margin: 0;
}

.nav-links {
    margin-left: auto;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
}

.navigation-safety-bar[hidden] {
    display: none !important;
}

.navigation-safety-bar {
    width: min(1200px, 100%);
    margin: 16px auto 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.app-back-button,
.app-home-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    border: 1px solid var(--cq-border);
    border-radius: 12px;
    color: inherit;
    background: rgba(255, 255, 255, 0.08);
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    backdrop-filter: blur(12px);
    transition: transform 0.18s ease, background 0.18s ease;
}

.app-back-button:hover,
.app-home-button:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.14);
}

body.light-mode .mobile-menu-toggle,
body.light-mode .app-back-button,
body.light-mode .app-home-button {
    border-color: rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.06);
}

/* Better controls and layout at every size */

.btn,
.option-btn {
    border: 0;
    cursor: pointer;
}

input,
select,
textarea {
    max-width: 100%;
}

.category-tabs {
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
}

.category-tab {
    scroll-snap-align: start;
    min-height: 44px;
}

.card,
.compare-card,
.match-card,
.gallery-achievement,
.saved-career-row,
.ranking-row {
    overflow-wrap: anywhere;
}

/* Quiz clarity */

.quiz-card {
    width: min(700px, 100%);
}

.quiz-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    text-align: left;
}

.quiz-heading-row h2 {
    margin-top: 5px;
    font-size: clamp(1.75rem, 6vw, 2.5rem);
    line-height: 1.08;
}

.quiz-question-count {
    flex: 0 0 auto;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 800;
}

.quiz-progress {
    width: 100%;
    height: 10px;
    margin: 18px 0 24px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.13);
}

.quiz-progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22c55e, #2dd4bf);
    transition: width 0.35s ease;
}

.quiz-options {
    display: grid;
    gap: 12px;
}

.quiz-options .option-btn {
    min-height: 56px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 18px;
    text-align: left;
    line-height: 1.35;
}

.option-arrow {
    flex: 0 0 auto;
    font-size: 1.25rem;
}

.quiz-help-text {
    margin-top: 18px;
    color: #94a3b8;
    font-size: 0.9rem;
    line-height: 1.45;
}

body.light-mode .quiz-question-count {
    border-color: rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.05);
}

body.light-mode .quiz-progress {
    background: rgba(15, 23, 42, 0.12);
}

/* Tablet */

@media (max-width: 900px) {
    body {
        padding-top: var(--cq-safe-top);
    }

    .navbar {
        position: sticky;
        top: 0;
        z-index: 2000;
        min-height: 64px;
        margin-right: calc(-1 * max(var(--cq-page-padding), var(--cq-safe-right)));
        margin-left: calc(-1 * max(var(--cq-page-padding), var(--cq-safe-left)));
        padding: 10px max(var(--cq-page-padding), var(--cq-safe-right)) 10px max(var(--cq-page-padding), var(--cq-safe-left));
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
        background: var(--cq-panel);
        border-bottom: 1px solid var(--cq-border);
        box-shadow: 0 10px 30px rgba(2, 6, 23, 0.18);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    body.light-mode .navbar {
        background: var(--cq-panel-light);
        border-color: rgba(15, 23, 42, 0.1);
    }

    .nav-logo {
        width: 38px;
        height: 38px;
        object-fit: cover;
    }

    .nav-brand {
        min-width: 0;
        font-size: 1rem;
    }

    .nav-brand span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        gap: 7px;
    }

    .nav-links {
        position: absolute;
        top: calc(100% + 8px);
        right: max(var(--cq-page-padding), var(--cq-safe-right));
        left: max(var(--cq-page-padding), var(--cq-safe-left));
        z-index: 2100;
        max-height: min(70vh, 560px);
        margin: 0;
        padding: 10px;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        overflow-y: auto;
        border: 1px solid var(--cq-border);
        border-radius: 16px;
        background: rgba(15, 23, 42, 0.985);
        box-shadow: var(--cq-shadow);
        overscroll-behavior: contain;
    }

    .nav-links.is-open {
        display: flex;
        animation: cqMenuIn 0.16s ease both;
    }

    body.light-mode .nav-links {
        border-color: rgba(15, 23, 42, 0.12);
        background: rgba(248, 250, 252, 0.99);
    }

    .nav-links a,
    .nav-player {
        width: 100%;
        min-height: var(--cq-touch-size);
        padding: 12px 14px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 9px;
        border-radius: 11px;
        background: rgba(255, 255, 255, 0.07);
        font-size: 1rem;
        white-space: normal;
    }

    body.light-mode .nav-links a,
    body.light-mode .nav-player {
        background: rgba(15, 23, 42, 0.055);
    }

    .navigation-safety-bar {
        margin-top: 12px;
    }

    .app-back-button,
    .app-home-button {
        min-height: var(--cq-touch-size);
        flex: 1 1 0;
    }

    .container,
    .result-page,
    .legal-page,
    .about-page,
    .career-detail-page {
        width: 100%;
        max-width: 100%;
    }

    .hero,
    .match-result-header,
    .saved-header,
    .leaderboard-header,
    .achievements-header,
    .compare-header {
        margin-top: 28px;
    }

    .grid,
    .match-results,
    .compare-results,
    .career-preview-grid,
    .roadmap-grid,
    .dashboard-grid,
    .dashboard-two-column,
    .profile-summary-grid,
    .achievement-gallery,
    .result-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .card {
        min-width: 0;
        min-height: 145px;
    }

    .btn,
    .option-btn,
    input,
    select,
    textarea {
        min-height: var(--cq-touch-size);
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .button-row,
    .result-actions,
    .career-detail-actions,
    .about-actions,
    .compare-actions {
        align-items: stretch;
    }

    .quiz-card,
    .result-card {
        margin: 24px auto 40px;
    }

    .result-page {
        margin-top: 24px;
    }

    .result-hero,
    .next-career-panel {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .score-ring {
        width: 145px;
        height: 145px;
    }

    .footer {
        margin-right: calc(-1 * max(var(--cq-page-padding), var(--cq-safe-right)));
        margin-left: calc(-1 * max(var(--cq-page-padding), var(--cq-safe-left)));
        padding-right: max(var(--cq-page-padding), var(--cq-safe-right));
        padding-bottom: max(24px, var(--cq-safe-bottom));
        padding-left: max(var(--cq-page-padding), var(--cq-safe-left));
    }
}

/* Phone */

@media (max-width: 700px) {
    .nav-brand span {
        display: inline;
    }

    .mobile-menu-toggle span:last-child {
        display: none;
    }

    .mobile-menu-toggle {
        width: 42px;
        min-width: 42px;
        justify-content: center;
        padding: 0;
        font-size: 1.15rem;
    }

    .navigation-safety-bar {
        position: sticky;
        top: 68px;
        z-index: 1500;
        padding: 6px 0 8px;
        background: linear-gradient(to bottom, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0));
    }

    body.light-mode .navigation-safety-bar {
        background: linear-gradient(to bottom, rgba(248, 250, 252, 0.97), rgba(248, 250, 252, 0));
    }

    .grid,
    .match-results,
    .compare-results,
    .career-preview-grid,
    .roadmap-grid,
    .dashboard-grid,
    .dashboard-two-column,
    .profile-summary-grid,
    .achievement-gallery,
    .result-summary-grid {
        grid-template-columns: 1fr;
    }

    .career-category-panel .grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    .card {
        min-height: 0;
        padding: 20px;
    }

    .card:hover,
    .btn:hover,
    .option-btn:hover {
        transform: none;
    }

    .hero {
        margin: 24px 0 30px;
    }

    .hero h1 {
        font-size: clamp(2rem, 11vw, 2.75rem);
    }

    .hero p {
        max-width: 34ch;
        margin-inline: auto;
        font-size: 1rem;
        line-height: 1.55;
    }

    .main-logo {
        width: 116px;
    }

    .name-card,
    .player-corner,
    .quiz-card,
    .result-card,
    .daily-challenge-card,
    .result-hero,
    .result-section,
    .result-stat,
    .personality-card,
    .career-detail-hero,
    .career-snapshot,
    .roadmap-block,
    .career-preview-panel,
    .legal-section,
    .about-section,
    .about-feature {
        padding: 20px;
        border-radius: 16px;
    }

    .name-card form,
    .result-actions,
    .career-detail-actions,
    .about-actions,
    .compare-actions,
    .button-row,
    .next-career-panel {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .name-card input,
    .name-card .btn,
    .result-actions .btn,
    .result-actions form,
    .result-actions form .btn,
    .career-detail-actions .btn,
    .career-detail-actions form,
    .career-detail-actions form .btn,
    .about-actions .btn,
    .compare-actions .btn,
    .button-row .btn,
    .next-career-panel .btn {
        width: 100%;
        margin: 0;
        text-align: center;
    }

    .quiz-heading-row {
        display: block;
    }

    .quiz-question-count {
        display: inline-flex;
        margin-top: 12px;
    }

    .question {
        margin: 24px 0 20px;
        font-size: 1.28rem;
        line-height: 1.42;
        text-align: left;
    }

    .scenario-box,
    .story-box {
        text-align: left;
    }

    .quiz-options .option-btn {
        min-height: 60px;
        font-size: 1rem;
    }

    .result-hero,
    .next-career-panel {
        display: block;
    }

    .score-ring {
        width: 132px;
        height: 132px;
        margin: 22px auto 0;
    }

    .score-ring strong {
        font-size: 2rem;
    }

    .section-heading-row,
    .career-browser-heading,
    .category-panel-heading,
    .dashboard-progress-top,
    .ranking-heading {
        align-items: flex-start;
        gap: 10px;
    }

    .ranking-row {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 10px;
    }

    .ranking-value {
        grid-column: 2;
    }

    .footer-brand-line,
    .footer-links {
        align-items: center;
        text-align: center;
    }
}

@media (max-width: 390px) {
    .nav-brand span {
        display: none;
    }

    .nav-controls {
        gap: 6px;
    }

    .navigation-safety-bar {
        gap: 8px;
    }

    .app-back-button,
    .app-home-button {
        padding-inline: 10px;
    }

    .quiz-card,
    .result-card,
    .name-card,
    .player-corner {
        padding: 17px;
    }

    .hero h1 {
        font-size: 2rem;
    }
}

@media (hover: none) {
    .card:hover,
    .btn:hover,
    .option-btn:hover,
    .app-back-button:hover,
    .app-home-button:hover {
        transform: none;
    }
}

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

@keyframes cqMenuIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.99);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* =====================================================
   NAVBAR + HORIZONTAL MOVEMENT REPAIR (v2)
   Keeps the header inside the safe area, opens the menu
   as a full-width panel, and locks the page to vertical pan.
===================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: hidden !important;
    overscroll-behavior-x: none;
}

@supports (overflow: clip) {
    html,
    body,
    .site-main {
        overflow-x: clip !important;
    }
}

body {
    position: relative;
    padding: 0 !important;
    touch-action: pan-y pinch-zoom;
}

body.menu-open {
    overflow: hidden !important;
}

.site-main,
.footer,
.navbar,
.navigation-safety-bar {
    width: 100%;
    max-width: 100%;
}

.site-main {
    min-width: 0;
}

.site-main > *,
.container,
.card,
.quiz-card,
.result-card,
form,
section,
article {
    min-width: 0;
}

pre,
code {
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.footer {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

.nav-links a[aria-current="page"] {
    background: rgba(59, 130, 246, 0.2);
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.35);
}

body.light-mode .nav-links a[aria-current="page"] {
    background: rgba(37, 99, 235, 0.12);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.2);
}

@media (max-width: 900px) {
    body {
        padding-top: 0 !important;
    }

    .navbar {
        position: sticky !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 3000 !important;

        width: 100% !important;
        max-width: 100% !important;
        min-height: 60px !important;
        margin: 0 !important;

        padding-top: max(8px, var(--cq-safe-top)) !important;
        padding-right: max(12px, var(--cq-safe-right)) !important;
        padding-bottom: 8px !important;
        padding-left: max(12px, var(--cq-safe-left)) !important;

        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 10px !important;

        background: rgba(15, 23, 42, 0.97) !important;
        border-bottom: 1px solid var(--cq-border);
        box-shadow: 0 8px 24px rgba(2, 6, 23, 0.22);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    body.light-mode .navbar {
        background: rgba(248, 250, 252, 0.98) !important;
    }

    .nav-brand {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: calc(100% - 108px);
        gap: 9px !important;
    }

    .nav-logo {
        flex: 0 0 auto;
        width: 38px !important;
        height: 38px !important;
        border-radius: 10px;
    }

    .nav-brand span {
        display: block !important;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1rem;
    }

    .nav-controls {
        flex: 0 0 auto !important;
        min-width: 98px;
        margin-left: auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 8px !important;
    }

    .mobile-menu-toggle,
    .theme-toggle {
        position: static !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        flex: 0 0 44px !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: inline-grid !important;
        place-items: center !important;
        border-radius: 12px !important;
        line-height: 1 !important;
        transform: none !important;
    }

    .mobile-menu-toggle span:last-child {
        display: none !important;
    }

    .nav-links {
        position: fixed !important;
        top: calc(60px + var(--cq-safe-top)) !important;
        right: max(10px, var(--cq-safe-right)) !important;
        left: max(10px, var(--cq-safe-left)) !important;
        z-index: 3100 !important;

        width: auto !important;
        max-width: none !important;
        max-height: calc(100dvh - 84px - var(--cq-safe-top) - var(--cq-safe-bottom));
        margin: 0 !important;
        padding: 10px !important;

        display: none !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 7px !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;

        border: 1px solid var(--cq-border);
        border-radius: 16px;
        background: rgba(15, 23, 42, 0.995) !important;
        box-shadow: 0 22px 60px rgba(2, 6, 23, 0.42);
    }

    .nav-links.is-open {
        display: flex !important;
    }

    body.light-mode .nav-links {
        background: rgba(248, 250, 252, 0.995) !important;
    }

    .nav-links a,
    .nav-player {
        width: 100% !important;
        min-height: 50px !important;
        flex: 0 0 auto !important;
        padding: 12px 14px !important;
        justify-content: flex-start !important;
        white-space: normal !important;
        overflow: visible !important;
    }

    .category-tabs {
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-wrap: wrap;
        overflow-x: visible !important;
        white-space: normal !important;
        scroll-snap-type: none !important;
    }

    .category-tab {
        flex: 1 1 135px;
        min-width: 0;
    }
}

@media (max-width: 700px) {
    body.has-navigation-safety .site-main {
        padding-bottom: calc(82px + var(--cq-safe-bottom));
    }

    body.has-navigation-safety .footer {
        padding-bottom: calc(96px + var(--cq-safe-bottom)) !important;
    }

    .navigation-safety-bar {
        position: fixed !important;
        top: auto !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        z-index: 2600 !important;

        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding-top: 8px !important;
        padding-right: max(12px, var(--cq-safe-right)) !important;
        padding-bottom: max(8px, var(--cq-safe-bottom)) !important;
        padding-left: max(12px, var(--cq-safe-left)) !important;

        display: flex;
        align-items: center;
        gap: 10px;

        background: rgba(15, 23, 42, 0.97) !important;
        border-top: 1px solid var(--cq-border);
        box-shadow: 0 -10px 28px rgba(2, 6, 23, 0.24);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    body.light-mode .navigation-safety-bar {
        background: rgba(248, 250, 252, 0.98) !important;
        border-top-color: rgba(15, 23, 42, 0.1);
    }

    .app-back-button,
    .app-home-button {
        min-height: 48px !important;
        margin: 0 !important;
    }
}

@media (max-width: 370px) {
    .nav-brand span {
        display: none !important;
    }

    .nav-brand {
        max-width: 50px;
    }
}


/* =====================================================
   CAREER QUEST UNIVERSAL BOTTOM NAVIGATION (v3)
   Visible on phone, tablet, desktop, and the App Store web view.
===================================================== */

:root {
    --cq-bottom-nav-height: 72px;
    --cq-topbar-height: 58px;
    --cq-bottom-nav-width: 760px;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
    overscroll-behavior-x: none;
}

@supports (overflow: clip) {
    html,
    body,
    .site-main,
    .footer {
        overflow-x: clip !important;
    }
}

body {
    min-height: 100dvh;
    margin: 0 !important;
    padding: 0 0 calc(var(--cq-bottom-nav-height) + var(--cq-safe-bottom) + 34px) !important;
    touch-action: pan-y pinch-zoom;
}

body.more-nav-open {
    overflow: hidden !important;
}

.site-main {
    width: min(1200px, 100%);
    max-width: 100%;
    min-width: 0;
    margin: 0 auto;
    padding-right: max(var(--cq-page-padding), var(--cq-safe-right));
    padding-left: max(var(--cq-page-padding), var(--cq-safe-left));
}

.footer {
    width: 100%;
    max-width: 100%;
    margin-right: 0 !important;
    margin-left: 0 !important;
    padding-bottom: 24px !important;
}

/* Slim top header: branding, back, player, theme only */

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 3000;
    width: 100%;
    padding-top: var(--cq-safe-top);
    color: white;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 26px rgba(2, 6, 23, 0.16);
    backdrop-filter: blur(20px) saturate(145%);
    -webkit-backdrop-filter: blur(20px) saturate(145%);
}

body.light-mode .app-topbar {
    color: #0f172a;
    background: rgba(248, 250, 252, 0.93);
    border-bottom-color: rgba(15, 23, 42, 0.09);
}

.app-topbar-inner {
    width: min(1200px, 100%);
    min-height: var(--cq-topbar-height);
    margin: 0 auto;
    padding: 7px max(var(--cq-page-padding), var(--cq-safe-right)) 7px max(var(--cq-page-padding), var(--cq-safe-left));
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-back-button,
.app-theme-toggle,
.topbar-player-button {
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: inherit;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

body.light-mode .topbar-back-button,
body.light-mode .app-theme-toggle,
body.light-mode .topbar-player-button {
    border-color: rgba(15, 23, 42, 0.1);
    background: rgba(15, 23, 42, 0.055);
}

.topbar-back-button,
.app-theme-toggle {
    position: static !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-grid !important;
    place-items: center !important;
    border-radius: 13px !important;
    line-height: 1 !important;
}

.topbar-back-button[hidden] {
    display: none !important;
}

.topbar-back-button svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-brand {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.app-brand-logo {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 7px 18px rgba(37, 99, 235, 0.22);
}

.app-brand span {
    overflow: hidden;
    color: inherit;
    font-size: clamp(1rem, 2vw, 1.18rem);
    font-weight: 900;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-player-button {
    max-width: 180px;
    min-height: 42px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 13px;
}

.topbar-player-button strong {
    overflow: hidden;
    font-size: 0.88rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Universal app-style bottom bar */

.bottom-app-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 4000;
    padding: 0 max(10px, var(--cq-safe-right)) max(10px, var(--cq-safe-bottom)) max(10px, var(--cq-safe-left));
    pointer-events: none;
}

.bottom-app-nav-inner {
    width: min(var(--cq-bottom-nav-width), 100%);
    min-height: var(--cq-bottom-nav-height);
    margin: 0 auto;
    padding: 7px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 24px;
    box-shadow: 0 18px 55px rgba(2, 6, 23, 0.36);
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    pointer-events: auto;
}

body.light-mode .bottom-app-nav-inner {
    color: #475569;
    background: rgba(248, 250, 252, 0.95);
    border-color: rgba(15, 23, 42, 0.11);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
}

.bottom-nav-item {
    position: relative;
    min-width: 0;
    min-height: 56px;
    margin: 0;
    padding: 7px 5px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    border-radius: 17px;
    color: inherit;
    background: transparent;
    text-decoration: none;
    font: inherit;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.bottom-nav-item svg {
    width: 23px;
    height: 23px;
    flex: 0 0 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bottom-nav-item span {
    width: 100%;
    overflow: hidden;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bottom-nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

body.light-mode .bottom-nav-item:hover {
    color: #0f172a;
    background: rgba(15, 23, 42, 0.055);
}

.bottom-nav-item.is-active {
    color: #ffffff;
    background: linear-gradient(145deg, rgba(37, 99, 235, 0.95), rgba(124, 58, 237, 0.9));
    box-shadow: 0 9px 24px rgba(37, 99, 235, 0.31), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    transform: translateY(-3px);
}

body.light-mode .bottom-nav-item.is-active {
    color: #ffffff;
}

.bottom-nav-item.is-active::after {
    content: "";
    position: absolute;
    bottom: 4px;
    left: 50%;
    width: 18px;
    height: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    transform: translateX(-50%);
}

/* More bottom sheet */

.more-nav-layer[hidden] {
    display: none !important;
}

.more-nav-layer {
    position: fixed;
    inset: 0;
    z-index: 3900;
    padding: max(16px, var(--cq-safe-top)) max(12px, var(--cq-safe-right)) calc(var(--cq-bottom-nav-height) + var(--cq-safe-bottom) + 20px) max(12px, var(--cq-safe-left));
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(2, 6, 23, 0.48);
    opacity: 0;
    transition: opacity 0.18s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.more-nav-layer.is-open {
    opacity: 1;
}

.more-nav-sheet {
    width: min(720px, 100%);
    max-height: min(680px, calc(100dvh - var(--cq-bottom-nav-height) - var(--cq-safe-top) - var(--cq-safe-bottom) - 38px));
    overflow-y: auto;
    padding: 10px 18px 18px;
    color: white;
    background: rgba(15, 23, 42, 0.985);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 26px;
    box-shadow: 0 28px 90px rgba(2, 6, 23, 0.48);
    transform: translateY(24px) scale(0.985);
    transition: transform 0.2s ease;
    overscroll-behavior: contain;
}

.more-nav-layer.is-open .more-nav-sheet {
    transform: translateY(0) scale(1);
}

body.light-mode .more-nav-sheet {
    color: #0f172a;
    background: rgba(248, 250, 252, 0.99);
    border-color: rgba(15, 23, 42, 0.1);
}

.more-nav-handle {
    width: 48px;
    height: 5px;
    margin: 1px auto 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
}

body.light-mode .more-nav-handle {
    background: rgba(15, 23, 42, 0.15);
}

.more-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.more-nav-kicker {
    display: block;
    margin-bottom: 3px;
    color: #93c5fd;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.more-nav-header h2 {
    margin: 0;
    font-size: 1.65rem;
    letter-spacing: -0.04em;
}

.more-nav-close {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 13px;
    color: inherit;
    background: rgba(255, 255, 255, 0.08);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

body.light-mode .more-nav-close {
    border-color: rgba(15, 23, 42, 0.1);
    background: rgba(15, 23, 42, 0.055);
}

.more-player-card {
    margin-bottom: 14px;
    padding: 13px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 17px;
    background: rgba(59, 130, 246, 0.11);
}

.more-player-avatar {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.1);
}

.more-player-card span:not(.more-player-avatar) {
    display: block;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 800;
}

.more-player-card strong {
    display: block;
    margin-top: 2px;
    font-size: 1rem;
}

.more-nav-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.more-nav-link {
    min-width: 0;
    min-height: 74px;
    padding: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    background: rgba(255, 255, 255, 0.065);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px;
    text-decoration: none;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

body.light-mode .more-nav-link {
    background: rgba(15, 23, 42, 0.045);
    border-color: rgba(15, 23, 42, 0.07);
}

.more-nav-link > span {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 1.35rem;
}

body.light-mode .more-nav-link > span {
    background: rgba(15, 23, 42, 0.06);
}

.more-nav-link strong,
.more-nav-link small {
    display: block;
}

.more-nav-link strong {
    font-size: 0.92rem;
}

.more-nav-link small {
    margin-top: 4px;
    color: #94a3b8;
    font-size: 0.72rem;
    line-height: 1.25;
}

.more-nav-link:hover,
.more-nav-link.is-active {
    transform: translateY(-2px);
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(96, 165, 250, 0.26);
}

.more-nav-secondary-links {
    margin-top: 14px;
    padding-top: 13px;
    display: flex;
    justify-content: center;
    gap: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

body.light-mode .more-nav-secondary-links {
    border-top-color: rgba(15, 23, 42, 0.08);
}

.more-nav-secondary-links a {
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
}

/* Remove the old top navigation and old safety bar if stale markup is cached. */

.navbar,
.navigation-safety-bar,
.mobile-menu-toggle,
.nav-links {
    display: none !important;
}

@media (max-width: 700px) {
    :root {
        --cq-bottom-nav-height: 68px;
    }

    .site-main {
        padding-right: max(12px, var(--cq-safe-right));
        padding-left: max(12px, var(--cq-safe-left));
    }

    .app-topbar-inner {
        padding-right: max(10px, var(--cq-safe-right));
        padding-left: max(10px, var(--cq-safe-left));
        gap: 8px;
    }

    .app-brand-logo {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .topbar-player-button {
        max-width: 118px;
        padding-inline: 9px;
    }

    .topbar-player-button strong {
        max-width: 72px;
    }

    .bottom-app-nav {
        padding-right: max(6px, var(--cq-safe-right));
        padding-bottom: max(6px, var(--cq-safe-bottom));
        padding-left: max(6px, var(--cq-safe-left));
    }

    .bottom-app-nav-inner {
        min-height: var(--cq-bottom-nav-height);
        padding: 5px;
        gap: 2px;
        border-radius: 20px;
    }

    .bottom-nav-item {
        min-height: 56px;
        padding-inline: 2px;
        border-radius: 15px;
    }

    .bottom-nav-item svg {
        width: 22px;
        height: 22px;
    }

    .bottom-nav-item span {
        font-size: 0.64rem;
    }

    .more-nav-layer {
        padding-right: max(8px, var(--cq-safe-right));
        padding-left: max(8px, var(--cq-safe-left));
    }

    .more-nav-sheet {
        padding: 9px 13px 15px;
        border-radius: 22px;
    }

    .more-nav-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .more-nav-link {
        min-height: 64px;
    }
}

@media (max-width: 420px) {
    .topbar-player-button {
        display: none;
    }

    .app-brand span {
        font-size: 1rem;
    }
}

@media (max-width: 350px) {
    .app-brand span {
        display: none;
    }

    .bottom-nav-item span {
        font-size: 0.59rem;
    }
}

@media (hover: none) {
    .bottom-nav-item:hover,
    .more-nav-link:hover {
        transform: none;
    }
}
