:root {
    --bg-deep: #07070a;
    --bg-surface: #0c0c12;
    --bg-elevated: #111118;
    --bg-card: #16161f;
    --bg-card-hover: #1c1c28;
    --bg-inset: #0a0a0f;
    --accent: #e94560;
    --accent-glow: rgba(233, 69, 96, 0.25);
    --accent-soft: rgba(233, 69, 96, 0.1);
    --text: #eeeef0;
    --text-secondary: #88889a;
    --text-muted: #555566;
    --border: #1e1e2a;
    --border-light: #2a2a3a;
    --success: #4ade80;
    --error: #f87171;
    --warning: #fbbf24;
    --info: #60a5fa;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow: 0 4px 24px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);
    --transition: 200ms ease;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
    --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
}

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

html, body { -webkit-user-select: none; user-select: none; }
.pack-entry, .pack-entry *, .ctx-menu, .ctx-menu * { -webkit-user-select: none; user-select: none; }
input, textarea, [contenteditable], .log-viewer-content, .news-modal-body, .pack-description-text { -webkit-user-select: text; user-select: text; }
.pack-entry { -webkit-touch-callout: default; }

html { font-size: 14px; }

body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#bg-canvas {
    position: fixed; inset: 0; width: 100%; height: 100%;
    z-index: 0; opacity: 0.14; pointer-events: none;
}
#login-screen.exiting { pointer-events: none; }
.login-container.exit { will-change: transform, opacity, filter; }
#bg-canvas.bg-exit { will-change: transform; }

#app { position: relative; z-index: 1; height: 100vh; display: flex; }

.screen {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.screen.hidden { opacity: 0; transform: scale(0.97); pointer-events: none; }

.hidden { display: none !important; }

/* ========== LOGIN ========== */
.login-container {
    position: relative; z-index: 1;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 32px 32px 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    transition: transform 0.35s ease, opacity 0.35s ease;
}

.login-header { text-align: center; margin-bottom: 28px; overflow: hidden; }
.brand-icon { margin-bottom: 12px; }
.login-title {
    font-size: 22px; font-weight: 700;
    color: var(--text); transition: transform 0.3s ease, opacity 0.3s ease;
}
.login-subtitle {
    color: var(--text-muted); font-size: 13px; margin-top: 4px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.field input {
    width: 100%; padding: 10px 12px; font-size: 15px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 4px; color: var(--text);
    font-family: var(--font); transition: border-color 150ms ease, box-shadow 150ms ease;
    outline: none;
}
.field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}
.field input.invalid {
    border-color: var(--error);
    box-shadow: 0 0 0 2px rgba(248,113,113,0.15);
}
.field .field-hint {
    font-size: 12px; color: var(--error); line-height: 1.4;
}
.field .field-hint.hidden { display: none; }
.field select {
    width: 100%; padding: 10px 12px; font-size: 15px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 4px; color: var(--text);
    font-family: var(--font); cursor: pointer; outline: none;
}
.field select:focus { border-color: var(--accent); }
#confirm-field {
    transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
    overflow: hidden; max-height: 60px; opacity: 1; margin: 0;
}
#confirm-field.hidden { max-height: 0; opacity: 0; margin: 0; display: block !important; padding: 0; overflow: hidden; pointer-events: none; }

.btn-primary {
    width: 100%; padding: 14px; border: none; border-radius: 4px;
    background: var(--accent); color: #fff;
    font-size: 14px; font-weight: 600; cursor: pointer;
    font-family: var(--font); transition: background 150ms ease, box-shadow 150ms ease;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; position: relative;
}
.btn-primary:hover { background: #d63850; }
.btn-primary:active { background: #c22f46; transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.error-msg {
    color: var(--error); font-size: 13px; text-align: center;
    padding: 10px; background: rgba(248,113,113,0.1);
    border-radius: 4px; animation: shake 0.4s ease;
}
@keyframes shake {
    0%,100%{transform:translateX(0)}20%{transform:translateX(-4px)}40%{transform:translateX(4px)}60%{transform:translateX(-3px)}80%{transform:translateX(3px)}
}

.login-footer {
    display: flex; justify-content: center; gap: 4px;
    font-size: 12px; color: var(--text-muted); margin-top: 4px;
}
.login-footer-action { color: var(--accent); cursor: pointer; }
.login-footer-action:hover { text-decoration: underline; }

.spinner {
    position: absolute; width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== OVERLAY ========== */
.overlay {
    position: fixed; inset: 0; background: rgba(7,7,10,0.92);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 100; animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.loader-ring {
    width: 48px; height: 48px;
    border: 3px solid var(--border-light); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 16px;
}
.loader-text { color: var(--text-secondary); font-size: 14px; }

/* ========== MAIN SHELL ========== */
.shell {
    display: flex; width: 100%; height: 100vh;
    background: var(--bg-surface);
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 260px; min-width: 260px;
    background: var(--bg-deep);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 16px 12px;
}

.sidebar-top { flex: 1; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px 16px; border-bottom: 1px solid var(--border);
}
.sidebar-brand-text { display: flex; flex-direction: column; }
.sidebar-brand-name { font-size: 16px; font-weight: 700; }
.sidebar-brand-ver { font-size: 11px; color: var(--text-muted); }

.sidebar-nav {
    display: flex; flex-direction: column; gap: 4px;
    padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.sidebar-nav-primary, .sidebar-nav-secondary {
    display: flex; gap: 4px;
}
.sidebar-nav-primary .nav-btn, .sidebar-nav-secondary .nav-btn {
    flex: 1;
}
.nav-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px; background: transparent; border: 1px solid transparent;
    border-radius: var(--radius-sm); color: var(--text-muted); font-size: 11px;
    font-weight: 500; cursor: pointer; font-family: var(--font);
    transition: var(--transition);
}
.nav-btn:hover { color: var(--text-secondary); background: var(--bg-card); }
.nav-btn.active { color: var(--accent); background: var(--accent-soft); border-color: rgba(233,69,96,0.2); }

.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px; padding: 0 4px;
}
.section-collapsible .section-header { cursor: pointer; user-select: none; }
.section-collapsible .section-header:hover .section-title { color: var(--text-secondary); }
.section-title-wrap {
    display: flex; align-items: center; gap: 6px; min-width: 0;
}
.section-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); transition: var(--transition); }
.section-chevron { flex-shrink: 0; color: var(--text-muted); transition: transform .2s var(--ease, ease); }
.section-collapsible { display: flex; flex-direction: column; min-height: 0; }
.section-collapsible:not(.collapsed) { flex: 1 1 auto; }
.section-collapsible:not(.collapsed) .section-chevron { transform: rotate(0deg); }
.section-collapsible.collapsed .section-chevron { transform: rotate(-90deg); }
.section-collapsible.collapsed .section-header { margin-bottom: 0; }
.section-collapsible.collapsed .section-title { color: var(--text-muted); }

.pack-list-collapse {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .3s var(--ease, ease);
    min-height: 0;
    overflow: hidden;
}
.section-collapsible:not(.collapsed) .pack-list-collapse {
    grid-template-rows: 1fr;
    flex: 1;
}
.pack-list-collapse > .pack-list {
    overflow-y: auto;
    min-height: 0;
}

.pack-list {
    display: flex; flex-direction: column; gap: 3px;
}
.pack-list:empty::after {
    content: 'No packs'; display: block; padding: 12px 8px;
    font-size: 12px; color: var(--text-muted); text-align: center;
}

.pack-entry {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    cursor: pointer; transition: var(--transition);
    border: 1px solid transparent;
}
.pack-entry:hover { background: var(--bg-card); }
.pack-entry.selected { background: var(--accent-soft); border-color: rgba(233,69,96,0.25); }

.pack-entry-icon { position: relative; }
.pack-entry-icon .update-badge {
    position: absolute; top: -3px; right: -3px; width: 10px; height: 10px;
    border-radius: 50%; background: #e94560; border: 2px solid var(--bg-main, #0f0f1a);
}
.update-label {
    display: inline-block; font-size: 10px; font-weight: 600; color: #e94560;
    background: rgba(233,69,96,0.12); padding: 0 5px; border-radius: 3px;
    margin-left: 4px; vertical-align: middle; line-height: 16px;
}
.pack-entry-icon {
    width: 32px; height: 32px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.pack-entry-icon.server { background: rgba(251,191,36,0.15); color: var(--warning); }
.pack-entry-icon.local { background: var(--accent-soft); color: var(--accent); }

.pack-entry-info { flex: 1; min-width: 0; }
.pack-entry-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pack-entry-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-icon {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
    color: var(--text-muted); cursor: pointer; transition: var(--transition); flex-shrink: 0;
}
.btn-icon:hover { color: var(--text); background: var(--bg-card); border-color: var(--border-light); }

/* Sidebar bottom */
.sidebar-bottom { padding-top: 12px; border-top: 1px solid var(--border); }
.user-card {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: var(--radius-sm);
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-badges { display: flex; gap: 4px; margin-top: 2px; }
.badge {
    font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 3px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-pro { background: rgba(74,222,128,0.15); color: var(--success); }
.badge-free { background: rgba(248,113,113,0.12); color: var(--error); }
.badge-role { background: rgba(96,165,250,0.15); color: var(--info); }

/* ========== CONTENT ========== */
.content {
    flex: 1; display: flex; flex-direction: column;
    padding: 24px 32px; min-width: 0;
    position: relative;
    overflow-y: auto;
}

.view { display: none; flex-direction: column; height: 100%; overflow-y: auto; }
.view.active { display: flex; }
#view-packs { overflow: hidden; }
#view-packs .pack-detail { flex: 1; overflow-y: auto; min-height: 0; }
#view-packs .play-bar { position: sticky; bottom: 0; z-index: 5; flex-shrink: 0; margin-top: 12px; }

.view-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 24px; gap: 16px;
}
.view-title { font-size: 22px; font-weight: 700; }
.view-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.view-actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn-secondary {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13px;
    font-weight: 500; cursor: pointer; font-family: var(--font);
    transition: var(--transition);
}
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text); border-color: var(--border); }
.btn-secondary.btn-danger:hover { color: var(--error); border-color: rgba(248,113,113,0.3); background: rgba(248,113,113,0.08); }

/* ========== PACK DETAIL ========== */
.pack-detail { flex: 1; display: flex; }
.pack-empty {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; color: var(--text-muted);
}
.pack-empty h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.pack-empty p { font-size: 13px; }

.pack-detail-content { flex: 1; display: flex; flex-direction: column; gap: 24px; }
.pack-hero { display: flex; align-items: center; gap: 16px; }
.pack-icon {
    width: 56px; height: 56px; border-radius: var(--radius-md);
    background: var(--bg-card); border: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: center; color: var(--accent);
}
.detail-name { font-size: 20px; font-weight: 700; }
.detail-tags { display: flex; gap: 6px; margin-top: 6px; }
.tag {
    font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 4px;
}
.tag-mc { background: var(--bg-card); color: var(--text-secondary); }
.tag-loader { background: rgba(99,102,241,0.15); color: #818cf8; }
.tag-server { background: rgba(251,191,36,0.15); color: var(--warning); }

.pack-stats {
    display: flex; gap: 24px; padding: 16px;
    background: var(--bg-card); border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ========== PLAY BAR ========== */
.play-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; margin-top: auto;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.play-bar-info { font-size: 14px; font-weight: 500; color: var(--text-secondary); }

/* ========== PACK DESCRIPTION ========== */
.pack-description {
    padding: 16px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-md);
}
.pack-description-text {
    font-size: 13px; color: var(--text-secondary); line-height: 1.6;
}
.pack-gallery {
    display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap;
}
.pack-gallery-item {
    width: 120px; height: 80px; border-radius: var(--radius-sm);
    background: var(--bg-elevated); border: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 11px;
    overflow: hidden;
}
.pack-gallery-item img {
    width: 100%; height: 100%; object-fit: cover;
}
.pack-description-text .news-link {
    color: var(--accent); text-decoration: underline; cursor: pointer;
}
.pack-description-text .news-link:hover {
    color: var(--accent-hover);
}

.btn-play {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 28px; border: none; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--success), #22c55e);
    color: #07070a; font-size: 15px; font-weight: 700; cursor: pointer;
    font-family: var(--font); transition: var(--transition);
    box-shadow: 0 4px 20px rgba(74,222,128,0.35);
}
.btn-play:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); box-shadow: 0 8px 32px rgba(74,222,128,0.45); }
.btn-play:active:not(:disabled) { transform: translateY(0); }
.btn-play:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ========== CUSTOM SELECT ========== */
.custom-select-wrap {
    position: relative;
    width: 100%;
}
.custom-select-trigger {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 10px 12px;
    background: var(--bg-surface); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); color: var(--text);
    font-size: 13px; font-family: var(--font); cursor: pointer;
    transition: var(--transition); user-select: none;
    gap: 8px;
}
.custom-select-trigger:hover { border-color: var(--text-muted); }
.custom-select-trigger.open { border-color: var(--accent); }
.custom-select-trigger .arrow {
    width: 16px; height: 16px; flex-shrink: 0;
    transition: transform 0.2s ease; opacity: 0.5;
}
.custom-select-trigger.open .arrow { transform: rotate(180deg); }
.custom-select-trigger .placeholder { color: var(--text-muted); }
.custom-select-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
    z-index: 100; max-height: 240px; display: none;
    flex-direction: column;
}
.custom-select-dropdown.open { display: flex; }
.custom-select-search {
    padding: 8px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--bg-elevated);
    z-index: 1;
}
.custom-select-search input {
    width: 100%; padding: 6px 10px;
    background: var(--bg-surface); border: 1px solid var(--border-light);
    border-radius: 4px; color: var(--text); font-size: 12px;
    font-family: var(--font); outline: none;
}
.custom-select-search input:focus { border-color: var(--accent); }
.custom-select-options {
    overflow-y: auto; flex: 1;
}
.custom-select-option {
    padding: 8px 12px; cursor: pointer; font-size: 13px;
    color: var(--text-secondary); transition: var(--transition);
}
.custom-select-option:hover { background: var(--bg-card); color: var(--text); }
.custom-select-option.selected { background: var(--accent-soft); color: var(--accent); }
.custom-select-option.hidden { display: none; }

/* ========== NEWS ========== */
.news-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px; overflow-y: auto; padding-bottom: 24px;
}
.news-loading {
    grid-column: 1 / -1; text-align: center; padding: 60px 20px;
    color: var(--text-muted); font-size: 14px;
}
.news-empty {
    grid-column: 1 / -1; text-align: center; padding: 60px 20px;
    color: var(--text-muted); font-size: 14px;
}
.news-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 24px; display: flex;
    flex-direction: column; gap: 12px; transition: var(--transition);
    cursor: pointer;
}
.news-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.news-preview {
    font-size: 13px; color: var(--text-secondary); line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
    overflow: hidden;
}
.news-card-badge {
    align-self: flex-start; font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1px; padding: 4px 10px; border-radius: 4px;
}
.news-placeholder .news-card-badge { background: var(--accent-soft); color: var(--accent); }
.news-card h3 { font-size: 16px; font-weight: 600; }
.news-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.news-card time { font-size: 11px; color: var(--text-muted); margin-top: auto; }
.news-card-badge.type-Update { background: rgba(96,165,250,0.15); color: var(--info); }
.news-card-badge.type-Announcement { background: rgba(251,191,36,0.15); color: var(--warning); }
.news-card-badge.type-Event { background: rgba(74,222,128,0.15); color: var(--success); }

.news-modal-body {
    max-height: 60vh; overflow-y: auto; line-height: 1.7;
    font-size: 14px; color: var(--text-secondary);
}
.news-modal-body .news-text-line { display: inline; }
.news-modal-body .news-link {
    color: var(--info); text-decoration: underline; cursor: pointer;
}
.news-modal-body .news-link:hover { color: var(--accent); }
.news-modal-body .news-photo {
    display: block; max-width: 100%; border-radius: var(--radius-sm);
    margin: 12px 0; cursor: pointer; border: 1px solid var(--border);
    transition: var(--transition);
}
.news-modal-body .news-photo:hover { opacity: 0.9; }
.modal-news { max-width: 640px; }

/* ========== SETTINGS ========== */
.settings-grid { display: flex; flex-direction: column; gap: 12px; }
.setting-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); gap: 24px;
}
.setting-info h4 { font-size: 14px; font-weight: 600; }
.setting-info p { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.setting-control { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.setting-control input[type="range"] {
    width: 160px; height: 4px; -webkit-appearance: none; appearance: none;
    background: var(--border); border-radius: 2px; outline: none;
}
.setting-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
    background: var(--accent); cursor: pointer; border: 2px solid var(--bg-deep);
}
.setting-value { font-size: 14px; font-weight: 600; color: var(--text); min-width: 48px; text-align: right; }
.setting-badge {
    font-size: 12px; padding: 4px 10px; border-radius: 4px;
    background: var(--bg-surface); color: var(--text-secondary); border: 1px solid var(--border-light);
}
.setting-pass { display: flex; align-items: center; gap: 8px; }
.setting-network-list {
    display: flex; flex-direction: column; gap: 6px; min-width: 260px; flex-shrink: 0;
}
.network-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    font-size: 12px; padding: 4px 10px; border-radius: 4px;
    background: var(--bg-surface); border: 1px solid var(--border-light);
}
.network-name {
    font-family: var(--mono); color: var(--text-secondary); text-transform: uppercase;
}
.network-state { font-weight: 600; }
.pass-input {
    width: 160px; padding: 6px 12px; border-radius: var(--radius-sm);
    background: var(--bg-inset); border: 1px solid var(--border-light);
    color: var(--text); font-size: 13px; outline: none;
}
.pass-input:focus { border-color: var(--accent); }
.setting-input {
    padding: 6px 10px; border-radius: var(--radius-sm);
    background: var(--bg-inset); border: 1px solid var(--border-light);
    color: var(--text); font-size: 13px; outline: none; font-family: var(--mono);
}
.setting-input:focus { border-color: var(--accent); }
.btn-sm { padding: 6px 14px !important; font-size: 12px !important; }

/* ========== TOGGLE ========== */
.toggle {
    position: relative; display: inline-block; width: 44px; height: 24px; cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--border-light); border-radius: 12px; transition: var(--transition);
}
.toggle-slider::before {
    content: ''; position: absolute; left: 3px; bottom: 3px; width: 18px; height: 18px;
    background: var(--text-secondary); border-radius: 50%; transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: #fff; }

/* ========== LOCALE SELECT ========== */
#locale-select { font-family: var(--font); cursor: pointer; }

/* ========== MODAL ========== */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(7,7,10,0.85);
    display: flex; align-items: center; justify-content: center; z-index: 50;
    animation: fadeIn 0.2s ease;
}
.modal {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-lg); width: 90%; max-width: 480px;
    max-height: 85vh; box-shadow: var(--shadow);
    animation: floatIn 0.3s ease;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 17px; font-weight: 600; }
.modal-close {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; color: var(--text-muted);
    font-size: 22px; cursor: pointer; border-radius: var(--radius-sm); transition: var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg-card); }

.modal-body { padding: 20px 24px 24px; }
.modal-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.modal-tab {
    flex: 1; padding: 10px; background: transparent; border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); color: var(--text-muted); font-size: 13px;
    font-weight: 500; cursor: pointer; font-family: var(--font); transition: var(--transition);
}
.modal-tab.active { background: var(--accent-soft); border-color: rgba(233,69,96,0.3); color: var(--accent); }
.modal-tab:hover:not(.active) { background: var(--bg-card); color: var(--text-secondary); }

.modal-tab-content { display: none; flex-direction: column; gap: 16px; }
.modal-tab-content.active { display: flex; }
.modal-tab-content .field label {
    display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary);
    margin-bottom: 6px; position: static; transform: none;
    background: none; padding: 0;
}

.tag-wip {
    font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
    background: rgba(251,191,36,0.15); color: var(--warning); vertical-align: middle; margin-left: 4px;
}
.disabled-tab {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 40px 20px; text-align: center; color: var(--text-muted);
}
.disabled-tab h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.disabled-tab p { font-size: 13px; line-height: 1.5; max-width: 300px; }

.select-wrap select {
    width: 100%; padding: 10px 12px; font-size: 13px;
    background: var(--bg-surface); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); color: var(--text);
    font-family: var(--font); cursor: pointer; outline: none;
}
.select-wrap select:focus { border-color: var(--accent); }

.install-progress { padding-top: 16px; border-top: 1px solid var(--border); }
.inline-install-progress { padding: 16px 20px; border-top: 1px solid var(--border); background: var(--bg-surface); }
.progress-track {
    height: 6px; background: var(--bg-surface); border-radius: 3px; overflow: hidden;
}
.progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), #ff6b6b);
    border-radius: 3px; transition: width 0.3s ease;
}
.progress-fill.indeterminate {
    width: 30%;
    transition: none;
    animation: indeterminate 1.3s ease-in-out infinite;
}
@keyframes indeterminate {
    0% { margin-left: -30%; }
    100% { margin-left: 100%; }
}
.progress-label { font-size: 13px; color: var(--text-secondary); margin-top: 8px; text-align: center; }
.progress-stage { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-align: center; }

/* ========== LOG VIEWER ========== */
.modal-log { max-width: 800px; }
.log-viewer-actions { display: flex; align-items: center; gap: 8px; }
.log-viewer-body { padding: 0 !important; }
.log-viewer-content {
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.5;
    background: var(--bg-deep);
    padding: 12px 16px;
    max-height: 50vh;
    overflow-y: auto;
    user-select: text;
    -webkit-user-select: text;
    white-space: pre-wrap;
    word-break: break-all;
}
.log-line { padding: 1px 0; }
.log-empty { color: var(--text-muted); font-family: var(--font); font-size: 13px; padding: 20px; text-align: center; }
.log-error { color: #f87171; }
.log-warn { color: #fbbf24; }
.log-info { color: #4ade80; }
.log-debug { color: #60a5fa; }

/* ========== TOAST ========== */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    padding: 12px 24px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; z-index: 200;
    background: var(--bg-elevated); border: 1px solid var(--border);
    color: var(--text); box-shadow: var(--shadow);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}
.toast.error { border-color: rgba(248,113,113,0.3); color: var(--error); }
.toast.success { border-color: rgba(74,222,128,0.3); color: var(--success); }
.toast.warning { border-color: rgba(251,191,36,0.3); color: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .sidebar { width: 200px; min-width: 200px; }
    .content { padding: 16px; }
}
@media (max-width: 700px) {
    .sidebar { width: 56px; min-width: 56px; }
    .sidebar-brand-text, .sidebar-nav-primary .nav-btn span, .sidebar-nav-secondary .nav-btn span,
    .section-header, .pack-entry-info, .user-info,
    .sidebar-bottom .user-card .btn-icon:first-child { display: none; }
    .sidebar-brand { justify-content: center; padding: 8px; }
    .sidebar-nav-primary, .sidebar-nav-secondary { flex-direction: column; }
    .nav-btn { padding: 8px; }
    .pack-entry { justify-content: center; padding: 8px; }
    .content { padding: 12px; }
    .play-bar { flex-direction: column; gap: 12px; }
    .view-header { flex-direction: column; }
}

/* ========== FRIENDS ========== */
.friends-search {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 12px;
}
.friends-search svg { flex-shrink: 0; color: var(--text-muted); }
.friends-search input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--text); font-size: 13px; font-family: var(--font);
}
.friends-search input::placeholder { color: var(--text-muted); }
.friends-list { display: flex; flex-direction: column; gap: 4px; }
.friends-empty {
    text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px;
}
.friends-group-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); padding: 8px 4px 4px; letter-spacing: 0.5px;
}
.friend-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-sm); transition: var(--transition);
}
.friend-item:hover { background: var(--bg-card-hover); }
.friend-item:hover .friend-remove-btn { opacity: 1; }
.friend-avatar {
    width: 36px; height: 36px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
    flex-shrink: 0; position: relative;
    background: var(--accent-soft); color: var(--accent);
}
.friend-avatar.online::after {
    content: ''; position: absolute; bottom: 0; right: 0;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--success); border: 2px solid var(--bg-surface);
}
.friend-avatar.offline { opacity: 0.6; }
.friend-info { flex: 1; min-width: 0; }
.friend-name-row { display: flex; align-items: center; gap: 6px; }
.friend-name { font-size: 13px; font-weight: 500; color: var(--text); }
.friend-status { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.friend-status-dot {
    width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.friend-status-dot.online { background: var(--success); }
.friend-status-dot.offline { background: var(--text-muted); }
.friend-pack { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-remove-btn {
    opacity: 0; transition: var(--transition); flex-shrink: 0;
    width: 28px; height: 28px; color: var(--text-muted);
}
.friend-remove-btn:hover { color: var(--error); }
.friend-requests-section {
    margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border);
}
.friend-requests-section .section-header {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); padding: 4px; margin-bottom: 8px; letter-spacing: 0.5px;
}
.friend-request-item {
    display: flex; align-items: center; gap: 10px; padding: 10px;
    background: var(--bg-card); border-radius: var(--radius-sm);
    margin-bottom: 6px;
}
.friend-request-avatar {
    width: 36px; height: 36px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
    flex-shrink: 0; background: var(--accent-soft); color: var(--accent);
}
.friend-request-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.friend-request-name { font-size: 13px; font-weight: 500; }
.friend-request-text { font-size: 11px; color: var(--text-muted); }
.friend-request-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ========== WHITELIST MODS ========== */
.whitelist-mods-section {
    margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border);
}
.whitelist-mods-section .section-header {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); padding: 4px; margin-bottom: 8px; letter-spacing: 0.5px;
}
.whitelist-mods-list { display: flex; flex-direction: column; gap: 4px; }
.whitelist-loading {
    text-align: center; padding: 20px; color: var(--text-muted); font-size: 12px;
}
.whitelist-mod-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-sm); transition: var(--transition);
    background: var(--bg-card);
}
.whitelist-mod-item:hover { background: var(--bg-card-hover); }
.whitelist-mod-checkbox {
    width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent);
}
.whitelist-mod-info { flex: 1; min-width: 0; }
.whitelist-mod-name { font-size: 13px; font-weight: 500; color: var(--text); }
.whitelist-mod-size { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.whitelist-mod-status { font-size: 11px; color: var(--success); }
.whitelist-install-btn {
    width: 100%; padding: 10px; margin-top: 8px;
    background: var(--accent-soft); border: 1px solid rgba(233,69,96,0.3);
    border-radius: var(--radius-sm); color: var(--accent); font-size: 13px;
    font-weight: 500; cursor: pointer; font-family: var(--font); transition: var(--transition);
}
.whitelist-install-btn:hover { background: var(--accent); color: #fff; }
.whitelist-install-btn:disabled { opacity: 0.4; cursor: default; }

/* ========== MODAL SM ========== */
.modal-sm { max-width: 360px; }

/* ========== BADGE SM ========== */
.badge-sm { font-size: 10px; padding: 2px 6px; }

/* ========== ADMIN PANEL ========== */
.admin-tabs {
    display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap;
}
.admin-tab {
    padding: 8px 14px; background: transparent; border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12px;
    font-weight: 500; cursor: pointer; font-family: var(--font); transition: var(--transition);
}
.admin-tab.active { background: var(--accent-soft); border-color: rgba(233,69,96,0.3); color: var(--accent); }
.admin-tab:hover:not(.active) { background: var(--bg-card); color: var(--text-secondary); }
.admin-tab-content { display: none; flex-direction: column; gap: 12px; }
.admin-tab-content.active { display: flex; }
.admin-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 16px;
}
.admin-card-header {
    font-size: 13px; font-weight: 600; margin-bottom: 12px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border); color: var(--text);
}
.admin-list { display: flex; flex-direction: column; gap: 4px; }
.admin-loading, .admin-empty {
    text-align: center; padding: 20px; color: var(--text-muted); font-size: 12px;
}
.admin-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap;
}
.admin-input {
    flex: 1; padding: 8px 12px; background: var(--bg-surface); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); color: var(--text); font-size: 13px; outline: none; font-family: var(--font);
}
.admin-input:focus { border-color: var(--accent); }
.admin-select {
    padding: 6px 10px; background: var(--bg-surface); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); color: var(--text); font-size: 12px; outline: none; cursor: pointer; font-family: var(--font);
}
.admin-textarea {
    width: 100%; min-height: 100px; padding: 10px; background: var(--bg-surface);
    border: 1px solid var(--border-light); border-radius: var(--radius-sm); color: var(--text);
    font-size: 13px; outline: none; font-family: var(--font); resize: vertical;
}
.admin-textarea:focus { border-color: var(--accent); }
.admin-file-input {
    font-size: 12px; color: var(--text-secondary); font-family: var(--font);
}
.admin-status {
    font-size: 12px; padding: 8px 12px; border-radius: var(--radius-sm); margin-top: 8px;
}
.admin-status.success { background: rgba(74,222,128,0.1); color: var(--success); }
.admin-status.error { background: rgba(248,113,113,0.1); color: var(--error); }
.admin-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-sm); transition: var(--transition); font-size: 13px;
}
.admin-item:hover { background: var(--bg-card-hover); }
.admin-item-name { flex: 1; color: var(--text); }
.admin-item-meta { font-size: 11px; color: var(--text-muted); }
.admin-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.admin-form { display: flex; flex-direction: column; gap: 8px; }
.admin-btn-danger { color: var(--error) !important; }
.admin-btn-danger:hover { background: rgba(248,113,113,0.1) !important; border-color: rgba(248,113,113,0.3) !important; }
.admin-news-item {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px;
    border-radius: var(--radius-sm); transition: var(--transition); border: 1px solid var(--border);
    margin-bottom: 6px;
}
.admin-news-item:hover { background: var(--bg-card-hover); }
.admin-news-info { flex: 1; min-width: 0; }
.admin-news-title { font-size: 13px; font-weight: 500; }
.admin-news-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.pack-entry.disabled { opacity: 0.5; pointer-events: none; }
.pack-entry.disabled .pack-entry-name::after { content: ' (' attr(data-disabled-text) ')'; color: var(--error); font-size: 11px; }
.admin-pack-disabled { color: var(--error) !important; font-weight: 600; }
.admin-pack-enabled { color: var(--success) !important; font-weight: 600; }

/* ========== OFFLINE MODE ========== */
.offline-container {
    position: relative; z-index: 1;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 32px 32px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    text-align: center;
}
.offline-badge {
    width: 64px; height: 64px;
    margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(233,69,96,0.12);
    border: 1px solid rgba(233,69,96,0.3);
    border-radius: 14px;
    color: var(--accent);
}
.offline-title { font-size: 22px; font-weight: 700; color: var(--text); }
.offline-subtitle {
    color: var(--text-muted); font-size: 13px; margin: 8px 0 20px; line-height: 1.5;
}
.offline-container .login-form { text-align: left; }
.offline-footer {
    display: flex; gap: 8px; justify-content: center; margin-top: 18px;
}
.btn-ghost {
    padding: 9px 14px; font-size: 13px;
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border); border-radius: 4px;
    cursor: pointer; font-family: var(--font);
    transition: border-color 150ms ease, color 150ms ease;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ========== LOCAL MODS ========== */
.mods-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.mods-section .section-header { display:flex; align-items:center; gap:10px; flex-wrap:wrap; font-size:11px; font-weight:600; text-transform:uppercase; color:var(--text-muted); padding:4px; margin-bottom:8px; letter-spacing:0.5px; }
.mods-count { font-size:11px; color:var(--text-secondary); margin-left:auto; }
.mods-search { margin-left:auto; min-width:160px; padding:6px 10px; border-radius:var(--radius-sm); background:var(--bg-surface); border:1px solid var(--border-light); color:var(--text); font-size:12px; outline:none; }
.mods-search:focus { border-color:var(--accent); }
.mods-list { display:flex; flex-direction:column; gap:4px; }
.mods-loading { text-align:center; padding:20px; color:var(--text-muted); font-size:12px; }
.mod-item { display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:var(--radius-sm); background:var(--bg-card); border:1px solid var(--border); transition:var(--transition); }
.mod-item:hover { background:var(--bg-card-hover); }
.mod-item.mod-disabled { opacity:0.6; }
.mod-icon { width:32px; height:32px; border-radius:6px; display:flex; align-items:center; justify-content:center; background:var(--bg-inset); color:var(--text-muted); flex-shrink:0; }
.mod-info { flex:1; min-width:0; }
.mod-name { font-size:13px; font-weight:500; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mod-meta { font-size:11px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mod-badge { font-size:10px; font-weight:700; padding:2px 6px; border-radius:4px; flex-shrink:0; }
.mod-badge-enabled { background:rgba(74,222,128,0.15); color:var(--success); }
.mod-badge-disabled { background:rgba(248,113,113,0.12); color:var(--error); }

/* ========== CONTEXT MENU (PKM) ========== */
.ctx-menu { position:fixed; z-index:300; min-width:200px; background:var(--bg-elevated); border:1px solid var(--border); border-radius:var(--radius-sm); box-shadow:0 12px 32px rgba(0,0,0,0.5); padding:4px; display:flex; flex-direction:column; gap:2px; animation:ctxIn 0.12s ease; }
@keyframes ctxIn { from { opacity:0; transform:translateY(4px) scale(0.98); } to { opacity:1; transform:none; } }
.ctx-item { display:flex; align-items:center; gap:10px; padding:8px 12px; border-radius:4px; font-size:13px; color:var(--text-secondary); cursor:pointer; transition:var(--transition); border:none; background:transparent; font-family:var(--font); text-align:left; width:100%; }
.ctx-item:hover { background:var(--bg-card); color:var(--text); }
.ctx-item.danger { color:var(--error); }
.ctx-item.danger:hover { background:rgba(248,113,113,0.08); }
.ctx-sep { height:1px; background:var(--border); margin:2px 0; }
.ctx-backdrop { position:fixed; inset:0; z-index:299; }

/* ========== ONBOARDING SPOTLIGHT ========== */
.onboard-overlay { position:fixed; inset:0; z-index:400; background:rgba(7,7,10,0.72); backdrop-filter:blur(2px); animation:fadeIn 0.2s ease; }
.onboard-card { position:fixed; left:50%; top:50%; transform:translate(-50%,-50%); z-index:405; max-width:420px; width:90%; background:var(--bg-elevated); border:1px solid var(--border); border-radius:var(--radius-lg); padding:24px; box-shadow:0 20px 60px rgba(0,0,0,0.6); animation:floatIn 0.25s ease; }
.onboard-card h3 { font-size:18px; font-weight:700; margin-bottom:8px; }
.onboard-card p { font-size:13px; color:var(--text-secondary); line-height:1.6; margin-bottom:16px; }
.onboard-progress { font-size:11px; color:var(--text-muted); letter-spacing:0.5px; text-transform:uppercase; margin-bottom:12px; }
.onboard-actions { display:flex; gap:8px; justify-content:flex-end; }
.onboard-spot { position:fixed; z-index:401; border:2px solid var(--accent); border-radius:var(--radius-sm); box-shadow:0 0 0 9999px rgba(7,7,10,0.55), 0 0 24px var(--accent-glow); pointer-events:auto; cursor:pointer; transition:all 0.35s ease; }
.onboard-spot-label { position:fixed; z-index:402; background:var(--accent); color:#fff; font-size:12px; font-weight:600; padding:6px 10px; border-radius:999px; pointer-events:auto; cursor:pointer; transform:translate(-50%, -100%); margin-top:-8px; white-space:nowrap; }

/* ========== PACK SETTINGS MODAL ========== */
.pack-settings-form { display:flex; flex-direction:column; gap:16px; }
