:root {
    --bg: #0a0a0b;
    --surface: #111113;
    --surface2: #18181b;
    --surface3: #1f1f24;
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);
    --accent: #3b82f6;
    --accent-dim: rgba(59,130,246,0.12);
    --accent-glow: rgba(59,130,246,0.25);
    --text: #e4e4e7;
    --text-muted: #71717a;
    --text-dim: #3f3f46;
    --green: #10b981;
    --green-dim: rgba(16,185,129,0.12);
    --red: #ef4444;
    --amber: #f59e0b;
    --sidebar-w: 240px;
    --right-w: 280px;
    --topbar-h: 52px;
    --mob-nav-h: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
.hide-scroll { scrollbar-width: none; }
.hide-scroll::-webkit-scrollbar { display: none; }

/* ── TOPBAR ── */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    flex-shrink: 0;
    z-index: 100;
}
.topbar-logo {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 15px;
    letter-spacing: -0.3px; white-space: nowrap;
    flex-shrink: 0;
}
.logo-icon {
    width: 26px; height: 26px;
    background: var(--accent); border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: white;
    font-family: 'DM Mono', monospace; flex-shrink: 0;
}
.logo-text { display: none; }
.topbar-search {
    flex: 1; position: relative; min-width: 0;
}
.topbar-search input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 32px 7px 32px;
    font-size: 14px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    outline: none;
    transition: border-color 0.15s;
}
.topbar-search input:focus { border-color: var(--accent); }
.topbar-search input::placeholder { color: var(--text-muted); }
.search-icon-left {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 15px; pointer-events: none;
}
.search-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 14px; cursor: pointer;
    display: none; background: none; border: none; padding: 2px;
}
.search-kbd {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text-dim);
    background: var(--surface3); border: 1px solid var(--border);
    padding: 2px 5px; border-radius: 4px;
}
.topbar-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.icon-btn {
    width: 34px; height: 34px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface2);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted); font-size: 16px;
    transition: all 0.15s; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface3); color: var(--text); border-color: var(--border-hover); }
.badge-dot { position: relative; }
.badge-dot::after {
    content: ''; position: absolute; top: 6px; right: 6px;
    width: 6px; height: 6px; background: var(--accent);
    border-radius: 50%; border: 1.5px solid var(--surface);
}
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: white; cursor: pointer;
    flex-shrink: 0;
}

/* ── LAYOUT SHELL ── */
.app-body { flex: 1; display: flex; overflow: hidden; }

/* ── SIDEBAR OVERLAY (mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 190;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ── LEFT SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    transition: transform 0.25s ease, width 0.2s ease;
    z-index: 200;
}
.sidebar.collapsed { width: 52px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .section-title,
.sidebar.collapsed .sidebar-footer-text,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px 6px; }
.sidebar-section { padding: 12px 8px 4px; }
.section-title {
    font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
    color: var(--text-dim); text-transform: uppercase;
    padding: 0 8px; margin-bottom: 4px;
}
.nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 10px; border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 400; color: var(--text-muted);
    transition: all 0.12s; white-space: nowrap; overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
.nav-item:hover, .nav-item:active { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item i { font-size: 17px; flex-shrink: 0; }
.nav-badge {
    margin-left: auto; font-size: 10px; font-weight: 600;
    background: var(--surface3); color: var(--text-muted);
    padding: 1px 6px; border-radius: 20px; white-space: nowrap;
}
.nav-item.active .nav-badge { background: var(--accent-glow); color: var(--accent); }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 12px; }
.sidebar-footer {
    margin-top: auto; padding: 12px 8px;
    border-top: 1px solid var(--border);
}

/* ── MAIN AREA ── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── STATS BAR ── */
.stats-bar {
    display: flex; align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; overflow-x: auto;
}
.stats-bar.hide-scroll { scrollbar-width: none; }
.stat-pill {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 16px; font-size: 12px; white-space: nowrap;
    border-right: 1px solid var(--border); flex-shrink: 0;
}
.stat-pill .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.stat-label { color: var(--text-muted); }
.stat-val { font-weight: 600; font-family: 'DM Mono', monospace; font-size: 12px; }
.stat-change { font-size: 10px; color: var(--green); }
.view-toggle {
    margin-left: auto; display: flex; align-items: center; gap: 4px;
    padding: 0 10px; flex-shrink: 0;
}
.vt-btn {
    padding: 5px 8px; border-radius: 6px; cursor: pointer;
    font-size: 15px; color: var(--text-muted); transition: all 0.12s;
    border: 1px solid transparent; -webkit-tap-highlight-color: transparent;
}
.vt-btn.active { background: var(--surface2); color: var(--text); border-color: var(--border); }

/* ── CONTENT AREA ── */
.content-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.content-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px; flex-wrap: wrap; gap: 8px;
}
.content-title { font-size: 15px; font-weight: 600; }
.filter-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-chip {
    padding: 5px 11px; border-radius: 20px; font-size: 12px;
    border: 1px solid var(--border); cursor: pointer; transition: all 0.12s;
    color: var(--text-muted); background: transparent; white-space: nowrap;
    font-family: 'DM Sans', sans-serif; -webkit-tap-highlight-color: transparent;
}
.filter-chip:hover, .filter-chip:active { border-color: var(--border-hover); color: var(--text); }
.filter-chip.active { background: var(--accent-dim); border-color: rgba(59,130,246,0.4); color: var(--accent); }

/* ── GRID VIEW ── */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}
.app-grid-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 13px; cursor: pointer;
    transition: all 0.15s; position: relative; overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
.app-grid-card:hover { border-color: var(--border-hover); background: var(--surface2); transform: translateY(-1px); }
.app-grid-card.selected { border-color: rgba(59,130,246,0.5); background: var(--surface2); }
.app-grid-card:active { transform: scale(0.98); }
.grid-card-icon {
    width: 48px; height: 48px; border-radius: 11px;
    object-fit: cover; background: var(--surface2);
    border: 1px solid var(--border); margin-bottom: 9px;
}
.grid-card-title {
    font-size: 12px; font-weight: 500; line-height: 1.3; color: var(--text);
    margin-bottom: 3px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.grid-card-meta {
    font-size: 11px; color: var(--text-muted);
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.grid-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--border);
}
.get-btn {
    padding: 4px 11px; border-radius: 6px; font-size: 11px;
    font-weight: 600; background: var(--accent-dim); color: var(--accent);
    border: 1px solid rgba(59,130,246,0.3); cursor: pointer;
    font-family: 'DM Sans', sans-serif; transition: all 0.12s;
    text-transform: uppercase; letter-spacing: 0.05em;
    -webkit-tap-highlight-color: transparent;
}
.get-btn:hover, .get-btn:active { background: var(--accent); color: white; border-color: var(--accent); }
.verified-badge { font-size: 10px; color: var(--green); font-weight: 500; display: flex; align-items: center; gap: 3px; }

/* ── LIST VIEW ── */
.app-list-view { display: flex; flex-direction: column; gap: 6px; }
.app-list-row {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 12px;
    display: flex; align-items: center; gap: 11px;
    cursor: pointer; transition: all 0.12s;
    -webkit-tap-highlight-color: transparent;
}
.app-list-row:hover { background: var(--surface2); border-color: var(--border-hover); }
.app-list-row.selected { border-color: rgba(59,130,246,0.5); background: var(--surface2); }
.app-list-row:active { transform: scale(0.99); }
.list-icon {
    width: 44px; height: 44px; border-radius: 10px;
    object-fit: cover; background: var(--surface2);
    border: 1px solid var(--border); flex-shrink: 0;
}
.list-info { flex: 1; min-width: 0; }
.list-title { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-desc { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.list-tags { display: flex; gap: 4px; margin-top: 4px; }
.tag { font-size: 9px; font-weight: 600; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.tag-blue { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(59,130,246,0.25); }
.tag-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,185,129,0.25); }
.list-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── RIGHT PANEL (desktop) ── */
.right-panel {
    width: var(--right-w);
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    flex-shrink: 0; overflow-y: auto;
    transition: width 0.2s, opacity 0.2s;
}
.right-panel.hidden { width: 0; overflow: hidden; opacity: 0; }
.panel-header {
    padding: 13px 14px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0; position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.panel-title { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── MOBILE SHEET ── */
.sheet-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.sheet-overlay.open { display: block; }
.bottom-sheet {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 310;
    background: #111113;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    max-height: 92dvh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: calc(16px + var(--safe-bottom));
}
.bottom-sheet.open { transform: translateY(0); }
.sheet-handle-bar {
    width: 36px; height: 4px; background: var(--surface3);
    border-radius: 2px; margin: 10px auto 0;
}
.sheet-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px 10px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: #111113; z-index: 2;
}
.sheet-title { font-size: 14px; font-weight: 600; }
.sheet-close {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface2); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted); font-size: 14px;
}
.sheet-body { padding: 14px 16px; }

/* ── SHARED DETAIL CONTENT ── */
.detail-icon {
    width: 68px; height: 68px; border-radius: 15px;
    object-fit: cover; border: 1px solid var(--border);
    background: var(--surface2); flex-shrink: 0;
}
.detail-title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.detail-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.meta-card {
    background: var(--surface2); border-radius: 8px;
    padding: 9px 11px; border: 1px solid var(--border);
}
.meta-card-label { font-size: 9px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 3px; }
.meta-card-val { font-size: 13px; font-weight: 600; font-family: 'DM Mono', monospace; }
.dl-btn {
    width: 100%; padding: 11px; border-radius: 9px;
    background: var(--accent); color: white; font-size: 13px;
    font-weight: 600; border: none; cursor: pointer;
    font-family: 'DM Sans', sans-serif; transition: all 0.12s;
    text-align: center; text-decoration: none; display: block;
    -webkit-tap-highlight-color: transparent;
}
.dl-btn:hover, .dl-btn:active { background: #2563eb; }
.dl-btn-outline {
    flex: 1; padding: 9px; border-radius: 8px;
    background: transparent; color: var(--text-muted); font-size: 12px;
    font-weight: 500; border: 1px solid var(--border); cursor: pointer;
    font-family: 'DM Sans', sans-serif; transition: all 0.12s; text-align: center;
    -webkit-tap-highlight-color: transparent;
}
.dl-btn-outline:hover, .dl-btn-outline:active { color: var(--text); border-color: var(--border-hover); background: var(--surface2); }
.dl-package {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 9px; padding: 11px 12px;
}
.dl-package-name { font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.dl-package-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }

/* ── BOTTOM NAV (mobile only) ── */
.mobile-nav {
    display: none;
    height: calc(var(--mob-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(17,17,19,0.92);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0; z-index: 100;
}
.mobile-nav-inner {
    height: var(--mob-nav-h);
    display: flex; align-items: center; justify-content: space-around;
}
.mob-tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    flex: 1; cursor: pointer; padding: 6px 0;
    color: var(--text-muted); transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.mob-tab i { font-size: 22px; }
.mob-tab span { font-size: 10px; font-weight: 500; }
.mob-tab.active { color: var(--accent); }
.mob-tab-badge {
    position: relative; display: inline-block;
}
.mob-tab-badge::after {
    content: attr(data-count);
    position: absolute; top: -4px; right: -8px;
    background: var(--accent); color: white;
    font-size: 8px; font-weight: 700;
    min-width: 14px; height: 14px;
    border-radius: 7px; display: flex; align-items: center; justify-content: center;
    padding: 0 3px; font-family: 'DM Mono', monospace;
    line-height: 14px;
    display: none;
}
.mob-tab-badge[data-count]:not([data-count="0"])::after { display: flex; }

/* ── LOADING ── */
.spinner {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--border); border-top-color: var(--accent);
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: var(--surface2); border-radius: 6px; animation: shimmer 1.5s ease-in-out infinite; }
@keyframes shimmer { 0%,100%{opacity:.4} 50%{opacity:.8} }

/* ── TOAST ── */
.toast-container {
    position: fixed; bottom: 80px; right: 16px; z-index: 500;
    display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
    background: var(--surface3); border: 1px solid var(--border-hover);
    border-radius: 10px; padding: 10px 14px;
    font-size: 12px; color: var(--text);
    display: flex; align-items: center; gap: 8px;
    animation: toastIn 0.2s ease; pointer-events: all;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.toast.removing { animation: toastOut 0.2s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ── KBD BAR ── */
.kbd-bar {
    height: 26px; background: var(--surface); border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px; padding: 0 14px;
    flex-shrink: 0; overflow-x: auto;
}
.kbd-hint { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-dim); white-space: nowrap; }
kbd {
    font-family: 'DM Mono', monospace; font-size: 9px;
    background: var(--surface2); border: 1px solid var(--border-hover);
    border-radius: 4px; padding: 1px 4px; color: var(--text-muted);
}

/* ── EMPTY / ERROR ── */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 60px 20px; color: var(--text-muted); text-align: center;
}
.empty-state i { font-size: 36px; margin-bottom: 12px; color: var(--text-dim); }
.empty-state p { font-size: 13px; }

/* skeleton grid */
.skel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.skel-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 13px; }

/* ════════════════════════════════
   RESPONSIVE BREAKPOINTS
════════════════════════════════ */

/* ── TABLET 768–1024px ── */
@media (min-width: 768px) {
    .logo-text { display: inline; }
    .topbar { padding: 0 16px; gap: 12px; }
    .mobile-nav { display: none !important; }
    .kbd-bar { display: flex; }
    .content-scroll { padding: 20px; }
}

@media (min-width: 768px) and (max-width: 1099px) {
    .sidebar { width: 52px; }
    .sidebar .nav-label,
    .sidebar .section-title,
    .sidebar .sidebar-footer-text,
    .sidebar .nav-badge { display: none; }
    .sidebar .nav-item { justify-content: center; padding: 9px 6px; }
    .right-panel { display: none !important; }
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ── DESKTOP 1100px+ ── */
@media (min-width: 1100px) {
    .logo-text { display: inline; }
    .topbar-logo { width: var(--sidebar-w); }
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
}

/* ── MOBILE <768px ── */
@media (max-width: 767px) {
    .sidebar { display: none !important; }
    .right-panel { display: none !important; }
    .kbd-bar { display: none; }
    .mobile-nav { display: block; }
    .stats-bar { display: flex; }
    .stat-pill { padding: 7px 12px; }
    .content-scroll {
        padding: 12px;
        padding-bottom: 8px;
    }
    .app-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
    .toast-container { bottom: calc(var(--mob-nav-h) + 12px + var(--safe-bottom)); right: 12px; }
    .topbar-search input { font-size: 16px; }
    .search-kbd { display: none; }
}
@media (max-width: 380px) {
    .app-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .grid-card-icon { width: 40px; height: 40px; }
}
