/* ===================================================================
   CC Design System — Desktop App Shell
   =================================================================== */

/* ===== Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ===== Theme Variables ===== */
:root,
[data-theme="dark"] {
    /* Backgrounds — surface elevation */
    --c2-bg-base: #1e1e2e;
    --c2-bg-deep: #16161e;
    --c2-bg-surface: #181825;
    --c2-bg-overlay: #2a2a3a;
    --c2-bg-highlight: #313244;
    --c2-bg-active: #45475a;

    /* Borders */
    --c2-border: #313244;
    --c2-border-subtle: #262637;
    --c2-border-light: #3a3a4a;
    --c2-border-active: #585b70;

    /* Text */
    --c2-text: #cdd6f4;
    --c2-text-muted: #9399b2;
    --c2-text-dim: #6c7086;

    /* Accent colors */
    --c2-accent-blue: #89b4fa;
    --c2-accent-green: #a6e3a1;
    --c2-accent-red: #f38ba8;
    --c2-accent-yellow: #f9e2af;
    --c2-accent-purple: #cba6f7;

    /* Semantic aliases */
    --c2-success: var(--c2-accent-green);
    --c2-danger: var(--c2-accent-red);
    --c2-warning: var(--c2-accent-yellow);
    --c2-info: var(--c2-accent-blue);

    /* Accent translucent */
    --c2-blue-04: rgba(137, 180, 250, 0.04);
    --c2-blue-08: rgba(137, 180, 250, 0.08);
    --c2-blue-15: rgba(137, 180, 250, 0.15);
    --c2-blue-18: rgba(137, 180, 250, 0.18);
    --c2-blue-30: rgba(137, 180, 250, 0.3);
    --c2-green-10: rgba(166, 227, 161, 0.1);
    --c2-green-12: rgba(166, 227, 161, 0.12);
    --c2-green-15: rgba(166, 227, 161, 0.15);
    --c2-green-18: rgba(166, 227, 161, 0.18);
    --c2-green-25: rgba(166, 227, 161, 0.25);
    --c2-green-30: rgba(166, 227, 161, 0.3);
    --c2-red-04: rgba(243, 139, 168, 0.04);
    --c2-red-12: rgba(243, 139, 168, 0.12);
    --c2-red-15: rgba(243, 139, 168, 0.15);
    --c2-red-18: rgba(243, 139, 168, 0.18);
    --c2-red-30: rgba(243, 139, 168, 0.3);
    --c2-red-40: rgba(243, 139, 168, 0.4);
    --c2-yellow-10: rgba(249, 226, 175, 0.1);
    --c2-yellow-12: rgba(249, 226, 175, 0.12);
    --c2-yellow-15: rgba(249, 226, 175, 0.15);
    --c2-yellow-18: rgba(249, 226, 175, 0.18);
    --c2-yellow-30: rgba(249, 226, 175, 0.3);
    --c2-yellow-40: rgba(249, 226, 175, 0.4);
    --c2-purple-40: rgba(203, 166, 247, 0.4);
    --c2-green-04: rgba(166, 227, 161, 0.04);

    /* Semantic surface aliases */
    --c2-bg-alt: var(--c2-bg-surface);
    --c2-bg-hover: var(--c2-bg-overlay);
    --c2-bg: var(--c2-bg-base);
    --c2-accent: var(--c2-accent-blue);

    /* Special */
    --c2-code: #11111b;
    --c2-shadow: rgba(0, 0, 0, 0.5);
    --c2-shadow-light: rgba(0, 0, 0, 0.4);
    --c2-resize-border: #585b70;
    --c2-window-border-glow: rgba(255, 255, 255, 0.05);
    --c2-overlay-bg: rgba(0, 0, 0, 0.75);
    --c2-scrollbar-thumb: #45475a;
    --c2-scrollbar-thumb-hover: #585b70;
    --c2-workspace-grad1: rgba(137, 180, 250, 0.03);
    --c2-workspace-grad2: rgba(203, 166, 247, 0.03);
    --c2-selection: rgba(137, 180, 250, 0.25);
    --c2-focus-ring: rgba(137, 180, 250, 0.5);
    --c2-hover-white: rgba(255, 255, 255, 0.1);
    --c2-hover-subtle: rgba(255, 255, 255, 0.02);
    --c2-blue-glow: rgba(137, 180, 250, 0.3);
    --c2-blue-glow-strong: rgba(137, 180, 250, 0.4);

    /* Spacing scale */
    --c2-space-1: 4px;
    --c2-space-2: 8px;
    --c2-space-3: 12px;
    --c2-space-4: 16px;
    --c2-space-5: 20px;
    --c2-space-6: 24px;
    --c2-space-7: 28px;
    --c2-space-8: 32px;

    /* Layout dimensions */
    --c2-titlebar-h: 36px;
    --c2-taskbar-h: 32px;

    /* Elevation */
    --c2-elevation-1: 0 1px 3px rgba(0, 0, 0, 0.2);
    --c2-elevation-2: 0 4px 12px rgba(0, 0, 0, 0.3);
    --c2-elevation-3: 0 8px 32px rgba(0, 0, 0, 0.5);

    /* Radius */
    --c2-radius-sm: 4px;
    --c2-radius-md: 6px;
    --c2-radius-lg: 8px;
    --c2-radius-xl: 12px;

    /* Motion */
    --c2-transition-fast: 100ms ease;
    --c2-transition-normal: 150ms ease;
    --c2-transition-slow: 200ms ease;

    color-scheme: dark;
}

[data-theme="light"] {
    --c2-bg-base: #eff1f5;
    --c2-bg-deep: #e6e9ef;
    --c2-bg-surface: #dce0e8;
    --c2-bg-overlay: #ccd0da;
    --c2-bg-highlight: #bcc0cc;
    --c2-bg-active: #acb0be;
    --c2-border: #bcc0cc;
    --c2-border-subtle: #ccd0da;
    --c2-border-light: #ccd0da;
    --c2-border-active: #9ca0b0;
    --c2-text: #4c4f69;
    --c2-text-muted: #6c6f85;
    --c2-text-dim: #8c8fa1;
    --c2-accent-blue: #1e66f5;
    --c2-accent-green: #40a02b;
    --c2-accent-red: #d20f39;
    --c2-accent-yellow: #df8e1d;
    --c2-accent-purple: #8839ef;

    --c2-blue-04: rgba(30, 102, 245, 0.04);
    --c2-blue-08: rgba(30, 102, 245, 0.08);
    --c2-blue-15: rgba(30, 102, 245, 0.15);
    --c2-blue-18: rgba(30, 102, 245, 0.18);
    --c2-blue-30: rgba(30, 102, 245, 0.3);
    --c2-green-10: rgba(64, 160, 43, 0.1);
    --c2-green-12: rgba(64, 160, 43, 0.12);
    --c2-green-15: rgba(64, 160, 43, 0.15);
    --c2-green-18: rgba(64, 160, 43, 0.18);
    --c2-green-25: rgba(64, 160, 43, 0.25);
    --c2-green-30: rgba(64, 160, 43, 0.3);
    --c2-red-04: rgba(210, 15, 57, 0.04);
    --c2-red-12: rgba(210, 15, 57, 0.12);
    --c2-red-15: rgba(210, 15, 57, 0.15);
    --c2-red-18: rgba(210, 15, 57, 0.18);
    --c2-red-30: rgba(210, 15, 57, 0.3);
    --c2-red-40: rgba(210, 15, 57, 0.4);
    --c2-yellow-10: rgba(223, 142, 29, 0.1);
    --c2-yellow-12: rgba(223, 142, 29, 0.12);
    --c2-yellow-15: rgba(223, 142, 29, 0.15);
    --c2-yellow-18: rgba(223, 142, 29, 0.18);
    --c2-yellow-30: rgba(223, 142, 29, 0.3);
    --c2-yellow-40: rgba(223, 142, 29, 0.4);
    --c2-purple-40: rgba(136, 57, 239, 0.4);
    --c2-green-04: rgba(64, 160, 43, 0.04);

    --c2-code: #dce0e8;
    --c2-shadow: rgba(0, 0, 0, 0.12);
    --c2-shadow-light: rgba(0, 0, 0, 0.08);
    --c2-resize-border: #9ca0b0;
    --c2-window-border-glow: rgba(0, 0, 0, 0.05);
    --c2-overlay-bg: rgba(0, 0, 0, 0.4);
    --c2-scrollbar-thumb: #acb0be;
    --c2-scrollbar-thumb-hover: #9ca0b0;
    --c2-workspace-grad1: rgba(30, 102, 245, 0.04);
    --c2-workspace-grad2: rgba(136, 57, 239, 0.04);
    --c2-selection: rgba(30, 102, 245, 0.2);
    --c2-focus-ring: rgba(30, 102, 245, 0.5);
    --c2-hover-white: rgba(0, 0, 0, 0.06);
    --c2-hover-subtle: rgba(0, 0, 0, 0.02);
    --c2-blue-glow: rgba(30, 102, 245, 0.3);
    --c2-blue-glow-strong: rgba(30, 102, 245, 0.4);

    --c2-elevation-1: 0 1px 3px rgba(0, 0, 0, 0.08);
    --c2-elevation-2: 0 4px 12px rgba(0, 0, 0, 0.12);
    --c2-elevation-3: 0 8px 32px rgba(0, 0, 0, 0.2);

    color-scheme: light;
}

/* ===== Base Reset ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    overflow: hidden;
    height: 100%;
    margin: 0;
    background: var(--c2-bg-base);
    color: var(--c2-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--c2-selection);
    color: var(--c2-text);
}

h1:focus { outline: none; }

code, pre, .mono {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

code {
    color: var(--c2-accent-blue);
    font-size: 0.9em;
}

pre {
    background: var(--c2-code) !important;
}

a {
    color: var(--c2-accent-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== Shared Spinner ===== */
.c2-spinner {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    border: 2px solid var(--c2-border-active);
    border-top-color: var(--c2-accent-blue);
    border-radius: 50%;
    animation: c2-spin 0.6s linear infinite;
    flex-shrink: 0;
}

.c2-spinner-xs {
    width: 0.7rem;
    height: 0.7rem;
    border-width: 1.5px;
}

.c2-spinner-inline {
    width: 0.75em;
    height: 0.75em;
    border-width: 1.5px;
}

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

/* ===== Blazor Error UI ===== */
#blazor-error-ui {
    color-scheme: dark only;
    background: #dc3545;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
    color: #fff;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 1.5rem;
    color: white;
    border-radius: var(--c2-radius-sm);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ===== Loading Screen ===== */
.c2-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    background: var(--c2-bg-base);
    animation: c2-loading-fade-in 0.3s ease;
}

.c2-loading-brand {
    font-weight: 700;
    font-size: 2rem;
    color: var(--c2-text);
    letter-spacing: 0.05em;
    opacity: 0.85;
}

.c2-loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 2.5px solid var(--c2-border-active);
    border-top-color: var(--c2-accent-blue);
    border-radius: 50%;
    animation: c2-spin 0.6s linear infinite;
}

.c2-loading-text {
    font-size: 0.75rem;
    color: var(--c2-text-dim);
}

.c2-loading-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

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

/* ===== Floating Windows ===== */
.app-window {
    position: fixed;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--c2-border-light);
    border-radius: var(--c2-radius-lg);
    box-shadow: var(--c2-elevation-3), 0 0 0 1px var(--c2-window-border-glow);
    background: var(--c2-bg-base);
    overflow: visible;
    min-width: 320px;
    min-height: 48px;
    animation: win-open var(--c2-transition-slow) ease-out;
    transition: box-shadow var(--c2-transition-normal), border-color var(--c2-transition-normal);
}

@keyframes win-open {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.app-window.focused {
    border-color: var(--c2-border-active);
    box-shadow: var(--c2-elevation-3), 0 0 0 1px var(--c2-blue-15);
}

.app-window.unfocused {
    border-color: var(--c2-border);
    box-shadow: var(--c2-elevation-1);
}

.app-window.unfocused .app-window-titlebar {
    background: var(--c2-bg-surface);
}

.app-window.unfocused .app-window-title {
    color: var(--c2-text-dim);
}

.app-window.unfocused .app-window-icon {
    opacity: 0.4;
}

.app-window.maximized {
    left: 0 !important;
    top: var(--c2-titlebar-h) !important;
    width: 100vw !important;
    height: calc(100vh - var(--c2-titlebar-h) - var(--c2-taskbar-h)) !important;
    border-radius: 0;
    border: none;
    animation: none;
}

.app-window.minimized {
    display: none;
}

/* Titlebar */
.app-window-titlebar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px 0 10px;
    height: 34px;
    background: var(--c2-bg-deep);
    color: var(--c2-text);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--c2-border-subtle);
    border-radius: var(--c2-radius-lg) var(--c2-radius-lg) 0 0;
    transition: background var(--c2-transition-normal);
}

.app-window.maximized .app-window-titlebar {
    border-radius: 0;
}

.app-window-titlebar:active {
    cursor: grabbing;
}

.app-window-icon {
    color: var(--c2-text-muted);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    transition: opacity var(--c2-transition-normal);
}

.app-window-title {
    flex: 1;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
    transition: color var(--c2-transition-normal);
}

/* Window control buttons */
.app-window-controls {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    margin-left: auto;
}

.app-window-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 24px;
    background: none;
    border: none;
    color: var(--c2-text-dim);
    cursor: pointer;
    border-radius: var(--c2-radius-sm);
    transition: background var(--c2-transition-fast), color var(--c2-transition-fast);
}

.app-window-btn:hover {
    background: var(--c2-hover-white);
    color: var(--c2-text);
}

.app-window-btn:active {
    background: var(--c2-bg-active);
}

.app-window-btn:focus-visible {
    outline: 2px solid var(--c2-focus-ring);
    outline-offset: -1px;
}

.app-window-btn.close-btn:hover {
    background: var(--c2-accent-red);
    color: #fff;
}

/* Body */
.app-window-body {
    flex: 1;
    overflow: hidden;
    padding: 0.75rem;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: 0 0 var(--c2-radius-lg) var(--c2-radius-lg);
}

.app-window.maximized .app-window-body {
    border-radius: 0;
}

.app-window-body > * {
    flex: 1;
    min-height: 0;
}

/* Edge resize handles */
.app-window-resize-n,
.app-window-resize-s,
.app-window-resize-e,
.app-window-resize-w,
.app-window-resize-nw,
.app-window-resize-ne,
.app-window-resize-sw,
.app-window-resize-se {
    position: absolute;
    z-index: 2;
}

.app-window-resize-n  { top: -3px; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.app-window-resize-s  { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.app-window-resize-e  { right: -3px; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.app-window-resize-w  { left: -3px; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.app-window-resize-nw { top: -3px; left: -3px; width: 12px; height: 12px; cursor: nwse-resize; }
.app-window-resize-ne { top: -3px; right: -3px; width: 12px; height: 12px; cursor: nesw-resize; }
.app-window-resize-sw { bottom: -3px; left: -3px; width: 12px; height: 12px; cursor: nesw-resize; }
.app-window-resize-se { bottom: -3px; right: -3px; width: 12px; height: 12px; cursor: nwse-resize; }

/* ===== Snap Preview ===== */
#c2-snap-preview {
    position: fixed;
    z-index: 9998;
    background: rgba(59, 130, 246, 0.10);
    border: 2px solid rgba(59, 130, 246, 0.45);
    border-radius: var(--bs-border-radius-lg, 8px);
    pointer-events: none;
    opacity: 0;
    transition: opacity 150ms ease, left 150ms ease, top 150ms ease, width 150ms ease, height 150ms ease;
}
#c2-snap-preview.visible {
    opacity: 1;
}

/* ===== Window Animations ===== */
.app-window.win-animating {
    transition: left 200ms cubic-bezier(.4,0,.2,1), top 200ms cubic-bezier(.4,0,.2,1),
                width 200ms cubic-bezier(.4,0,.2,1), height 200ms cubic-bezier(.4,0,.2,1),
                border-radius 200ms ease, box-shadow 200ms ease;
    will-change: left, top, width, height;
}
.app-window.win-dragging {
    will-change: left, top;
    transition: none !important;
    cursor: grabbing;
}
.app-window.win-resizing {
    will-change: left, top, width, height;
    transition: none !important;
}
.app-window.win-minimizing {
    transition: transform 200ms cubic-bezier(.4,0,.2,1), opacity 200ms cubic-bezier(.4,0,.2,1);
    transform: scale(0.5) translateY(50vh);
    opacity: 0;
    pointer-events: none;
}
.app-window.win-closing {
    transition: transform 150ms ease, opacity 150ms ease;
    transform: scale(0.95);
    opacity: 0;
    pointer-events: none;
}

/* ===== Taskbar ===== */
.mdi-taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--c2-taskbar-h);
    background: var(--c2-bg-deep);
    border-top: 1px solid var(--c2-border-subtle);
    display: flex;
    align-items: center;
    padding: 0 var(--c2-space-2);
    gap: 2px;
    z-index: 1050;
    overflow: visible;
}

.mdi-taskbar-spacer {
    flex: 1;
    min-width: 0;
}

/* Taskbar menu button */
.mdi-taskbar-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--c2-bg-overlay);
    border: 1px solid var(--c2-border);
    color: var(--c2-text-muted);
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: var(--c2-radius-sm);
    cursor: pointer;
    transition: background var(--c2-transition-normal), color var(--c2-transition-normal);
    flex-shrink: 0;
}

.mdi-taskbar-menu-btn:hover {
    background: var(--c2-bg-highlight);
    color: var(--c2-text);
}

/* Taskbar dropdown menu */
.taskbar-menu-wrapper {
    position: relative;
    flex-shrink: 0;
}

.taskbar-dropdown {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--c2-bg-surface);
    border: 1px solid var(--c2-border);
    border-radius: var(--c2-radius-md);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
    padding: 4px;
    z-index: 1060;
}

.taskbar-dropdown-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--c2-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px 2px;
}

.taskbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: var(--c2-text-muted);
    font-size: 0.75rem;
    padding: 6px 8px;
    border-radius: var(--c2-radius-sm);
    cursor: pointer;
    transition: background var(--c2-transition-normal), color var(--c2-transition-normal);
    text-align: left;
}

.taskbar-dropdown-item:hover:not(:disabled) {
    background: var(--c2-bg-highlight);
    color: var(--c2-text);
}

.taskbar-dropdown-item:disabled {
    opacity: 0.35;
    cursor: default;
}

.taskbar-dropdown-danger {
    color: var(--c2-accent-red);
}

.taskbar-dropdown-danger:hover:not(:disabled) {
    background: rgba(243, 139, 168, 0.1);
    color: var(--c2-accent-red);
}

.taskbar-dropdown-divider {
    height: 1px;
    background: var(--c2-border);
    margin: 4px 0;
}

.taskbar-dropdown-section {
    display: flex;
    flex-direction: column;
}

.mdi-taskbar-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--c2-bg-overlay);
    border: 1px solid var(--c2-border);
    color: var(--c2-text-muted);
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: var(--c2-radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--c2-transition-normal), color var(--c2-transition-normal);
    max-width: 200px;
}

.mdi-taskbar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mdi-taskbar-item:hover {
    background: var(--c2-bg-highlight);
    color: var(--c2-text);
}

.mdi-taskbar-item:focus-visible {
    outline: 2px solid var(--c2-focus-ring);
    outline-offset: -1px;
}

.mdi-taskbar-item:active {
    transform: scale(0.97);
}

.mdi-taskbar-item.active {
    background: var(--c2-bg-active);
    color: var(--c2-text);
    border-color: var(--c2-border-active);
}

.mdi-taskbar-item.minimized {
    opacity: 0.5;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--c2-scrollbar-thumb);
    border-radius: var(--c2-radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--c2-scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* ===== Notifications ===== */
.notif-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.notif-bell {
    background: none;
    border: none;
    color: var(--c2-text-muted);
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    border-radius: var(--c2-radius-sm);
    transition: background var(--c2-transition-normal), color var(--c2-transition-normal);
    position: relative;
    display: flex;
    align-items: center;
}

.notif-bell:hover {
    background: var(--c2-bg-highlight);
    color: var(--c2-text);
}

.notif-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--c2-accent-red);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    pointer-events: none;
}

.notif-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    width: 340px;
    max-height: 420px;
    background: var(--c2-bg-surface);
    border: 1px solid var(--c2-border);
    border-radius: var(--c2-radius-lg);
    box-shadow: var(--c2-elevation-3);
    z-index: 11000;
    display: flex;
    flex-direction: column;
    animation: notif-drop var(--c2-transition-normal);
}

@keyframes notif-drop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--c2-border);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--c2-text);
}

.notif-clear-all {
    background: none;
    border: none;
    color: var(--c2-accent-red);
    font-size: 0.72rem;
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    transition: background var(--c2-transition-normal);
}

.notif-clear-all:hover {
    background: var(--c2-red-15);
}

.notif-update {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--c2-blue-18);
    border-bottom: 1px solid var(--c2-accent-blue);
    font-size: 0.78rem;
    color: var(--c2-accent-blue);
}

.notif-reload {
    background: var(--c2-accent-blue);
    color: var(--c2-bg-deep);
    border: none;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.notif-reload:hover {
    opacity: 0.85;
}

.notif-list {
    overflow-y: auto;
    flex: 1;
}

.notif-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--c2-text-dim);
    font-size: 0.78rem;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    line-height: 1.4;
    border-bottom: 1px solid var(--c2-border);
    transition: background 0.1s;
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--c2-hover-subtle); }
.notif-item.notif-error { border-left: 3px solid var(--c2-accent-red); }
.notif-item.notif-success { border-left: 3px solid var(--c2-accent-green); }
.notif-item.notif-warning { border-left: 3px solid var(--c2-accent-yellow); }
.notif-item.notif-info { border-left: 3px solid var(--c2-accent-blue); }

.notif-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.notif-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.notif-source {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--c2-text-dim);
    background: var(--c2-bg-highlight);
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    flex-shrink: 0;
    white-space: nowrap;
}

.notif-title {
    font-weight: 600;
    color: var(--c2-text);
    font-size: 0.78rem;
    line-height: 1.3;
}

.notif-detail {
    font-size: 0.72rem;
    color: var(--c2-text-muted);
    line-height: 1.35;
    word-break: break-word;
}

.notif-text {
    flex: 1;
    color: var(--c2-text);
    word-break: break-word;
}

.notif-time {
    font-size: 0.68rem;
    color: var(--c2-text-dim);
    white-space: nowrap;
    flex-shrink: 0;
    padding-top: 1px;
}

.notif-copy,
.notif-remove {
    background: none;
    border: none;
    color: var(--c2-text-dim);
    line-height: 1;
    padding: 0 0.15rem;
    cursor: pointer;
    opacity: 0;
    flex-shrink: 0;
    border-radius: 3px;
    transition: opacity var(--c2-transition-normal), color var(--c2-transition-normal);
}

.notif-copy { font-size: 0.75rem; }
.notif-remove { font-size: 0.95rem; }

.notif-item:hover .notif-copy,
.notif-item:hover .notif-remove {
    opacity: 0.6;
}

.notif-copy:hover { opacity: 1 !important; color: var(--c2-accent-blue); }
.notif-remove:hover { opacity: 1 !important; color: var(--c2-accent-red); }

/* ===== Theme Toggle ===== */
.theme-toggle {
    background: none;
    border: none;
    color: var(--c2-text-muted);
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    border-radius: var(--c2-radius-sm);
    transition: background var(--c2-transition-normal), color var(--c2-transition-normal);
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    background: var(--c2-bg-highlight);
    color: var(--c2-text);
}

/* ===== Shared Keyframes ===== */
@keyframes c2-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes c2-fade-in {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

/* ===== Shared Panel Patterns ===== */

/* Tabs — used by Downloads, FileSearch, Settings */
.panel-tabs {
    display: flex;
    gap: 1px;
    border-bottom: 1px solid var(--c2-border);
}

.panel-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--c2-text-dim);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.panel-tab:hover {
    color: var(--c2-text-muted);
}

.panel-tab.active {
    color: var(--c2-accent-blue);
    border-bottom-color: var(--c2-accent-blue);
}

.panel-tab-count {
    font-size: 0.6rem;
    color: var(--c2-text-dim);
    margin-left: 0.2rem;
}

.panel-tab.active .panel-tab-count {
    color: var(--c2-accent-blue);
}

/* Empty state — used by all panels */
.panel-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    color: var(--c2-text-dim);
    font-size: 0.8rem;
    font-style: italic;
    text-align: center;
}

/* Agent label in header — used by Downloads, FileSearch */
.panel-agent-label {
    font-size: 0.7rem;
    color: var(--c2-accent-blue);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

/* Stats bar — used by SearchJobs, Uploads */
.panel-stats {
    display: flex;
    gap: 0;
    padding: 0.4rem 0;
}

.panel-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.panel-stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--c2-text);
}

.panel-stat-label {
    font-size: 0.6rem;
    color: var(--c2-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.panel-stat-active { color: var(--c2-accent-blue); }
.panel-stat-done { color: var(--c2-accent-green); }
.panel-stat-fail { color: var(--c2-accent-red); }

/* Status dot — used by Agents, SearchJobs, Uploads */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-on {
    background: var(--c2-accent-green);
    box-shadow: 0 0 4px var(--c2-accent-green);
}

.dot-off {
    background: var(--c2-text-dim);
}

/* Remove button hover — used by Downloads, FileSearch */
.panel-remove-btn:hover:not(:disabled) {
    color: var(--c2-accent-red) !important;
}

/* Agent card list — used by SearchJobs, Uploads */
.panel-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.panel-card {
    border: 1px solid var(--c2-border);
    border-radius: 4px;
    overflow: hidden;
}

.panel-card-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: var(--c2-hover-subtle);
    border-bottom: 1px solid var(--c2-border);
}

.panel-card-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--c2-text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-card-summary {
    display: flex;
    gap: 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
}

/* Count colors — used by SearchJobs, Uploads */
.panel-count-active { color: var(--c2-accent-blue); }
.panel-count-queued { color: var(--c2-text-dim); }
.panel-count-paused { color: var(--c2-accent-yellow); }
.panel-count-done { color: var(--c2-accent-green); }
.panel-count-fail { color: var(--c2-accent-red); }

/* Card row items — used by SearchJobs, Uploads */
.panel-row-item {
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid var(--c2-border);
}

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

.panel-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.panel-row-icon {
    width: 1em;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.65rem;
    color: var(--c2-text-dim);
}

.panel-row-icon.active {
    color: var(--c2-accent-blue);
    animation: c2-pulse 1.5s ease-in-out infinite;
}

.panel-row-icon.done {
    color: var(--c2-accent-green);
}

.panel-row-icon.fail {
    color: var(--c2-accent-red);
}

.panel-row-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.panel-row-name {
    flex: 1;
    font-family: monospace;
    font-size: 0.72rem;
    color: var(--c2-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-row-meta {
    font-size: 0.6rem;
    color: var(--c2-text-dim);
}

.panel-row-status {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Completed summary — used by SearchJobs, Uploads */
.panel-done-summary {
    cursor: pointer;
    transition: background 0.15s;
}

.panel-done-summary:hover {
    background: var(--c2-hover-subtle);
}

.panel-done-summary .panel-row-name {
    font-family: inherit;
    color: var(--c2-text-dim);
    font-size: 0.7rem;
}

.panel-expand {
    font-size: 0.6rem;
    color: var(--c2-text-dim);
}

.panel-done-item {
    opacity: 0.6;
}

.panel-spinning {
    animation: c2-pulse 1.5s ease-in-out infinite;
}

/* ===== Tablet Responsive (≤1024px) ===== */
@media (max-width: 1024px) {
    .app-window-body {
        padding: 0.5rem;
    }

    .notif-dropdown {
        width: 300px;
    }

    .panel-stats {
        gap: 0;
    }

    .panel-stat-value {
        font-size: 0.9rem;
    }

    /* Tighter table cells on tablet */
    .c2-table th {
        padding: 0.35rem 0.45rem;
        font-size: 0.62rem;
    }

    .c2-table td {
        padding: 0.3rem 0.45rem;
        font-size: 0.74rem;
    }
}

/* ===== Mobile / Touch Responsive (≤768px) ===== */
@media (max-width: 768px) {
    :root {
        --c2-taskbar-h: 44px;
    }

    .app-window:not(.minimized) {
        left: 0 !important;
        top: var(--c2-titlebar-h) !important;
        width: 100vw !important;
        height: calc(100vh - var(--c2-titlebar-h) - var(--c2-taskbar-h)) !important;
        border-radius: 0;
        border: none;
    }

    /* Hide edge resize handles on mobile */
    .app-window-resize-n, .app-window-resize-s,
    .app-window-resize-e, .app-window-resize-w,
    .app-window-resize-nw, .app-window-resize-ne,
    .app-window-resize-sw, .app-window-resize-se {
        display: none;
    }

    .app-window-titlebar {
        padding: 0 8px;
        height: 40px;
        font-size: 0.85rem;
    }

    .app-window-btn {
        width: 40px;
        height: 36px;
        font-size: 0.9rem;
    }

    .app-window-body {
        padding: 0.4rem;
        font-size: 0.82rem;
    }

    /* Taskbar — larger items on mobile */
    .mdi-taskbar {
        height: var(--c2-taskbar-h);
        gap: 3px;
        padding: 0 var(--c2-space-1);
    }

    .mdi-taskbar-item {
        font-size: 0.7rem;
        padding: 4px 8px;
        min-height: 34px;
    }

    /* Notifications — full width on mobile */
    .notif-dropdown {
        width: calc(100vw - 1rem);
        right: -0.5rem;
        max-height: 60vh;
    }

    .notif-item {
        padding: 0.6rem 0.75rem;
    }

    /* Panel stats — compact on mobile */
    .panel-stat-value {
        font-size: 0.85rem;
    }

    .panel-stat-label {
        font-size: 0.55rem;
    }

    /* Panel tabs — scrollable on mobile */
    .panel-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .panel-tabs::-webkit-scrollbar {
        display: none;
    }

    .panel-tab {
        padding: 0.4rem 0.7rem;
        font-size: 0.72rem;
        white-space: nowrap;
    }

    /* Tables — compact mode on mobile */
    .c2-table th {
        padding: 0.3rem 0.35rem;
        font-size: 0.58rem;
    }

    .c2-table td {
        padding: 0.3rem 0.35rem;
        font-size: 0.72rem;
    }

    /* Panel empty state */
    .panel-empty {
        padding: 1.5rem 0.75rem;
        font-size: 0.78rem;
    }

    /* Card list items — more touch-friendly */
    .panel-row-item {
        padding: 0.45rem 0.6rem;
    }

    .panel-card-header {
        padding: 0.5rem 0.6rem;
    }

    /* Status dots — slightly larger on mobile */
    .status-dot {
        width: 9px;
        height: 9px;
    }
}

/* ===== Small Phone (≤480px) ===== */
@media (max-width: 480px) {
    :root {
        --c2-taskbar-h: 48px;
    }

    .app-window-body {
        padding: 0.25rem;
    }

    .mdi-taskbar-item {
        font-size: 0.65rem;
        padding: 4px 6px;
        max-width: 140px;
    }

    .panel-stat-value {
        font-size: 0.78rem;
    }

    .panel-agent-label {
        max-width: 100px;
        font-size: 0.65rem;
    }
}

/* ===== Touch Device Enhancements ===== */
@media (pointer: coarse) {
    .app-window-titlebar {
        -webkit-user-select: none;
        user-select: none;
    }

    .app-window-btn {
        width: 40px;
        height: 34px;
    }

    /* Wider touch targets for edge resize */
    .app-window-resize-n, .app-window-resize-s { height: 12px; }
    .app-window-resize-e, .app-window-resize-w { width: 12px; }
    .app-window-resize-nw, .app-window-resize-ne,
    .app-window-resize-sw, .app-window-resize-se { width: 18px; height: 18px; }

    /* Larger scrollbar thumb for touch */
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    /* Prevent text selection on interactive elements */
    .panel-tab,
    .ap-relay-tab,
    .mdi-taskbar-item,
    .mdi-menu-item {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Increase minimum touch target size */
    .c2-btn {
        min-height: 32px;
        min-width: 32px;
    }

    .c2-btn-xs {
        min-height: 28px;
        min-width: 28px;
    }

    .c2-btn-icon {
        min-height: 32px;
        min-width: 32px;
    }
}
