/**
 * XPP — Shared Base Styles
 * Apple-native design system. CSS variables, reset, layout, and common components.
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    /* Background */
    --color-bg: #ffffff;
    --color-bg-card: #ffffff;
    --color-bg-secondary: #f5f5f5;

    /* Border */
    --color-border: rgba(0, 0, 0, 0.09);

    /* Text */
    --color-text: #0d0d0d;
    --color-text-secondary: #555555;
    --color-text-muted: #999999;

    /* Accent */
    --color-accent: #007AFF;

    /* Functional */
    --color-success: #34C759;
    --color-error: #FF3B30;
    --color-warning: #FF9500;

    /* Semantic tint backgrounds */
    --color-success-bg: rgba(52, 199, 89, 0.10);
    --color-error-bg: rgba(255, 59, 48, 0.08);
    --color-warning-bg: rgba(255, 149, 0, 0.08);
    --color-info-bg: rgba(0, 122, 255, 0.08);

    /* Semantic text */
    --color-success-text: #248a3d;
    --color-error-text: #d70015;
    --color-warning-text: #c93400;
    --color-info-text: #0040dd;

    /* Palette colors */
    --color-text-inverse: #ffffff;
    --color-blue: #007AFF;
    --color-purple: #AF52DE;
    --color-cyan: #32ADE6;
    --color-orange: #FF9500;
    --color-pink: #FF2D55;
    --color-teal: #5AC8FA;
    --color-slate: #8E8E93;
    --color-blue-bg: rgba(0, 122, 255, 0.08);
    --color-purple-bg: rgba(175, 82, 222, 0.08);
    --color-cyan-bg: rgba(50, 173, 230, 0.08);
    --color-orange-bg: rgba(255, 149, 0, 0.08);
    --color-pink-bg: rgba(255, 45, 85, 0.08);
    --color-teal-bg: rgba(90, 200, 250, 0.08);

    /* Overlay / glass */
    --color-overlay: rgba(0, 0, 0, 0.03);
    --color-overlay-heavy: rgba(0, 0, 0, 0.3);
    --color-overlay-medium: rgba(0, 0, 0, 0.4);
    --color-overlay-light: rgba(0, 0, 0, 0.06);
    --color-glass: rgba(255, 255, 255, 0.92);
    --color-glass-border: rgba(0, 0, 0, 0.06);
    --glass-blur: 20px;

    /* Font */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Menlo', Consolas, monospace;

    /* Typography scale */
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-base: 15px;
    --font-size-lg: 17px;
    --font-size-xl: 22px;
    --font-size-2xl: 28px;

    /* Radius */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 100px;

    /* Shadow */
    --shadow: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-hover: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
    --shadow-modal: 0 16px 48px rgba(0,0,0,0.14), 0 0 1px rgba(0,0,0,0.06);

    /* Motion */
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 350ms;
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    --spacing-2xl: 32px;
    --spacing-3xl: 40px;
}

/* ============================================
   Dark Theme
   ============================================ */
[data-theme="dark"] {
    --color-bg: #1c1c1e;
    --color-bg-card: #2c2c2e;
    --color-bg-secondary: #38383a;
    --color-border: rgba(255, 255, 255, 0.10);
    --color-text: #f5f5f7;
    --color-text-secondary: #98989d;
    --color-text-muted: #636366;
    --color-accent: #0A84FF;
    --color-success: #30D158;
    --color-error: #FF453A;
    --color-warning: #FFD60A;
    --color-success-bg: rgba(48, 209, 88, 0.14);
    --color-error-bg: rgba(255, 69, 58, 0.12);
    --color-warning-bg: rgba(255, 214, 10, 0.12);
    --color-info-bg: rgba(10, 132, 255, 0.12);
    --color-success-text: #30D158;
    --color-error-text: #FF453A;
    --color-warning-text: #FFD60A;
    --color-info-text: #64D2FF;
    --color-text-inverse: #1c1c1e;
    --color-blue: #0A84FF;
    --color-purple: #BF5AF2;
    --color-cyan: #64D2FF;
    --color-orange: #FF9F0A;
    --color-pink: #FF375F;
    --color-teal: #6AC4DC;
    --color-slate: #98989d;
    --color-blue-bg: rgba(10, 132, 255, 0.14);
    --color-purple-bg: rgba(191, 90, 242, 0.14);
    --color-cyan-bg: rgba(100, 210, 255, 0.14);
    --color-orange-bg: rgba(255, 159, 10, 0.14);
    --color-pink-bg: rgba(255, 55, 95, 0.14);
    --color-teal-bg: rgba(106, 196, 220, 0.14);
    --color-overlay: rgba(255, 255, 255, 0.04);
    --color-overlay-heavy: rgba(0, 0, 0, 0.5);
    --color-overlay-medium: rgba(0, 0, 0, 0.55);
    --color-overlay-light: rgba(255, 255, 255, 0.07);
    --color-glass: rgba(44, 44, 46, 0.78);
    --color-glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-hover: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.3);
    --shadow-modal: 0 16px 48px rgba(0,0,0,0.4), 0 0 1px rgba(0,0,0,0.2);
    color-scheme: dark;
}

[data-theme="dark"] body {
    background: #1c1c1e;
}

[data-theme="dark"] img:not([data-no-invert]) {
    opacity: 0.92;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

body {
    font-family: var(--font);
    font-size: var(--font-size-base);
    line-height: 1.47;
    letter-spacing: -0.01em;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: opacity var(--duration-fast) var(--ease);
}

a:hover {
    text-decoration: none;
    opacity: 0.85;
}

/* Custom selection colors */
::selection {
    background: rgba(0, 122, 255, 0.18);
    color: inherit;
}
[data-theme="dark"] ::selection {
    background: rgba(10, 132, 255, 0.28);
}

/* Focus-visible ring — accessible keyboard focus */
:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* macOS-style thin scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.15) transparent;
}
[data-theme="dark"] * {
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ============================================
   Side Rail (desktop left icon bar)
   ============================================ */
body:has(.side-rail) {
    display: flex;
    min-height: 100dvh;
}

.side-rail {
    width: 64px;
    height: 100dvh;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--color-glass);
    backdrop-filter: saturate(180%) blur(var(--glass-blur));
    -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
    border-right: 0.5px solid var(--color-glass-border);
    z-index: 200;
    padding: 8px 0;
    box-sizing: border-box;
}

.side-rail-logo {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-accent);
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease);
    text-decoration: none;
}
.side-rail-logo:hover { background: var(--color-overlay); }
.side-rail-logo svg { width: 20px; height: 20px; }

.side-rail-plugins {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    width: 100%;
    padding: 0 6px;
}
.side-rail-plugins::-webkit-scrollbar { display: none; }

.side-rail-icon {
    width: 52px;
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease);
    position: relative;
    text-decoration: none;
    border: none;
    background: transparent;
    flex-shrink: 0;
    padding: 4px 2px;
}
.side-rail-icon:hover {
    background: var(--color-overlay);
    color: var(--color-text-secondary);
}
.side-rail-icon.active {
    color: var(--color-accent);
    background: var(--color-info-bg);
}
.side-rail-icon.active::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 20px;
    background: var(--color-accent);
    border-radius: 0 2px 2px 0;
}
.side-rail-icon svg { width: 18px; height: 18px; flex-shrink: 0; }
.side-rail-icon-label {
    font-size: var(--font-size-xs);
    line-height: 1.1;
    font-weight: 500;
    max-width: 50px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-rail-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 6px 4px;
    border-top: 0.5px solid var(--color-border);
    width: 100%;
}

.side-rail-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    font-size: 10px;
    background: #ef4444;
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Side Panel (flyout for subnav) */
.side-panel {
    position: fixed;
    left: 64px;
    top: 0;
    width: 220px;
    height: 100dvh;
    background: var(--color-glass);
    backdrop-filter: saturate(180%) blur(var(--glass-blur));
    -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
    border-right: 0.5px solid var(--color-glass-border);
    box-shadow: var(--shadow-hover);
    z-index: 199;
    padding: 16px 8px;
    display: none;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}
.side-panel.open { display: flex; }
.side-panel-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    padding: 6px 10px 10px;
}
.side-panel-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-xs);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease);
}
.side-panel-link:hover { background: var(--color-overlay); color: var(--color-text); }
.side-panel-link.active { color: var(--color-accent); font-weight: 500; background: var(--color-info-bg); }
.side-panel-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.side-panel-section {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    padding: 12px 10px 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* App Shell */
.app-shell {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* Mini Topbar — macOS title bar feel */
.mini-topbar {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 0.5px solid var(--color-border);
    background: var(--color-glass);
    backdrop-filter: saturate(180%) blur(var(--glass-blur));
    -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
    flex-shrink: 0;
    z-index: 50;
}
.mini-topbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    min-width: 0;
}
.mini-topbar-plugin-name {
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}
.mini-topbar-sep {
    color: var(--color-text-muted);
    font-size: 12px;
}
.mini-topbar-nav-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    white-space: nowrap;
    transition: all var(--duration-fast) var(--ease);
}
.mini-topbar-nav-link:hover { background: var(--color-overlay); color: var(--color-text); }
.mini-topbar-nav-link.active { color: var(--color-accent); font-weight: 500; }
.mini-topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}
.mini-topbar-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease);
    text-decoration: none;
}
.mini-topbar-btn:hover { background: var(--color-overlay); color: var(--color-text-secondary); }
.mini-topbar-btn svg { width: 15px; height: 15px; }

/* Hide old topbar on desktop, show on mobile */
@media (min-width: 961px) {
    .topbar { display: none !important; }
    .subnav { display: none !important; }
}

/* Hide side-rail on mobile */
@media (max-width: 960px) {
    .side-rail { display: none !important; }
    .side-panel { display: none !important; }
    .mini-topbar { display: none !important; }
    .app-shell { width: 100%; min-height: auto; display: block; }
    body:has(.side-rail) { display: block; }
}

/* ============================================
   Topbar Navigation (mobile only now)
   ============================================ */
.topbar {
    background: var(--color-glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 52px;
}

.topbar-inner {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 100%;
    gap: 8px;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    margin-right: 16px;
    flex-shrink: 0;
}

.topbar-logo:hover {
    text-decoration: none;
    opacity: 0.8;
}

.topbar-logo svg {
    width: 22px;
    height: 22px;
    color: var(--color-accent);
}

/* Plugin tabs in topbar */
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.topbar-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 400;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--duration-fast) var(--ease);
}

.topbar-tab:hover {
    color: var(--color-text);
    background: var(--color-bg-secondary);
    text-decoration: none;
}

.topbar-tab svg {
    width: 16px;
    height: 16px;
}

.topbar-tab.active {
    color: var(--color-text);
    font-weight: 500;
    background: var(--color-overlay);
}

/* Drag-and-drop tab reordering */
.topbar-tab[draggable="true"] { cursor: grab; }
.topbar-tab[draggable="true"]:active { cursor: grabbing; }
.topbar-tab.tab-dragging { opacity: 0.35; }
.topbar-tab.tab-drop-before { box-shadow: -2px 0 0 0 var(--color-accent); }
.topbar-tab.tab-drop-after { box-shadow: 2px 0 0 0 var(--color-accent); }

/* Service status dot */
.svc-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-border);
    flex-shrink: 0;
    transition: background 0.3s ease;
}
.svc-dot.idle   { background: var(--color-success); }
.svc-dot.busy   { background: var(--color-warning); }
.svc-dot.error  { background: var(--color-error); }

/* Tab close button */
.topbar-tab {
    position: relative;
}
.topbar-tab-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 50%;
    color: var(--color-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.12s ease;
    margin-left: -2px;
}
.topbar-tab:hover .topbar-tab-close {
    display: inline-flex;
}
.topbar-tab:hover .svc-dot {
    display: none;
}
.topbar-tab-close:hover {
    background: var(--color-overlay);
    color: var(--color-text);
}
.topbar-tab-close svg {
    width: 12px;
    height: 12px;
}

/* App Drawer trigger in topbar (next to settings icons) */
.topbar-app-drawer-btn {
    color: var(--color-accent);
    border: none;
    background: none;
    cursor: pointer;
}
.topbar-app-drawer-btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

/* ============================================
   App Drawer — macOS Launchpad / iOS style
   ============================================ */

/* Overlay */
.app-drawer-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-overlay-heavy);
    backdrop-filter: blur(8px) saturate(150%);
    -webkit-backdrop-filter: blur(8px) saturate(150%);
    z-index: 1100;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 52px 80px 0 0;
    animation: overlayFadeIn 0.18s ease-out;
}
.app-drawer-overlay:not(.active) {
    display: none;
}

/* Panel: drops down from topbar button */
.app-drawer {
    background: var(--color-glass);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    border: 1px solid var(--color-glass-border);
    border-radius: 14px;
    width: 380px;
    max-width: 94vw;
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    box-shadow:
        0 0 0 0.5px rgba(0, 0, 0, 0.04),
        0 12px 48px rgba(0, 0, 0, 0.15),
        0 2px 6px rgba(0, 0, 0, 0.06);
    transform-origin: top right;
    animation: drawerDropIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
    overflow: hidden;
}
@keyframes drawerDropIn {
    from { opacity: 0; transform: scale(0.92) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}


/* Header */
.app-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px 4px;
    flex-shrink: 0;
}
.app-drawer-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: 0.01em;
}

/* Close button */
.app-drawer-close-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--color-overlay);
    border-radius: 50%;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all 0.12s ease;
}
.app-drawer-close-btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}
.app-drawer-close-btn svg {
    width: 13px;
    height: 13px;
}

/* Scrollable body */
.app-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 6px 16px 18px;
}
.app-drawer-body::-webkit-scrollbar {
    width: 3px;
}
.app-drawer-body::-webkit-scrollbar-thumb {
    background: var(--color-text-muted);
    border-radius: 3px;
}

/* Group */
.app-drawer-group {
    margin-bottom: 4px;
}
.app-drawer-group:last-child {
    margin-bottom: 0;
}
.app-drawer-group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    padding: 10px 6px 6px;
    letter-spacing: 0.03em;
}


/* Grid */
.app-drawer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
}

/* Card */
.app-drawer-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px 6px 8px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--color-text);
    position: relative;
    transition: background 0.15s ease, transform 0.15s var(--ease-spring);
    -webkit-tap-highlight-color: transparent;
}
.app-drawer-card:hover {
    background: var(--color-overlay);
    text-decoration: none;
    transform: translateY(-2px);
}
.app-drawer-card:active {
    transform: scale(0.94);
    transition: transform 0.08s ease;
}

/* Pinned ring */
.app-drawer-card.pinned .app-drawer-card-icon {
    box-shadow:
        0 0 0 2px var(--color-bg-card),
        0 0 0 3.5px var(--color-accent),
        0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Icon */
.app-drawer-card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-accent), #5856D6);
    color: var(--color-text-inverse);
    margin-bottom: 6px;
    flex-shrink: 0;
    box-shadow: var(--shadow-hover);
    transition: transform 0.15s ease;
}
.app-drawer-card:hover .app-drawer-card-icon {
    transform: scale(1.08);
}
.app-drawer-card-icon svg {
    width: 24px;
    height: 24px;
}

/* Name */
.app-drawer-card-name {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--color-text);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Service dot */
.app-drawer-card .svc-dot {
    position: absolute;
    top: 6px;
    right: 6px;
}

/* Legacy elements hidden */
.app-drawer-card-info,
.app-drawer-card-desc,
.app-drawer-pin-badge,
.app-drawer-group-count {
    display: none;
}

/* Testing plugins dropdown */
.topbar-testing-dropdown {
    position: relative;
}
.topbar-testing-btn {
    cursor: pointer;
    border: 1px dashed var(--color-border);
    background: transparent;
    opacity: 0.75;
}
.topbar-testing-btn:hover {
    opacity: 1;
}
.topbar-testing-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-modal);
    z-index: 100;
    padding: 4px;
    animation: testing-dropdown-in 0.15s ease;
}
@keyframes testing-dropdown-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.topbar-testing-menu.open {
    display: block;
}
.topbar-testing-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm, 6px);
    transition: all 0.12s ease;
}
.topbar-testing-item:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    text-decoration: none;
}
.topbar-testing-item.active {
    color: var(--color-text);
    font-weight: 500;
}
.topbar-testing-item svg {
    width: 15px; height: 15px;
}
.testing-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    font-weight: 600;
    margin-left: auto;
}
/* Accent color swatches */
.accent-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    position: relative;
    padding: 0;
}
.accent-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.accent-swatch.active {
    border-color: var(--color-text);
    box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px currentColor;
}
.accent-swatch::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.theme-option:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}
.theme-option.active {
    color: var(--color-accent);
    font-weight: 600;
    background: var(--color-info-bg);
}
.theme-option.active::after {
    content: '';
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-accent);
    margin-left: auto;
    flex-shrink: 0;
}

.topbar-drawer-section {
    padding: 12px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.topbar-drawer-link.testing {
    opacity: 0.8;
}

/* 移动端抽屉内：测试中插件折叠块（默认折叠） */
.drawer-testing-details {
    border: none;
    margin: 0;
}
.drawer-testing-summary {
    padding: 12px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}
.drawer-testing-summary::-webkit-details-marker { display: none; }
.drawer-testing-chevron {
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
    transition: transform 0.2s ease;
}
.drawer-testing-details[open] .drawer-testing-chevron {
    transform: rotate(180deg);
}
.drawer-testing-links {
    padding-left: 8px;
}

/* Plugin management card styles */
.plugin-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.plugin-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 10px;
    transition: all 0.15s ease;
}
.plugin-row:hover {
    background: var(--color-bg-secondary, #f9fafb);
}
.plugin-row-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #6366f1, var(--color-purple));
    color: var(--color-text-inverse);
    flex-shrink: 0;
}
.plugin-row-icon svg { width: 18px; height: 18px; }
.plugin-row-info { flex: 1; min-width: 0; }
.plugin-row-name { font-size: 14px; font-weight: 600; }
.plugin-row-desc { font-size: 12px; color: var(--color-text-secondary); margin-top: 2px; }
.plugin-row-actions { flex-shrink: 0; }
.plugin-state-select {
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--color-bg-card);
    color: var(--color-text);
    cursor: pointer;
    transition: border-color 0.15s ease;
    outline: none;
}
.plugin-state-select:focus {
    border-color: var(--color-accent);
}
.plugin-state-select.state-enabled { border-color: var(--color-success); color: var(--color-success-text); }
.plugin-state-select.state-testing { border-color: var(--color-warning); color: var(--color-warning-text); }
.plugin-state-select.state-disabled { border-color: var(--color-error); color: var(--color-error-text); }

/* System settings gear icon */
.topbar-settings {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    text-decoration: none;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.topbar-settings:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.topbar-settings.active {
    color: var(--color-accent);
}

.topbar-settings svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   Sub-navigation (inside a plugin)
   ============================================ */
.subnav {
    background: var(--color-bg-card);
    border-bottom: 0.5px solid var(--color-border);
    position: sticky;
    top: 52px;
    z-index: 99;
}

.subnav-inner {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 44px;
}

/* 第三排：与第二排同宽的 inner，内部 .subnav-row3-links 由 JS 对齐到父项正下方 */
.subnav-row3-wrap {
    background: var(--color-bg-secondary);
    border-top: 0.5px solid var(--color-border);
}
.subnav-row3-inner {
    position: relative;
    height: 38px;
    display: flex;
    align-items: center;
}
.subnav-row3-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    height: 38px;
    box-sizing: border-box;
}
.subnav-row3-links .subnav-link {
    font-size: 12px;
    padding: 5px 12px;
}
.subnav-row3-links .subnav-link svg {
    width: 14px;
    height: 14px;
}

.subnav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.subnav-link:hover {
    color: var(--color-text);
    background: var(--color-bg-secondary);
    text-decoration: none;
}

.subnav-link svg {
    width: 15px;
    height: 15px;
}

.subnav-link.active {
    color: var(--color-accent);
    font-weight: 500;
    background: transparent;
    border-bottom: 2px solid var(--color-accent);
    border-radius: 0;
    padding-bottom: 4px;
}


/* ============================================
   Main Content Area
   ============================================ */
.main {
    max-width: 1600px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
    padding: var(--spacing-3xl) var(--spacing-2xl) 48px;
    min-height: calc(100vh - 40px);
    flex: 1;
}
@media (min-width: 1800px) {
    .main { max-width: 1800px; }
}

/* ============================================
   Common Button Styles — Apple-native
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    height: 36px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: var(--font);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease);
    border: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    filter: brightness(0.95);
}

.btn:active {
    filter: brightness(0.90);
    transform: scale(0.98);
}

.btn svg {
    width: 14px;
    height: 14px;
}

.btn-primary {
    background: var(--color-accent);
    color: var(--color-text-inverse);
}

.btn-primary:hover {
    filter: brightness(0.92);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: none;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-overlay);
    filter: none;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    padding: 8px;
}

.btn-ghost:hover {
    background: var(--color-overlay);
    color: var(--color-text);
    filter: none;
}

.btn-small, .btn-sm {
    padding: 4px 10px;
    height: 28px;
    font-size: var(--font-size-xs);
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-lg {
    padding: 10px 24px;
    height: 44px;
    font-size: var(--font-size-base);
}

/* ============================================
   Common Card Styles
   ============================================ */
.card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: var(--spacing-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xl);
    border-bottom: 0.5px solid var(--color-border);
}

.card-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.card-title svg {
    width: 18px;
    height: 18px;
    color: var(--color-accent);
}

.card-body {
    padding: var(--spacing-xl);
}

/* ============================================
   Common Form Styles — Apple-native
   ============================================ */
.form-input {
    width: 100%;
    padding: 10px 12px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
    background: var(--color-bg-card);
    color: var(--color-text);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12), 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .form-input:focus {
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.12);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}

.form-group {
    margin-bottom: 16px;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ============================================
   Tags
   ============================================ */
.tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: var(--font-size-xs);
    font-family: var(--font-mono);
    letter-spacing: 0.01em;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
}

.tag-accent {
    background: var(--color-info-bg);
    color: var(--color-accent);
}

.tag-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.tag.muted {
    color: var(--color-text-muted);
}

.status-badge {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}

.status-badge.success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.status-badge.error {
    background: var(--color-error-bg);
    color: var(--color-error);
}

.status-badge.warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--color-text-muted);
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
}

/* ============================================
   Loading & Spinner
   ============================================ */
.loading-state {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner, .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
    margin: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Modal — unified glass overlay
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-overlay-medium);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayFadeIn var(--duration-normal) var(--ease);
}

.modal-overlay:not(.active) {
    display: none;
}

.modal-content {
    background: var(--color-bg-card);
    border: 1px solid var(--color-glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-modal);
    animation: modalSlideUp var(--duration-slow) var(--ease-spring);
}

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

.modal-title {
    font-size: 17px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 4px;
    border-radius: 4px;
    display: flex;
}

.modal-close:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

/* 分享链接弹层 */
.share-link-modal-content {
    max-width: 520px;
    width: 95%;
}
.share-link-body {
    padding-top: 4px;
}
.share-link-label {
    display: block;
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}
.share-link-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-family: var(--font);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-secondary);
    color: var(--color-text);
    margin-bottom: 16px;
    box-sizing: border-box;
}
.share-link-input:focus {
    outline: none;
    border-color: var(--color-accent);
}
.share-link-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--color-glass);
    backdrop-filter: saturate(180%) blur(var(--glass-blur));
    -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
    border: 0.5px solid var(--color-glass-border);
    border-radius: var(--radius);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn var(--duration-normal) var(--ease-spring);
    max-width: 360px;
    transition: opacity var(--duration-normal) var(--ease), transform var(--duration-normal) var(--ease);
}

.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-error); }
.toast.info { border-left: 3px solid var(--color-accent); }

.toast svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.toast.success svg { color: var(--color-success); }
.toast.error svg { color: var(--color-error); }
.toast.info svg { color: var(--color-accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============================================
   Progress Bar (shared)
   ============================================ */
.progress-bar {
    height: 6px;
    background: var(--color-bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

.progress-fill {
    height: 100%;
    background: var(--color-accent);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 13px;
    color: var(--color-text-secondary);
    text-align: center;
}

/* ============================================
   Status Bar
   ============================================ */
.status-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--color-info-bg);
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--color-accent);
}

.status-bar.active {
    display: flex;
}

/* ============================================
   Info Rows (Settings-style)
   ============================================ */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 0.5px solid var(--color-border);
    gap: 24px;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 14px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    min-width: 100px;
}

.info-value {
    font-size: 14px;
    color: var(--color-text);
    text-align: right;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.info-value.path {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
}

.action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

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

.action-info h4 {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
}

.action-info p {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.action-row .btn {
    flex-shrink: 0;
}

/* ============================================
   Page Footer — hidden by default, minimal
   ============================================ */
.page-footer {
    display: none;
}
.page-footer-quote {
    display: none;
}

/* ============================================
   Unified Drawer (iPad-style rounded panel)
   All plugin drawers inherit from .xpp-drawer.
   Sits inside the plugin frame: below subnav, above footer.
   Draggable by header, resizable by left edge.
   ============================================ */
:root {
    --xpp-drawer-inset: 12px;  /* equal gap top & bottom from frame edges */
    --xpp-drawer-top: calc(96px + var(--xpp-drawer-inset));  /* topbar 52 + subnav 44 + gap */
    --xpp-drawer-bottom: var(--xpp-drawer-inset);
    --xpp-drawer-width: min(500px, 90vw);
    --xpp-drawer-radius: 14px;
    --xpp-drawer-z: 500;
}
.xpp-drawer {
    position: fixed;
    top: var(--xpp-drawer-top);
    bottom: var(--xpp-drawer-bottom);
    right: var(--xpp-drawer-inset);
    width: var(--xpp-drawer-width);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--xpp-drawer-radius);
    box-shadow: var(--shadow-modal);
    z-index: var(--xpp-drawer-z);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(calc(100% + 24px));
    transition: transform var(--duration-slow) cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: none;
}
.xpp-drawer.open {
    transform: translateX(0);
    pointer-events: auto;
}
.xpp-drawer.xpp-drawer-dragging,
.xpp-drawer.xpp-drawer-resizing {
    transition: none !important;
    user-select: none;
}
.xpp-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    background: var(--color-bg);
    border-radius: var(--xpp-drawer-radius) var(--xpp-drawer-radius) 0 0;
    cursor: grab;
}
.xpp-drawer-header:active { cursor: grabbing; }
.xpp-drawer-header .xpp-drawer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    pointer-events: none;
}
.xpp-drawer-header .xpp-drawer-title svg,
.xpp-drawer-header .xpp-drawer-title i { width: 16px; height: 16px; }
.xpp-drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    color: var(--color-text-muted, #94a3b8);
    display: flex;
    align-items: center;
    transition: background 0.12s;
    pointer-events: auto;
}
.xpp-drawer-close:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}
.xpp-drawer-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 14px 16px;
}
/* Left-edge resize handle */
.xpp-drawer-resize {
    position: absolute;
    left: -3px; top: 0; bottom: 0; width: 6px;
    cursor: col-resize; z-index: 5;
}
.xpp-drawer-resize::after {
    content: ''; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 28px; border-radius: 2px;
    background: var(--color-border);
    opacity: 0; transition: opacity 0.15s;
}
.xpp-drawer-resize:hover::after,
.xpp-drawer.xpp-drawer-resizing .xpp-drawer-resize::after {
    opacity: 1;
}
@media (max-width: 768px) {
    :root { --xpp-drawer-width: calc(100vw - 16px); }
    .xpp-drawer { right: 8px; }
    .xpp-drawer-resize { display: none; }
}

/* Drawer floating toggle pill */
.xpp-drawer-pill {
    position: fixed;
    z-index: var(--xpp-drawer-z, 500);
    right: 14px;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--color-text);
    color: var(--color-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-hover);
    transition: opacity 0.18s, transform 0.18s;
    opacity: 0; pointer-events: none;
    transform: scale(0.8);
}
.xpp-drawer-pill.visible {
    opacity: 1; pointer-events: auto; transform: scale(1);
}
.xpp-drawer-pill:hover { opacity: 0.85; }
.xpp-drawer-pill svg, .xpp-drawer-pill i { width: 18px; height: 18px; }

/* ============================================
   Tabs (in-page navigation)
   ============================================ */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--color-border);
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font);
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--color-text);
}

.tab-btn.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
}

.stat-card-label {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-card-label svg {
    width: 14px;
    height: 14px;
}

.stat-card-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-accent);
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}

.stat-card-sub {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* ============================================
   Filter Bar
   ============================================ */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--color-bg-secondary);
    border-radius: 10px;
}

.filter-bar input,
.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
}

.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--color-accent);
}

.filter-bar input[type="text"] {
    width: 200px;
}

.filter-bar .filter-sep {
    width: 1px;
    height: 24px;
    background: var(--color-border);
}

.filter-bar .filter-label {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.filter-bar .filter-info {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-left: auto;
    white-space: nowrap;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--color-info-bg);
    color: var(--color-accent);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

.filter-chip .remove-filter {
    cursor: pointer;
    font-weight: 700;
    margin-left: 2px;
}

/* ============================================
   Results Table
   ============================================ */
.results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    background: var(--color-bg-card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.results-table th,
.results-table td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.results-table th {
    background: var(--color-bg-secondary);
    font-weight: 600;
    position: sticky;
    top: 0;
    font-size: var(--font-size-xs);
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
    color: var(--color-text-secondary);
    cursor: pointer;
    user-select: none;
    transition: background var(--duration-fast) var(--ease);
}

.results-table th:hover {
    background: var(--color-bg-secondary);
}

.results-table th .sort-arrow {
    font-size: 10px;
    margin-left: 4px;
    opacity: .3;
}

.results-table th.sorted .sort-arrow {
    opacity: 1;
    color: var(--color-accent);
}

.results-table tr {
    transition: background var(--duration-fast) var(--ease);
}
.results-table tr:hover td {
    background: var(--color-overlay);
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table .cell-title {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    font-size: 14px;
    color: var(--color-text);
}

.results-table .cell-meta {
    color: var(--color-text-secondary);
    font-size: 12px;
}

.results-table .action-link {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    transition: background .2s;
}

.results-table .action-link:hover {
    background: var(--color-bg-secondary);
    text-decoration: none;
}

/* Table responsive wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 8px;
}

/* ============================================
   Feature Components (Analysis / Dashboard)
   ============================================ */

.feat-section {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.feat-section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.feat-section-title svg { width: 16px; height: 16px; }

.feat-stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.feat-stat {
    padding: 12px 16px;
    background: var(--color-bg-card);
    border: 0.5px solid var(--color-border);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    min-width: 110px;
    flex: 1;
}
.feat-stat::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    border-radius: 3px 0 0 3px;
    background: var(--color-border);
}
.feat-stat.accent-blue::before  { background: var(--color-blue); }
.feat-stat.accent-green::before { background: var(--color-success-text); }
.feat-stat.accent-amber::before { background: var(--color-orange); }
.feat-stat.accent-purple::before { background: var(--color-purple); }
.feat-stat.accent-red::before   { background: var(--color-error); }
.feat-stat.accent-cyan::before  { background: var(--color-cyan); }

.feat-stat .label {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 3px;
    white-space: nowrap;
}
.feat-stat .value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--color-accent);
}
.feat-stat .sub {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.feat-table-wrap {
    overflow-x: auto;
    border: 0.5px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg-card);
}
.feat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.feat-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    white-space: nowrap;
    border-bottom: 0.5px solid var(--color-border);
}
.feat-table td {
    padding: 8px 12px;
    border-bottom: 0.5px solid color-mix(in srgb, var(--color-border) 60%, transparent);
}
.feat-table tr:last-child td { border-bottom: none; }
.feat-table tr:hover td { background: var(--color-overlay); }
.feat-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.results-table td { font-variant-numeric: tabular-nums; }
.feat-table .highlight td { background: var(--color-info-bg); font-weight: 500; }
.feat-table .summary td {
    background: var(--color-bg-secondary);
    font-weight: 600;
    border-top: 1.5px solid var(--color-border);
    border-bottom: none;
}
.feat-table a { color: var(--color-accent); text-decoration: none; font-weight: 500; }
.feat-table a:hover { text-decoration: underline; }

.feat-pill {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--color-bg-secondary);
    white-space: nowrap;
}
.feat-pill.positive { background: var(--color-success-bg); color: var(--color-success-text); }
.feat-pill.negative { background: var(--color-error-bg); color: var(--color-error-text); }
.feat-pill.neutral  { background: var(--color-bg-secondary); color: var(--color-text-muted); }

.feat-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--color-bg-secondary);
    overflow: hidden;
}
.feat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.feat-chart-bar {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 80px;
}
.feat-chart-bar .bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.feat-chart-bar .bar-val {
    font-size: 10px;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}
.feat-chart-bar .bar-fill {
    width: 100%;
    max-width: 40px;
    border-radius: 3px 3px 0 0;
    transition: height 0.4s ease;
}
.feat-chart-bar .bar-label {
    font-size: 10px;
    color: var(--color-text-muted);
}

.feat-footnote {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 10px;
}

@media (max-width: 640px) {
    .feat-stat-row { gap: 8px; }
    .feat-stat { min-width: 90px; padding: 10px 12px; }
    .feat-stat .value { font-size: 18px; }
    .feat-table th, .feat-table td { padding: 7px 8px; }
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding: 12px 0;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: var(--color-text-muted);
}

.pagination-btns {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pagination-btns button {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font);
    color: var(--color-text-secondary);
    transition: all .15s;
}

.pagination-btns button:hover:not(:disabled) {
    background: var(--color-bg-secondary);
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-1px);
}

.pagination-btns button.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-inverse);
    font-weight: 600;
}

.pagination-btns button:disabled {
    opacity: .4;
    cursor: default;
}

.pagination-btns .page-ellipsis {
    width: 36px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
    user-select: none;
}

.page-size-select {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.page-size-select select {
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--color-bg);
}

/* ============================================
   Config Panel
   ============================================ */
.config-panel {
    background: var(--color-bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.config-item label {
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.config-item input,
.config-item select {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
}

.config-item input[type="checkbox"] {
    width: auto;
}

/* ============================================
   History List
   ============================================ */
.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}

.history-item:hover {
    background: var(--color-overlay);
    transform: translateX(2px);
}

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

.history-item-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item-title {
    font-weight: 600;
    color: var(--color-text);
}

.history-item-time {
    font-size: 12px;
    color: var(--color-text-muted);
}

.history-item-stats {
    text-align: right;
}

.history-item-count {
    font-size: 18px;
    font-weight: 600;
}

.history-item-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}

.history-item-status.completed {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.history-item-status.failed {
    background: var(--color-error-bg);
    color: var(--color-error);
}

.history-item-status.running {
    background: var(--color-info-bg);
    color: var(--color-accent);
}

/* ============================================
   Section heading (page-level)
   ============================================ */
.page-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-title svg {
    width: 22px;
    height: 22px;
    color: var(--color-accent);
}

/* ============================================
   Stock Toolbar (shared action bar)
   ============================================ */
.stock-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ============================================
   Responsive — 手机 / iPad / 平板
   ============================================ */

/* 安全区域（刘海屏、圆角） */
@supports (padding: max(0px)) {
    .topbar-inner { padding-left: max(16px, env(safe-area-inset-left)); }
    .page-footer { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

/* 平板 (768px - 1024px) */
@media (max-width: 1024px) {
    .topbar-inner,
    .subnav-inner {
        padding: 0 20px;
    }

    .main {
        padding: var(--spacing-2xl) var(--spacing-xl) 56px;
        max-width: 100%;
    }

    .card-header,
    .card-body {
        padding: var(--spacing-lg);
    }

    .topbar-tab {
        padding: 8px 10px;
        font-size: 13px;
    }

    .subnav-inner {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .subnav-inner::-webkit-scrollbar { display: none; }
    .subnav-link {
        flex-shrink: 0;
    }

    .modal-content {
        max-width: 90%;
    }

    .info-row {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }
    .info-value {
        justify-content: flex-start;
        text-align: left;
    }

    .action-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .action-row .btn {
        align-self: flex-start;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        top: 70px;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }
}

/* 手机 + 小平板 (< 768px) */
@media (max-width: 768px) {
    .topbar-inner,
    .subnav-inner {
        padding: 0 12px;
    }

    .main {
        padding: var(--spacing-xl) var(--spacing-md) 48px;
    }

    /* 移动端：隐藏标签文字，仅显示图标 */
    .topbar-tab span:not(.svc-dot) {
        display: none;
    }

    .topbar-logo span {
        display: none;
    }

    .topbar-tab {
        padding: 8px 10px;
    }

    .topbar-settings {
        width: 40px;
        height: 40px;
    }

    .subnav {
        top: 52px;
    }
    .subnav-link {
        font-size: 12px;
        padding: 6px 12px;
    }

    .empty-state,
    .loading-state {
        padding: 40px 16px;
    }

    .empty-state svg {
        width: 48px;
        height: 48px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px; /* 触摸友好 */
    }

    .form-input {
        padding: 12px 14px;
        font-size: 16px; /* 防止 iOS 缩放 */
    }

    .modal-content {
        width: calc(100% - 32px);
        max-width: none;
        margin: 16px;
    }

    .page-footer {
        padding: 8px 16px;
    }
    .page-footer-quote {
        font-size: 11px;
    }

    /* Shared components responsive */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab-btn {
        padding: 8px 14px;
        font-size: 13px;
        flex-shrink: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stat-card {
        padding: 12px;
    }
    .stat-card-value {
        font-size: 20px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
    }
    .filter-bar input[type="text"] {
        width: 100%;
    }
    .filter-bar .filter-sep {
        display: none;
    }

    .results-table th,
    .results-table td {
        padding: 10px 12px;
        font-size: 12px;
    }

    .pagination {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .stock-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .stock-toolbar .btn {
        justify-content: center;
    }
}

/* 小屏手机 (< 480px) */
@media (max-width: 480px) {
    .topbar-inner {
        padding: 0 8px;
        gap: 4px;
    }

    .main {
        padding: var(--spacing-lg) var(--spacing-sm) 48px;
    }

    .topbar-tab {
        padding: 8px;
    }

    .card {
        border-radius: var(--radius-sm);
    }

    .card-header {
        padding: var(--spacing-lg);
    }

    .card-body {
        padding: var(--spacing-lg);
    }

    .modal-content {
        margin: 8px;
        width: calc(100% - 16px);
    }
}

/* 移动端汉堡菜单：窄屏时显示，点击展开插件列表 */
.topbar-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    cursor: pointer;
    flex-shrink: 0;
}
.topbar-menu-btn:hover {
    background: var(--color-bg-secondary);
}
.topbar-menu-btn svg {
    width: 22px;
    height: 22px;
}

/* 移动端导航抽屉 */
.topbar-drawer {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-overlay-heavy);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.topbar-drawer.open {
    opacity: 1;
    visibility: visible;
}
.topbar-drawer-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: min(280px, 85vw);
    max-height: 100%;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border);
    box-shadow: var(--shadow-modal);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 12px 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.topbar-drawer.open .topbar-drawer-panel {
    transform: translateX(0);
}
.topbar-drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    font-size: 15px;
    color: var(--color-text);
    text-decoration: none;
    border-radius: 0;
    transition: background 0.15s;
}
.topbar-drawer-link:hover {
    background: var(--color-bg-secondary);
    text-decoration: none;
}
.topbar-drawer-link.active {
    background: var(--color-overlay);
    font-weight: 500;
}
.topbar-drawer-link svg {
    width: 20px;
    height: 20px;
    color: var(--color-accent);
}
.topbar-drawer-link .svc-dot {
    margin-left: auto;
}

@media (max-width: 640px) {
    /* 窄屏：隐藏顶部 tab，显示汉堡菜单 */
    .topbar-nav {
        display: none;
    }
    .topbar-menu-btn {
        display: flex;
    }
    .topbar-drawer {
        display: block;
    }
}

/* ============================================
   XPP Unified Components: Loading / Skeleton / Empty
   ============================================ */

/* -- xpp-loading: centered spinner with optional text -- */
.xpp-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    gap: 12px;
    color: var(--color-text-secondary);
    font-size: 14px;
}
.xpp-loading .xpp-loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* -- xpp-skeleton: shimmer placeholders -- */
.xpp-skeleton {
    background: linear-gradient(90deg,
        var(--color-bg-secondary) 25%,
        var(--color-border) 50%,
        var(--color-bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: xpp-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm, 6px);
}
.xpp-skeleton--text {
    height: 14px;
    margin-bottom: 10px;
    border-radius: 4px;
}
.xpp-skeleton--text:last-child {
    width: 60%;
}
.xpp-skeleton--rect {
    height: 120px;
    border-radius: var(--radius, 12px);
    margin-bottom: 16px;
}
.xpp-skeleton--circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}
@keyframes xpp-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* -- xpp-empty: enhanced empty state with optional CTA -- */
.xpp-empty {
    text-align: center;
    padding: 56px 24px;
    color: var(--color-text-secondary);
}
.xpp-empty .xpp-empty-icon {
    width: 56px;
    height: 56px;
    color: var(--color-text-muted);
    margin: 0 auto 14px;
    opacity: 0.7;
}
.xpp-empty .xpp-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}
.xpp-empty .xpp-empty-desc {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}
.xpp-empty .xpp-empty-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    background: var(--color-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.xpp-empty .xpp-empty-action:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

@media (max-width: 640px) {
    .xpp-loading { padding: 32px 16px; }
    .xpp-empty { padding: 40px 16px; }
    .xpp-empty .xpp-empty-icon { width: 44px; height: 44px; }
}

/* ═══════════════════════════════════════════════════════════════
   XPP Brand Icon  –  blue circle + diamond
   Usage: <span class="xpp-brand-icon"></span>
   Size controlled by font-size or --xpp-icon-size
   ═══════════════════════════════════════════════════════════════ */
.xpp-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--xpp-icon-size, 24px);
    height: var(--xpp-icon-size, 24px);
    flex-shrink: 0;
}
.xpp-brand-icon::after {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='44' fill='none' stroke='%23007AFF' stroke-width='7'/%3E%3Cg transform='rotate(-30 50 50)'%3E%3Cpath d='M50 20 L70 50 L50 80 L30 50 Z' fill='%23007AFF'/%3E%3Cpath d='M50 32 L60 50 L50 68 L40 50 Z' fill='white'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat;
}

/* ============================================
   Entrance Animations — staggered fade-in for page content
   ============================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.animate-in {
    animation: fadeInUp 0.4s var(--ease) both;
}

.page-title,
.stats-grid,
.filter-bar,
.card,
.feat-section,
.gs-card,
.s-card,
.xpp-stat,
.gs-hero {
    animation: fadeInUp 0.45s var(--ease) both;
}

.page-title { animation-delay: 0ms; }
.gs-hero { animation-delay: 0ms; }
.stats-grid, .xpp-stats { animation-delay: 60ms; }
.filter-bar { animation-delay: 100ms; }

.gs-card:nth-child(1) { animation-delay: 80ms; }
.gs-card:nth-child(2) { animation-delay: 130ms; }
.gs-card:nth-child(3) { animation-delay: 180ms; }
.gs-card:nth-child(4) { animation-delay: 230ms; }
.gs-card:nth-child(5) { animation-delay: 280ms; }
.gs-card:nth-child(6) { animation-delay: 330ms; }
.gs-card:nth-child(7) { animation-delay: 380ms; }
.gs-card:nth-child(8) { animation-delay: 430ms; }

.card:nth-child(1),
.feat-section:nth-child(1),
.s-card:nth-child(1) { animation-delay: 60ms; }
.card:nth-child(2),
.feat-section:nth-child(2),
.s-card:nth-child(2) { animation-delay: 120ms; }
.card:nth-child(3),
.feat-section:nth-child(3),
.s-card:nth-child(3) { animation-delay: 180ms; }
.card:nth-child(4),
.feat-section:nth-child(4),
.s-card:nth-child(4) { animation-delay: 240ms; }

.xpp-stat:nth-child(1) { animation-delay: 60ms; }
.xpp-stat:nth-child(2) { animation-delay: 100ms; }
.xpp-stat:nth-child(3) { animation-delay: 140ms; }
.xpp-stat:nth-child(4) { animation-delay: 180ms; }

/* Scroll-triggered reveal */
.scroll-reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .animate-in,
    .page-title,
    .stats-grid,
    .filter-bar,
    .card,
    .feat-section,
    .gs-card,
    .s-card,
    .xpp-stat,
    .gs-hero {
        animation: none !important;
    }
    .scroll-reveal {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

/* ============================================
   View Transitions — smooth crossfade between pages
   ============================================ */
@view-transition {
    navigation: auto;
}
::view-transition-old(root) {
    animation: vt-fade-out var(--duration-fast) var(--ease);
}
::view-transition-new(root) {
    animation: vt-fade-in var(--duration-fast) var(--ease);
}
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }
