/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
    --tg-viewport-height: 100vh;
    --tg-viewport-stable-height: 100vh;
}
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-subtle: rgba(59, 130, 246, 0.12);
    --border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --danger: #ef4444;
    --success: #10b981;
    --top-offset: 0;
    --menu-offset: 0;
}

[data-theme="black"] {
    --bg-primary: #000000;
    --bg-secondary: #111111;
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-subtle: rgba(59, 130, 246, 0.12);
    --border: rgba(255, 255, 255, 0.15);
    --glass-bg: rgba(10, 10, 10, 0.7);
    --danger: #ef4444;
    --success: #10b981;
    --top-offset: 0;
    --menu-offset: 0;
}

[data-theme="sunny"] {
    --bg-primary: #fffdf2;
    --bg-secondary: #fdf4d6;
    --text-primary: #3b2e1e;
    --text-secondary: #6b5a45;
    --accent: #e59a22;
    --accent-hover: #cf8419;
    --accent-subtle: rgba(229, 154, 34, 0.15);
    --border: rgba(207, 187, 160, 0.4);
    --glass-bg: rgba(255, 253, 242, 0.85);
    --danger: #dc4b4b;
    --success: #1fa373;
    --top-offset: 0;
    --menu-offset: 0;
}

/* --- HUB MODE THEMES --- */
html[data-theme="dark"] body.hub-mode {
    background-color: #171026;
    --bg-primary: #171026;
    --bg-secondary: #1e1535;
    --border: rgba(139, 92, 246, 0.12);
    --glass-bg: rgba(30, 21, 53, 0.9);
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-subtle: rgba(139, 92, 246, 0.15);
}
html[data-theme="dark"] body.hub-mode .nav,
html[data-theme="dark"] body.hub-mode .mobile-header {
    background: #171026;
}

html[data-theme="black"] body.hub-mode {
    background-color: #050010;
    --bg-primary: #050010;
    --bg-secondary: #0d0020;
    --border: rgba(139, 92, 246, 0.15);
    --glass-bg: rgba(13, 0, 32, 0.95);
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-subtle: rgba(139, 92, 246, 0.15);
}
html[data-theme="black"] body.hub-mode .nav,
html[data-theme="black"] body.hub-mode .mobile-header {
    background: #050010;
}

html[data-theme="sunny"] body.hub-mode {
    background-color: #fcf7ea;
    --bg-primary: #fcf7ea;
    --bg-secondary: #f5ead3;
    --border: rgba(216, 142, 26, 0.2);
    --glass-bg: rgba(252, 247, 234, 0.9);
    --text-primary: #4a3821;
    --text-secondary: #7d6549;
    --accent: #d88e1a;
    --accent-hover: #c47d15;
    --accent-subtle: rgba(216, 142, 26, 0.12);
}
html[data-theme="sunny"] body.hub-mode .nav,
html[data-theme="sunny"] body.hub-mode .mobile-header {
    background: #fcf7ea;
}

[dir="rtl"] {
    font-family: Tahoma, "IranSans", system-ui, sans-serif;
}


.theme-btn:hover, .lang-btn:hover {
    filter: brightness(1.1);
}
.theme-btn.active, .lang-btn.active {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 0.0625rem var(--accent);
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: var(--tg-viewport-height, 100vh);
    overflow-x: hidden;
}

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

/* =============================================
   PAGE WRAPPER
   ============================================= */
.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: var(--top-offset);
    padding-bottom: var(--menu-offset);
}

/* =============================================
   MOBILE HEADER (Top)
   ============================================= */
.mobile-header {
    display: none; /* hidden on desktop */
    background: var(--bg-primary);
    border-bottom: 0.0625rem solid var(--border);
    z-index: 1000;
}

.mobile-header-inner {
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}




/* Custom Dropdown */
.custom-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    background: transparent;
    color: var(--text-primary);
    border: 0.0625rem solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s, border-color 0.2s;
}

.dropdown-trigger:hover, .custom-dropdown.active .dropdown-trigger {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    inset-inline-end: 0;
    background: var(--bg-secondary);
    border: 0.0625rem solid var(--border);
    border-radius: 0.5rem;
    padding: 0.25rem;
    min-width: 8.125rem;
    box-shadow: 0 0.25rem 1.25rem rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.625rem);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2000;
}

.custom-dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--accent-subtle);
}

.dropdown-item.selected {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 600;
}

/* User Profile Menu Specifics */
.profile-trigger {
    padding: 0.35rem 0.6rem;
    gap: 0.4rem;
}

.profile-menu {
    min-width: 13.75rem;
    padding: 0;
    max-width: calc(100vw - 1.25rem);
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    overflow-x: hidden;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-bottom: 0.0625rem solid var(--border);
}

.profile-avatar ion-icon {
    font-size: 2.5rem;
    color: var(--accent);
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.profile-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.profile-stats {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dropdown-divider {
    height: 0.0625rem;
    background: var(--border);
    margin: 0;
}

.logout-btn {
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 0;
    padding: 0.75rem 1rem;
    color: var(--danger);
    font-family: inherit;
    justify-content: center;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* =============================================
   MAIN NAV
   ============================================= */
.nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-primary);
    border-bottom: 0.0625rem solid var(--border);
    box-shadow: 0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 75rem;
    margin: 0 auto;
    padding: 0.625rem 1.25rem;
}

.nav-items {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.nav-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.nav-center {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Brand Link in Desktop Nav */
.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.0187rem;
    white-space: nowrap;
}

.nav-brand ion-icon {
    color: var(--accent);
    font-size: 1.5rem;
    flex-shrink: 0;
}

/* Nav Links Container */
#nav-items-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

#nav-items-container a {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.875rem;
    border-radius: 0.6rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

#nav-items-container a:hover {
    background: var(--accent-subtle);
    color: var(--text-primary);
}

#nav-items-container a.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 600;
}

#nav-items-container a svg.icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.content {
    flex: 1;
    width: 100%;
    max-width: 75rem;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.0313rem;
}

/* =============================================
   GLASS CARD
   ============================================= */
.glass-card {
    background: var(--bg-secondary);
    border: 0.0625rem solid var(--border);
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.25);
}

.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    fill: currentColor;
    stroke: currentColor;
    vertical-align: -0.125em;
}

.ionicon-fill-none {
    fill: none;
}

.ionicon-stroke-width {
    stroke-width: 2rem;
    stroke: currentColor;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(0.375rem); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =============================================
   BUTTONS
   ============================================= */
.primary-btn {
    background-color: var(--accent);
    color: #fff;
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 0.25rem 0.75rem rgba(59, 130, 246, 0.3);
    white-space: nowrap;
}

.primary-btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
    transform: translateY(-0.0625rem);
    box-shadow: 0 0.375rem 1rem rgba(59, 130, 246, 0.4);
}

.primary-btn:disabled, .icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.icon-btn {
    width: 2.125rem;
    height: 2.125rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 0.0625rem solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.1);
}

.close-btn {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.65;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.125rem;
    font-size: 1rem;
    transition: opacity 0.2s;
}

.close-btn:hover { opacity: 1; }

/* =============================================
   SERVER LIST
   ============================================= */
.server-list, .users-list, .list-container {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    border: 0.0625rem solid var(--border);
    overflow: hidden;
}

.list-item {
    background: transparent;
    border-bottom: 0.0625rem solid var(--border);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: background 0.15s;
}

.list-item:last-child { 
    border-bottom: none; 
}

.list-item:hover {
    background: var(--glass-bg);
}

.list-item-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.list-item-info {
    flex: 1;
    min-width: 0;
}

.list-item-info h3 {
    font-size: 0.975rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-info small {
    color: var(--text-secondary);
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.badge {
    background: rgba(255,255,255,0.07);
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.72rem;
    font-weight: 500;
}

.list-item-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.test-status-box {
    display: none;
    align-items: flex-start;
    gap: 0.6rem;
    margin-top: 0.6rem;
    padding: 0.6rem 0.85rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.test-status-box span {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    width: 92%;
    max-width: 30rem;
    transform: translateY(1.25rem) scale(0.96);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 2rem;
    min-height: auto;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 { font-size: 1.3rem; font-weight: 700; }

.modal-header .icon-btn {
    margin-inline-end: -0.5rem;
    margin-inline-start: auto;
    background: transparent;
    color: var(--text-secondary);
}

/* =============================================
   FORM
   ============================================= */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 0.0625rem solid var(--border);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 0.1875rem var(--accent-subtle);
}

.form-input option { background: var(--bg-secondary); }

/* =============================================
   RESPONSIVE — ADAPTIVE MOBILE LAYOUT
   (Based on irandawn's CSS structure)
   ============================================= */

/* Mobile - adaptive layout (Max 52.4375rem) */
@media (max-width: 52.4375rem) {
    :root {
        --top-offset: calc(4.375rem + env(safe-area-inset-top));   /* For mobile header + safe area */
        --menu-offset: 4.0625rem;  /* For bottom nav */
    }

    .mobile-header {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    }

    .nav {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-top: 0.125rem solid var(--accent);
        border-bottom: none;
        box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.35);
    }

    body.hub-mode .nav:has(#dynamic-hub-nav:empty) {
        border-top: none;
        box-shadow: none;
    }

    .nav-container {
        padding: 0.5rem 1rem;
    }

    .nav-items {
        justify-content: center;
    }

    .nav-left, .nav-right {
        display: none !important; /* Brand and desktop selector hidden in bottom nav */
    }

    .nav-center {
        flex: 1;
    }

    #nav-items-container {
        width: 100%;
        justify-content: space-around;
        gap: 0.45em;
    }

    #nav-items-container a {
        flex: 1;
        flex-direction: column; /* Stack icon and text */
        gap: 0.25rem;
        padding: 0.375rem 0.625rem;
        font-size: 0.7rem; /* Make text tiny */
        text-align: center;
        justify-content: center;
    }

    #nav-items-container a svg.icon {
        font-size: 1.4rem;
        margin: 0 auto;
    }

    .content {
        padding: 1.5rem 1rem;
    }

    .content-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .primary-btn {
        width: auto;
        padding: 0.6rem 1rem;
    }

    h1 { font-size: 1.5rem; }
}

/* Small screens - icons only (29.9375rem and below) */
@media (max-width: 29.9375rem) {
    :root {
        --menu-offset: 3.375rem;
    }

    .nav-container {
        padding: 0.375rem 0;
    }

    /* Hide the brand text in the top mobile header */
    .nav-brand span {
        display: none;
    }

    #nav-items-container a {
        flex-direction: row; /* reset direction for centering icon perfectly */
        padding: 0.5rem;
        gap: 0;
    }

    #nav-items-container a span {
        display: none; /* hide menu text */
    }

    #nav-items-container a svg.icon {
        font-size: 1.5rem;
        margin: 0 auto;
    }
}

/* =============================================
   MOBILE DROPDOWN FIXES
   ============================================= */
@media (max-width: 52.4375rem) {
    .dropdown-menu.profile-menu,
    .dropdown-menu.hub-profile-menu {
        position: fixed !important;
        top: 4.0625rem !important; /* Just below mobile header */
        right: 0.625rem !important;
        left: auto !important;
        width: calc(100vw - 1.25rem) !important;
        max-width: 23.75rem !important;
        max-height: calc(100vh - 5rem) !important;
        z-index: 9999 !important;
        transform: translateY(-0.625rem) !important;
    }
    
    [dir="rtl"] .dropdown-menu.profile-menu,
    [dir="rtl"] .dropdown-menu.hub-profile-menu {
        right: auto !important;
        left: 0.625rem !important;
    }

    .custom-dropdown.active .dropdown-menu.profile-menu,
    .custom-dropdown.active .dropdown-menu.hub-profile-menu {
        transform: translateY(0) !important;
    }
}

/* =============================================
   CUSTOM RADIO BUTTON GRID
   ============================================= */
.panel-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.panel-type-option {
    position: relative;
    cursor: pointer;
}

.panel-type-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.panel-type-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 0.0625rem solid var(--border);
    border-radius: 0.75rem;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.panel-type-content .icon {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.panel-type-option:hover .panel-type-content {
    border-color: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.02);
}

.panel-type-option input[type="radio"]:checked + .panel-type-content {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
}

.panel-type-option input[type="radio"]:checked + .panel-type-content .icon {
    color: var(--accent);
}

/* =============================================
   LOADING SPINNER
   ============================================= */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 0.1875rem solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    flex-shrink: 0;
}

.spinner-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
}

/* Hub Profile Premium Styling */
.hub-trigger {
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.75rem;
    background: transparent;
    border: 0.0625rem solid rgba(139, 92, 246, 0.15);
    transition: all 0.2s ease;
}
.hub-trigger:hover {
    background: var(--bg-secondary);
    border-color: rgba(139, 92, 246, 0.3);
}
.hub-trigger-icon {
    width: 1.75rem; height: 1.75rem;
    border-radius: 0.5rem;
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    color: #a78bfa;
}
.hub-trigger .hub-server-name {
    font-weight: 600; font-size: 0.9rem;
    color: var(--text-primary);
    max-width: 8.75rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hub-profile-menu {
    border: 0.0625rem solid var(--border);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
    background: var(--bg-secondary);
    max-width: calc(100vw - 1.25rem);
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    overflow-x: hidden;
}
.hub-profile-menu.desktop-menu {
    min-width: 17.5rem;
    inset-inline-end: 0; inset-inline-start: auto;
}
.hub-profile-header {
    padding: 1rem 1.25rem;
    background: transparent;
    border-bottom: 0.0625rem solid var(--border);
}
.hub-profile-header-main {
    display: flex; align-items: center; gap: 1rem;
}
.hub-server-icon-large {
    width: 2.5rem; height: 2.5rem; border-radius: 0.625rem;
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    color: #a78bfa;
    border: 0.0625rem solid rgba(139,92,246,0.2);
    box-shadow: inset 0 0.125rem 0.25rem rgba(255,255,255,0.05);
}
.hub-server-icon-large .icon { font-size: 1.5rem; }
.hub-server-titles { min-width: 0; }
.hub-server-name-full {
    font-weight: 700; font-size: 1.05rem;
    color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hub-server-badges {
    display: flex; align-items: center; gap: 0.5rem; margin-top: 0.3rem;
}
.hub-server-type {
    font-size: 0.65rem; padding: 0.15rem 0.4rem;
    background: transparent; color: #a78bfa;
    border-radius: 0.25rem; font-weight: 600; letter-spacing: 0.05em;
    border: 0.0625rem solid rgba(139,92,246,0.2);
}
.hub-server-status-badge {
    font-size: 0.65rem; padding: 0.15rem 0.4rem;
    border-radius: 0.25rem; font-weight: 600;
    background: rgba(34,197,94,0.15); color: #4ade80;
    border: 0.0625rem solid rgba(34,197,94,0.2);
}
.hub-server-url-box {
    margin-top: 1rem; padding: 0.6rem 0.8rem;
    background: var(--bg-secondary); border-radius: 0.5rem;
    border: 0.0625rem solid var(--border);
    display: flex; align-items: center; gap: 0.6rem;
}
.hub-server-url-box .icon { font-size: 1rem; color: var(--text-secondary); }
.hub-server-url {
    font-size: 0.8rem; color: var(--text-secondary);
    display: block;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace;
}
.hub-profile-actions {
    padding: 0.5rem;
}
.hub-action-btn {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.75rem; border-radius: 0.625rem;
    transition: all 0.2s ease;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
}
.hub-action-btn:hover { background: var(--bg-secondary); }
.hub-action-icon {
    width: 2rem; height: 2rem; border-radius: 0.5rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.hub-action-text {
    display: flex; flex-direction: column; align-items: flex-start;
}
.hub-action-text .title { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }
.hub-action-text .desc { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.1rem; }
.exit-hub-btn { margin-top: 0.25rem; }
.exit-hub-btn .hub-action-icon {
    background: transparent; color: var(--error-color);
}

/* =============================================
   MOBILE SAFE AREA INSETS (Notches & Home Bars)
   ============================================= */
.nav, .mobile-header {
    padding-top: calc(0.5rem + env(safe-area-inset-top));
}
.bottom-sheet-content, .hub-profile-menu, .modal-content {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* =============================================
   BUTTON LOADING STATES
   ============================================= */
.btn-loading {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
    color: transparent !important;
}
.btn-loading svg, .btn-loading .icon { opacity: 0; }
.btn-loading::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1.2rem;
    height: 1.2rem;
    margin: -0.6rem 0 0 -0.6rem;
    border: 0.125rem solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* =============================================
   SKELETON LOADERS
   ============================================= */
.skeleton-card {
    background: var(--bg-secondary);
    border: 0.0625rem solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    opacity: 0.7;
    animation: pulse 1.5s infinite ease-in-out;
}
.skeleton-line {
    height: 1rem;
    background: var(--border);
    border-radius: 0.25rem;
    width: 100%;
}
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

/* --- Extracted Inline Styles --- */
.inline-div-1 { width:2.75rem;height:2.75rem;border-width:0.25rem; }
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
#login-screen { flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.inline-div-2 { width: 100%; max-width: 25rem; text-align: center; }
.inline-h2-3 { margin-bottom: 1rem; color: var(--text-primary); display:flex; align-items:center; gap:0.5rem; justify-content:center; }
.inline-img-4 { width: 1.5em; height: 1.5em; object-fit: contain; }
.inline-p-5 { color: var(--text-secondary); margin-bottom: 2rem; }
#login-error { color: #ef4444; background: rgba(239, 68, 68, 0.1); padding: 0.75rem; border-radius: 0.5rem; font-size: 0.9rem; margin-bottom: 1rem; display: none; }
.inline-p-6 { color: var(--text-secondary); margin-bottom: 2rem; font-size: 0.95rem; line-height: 1.5; }
#login-code { text-align: center; font-size: 1rem; letter-spacing: 0.1rem; margin-bottom: 1.5rem; padding: 1rem; }
.inline-button-7 { width: 100%; justify-content: center; padding: 0.8rem; }
.inline-div-8 { margin-top: 2rem; border-top: 0.0625rem solid var(--border); padding-top: 1.5rem; }
.inline-div-9 { display: flex; gap: 1.5rem; justify-content: center; }
.inline-div-10 { flex: 1; text-align: start; }
.inline-span-11 { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.5rem; display: block; }
.inline-div-12 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.inline-button-13 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: #fef3c7; color: #78350f; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-button-14 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: #1e293b; color: #f8fafc; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-button-15 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: #000000; color: #ffffff; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-div-16 { flex: 1; text-align: start; }
.inline-span-17 { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.5rem; display: block; }
.inline-div-18 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.inline-button-19 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: var(--glass-bg); color: var(--text-primary); display: flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer; transition: 0.2s; }
.inline-span-20 { font-size: 1.2rem; }
.inline-button-21 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: var(--glass-bg); color: var(--text-primary); display: flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer; transition: 0.2s; }
.inline-span-22 { font-size: 1.2rem; }
#app-page { flex-direction: column; }
.inline-img-23 { width: 1.5em; height: 1.5em; object-fit: contain; }
.inline-a-24 { display:none; color: var(--text-primary); text-decoration: none; align-items: center; gap: 0.5rem; }
.inline-svg-25 { font-size: 1.4rem; }
.inline-span-26 { font-weight: 600; }
#mobile-hub-profile { display:none; }
.inline-div-27 { flex: 1; display: flex; align-items: center; justify-content: space-between; }
.inline-div-28 { color: #60a5fa; background: transparent; }
.inline-div-29 { color: #34d399; background: transparent; }
.inline-div-30 { color: #fb923c; background: transparent; }
.inline-svg-31 { font-size: 1.4rem; color: var(--accent); }
.inline-svg-32 { font-size: 0.9em; opacity: 0.7; }
.inline-span-33 { background: transparent; color: var(--accent); }
.inline-span-34 { font-weight: 600; color: var(--success); }
.inline-span-35 { font-size: 0.85rem; color: var(--text-secondary); }
.inline-div-36 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.75rem; }
.inline-button-37 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: #fef3c7; color: #78350f; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-button-38 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: #1e293b; color: #f8fafc; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-button-39 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: #000000; color: #ffffff; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-span-40 { font-size: 0.85rem; color: var(--text-secondary); }
.inline-div-41 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.inline-button-42 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: var(--glass-bg); color: var(--text-primary); display: flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer; transition: 0.2s; }
.inline-span-43 { font-size: 1.2rem; }
.inline-button-44 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: var(--glass-bg); color: var(--text-primary); display: flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer; transition: 0.2s; }
.inline-span-45 { font-size: 1.2rem; }
.inline-img-46 { width: 1.5em; height: 1.5em; object-fit: contain; }
.inline-a-47 { display:none; color: var(--text-primary); text-decoration: none; align-items: center; gap: 0.5rem; }
.inline-svg-48 { font-size: 1.4rem; }
.inline-span-49 { font-weight: 600; }
#nav-users { display:none; }
#nav-settings { display:none; }
#dynamic-hub-nav { display: contents; }
#desktop-hub-profile { display:none; }
.inline-div-50 { flex: 1; display: flex; align-items: center; justify-content: space-between; }
.inline-div-51 { color: #60a5fa; background: transparent; }
.inline-div-52 { color: #34d399; background: transparent; }
.inline-div-53 { color: #fb923c; background: transparent; }
.inline-svg-54 { font-size: 1.4rem; color: var(--accent); }
.inline-svg-55 { font-size: 0.9em; opacity: 0.7; }
.inline-span-56 { background: transparent; color: var(--accent); }
.inline-span-57 { font-weight: 600; color: var(--success); }
.inline-span-58 { font-size: 0.85rem; color: var(--text-secondary); }
.inline-div-59 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.75rem; }
.inline-button-60 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: #fef3c7; color: #78350f; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-button-61 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: #1e293b; color: #f8fafc; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-button-62 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: #000000; color: #ffffff; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.inline-span-63 { font-size: 0.85rem; color: var(--text-secondary); }
.inline-div-64 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.inline-button-65 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: var(--glass-bg); color: var(--text-primary); display: flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer; transition: 0.2s; }
.inline-span-66 { font-size: 1.2rem; }
.inline-button-67 { padding: 0.5rem; border-radius: 0.5rem; border: 0.0625rem solid var(--border); background: var(--glass-bg); color: var(--text-primary); display: flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer; transition: 0.2s; }
.inline-span-68 { font-size: 1.2rem; }
.inline-div-69 { text-align: center; margin-top: 3rem; color: var(--text-secondary); }
.inline-svg-70 { font-size: 4rem; opacity: 0.5; margin-bottom: 1rem; }
.inline-div-71 { height: 4.5rem; }
.inline-div-72 { height: 4.5rem; }
.inline-div-73 { height: 4.5rem; }
.inline-div-74 { height: 7.5rem; }
.inline-div-75 { height: 7.5rem; }
.inline-div-76 { height: 7.5rem; }
.inline-h3-77 { margin-bottom: 0.35rem; display: flex; align-items: center; gap: 0.5rem; }
.inline-svg-78 { color: var(--accent); }
.inline-small-79 { color: var(--text-secondary); }
.inline-span-80 { background: rgba(255,255,255,0.1); padding: 0.2rem 0.5rem; border-radius: 0.25rem; margin-right: 0.5rem; }
.inline-span-81 { color: #10b981; }
.inline-button-82 { color: #ef4444; }
.inline-div-83 { display: none; }
.inline-span-84 { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.inline-p-85 { color: var(--text-secondary); margin-bottom: 1rem; min-height: 2.5rem; }
.inline-div-86 { margin-top: 1rem; border-top: 0.0625rem solid var(--border); padding-top: 1rem; display: flex; gap: 0.5rem; justify-content: flex-end; }
.inline-button-87 { color: #ef4444; }
.inline-div-88 { display: flex; flex-direction: column; }
.inline-h3-89 { margin-bottom: 0.35rem; display: flex; align-items: center; gap: 0.5rem; }
.inline-svg-90 { color: var(--accent); font-size: 1.2rem; }
.inline-small-91 { color: var(--text-secondary); }
.inline-span-92 { padding: 0.2rem 0.5rem; border-radius: 0.25rem; margin-right: 0.5rem; text-transform: uppercase; }
.inline-span-93 { color: #10b981; }
.inline-div-94 { text-align: center; padding: 1rem 0; }
.inline-svg-95 { font-size: 4rem; color: #ef4444; margin-bottom: 1rem; }
.inline-p-96 { margin-bottom: 2rem; font-size: 1.1rem; color: var(--text-primary); }
.inline-span-97 { font-size: 0.9rem; color: var(--text-secondary); }
.inline-div-98 { display:flex; gap: 1rem; }
.inline-button-99 { flex:1; background: var(--bg-secondary); border: 0.0625rem solid var(--border); box-shadow: none; justify-content:center; }
.inline-button-100 { flex:1; background: #ef4444; box-shadow: 0 0.25rem 0.75rem rgba(239, 68, 68, 0.4); justify-content:center; }

/* View Transitions for smooth & fast nav switching */
#main-view {
  view-transition-name: main-content;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}

::view-transition-old(main-content),
::view-transition-new(main-content) {
  animation-duration: 0.15s;
  animation-timing-function: ease-out;
}

::view-transition-old(main-content) {
  animation-name: fade-out-fast;
}

::view-transition-new(main-content) {
  animation-name: fade-in-fast;
}

::view-transition-group(main-content) {
  animation: none;
}

@keyframes fade-in-fast {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out-fast {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Global Toast (List Status) */
#list-status {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    display: none;
    z-index: 9999;
    transition: opacity 0.3s ease;
    box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.5);
    color: #fff;
}
#list-status.show {
    display: block;
}
#list-status.visible {
    opacity: 1;
}
#list-status.success {
    background: #10b981;
}
#list-status.error {
    background: #ef4444;
}
