@import url('https://fonts.googleapis.com/css2?family=Kumbh+Sans:wght@400;500;600;700&family=Roboto:wght@300;400;500;700&family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

:root {
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 72px;
}

:root {
    /* Primary colors */
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;

    /* Secondary colors */
    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #1D192B;

    /* Tertiary colors */
    --md-sys-color-tertiary: #7D5260;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #FFD8E4;
    --md-sys-color-on-tertiary-container: #31111D;

    /* Surface colors */
    --md-sys-color-surface: #FEF7FF;
    --md-sys-color-on-surface: #1D1B20;
    --md-sys-color-surface-variant: #E7E0EC;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-surface-container: #F3EDF7;
    --md-sys-color-surface-container-high: #ECE6F0;
    --md-sys-color-surface-container-highest: #E6E0E9;
    --md-sys-color-surface-container-low: #F7F2FA;
    --md-sys-color-surface-container-lowest: #FFFFFF;
    --md-sys-color-surface-dim: #DED8E1;
    --md-sys-color-surface-bright: #FEF7FF;

    /* Background colors */
    --md-sys-color-background: #FEF7FF;
    --md-sys-color-on-background: #1D1B20;

    /* Outline colors */
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #CAC4D0;

    /* Error colors */
    --md-sys-color-error: #B3261E;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #F9DEDC;
    --md-sys-color-on-error-container: #410E0B;

    /* Inverse colors */
    --md-sys-color-inverse-surface: #322F35;
    --md-sys-color-inverse-on-surface: #F5EFF7;
    --md-sys-color-inverse-primary: #D0BCFF;

    /* Scrim */
    --md-sys-color-scrim: #000000;
    --md-sys-color-shadow: #000000;

    /* Let the browser/OS pick the accent for native controls. */
    accent-color: auto;

    /* Workspace-only theming hooks (defaults). */
    --workspace-sidebar-bg: #ffffff;
}

/* Dark mode color palette - Material Design 3 */
@media (prefers-color-scheme: dark) {
    :root {
        /* Primary colors */
        --md-sys-color-primary: #D0BCFF;
        --md-sys-color-on-primary: #381E72;
        --md-sys-color-primary-container: #4F378B;
        --md-sys-color-on-primary-container: #EADDFF;

        /* Secondary colors */
        --md-sys-color-secondary: #CCC2DC;
        --md-sys-color-on-secondary: #332D41;
        --md-sys-color-secondary-container: #4A4458;
        --md-sys-color-on-secondary-container: #E8DEF8;

        /* Tertiary colors */
        --md-sys-color-tertiary: #EFB8C8;
        --md-sys-color-on-tertiary: #492532;
        --md-sys-color-tertiary-container: #633B48;
        --md-sys-color-on-tertiary-container: #FFD8E4;

        /* Surface colors */
        --md-sys-color-surface: #141218;
        --md-sys-color-on-surface: #E6E0E9;
        --md-sys-color-surface-variant: #49454F;
        --md-sys-color-on-surface-variant: #CAC4D0;
        --md-sys-color-surface-container: #211F26;
        --md-sys-color-surface-container-high: #2B2930;
        --md-sys-color-surface-container-highest: #36343B;
        --md-sys-color-surface-container-low: #1D1B20;
        --md-sys-color-surface-container-lowest: #0F0D13;
        --md-sys-color-surface-dim: #141218;
        --md-sys-color-surface-bright: #3B383E;

        /* Outline colors */
        --md-sys-color-outline: #938F99;
        --md-sys-color-outline-variant: #49454F;

        /* Background */
        --md-sys-color-background: #141218;
        --md-sys-color-on-background: #E6E0E9;

        /* Error colors */
        --md-sys-color-error: #F2B8B5;
        --md-sys-color-on-error: #601410;
        --md-sys-color-error-container: #8C1D18;
        --md-sys-color-on-error-container: #F9DEDC;

        /* Inverse colors */
        --md-sys-color-inverse-surface: #E6E0E9;
        --md-sys-color-inverse-on-surface: #322F35;
        --md-sys-color-inverse-primary: #6750A4;

        /* Scrim */
        --md-sys-color-scrim: #000000;
        --md-sys-color-shadow: #000000;

        /* Workspace sidebar */
        --workspace-sidebar-bg: #211F26;
    }
}

/* Windows system accent integration - Primary colors only */
@supports (color: AccentColor) {
    html.platform-windows {
        /* Only apply OS accent to primary (pink/purple) colors, not white surfaces */
        --md-sys-color-primary: AccentColor;
        --md-sys-color-primary-container: color-mix(in srgb, AccentColor 18%, var(--md-sys-color-surface-container-lowest));
        --md-sys-color-on-primary-container: var(--md-sys-color-on-surface);
        /* Sidebar remains neutral - no accent tinting */
    }

    @media (prefers-color-scheme: dark) {
        html.platform-windows {
            --md-sys-color-primary-container: color-mix(in srgb, AccentColor 28%, var(--md-sys-color-surface-container-low));
            /* Sidebar remains neutral in dark mode too */
        }
    }
}

@supports (color: AccentColorText) {
    html.platform-windows {
        --md-sys-color-on-primary: AccentColorText;
    }
}

/* Global Typography */
html,
body {
    font-family: 'Kumbh Sans', sans-serif;
}

*:not(.material-symbols-rounded):not(code):not(pre):not(kbd):not(samp) {
    font-family: 'Kumbh Sans', sans-serif !important;
}

code,
pre,
kbd,
samp {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--md-sys-color-surface);
}

/* Iframe embed mode */
body.embed-mode #global-topbar {
    display: none !important;
}

body.embed-mode #sidebar {
    display: none !important;
}

body.embed-mode #app-loading-overlay {
    display: none !important;
}

body.embed-mode #app {
    height: 100vh;
}

body.embed-mode #main-content {
    max-width: none !important;
    margin: 0 !important;
}

/* Material Symbols Rounded (Highest Priority) */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded' !important;
    font-variation-settings:
        'FILL' 1,
        'wght' 400,
        'GRAD' 0,
        'opsz' 24 !important;
    text-transform: none;
    -webkit-font-smoothing: antialiased;
}

/* Font application for Branding & Navigation */
#global-topbar,
#global-topbar a,
#global-topbar span:not(.material-symbols-rounded),
#app-switcher,
.sidebar-header h2,
#sidebar-toggle:not(.material-symbols-rounded) {
    font-family: 'Kumbh Sans', sans-serif !important;
}

/* Global Topbar Refinement */
#global-topbar {
    display: flex !important;
    align-items: center;
    justify-content: center !important;
    background-color: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0 24px 0 0 !important;
    height: 64px !important;
    box-sizing: border-box !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

@media (prefers-color-scheme: dark) {
    #global-topbar {
        background-color: rgba(20, 18, 24, 0.8) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
}

#global-topbar nav {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 0 !important;
    position: relative;
    min-width: 0;
}

#global-topbar .topbar-branding {
    font-family: 'Kumbh Sans', sans-serif !important;
    font-weight: 800 !important;
    font-size: 20px !important;
    color: var(--md-sys-color-primary) !important;
    text-decoration: none !important;
    letter-spacing: -0.8px;
    margin-right: 24px !important;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

#global-topbar .topbar-branding img {
    height: 32px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.topbar-nav-container {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

#app-switcher {
    display: flex !important;
    gap: 12px !important;
    align-items: center !important;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

#brand-container {
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

#global-search-container {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    position: relative;
    z-index: 2;
}

#topbar-buttons {
    display: flex !important;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.topbar-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.topbar-btn .material-symbols-rounded {
    font-size: 18px;
}

.switcher-item {
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Kumbh Sans', sans-serif !important;
    white-space: nowrap;
}

.switcher-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--md-sys-color-on-surface);
}

.switcher-item.active {
    color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-primary-container);
}

/* Topbar Dropdown Menus - Ensure solid backgrounds */
#global-topbar .dropdown,
#global-topbar .dropdown-menu,
#global-topbar .menu,
#global-topbar .popup,
#global-topbar [role="menu"],
#global-topbar [role="listbox"],
#global-topbar .user-menu,
#global-topbar .profile-menu,
#global-topbar>*>* [class*="dropdown"],
#global-topbar>*>* [class*="menu"]:not(.material-symbols-rounded),
#global-topbar>* [class*="dropdown"],
#global-topbar>* [class*="menu"]:not(.material-symbols-rounded) {
    background-color: var(--md-sys-color-surface-container-high, var(--md-sys-color-surface-container, #FFFFFF)) !important;
    background: var(--md-sys-color-surface-container-high, var(--md-sys-color-surface-container, #FFFFFF)) !important;
}

/* Base Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-item {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
    opacity: 0;
}

/* Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: "";
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, #000 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform .5s, opacity 1s;
}

.ripple:active::after {
    transform: scale(0, 0);
    opacity: .3;
    transition: 0s;
}

/* Sidebar Collapse System */
#sidebar {
    width: var(--sidebar-width);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    overflow: visible;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    z-index: 900;
    background-color: var(--workspace-sidebar-bg, #ffffff);
    box-shadow: none;
}

#sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: -16px;
    width: 16px;
    height: 16px;
    background-color: var(--workspace-sidebar-bg, var(--md-sys-color-surface-container));
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M0 16 A16 16 0 0 1 16 0 L0 0 Z'/%3E%3C/svg%3E");
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M0 16 A16 16 0 0 1 16 0 L0 0 Z'/%3E%3C/svg%3E");
    mask-size: cover;
    -webkit-mask-size: cover;
    pointer-events: none;
    z-index: 10;
}


body.sidebar-collapsed #sidebar {
    width: var(--sidebar-collapsed-width) !important;
}

#sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    padding: 12px;
    margin: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    box-sizing: border-box;
}

/* When sidebar is expanded, ensure toggle button looks normal */
body:not(.sidebar-collapsed) #sidebar-toggle {
    margin: 8px 8px 8px 16px;
    align-self: flex-start;
}

#sidebar-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Hide text when collapsed */
.sidebar-collapsed #sidebar h2,
.sidebar-collapsed #sidebar span:not(.material-symbols-rounded),
.sidebar-collapsed #sidebar button:not(#sidebar-toggle) span:not(.material-symbols-rounded),
.sidebar-collapsed #sidebar .nav-item span:not(.material-symbols-rounded),
.sidebar-collapsed #sidebar .sidebar-action span:not(.material-symbols-rounded),
.sidebar-collapsed #sidebar .sidebar-nav li span:not(.material-symbols-rounded),
.sidebar-collapsed #sidebar .group-item span:not(.material-symbols-rounded) {
    display: none !important;
}

/* Sidebar content area */
.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px 24px;
    flex-shrink: 0;
}

/* Sidebar header with toggle button - flex layout */
.sidebar-header-with-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
}

.sidebar-header-with-toggle #sidebar-toggle {
    margin: 0;
    padding: 8px;
    width: 40px;
    height: 40px;
    font-size: 20px;
}

.sidebar-header-with-toggle h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Topbar Sidebar Toggle */
#topbar-sidebar-toggle-container {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

#topbar-sidebar-toggle-container #sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    padding: 8px;
    margin: 0;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

#topbar-sidebar-toggle-container #sidebar-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Sidebar toggle button directly in topbar-left */
.topbar-left #sidebar-toggle,
#topbar-sidebar-toggle-container #sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
    font-size: 24px;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    flex-shrink: 0;
}

.topbar-left #sidebar-toggle:hover,
#topbar-sidebar-toggle-container #sidebar-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Remove left padding from topbar-left container */
.topbar-left {
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* Sidebar toggle - flush with left edge */
.topbar-left > *:first-child {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

#sidebar-toggle {
    margin-left: 0 !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
}

/* Sidebar Search */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 16px 12px;
    padding: 8px 12px;
    background: var(--md-sys-color-surface-container-highest);
    border-radius: 12px;
    border: 1px solid transparent;
    transition: border-color 0.2s, background-color 0.2s;
}

.sidebar-search:focus-within {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-surface);
}

.sidebar-search .material-symbols-rounded {
    font-size: 18px;
    color: var(--md-sys-color-on-surface-variant);
}

.sidebar-search input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
}

.sidebar-search input::placeholder {
    color: var(--md-sys-color-on-surface-variant);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

/* Sidebar footer for bottom buttons */
.sidebar-footer {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    width: 100%;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 100px;
    cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    background: transparent;
    border: none;
    transition: all 0.2s;
    margin: 8px;
    width: calc(100% - 16px);
    box-sizing: border-box;
    font-family: inherit;
    font-size: inherit;
}

.sidebar-btn:hover {
    background-color: var(--md-sys-color-surface-container-high);
    color: var(--md-sys-color-on-surface);
}

.sidebar-btn.primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.sidebar-btn.primary:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.sidebar-btn .material-symbols-rounded {
    font-size: 20px;
}

/* Adjust sidebar items when collapsed */
.sidebar-collapsed .nav-item,
.sidebar-collapsed .sidebar-action,
.sidebar-collapsed .group-item,
.sidebar-collapsed .sidebar-nav li {
    justify-content: center !important;
    padding: 12px 0 !important;
    margin: 4px 8px !important;
}

/* Collapsed state for sidebar footer and buttons */
.sidebar-collapsed .sidebar-footer {
    padding-top: 4px;
}

.sidebar-collapsed .sidebar-btn {
    margin: 4px;
    width: calc(100% - 8px);
    padding: 12px;
    justify-content: center;
}

.sidebar-collapsed .sidebar-btn span:not(.material-symbols-rounded) {
    display: none;
}

.sidebar-collapsed .sidebar-btn .material-symbols-rounded {
    margin: 0;
}

/* Global Tooltip */
.global-tooltip {
    position: fixed;
    background-color: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    z-index: 10000;
    white-space: nowrap;
    box-shadow: 0 2px 8px var(--md-sys-color-shadow);
    animation: tooltipFadeIn 0.15s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Global Search Styles */
#global-search-container {
    flex: 0 1 400px;
    margin: 0 auto;
    min-width: 200px;
    max-width: 600px;
}

/* Responsive styling to prevent overlap */
@media (max-width: 1200px) {
    #global-topbar {
        padding: 0 16px 0 0 !important;
    }

    #global-topbar .topbar-branding {
        font-size: 18px !important;
        margin-right: 16px !important;
    }

    #app-switcher {
        gap: 8px !important;
    }

    .switcher-item {
        font-size: 14px;
        padding: 6px 10px;
    }

    #global-search-container {
        flex: 0 1 300px;
    }
}

@media (max-width: 768px) {
    #global-topbar {
        padding: 0 12px 0 0 !important;
    }

    #global-topbar .topbar-branding {
        font-size: 16px !important;
        margin-right: 12px !important;
    }

    #app-switcher {
        gap: 6px !important;
    }

    .switcher-item {
        font-size: 13px;
        padding: 4px 8px;
    }

    #global-search-container {
        flex: 0 1 200px;
    }

    #global-search-input {
        font-size: 13px;
        padding: 8px 12px 8px 36px;
    }
}

#global-search-wrapper {
    position: relative;
    width: 100%;
}

#global-search-input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 24px;
    background-color: var(--md-sys-color-surface-container-high);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

#global-search-input:focus {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface);
    box-shadow: 0 1px 6px rgba(103, 80, 164, 0.15);
}

#global-search-input::placeholder {
    color: var(--md-sys-color-outline);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-outline);
    font-size: 20px;
    pointer-events: none;
}

#global-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 8px;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    transition: background-color 0.2s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: var(--md-sys-color-surface-container);
}

.search-result-item .result-icon {
    margin-right: 12px;
    color: var(--md-sys-color-primary);
    font-size: 20px;
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--md-sys-color-outline);
}

.result-source {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 11px;
}

.result-description {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.search-no-results {
    padding: 24px;
    text-align: center;
    color: var(--md-sys-color-outline);
    font-size: 14px;
}

/* New Topbar Layout */
.global-topbar {
    display: flex !important;
    align-items: center;
    justify-content: space-between !important;
    height: 64px;
    padding: 0 16px 0 24px;
    background-color: var(--md-sys-color-surface-container-lowest) !important;
    border-bottom: none;
    z-index: 1000 !important;
    box-sizing: border-box;
    width: 100% !important;
}

.topbar-left {
    display: flex !important;
    align-items: center !important;
    flex: 1;
}

.topbar-branding {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-family: 'Kumbh Sans', sans-serif !important;
    font-weight: 700 !important;
    font-size: 20px !important;
    color: var(--md-sys-color-on-surface) !important;
    text-decoration: none !important;
    white-space: nowrap;
    margin-right: 16px;
    /* Space after branding */
}

.topbar-branding .topbar-logo {
    display: none;
    height: 32px;
}

.topbar-branding .topbar-brand-text {
    display: block;
}

.beta-badge {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.offline-badge {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@media (max-width: 768px) {
    .topbar-branding .topbar-logo {
        display: block;
    }

    .topbar-branding .topbar-brand-text {
        display: none;
    }
}

.topbar-branding .material-symbols-rounded {
    font-size: 24px;
    color: var(--md-sys-color-primary);
}

.topbar-nav-item {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 16px !important;
    border-radius: 100px !important;
    text-decoration: none !important;
    color: var(--md-sys-color-on-surface-variant) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    white-space: nowrap;
    margin-left: 5px;
    /* Space between buttons */
}

.topbar-nav-item:hover {
    background-color: var(--md-sys-color-surface-container-high) !important;
    color: var(--md-sys-color-on-surface) !important;
}

.topbar-nav-item.active {
    background-color: var(--md-sys-color-secondary-container) !important;
    color: var(--md-sys-color-on-secondary-container) !important;
}

.topbar-nav-item .material-symbols-rounded {
    font-size: 20px;
}

.topbar-center {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    max-width: 600px !important;
    margin: 0 24px !important;
}

.topbar-search {
    position: relative !important;
    width: 100% !important;
}

.topbar-search .material-symbols-rounded {
    position: absolute !important;
    left: 16px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: var(--md-sys-color-outline) !important;
    font-size: 20px !important;
    pointer-events: none !important;
    z-index: 1 !important;
}

.topbar-search input {
    width: 100% !important;
    padding: 12px 16px 12px 48px !important;
    border: 1px solid var(--md-sys-color-outline-variant) !important;
    border-radius: 24px !important;
    background-color: var(--md-sys-color-surface-container-high) !important;
    font-size: 14px !important;
    outline: none !important;
    transition: all 0.2s ease !important;
    box-sizing: border-box !important;
}

.topbar-search input:focus {
    border-color: var(--md-sys-color-primary) !important;
    background-color: var(--md-sys-color-surface) !important;
    box-shadow: 0 1px 6px rgba(103, 80, 164, 0.15) !important;
}

.topbar-search input::placeholder {
    color: var(--md-sys-color-outline) !important;
}

.topbar-right {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 1;
}

.topbar-account {
    display: flex !important;
    align-items: center !important;
}

.account-btn {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 16px !important;
    border: 1px solid var(--md-sys-color-outline-variant) !important;
    border-radius: 100px !important;
    background-color: var(--md-sys-color-surface) !important;
    color: var(--md-sys-color-on-surface) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
}

.account-btn:hover {
    background-color: var(--md-sys-color-surface-container-high) !important;
    border-color: var(--md-sys-color-outline) !important;
}

.account-btn .material-symbols-rounded {
    font-size: 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .global-topbar {
        padding: 0 16px !important;
    }

    .topbar-left {
        gap: 16px !important;
    }

    .topbar-branding span:last-child {
        display: none !important;
    }

    .topbar-nav-item span:last-child {
        display: none !important;
    }

    .topbar-center {
        margin: 0 16px !important;
    }

    .account-btn span:last-child {
        display: none !important;
    }
}

/* Material 3 Expressive Loading Animation */
#app-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(254, 247, 255, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#app-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-container {
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#app-loading-overlay.active .loading-container {
    transform: scale(1);
}

.loading-spinner {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
}

.loading-icon {
    font-size: 48px !important;
    color: var(--md-sys-color-primary);
    animation: expressive-spin 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--md-sys-color-primary-container);
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(103, 80, 164, 0.2);
}

@keyframes expressive-spin {
    0% {
        transform: rotate(0deg) scale(1);
        border-radius: 24px;
    }

    25% {
        transform: rotate(90deg) scale(1.05);
        border-radius: 28px;
    }

    50% {
        transform: rotate(180deg) scale(1);
        border-radius: 24px;
    }

    75% {
        transform: rotate(270deg) scale(0.95);
        border-radius: 20px;
    }

    100% {
        transform: rotate(360deg) scale(1);
        border-radius: 24px;
    }
}

.loading-text {
    font-family: 'Kumbh Sans', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
    animation: expressive-text 2s ease-in-out infinite;
}

@keyframes expressive-text {

    0%,
    100% {
        opacity: 1;
        transform: translateY(0);
    }

    50% {
        opacity: 0.7;
        transform: translateY(-2px);
    }
}

/* Loading dots animation */
.loading-text::after {
    content: '';
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0% {
        content: '.';
    }

    33% {
        content: '..';
    }

    66% {
        content: '...';
    }

    100% {
        content: '.';
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #app-loading-overlay {
        background: rgba(29, 27, 32, 0.95);
    }

    .loading-icon {
        background: var(--md-sys-color-primary-container);
        box-shadow: 0 4px 12px rgba(208, 188, 255, 0.2);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .loading-icon {
        animation: none;
    }

    .loading-text {
        animation: none;
    }

    .loading-text::after {
        animation: none;
        content: '...';
    }
}

/* Global animated caret */
.animated-caret-target {
  caret-color: transparent !important;
}

#global-animated-caret {
  position: fixed;
  top: 0;
  left: 0;
  width: 2px;
  background: var(--md-sys-color-primary);
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  transform: translate(0px, 0px);
  transition: transform 90ms cubic-bezier(0.2, 0.0, 0.0, 1), height 90ms cubic-bezier(0.2, 0.0, 0.0, 1), opacity 120ms ease;
  animation: global-caret-blink 1.05s step-end infinite;
  z-index: 9999;
}

#global-animated-caret.visible {
  opacity: 1;
}

#global-animated-caret.typing {
  animation: none;
  opacity: 1 !important;
}

@keyframes global-caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* App Switching Page Transitions */
body {
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), filter 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.app-exiting {
  opacity: 0;
  filter: blur(4px);
}

/* Global Context Menu - highest z-index to be above everything */
.context-menu {
    position: absolute;
    z-index: 10002 !important;
}

.context-menu-overlay {
    position: fixed;
    z-index: 10001 !important;
}

/* Command Palette / Quick Search */
.command-palette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 11000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}

.command-palette.show {
    display: flex;
}

.command-palette-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    animation: fadeIn 0.15s ease;
}

.command-palette-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    background: var(--md-sys-color-surface);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0 16px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.command-palette-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.command-palette-header .material-symbols-rounded {
    font-size: 24px;
    color: var(--md-sys-color-on-surface-variant);
}

.command-palette-header input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--md-sys-color-on-surface);
    outline: none;
}

.command-palette-header input::placeholder {
    color: var(--md-sys-color-on-surface-variant);
}

.command-palette-shortcut {
    font-size: 12px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    background: var(--md-sys-color-surface-variant);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: monospace;
}

.command-palette-content {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
}

.command-palette-section {
    padding: 8px 0;
}

.command-palette-section:not(:last-child) {
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.command-palette-section .section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-on-surface-variant);
    padding: 8px 20px;
}

.palette-items {
    display: flex;
    flex-direction: column;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.palette-item:hover,
.palette-item.selected {
    background: var(--md-sys-color-surface-variant);
}

.palette-item .material-symbols-rounded {
    font-size: 20px;
    color: var(--md-sys-color-on-surface-variant);
    width: 24px;
    text-align: center;
}

.palette-item .item-info {
    flex: 1;
    min-width: 0;
}

.palette-item .item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.palette-item .item-desc {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.palette-item .item-shortcut {
    font-size: 11px;
    color: var(--md-sys-color-on-surface-variant);
    font-family: monospace;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.palette-item:hover .item-shortcut,
.palette-item.selected .item-shortcut {
    opacity: 1;
}

/* App Sidebar Feature */
.sidebar-drop-zone {
    position: fixed;
    top: 0;
    width: 80px;
    height: 100vh;
    z-index: 998;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-drop-zone.active {
    opacity: 1;
    pointer-events: all;
}

.sidebar-drop-zone.left {
    left: 0;
    background: linear-gradient(to right, rgba(var(--md-sys-color-primary-rgb), 0.15), transparent);
}

.sidebar-drop-zone.right {
    right: 0;
    background: linear-gradient(to left, rgba(var(--md-sys-color-primary-rgb), 0.15), transparent);
}

.sidebar-drop-zone-inner {
    background: var(--md-sys-color-surface-container);
    border-radius: 12px;
    padding: 16px 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 2px dashed var(--md-sys-color-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sidebar-drop-zone-inner .material-symbols-rounded {
    font-size: 32px;
    color: var(--md-sys-color-primary);
}

.sidebar-drop-zone-inner span {
    font-size: 12px;
    color: var(--md-sys-color-on-surface);
    font-weight: 500;
}

/* App Sidebar Panel */
#app-sidebar-panel {
    position: fixed;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--md-sys-color-surface);
    z-index: 997;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

#app-sidebar-panel.hidden {
    transform: translateX(-100%);
}

#app-sidebar-panel.right {
    right: 0;
}

#app-sidebar-panel.left {
    left: 0;
}

#app-sidebar-panel.right.hidden {
    transform: translateX(100%);
}

#app-sidebar-panel.left.hidden {
    transform: translateX(-100%);
}

.app-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container);
}

.app-sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
}

.app-sidebar-title .material-symbols-rounded {
    font-size: 20px;
}

.app-sidebar-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-sidebar-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.app-sidebar-iframe {
    flex: 1;
    border: none;
    width: 100%;
}

/* Make Sidebar Prompt Modal */
#make-sidebar-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
}

#make-sidebar-prompt.show {
    display: flex;
}

.make-sidebar-content {
    background: var(--md-sys-color-surface);
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.make-sidebar-icon {
    width: 56px;
    height: 56px;
    background: var(--md-sys-color-primary-container);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.make-sidebar-icon .material-symbols-rounded {
    font-size: 28px;
    color: var(--md-sys-color-on-primary-container);
}

.make-sidebar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
}

.make-sidebar-desc {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 24px;
}

.make-sidebar-buttons {
    display: flex;
    gap: 12px;
}

.make-sidebar-buttons button {
    flex: 1;
    padding: 12px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.make-sidebar-cancel {
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
}

.make-sidebar-cancel:hover {
    background: var(--md-sys-color-outline-variant);
}

.make-sidebar-confirm {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.make-sidebar-confirm:hover {
    background: var(--md-sys-color-primary-hover, var(--md-sys-color-primary));
}

/* Draggable state for app items */
.app-item-dragging {
    opacity: 0.7;
    cursor: grabbing !important;
}

/* Hide main sidebar when app sidebar is open */
body.has-app-sidebar-left #sidebar {
    margin-left: 400px;
}

body.has-app-sidebar-right {
    margin-right: 400px;
}

/* Mobile Responsive Layout - Applies on small screens (max-width: 768px) */
@media (max-width: 768px) {
    /* Topbar - Horizontally scrollable */
    .global-topbar {
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    .global-topbar::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    .topbar-left {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: max-content;
    }
    
    .topbar-branding {
        flex-shrink: 0;
    }
    
    .topbar-nav-item {
        flex-shrink: 0;
        padding: 8px 12px;
    }
    
    /* Sidebar - Hidden by default, full-screen when open */
    #sidebar {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background-color: var(--md-sys-color-surface);
    }
    
    /* Sidebar open state */
    body.sidebar-open #sidebar {
        transform: translateX(0);
    }
    
    /* Overlay when sidebar is open */
    body.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    /* Main content - Full width when sidebar is hidden */
    #main-content {
        margin-left: 0 !important;
        padding: 16px;
    }
    
    #app {
        margin-top: 64px;
        height: calc(100vh - 64px);
    }
    
    /* Hide sidebar toggle button from topbar on mobile */
    #sidebar-toggle {
        display: flex;
    }
    
    /* Add mobile menu button */
    .mobile-menu-btn {
        display: flex;
    }
    
    /* Adjust sidebar content for mobile */
    .sidebar-content {
        overflow-y: auto;
        flex: 1;
    }
    
    /* Ensure proper spacing on mobile */
    .sidebar-nav li a {
        padding: 16px;
    }
    
    /* 9:16 aspect ratio container for content areas */
    .mobile-content-container {
        max-width: 100%;
        aspect-ratio: 9/16;
        margin: 0 auto;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    .global-topbar {
        padding: 0 12px;
    }
    
    .topbar-brand-text {
        font-size: 14px;
    }
    
    .topbar-nav-item span:last-child {
        font-size: 13px;
    }
    
    #main-content {
        padding: 12px;
    }
    
    /* Compact sidebar items on mobile */
    .sidebar-nav li a {
        padding: 12px;
    }
}
