/* 
   Ghost Protocol Header & Toolbar SSR Styles
   Extracted from header.js to eliminate layout shift 
*/

:root {
    --bg: #0b0f14;
    --card: #111827;
    --card-soft: #020617;
    --primary: #00ffa3;
    --blue: #4da6ff;
    --purple: #a855f7;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --danger: #ff3b3b;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top, #1f2937, #020617 70%);
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    font-family: system-ui, -apple-system, sans-serif;
}

* {
    font-family: inherit;
    box-sizing: border-box;
}

h1 {
    text-align: center;
}

.container {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

.subtitle {
    text-align: center;
    color: var(--muted);
    margin-bottom: 30px;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

/* Global trust banner / features section */
.features {
    display: flex;
    justify-content: center;
    gap: 50px;
    flex-wrap: wrap;
    margin: 30px 0;
    padding: 25px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.feature {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.feature-text {
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .features {
        gap: 20px;
        padding: 15px;
    }

    .feature-icon {
        font-size: 1.5rem;
    }

    .feature-text {
        font-size: 0.8rem;
    }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 60px;
    padding: 0 20px;
    transition: padding 0.3s;
}

/* Desktop: fixed header */
@media (min-width: 769px) {
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 10001;
        /* Constrain content to ~1300px centered, background stays full-width */
        padding: 0 max(40px, calc((100vw - 1300px) / 2));
        margin-bottom: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    body {
        padding-top: 90px;
    }

    /* Normalize container spacing across all pages on desktop */
    .container {
        margin-top: 0;
        padding-top: 24px;
    }
}

/* Flash protection: if session token detected, hide login link immediately */
.is-logged-in-potential #header-account-link {
    display: none !important;
}

/* Desktop anti-flicker: pre-apply toolbar spacing + show toolbar before async API resolves */
@media (min-width: 769px) {
    html.is-logged-in-potential body:not(.pwa-mode) {
        padding-top: 141px;
    }
    /* Show toolbar immediately — higher specificity beats .toolbar-hidden */
    html.is-logged-in-potential #services-toolbar {
        display: flex !important;
        position: fixed !important;
        top: 70px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 1001 !important;
        margin: 0 !important;
    }
    /* Pre-allocate credits badge space without showing "0 Credits" */
    html.is-logged-in-potential #header-credits {
        display: inline-block !important;
        visibility: hidden;
    }
}

/* Mobile nav center slot: account visible by default, panic hidden */
#mobilePanicBtn { display: none; width: 52px; height: 52px; flex: none; gap: 0; }
#mobilePanicBtn .mb-nav-panic-icon { margin-top: 0; }
#mobilePanicBtn .mb-nav-label { margin-top: -4px; }

/* Logged-in state: swap center slot */
.mobile-bottom-nav.center-logged-in #mb-account-btn { display: none !important; }
.mobile-bottom-nav.center-logged-in #mobilePanicBtn  { display: flex !important; }

.pwa-mode .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(80px + env(safe-area-inset-top));
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10001;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: calc(env(safe-area-inset-top) + 8px) 20px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
}

.pwa-mode .header .header-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
}

.pwa-mode .header .logo {
    font-size: 1.2rem;
}

.pwa-mode .header .header-pwa-extras {
    display: flex !important;
    align-items: center;
    gap: 10px;
}

.pwa-mode .header .pwa-flags {
    display: flex;
    gap: 4px;
}

.pwa-mode .header .lang-btn {
    font-size: 1rem;
}

.pwa-mode .header .pwa-account-btn {
    text-decoration: none;
    font-size: 1.1rem;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.pwa-mode .header .nav {
    display: none !important;
}

.mobile-bottom-nav {
    z-index: 10002 !important;
    /* Always on top */
}

.pwa-mode #header-credits {
    display: none !important;
    /* Hide credits in PWA */
}

.pwa-mode .header-links {
    display: none !important;
    /* Hide desktop links in PWA header */
}

body.pwa-mode {
    padding-top: calc(95px + env(safe-area-inset-top)) !important;
    padding-bottom: calc(85px + env(safe-area-inset-bottom)) !important;
    overflow-x: hidden;
}

/* PWA standalone mode adjustments */
.pwa-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    /* Action buttons shouldn't shrink */
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 75px;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    justify-content: space-around;
    align-items: center;
    z-index: 10000;
    padding-bottom: env(safe-area-inset-bottom);
    margin: 0;
    /* Force no margin */
}

/* Docked PANIC inside the bottom nav — overrides the default large circle */
.mobile-bottom-nav .mb-nav-panic {
    width: 52px;
    height: 52px;
    flex: none;
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 18px rgba(255, 59, 59, 0.8), 0 0 36px rgba(255, 59, 59, 0.4);
    cursor: pointer;
}

.mb-nav-item,
.mb-nav-panic {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #9ca3af;
    font-size: 0.7rem;
    font-weight: 600;
    gap: 4px;
    flex: 1;
    transition: 0.2s;
    cursor: pointer;
    position: relative;
    /* Fix for absolute badge */
}

.mb-nav-item.active {
    color: #00ffa3;
}

.panic-holding {
    animation: panic-pulse 0.2s infinite alternate !important;
}

@keyframes panic-pulse {
    from {
        transform: scale(1);
        filter: brightness(1);
    }

    to {
        transform: scale(0.95);
        filter: brightness(1.2);
    }
}

.mb-nav-icon,
.mb-nav-panic-icon {
    font-size: 1.5rem;
}

.mb-nav-badge {
    position: absolute;
    top: 2px;
    right: 20%;
    background: #ff3b3b;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 10px;
    min-width: 14px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(255, 59, 59, 0.4);
}

.mb-nav-panic {
    position: relative;
    background: #dc2626 !important;
    border: 2px solid #ff3b3b;
    border-radius: 50%;
    width: 65px;
    height: 65px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(255, 59, 59, 0.3);
    color: #fff;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.mb-nav-panic .mb-nav-panic-icon {
    color: #fff;
}

.mb-nav-panic .mb-nav-label {
    font-size: 0.6rem;
}

/* Center spacer for PANIC FAB */

/* Button reset for nav items rendered as <button> */
button.mb-nav-item {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    color: #9ca3af;
}

/* ===== Action Sheets ===== */
.action-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10003;
}
.action-sheet-overlay.active { display: block; }

.action-sheet {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    width: calc(100% - 32px);
    max-width: 420px;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 12px 8px 16px;
    z-index: 10004;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.action-sheet.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.action-sheet-handle {
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    margin: 0 auto 12px;
}

.action-sheet-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    color: #e5e7eb;
    text-decoration: none;
    border-radius: 16px;
    transition: background 0.15s;
    font-weight: 600;
    font-size: 1rem;
    position: relative;
}
.action-sheet-item:active {
    background: rgba(255, 255, 255, 0.08);
}

.action-sheet-icon {
    font-size: 1.4rem;
    width: 36px;
    text-align: center;
    flex-shrink: 0;
}

.action-sheet-badge {
    margin-left: auto;
    background: #ff3b3b;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* Hide top nav on PWA */
body.pwa-mode .header .nav {
    display: none;
}

body.pwa-mode .services-toolbar {
    display: none !important;
}

body.pwa-mode .mobile-bottom-nav {
    display: flex !important;
}

/* Desktop / Large mobile toolbar */
/* Mobile Bottom Navigation - Controlled by header.js */
.mobile-bottom-nav {
    display: none;
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    text-decoration: none;
    color: var(--text, #e5e7eb);
    white-space: nowrap;
}

.logo span {
    color: var(--primary, #00ffa3);
}

.nav {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav>a,
.nav .dropdown-toggle {
    color: var(--muted, #9ca3af);
    text-decoration: none;
    transition: 0.2s;
    white-space: nowrap;
}

.nav>a:hover,
.nav>a.active,
.nav .dropdown-toggle:hover {
    color: var(--primary, #00ffa3);
}

.nav>a.credits-badge {
    color: var(--primary, #00ffa3);
}

/* Dropdown menu */
.nav-dropdown {
    position: relative;
}

.dropdown-toggle {
    cursor: pointer;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card, #1e293b);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 0;
    min-width: 180px;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.nav-dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text, #e5e7eb);
    text-decoration: none;
    transition: 0.2s;
    white-space: nowrap;
}

.dropdown-menu a:hover {
    background: rgba(0, 255, 163, 0.1);
    color: var(--primary, #00ffa3);
}

/* Credits badge */
.credits-badge {
    background: rgba(0, 255, 163, 0.15);
    color: var(--primary, #00ffa3);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    display: none;
    text-decoration: none;
    white-space: nowrap;
}

.credits-badge:hover {
    background: rgba(0, 255, 163, 0.25);
}

.credits-badge.danger {
    background: rgba(255, 59, 59, 0.15);
    color: var(--danger);
}

.inbox-badge {
    background: linear-gradient(135deg, #374151, #1f2937);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    display: none;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.inbox-badge:hover {
    background: linear-gradient(135deg, #4b5563, #374151);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.inbox-badge.visible {
    display: inline-block;
}

.inbox-badge.has-messages {
    background: linear-gradient(135deg, var(--danger), #ff6b6b);
    color: white;
    border-color: var(--danger);
    box-shadow: 0 2px 8px rgba(255, 59, 59, 0.4);
    animation: pulse 2s infinite;
}

.inbox-badge.has-messages:hover {
    background: linear-gradient(135deg, #ff6b6b, var(--danger));
    box-shadow: 0 4px 12px rgba(255, 59, 59, 0.5);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.lang-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    filter: grayscale(1);
    transition: 0.2s;
    padding: 4px;
}

.lang-btn:hover,
.lang-btn.active {
    opacity: 1;
    filter: grayscale(0);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 30px;
        padding: 0 10px;
    }

    .logo {
        font-size: 1.2rem;
    }

    .nav {
        gap: 8px;
        justify-content: center;
        font-size: 0.85rem;
    }

    .nav>a,
    .nav .dropdown-toggle {
        padding: 4px 8px;
    }

    .credits-badge {
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    .dropdown-menu {
        position: fixed;
        left: 50%;
        top: auto;
        min-width: 200px;
    }

    .lang-btn {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .nav {
        gap: 6px;
        font-size: 0.8rem;
    }

    .nav>a,
    .nav .dropdown-toggle {
        padding: 3px 6px;
    }
}

/* Footer responsive — prevent overflow on mobile */
@media (max-width: 768px) {
    .footer {
        padding: 30px 20px !important;
        box-sizing: border-box;
        width: 100%;
        overflow-wrap: break-word;
    }

    .footer-links,
    .news-footer-links {
        flex-wrap: wrap !important;
        gap: 12px 20px !important;
        padding: 0 10px;
    }
}

/* ===================== */
/* Services Toolbar      */
/* ===================== */
.services-toolbar {
    display: flex;
    justify-content: center !important;
    gap: 8px !important;
    padding: 10px 20px !important;
    margin: 0 auto 16px !important;
    width: max-content !important;
    max-width: 95vw !important;
    background: rgba(30, 41, 59, 0.6) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    z-index: 1000;
    position: sticky;
    top: 70px;
}

.toolbar-hidden {
    display: none !important;
}

.tb-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    color: var(--muted, #9ca3af);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tb-item:hover {
    color: var(--primary, #00ffa3);
    background: rgba(0, 255, 163, 0.08);
    transform: translateY(-1px);
}

.tb-item.tb-active {
    color: var(--primary, #00ffa3);
    background: rgba(0, 255, 163, 0.12);
    box-shadow: 0 0 12px rgba(0, 255, 163, 0.15);
}

.tb-item.tb-disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.tb-icon {
    font-size: 1rem;
}

.tb-inbox-badge {
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
    line-height: 1;
}

@media (max-width: 768px) {
    .services-toolbar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 10px;
        margin: -15px auto 20px;
        max-width: 320px;
    }

    .tb-item {
        flex-direction: column;
        padding: 14px 8px;
        gap: 5px;
        border-radius: 14px;
        justify-content: center;
        align-items: center;
        font-size: 0.75rem;
    }

    .tb-label {
        display: block;
        font-size: 0.72rem;
        text-align: center;
    }

    .tb-icon {
        font-size: 1.8rem;
    }

    .tb-inbox-badge {
        position: absolute;
        top: 5px;
        right: 5px;
        font-size: 0.65rem;
        padding: 2px 5px;
        min-width: 16px;
        text-align: center;
    }
}

/* Contact Modal */
.contact-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.contact-modal-overlay.active {
    display: flex;
}

.contact-modal {
    background: #111827;
    border-radius: 20px;
    padding: 35px;
    max-width: 420px;
    width: 90%;
    border: 1px solid rgba(0, 255, 163, 0.15);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: contactSlideIn 0.25s ease;
}

@keyframes contactSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.contact-modal h3 {
    margin: 0 0 20px 0;
    color: #e5e7eb;
    font-size: 1.3rem;
    text-align: center;
}

.contact-option {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 12px;
    text-decoration: none;
    color: #e5e7eb;
    transition: all 0.2s;
    cursor: pointer;
}

.contact-option:hover {
    border-color: #00ffa3;
    background: rgba(0, 255, 163, 0.06);
    transform: translateY(-2px);
}

.contact-option .co-icon {
    font-size: 1.8rem;
}

.contact-option .co-info {
    flex: 1;
}

.contact-option .co-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 3px;
}

.contact-option .co-desc {
    color: #9ca3af;
    font-size: 0.82rem;
}

.contact-option .co-badge {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
}

.contact-modal-close {
    display: block;
    margin: 15px auto 0;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #9ca3af;
    padding: 8px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
}

.contact-modal-close:hover {
    border-color: #00ffa3;
    color: #00ffa3;
}

/* Panic Group Refined */
.panic-group-container {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #ff3b3b 0%, #cc2b2b 100%);
    border-radius: 12px;
    padding: 2px;
    margin-left: 8px;
    box-shadow: 0 4px 15px rgba(255, 59, 59, 0.3);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.panic-group-container:hover {
    box-shadow: 0 6px 22px rgba(255, 59, 59, 0.5);
    transform: translateY(-1px);
}

.btn-panic-header {
    background: transparent !important;
    border: none !important;
    color: white !important;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    padding: 8px 16px !important;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.panic-info-tooltip {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: white;
    font-family: serif;
    font-style: italic;
    font-weight: bold;
    font-size: 13px;
    margin-right: 8px;
    cursor: help;
    transition: all 0.2s;
}

.panic-info-tooltip:hover {
    background: rgba(255, 255, 255, 0.3);
}

.panic-tooltip-content {
    visibility: hidden;
    position: absolute;
    bottom: 140%;
    right: -10px;
    background: #1e293b;
    color: #e5e7eb;
    text-align: left;
    padding: 12px;
    border-radius: 12px;
    width: 200px;