<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:shell="clr-namespace:System.Windows.Shell;assembly=PresentationFramework"
                    xmlns:controls="clr-namespace:NexusShell.Controls">

    <!-- ═══ Nexus Design System 2.0 — semantic tokens (shell source of truth) ═══ -->

    <!-- Colors -->
    <Color x:Key="Nexus.Background">#020712</Color>
    <Color x:Key="Nexus.Surface">#0A1020</Color>
    <Color x:Key="Nexus.SurfaceGlass">#55101828</Color>
    <Color x:Key="Nexus.Border.Cyan">#4800D9FF</Color>
    <Color x:Key="Nexus.Border.Purple">#598A4FFF</Color>
    <Color x:Key="Nexus.Text.Primary">#F8FAFC</Color>
    <Color x:Key="Nexus.Text.Secondary">#8B9CB8</Color>
    <Color x:Key="Nexus.Accent.Cyan">#00D9FF</Color>
    <Color x:Key="Nexus.Accent.Purple">#8A4FFF</Color>
    <Color x:Key="Nexus.Glow.Primary">#00D9FF</Color>
    <Color x:Key="Nexus.Error">#FF4D6D</Color>
    <Color x:Key="Nexus.Divider">#2200D9FF</Color>

    <SolidColorBrush x:Key="Nexus.BackgroundBrush" Color="{StaticResource Nexus.Background}"/>
    <SolidColorBrush x:Key="Nexus.SurfaceBrush" Color="{StaticResource Nexus.Surface}"/>
    <SolidColorBrush x:Key="Nexus.SurfaceGlassBrush" Color="{StaticResource Nexus.SurfaceGlass}"/>
    <SolidColorBrush x:Key="Nexus.Border.CyanBrush" Color="{StaticResource Nexus.Border.Cyan}"/>
    <SolidColorBrush x:Key="Nexus.Border.PurpleBrush" Color="{StaticResource Nexus.Border.Purple}"/>
    <SolidColorBrush x:Key="Nexus.Text.PrimaryBrush" Color="{StaticResource Nexus.Text.Primary}"/>
    <SolidColorBrush x:Key="Nexus.Text.SecondaryBrush" Color="{StaticResource Nexus.Text.Secondary}"/>
    <SolidColorBrush x:Key="Nexus.Accent.CyanBrush" Color="{StaticResource Nexus.Accent.Cyan}"/>
    <SolidColorBrush x:Key="Nexus.Accent.PurpleBrush" Color="{StaticResource Nexus.Accent.Purple}"/>
    <SolidColorBrush x:Key="Nexus.Glow.PrimaryBrush" Color="{StaticResource Nexus.Glow.Primary}"/>
    <SolidColorBrush x:Key="Nexus.ErrorBrush" Color="{StaticResource Nexus.Error}"/>
    <SolidColorBrush x:Key="Nexus.DividerBrush" Color="{StaticResource Nexus.Divider}"/>

    <LinearGradientBrush x:Key="Nexus.WindowShellBrush" StartPoint="0,0" EndPoint="1,1">
        <GradientStop Color="#CC081428" Offset="0"/>
        <GradientStop Color="#AA0A1830" Offset="0.55"/>
        <GradientStop Color="#99081228" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="Nexus.IconBadgeBrush" StartPoint="0,0" EndPoint="1,1">
        <GradientStop Color="#668A4FFF" Offset="0"/>
        <GradientStop Color="#4400D9FF" Offset="1"/>
    </LinearGradientBrush>

    <!-- Spacing -->
    <sys:Double x:Key="Nexus.Spacing.Xs">4</sys:Double>
    <sys:Double x:Key="Nexus.Spacing.Sm">8</sys:Double>
    <sys:Double x:Key="Nexus.Spacing.Md">12</sys:Double>
    <sys:Double x:Key="Nexus.Spacing.Lg">16</sys:Double>
    <sys:Double x:Key="Nexus.Spacing.Xl">20</sys:Double>
    <sys:Double x:Key="Nexus.Spacing.2xl">24</sys:Double>
    <sys:Double x:Key="Nexus.Spacing.3xl">32</sys:Double>
    <Thickness x:Key="Nexus.Padding.Window">10</Thickness>
    <Thickness x:Key="Nexus.Padding.TitleBar">22,18,18,14</Thickness>
    <Thickness x:Key="Nexus.Padding.Content">18,12,18,18</Thickness>
    <Thickness x:Key="Nexus.Padding.Card">16</Thickness>

    <!-- Radius -->
    <CornerRadius x:Key="Nexus.Radius.Sm">10</CornerRadius>
    <CornerRadius x:Key="Nexus.Radius.Md">12</CornerRadius>
    <CornerRadius x:Key="Nexus.Radius.Lg">16</CornerRadius>
    <CornerRadius x:Key="Nexus.Radius.Xl">22</CornerRadius>
    <CornerRadius x:Key="Nexus.Radius.Window">22</CornerRadius>
    <CornerRadius x:Key="Nexus.Radius.Pill">999</CornerRadius>

    <!-- Typography -->
    <sys:Double x:Key="Nexus.Font.Size.Caption">10.5</sys:Double>
    <sys:Double x:Key="Nexus.Font.Size.Body">13</sys:Double>
    <sys:Double x:Key="Nexus.Font.Size.Subtitle">15</sys:Double>
    <sys:Double x:Key="Nexus.Font.Size.Title">20</sys:Double>
    <sys:Double x:Key="Nexus.Font.Size.Display">22</sys:Double>
    <FontFamily x:Key="Nexus.Font.Family">Segoe UI Variable Display, Segoe UI</FontFamily>

    <Style x:Key="Nexus.Text.TitleStyle" TargetType="TextBlock">
        <Setter Property="FontFamily" Value="{StaticResource Nexus.Font.Family}"/>
        <Setter Property="FontSize" Value="{StaticResource Nexus.Font.Size.Title}"/>
        <Setter Property="FontWeight" Value="SemiBold"/>
        <Setter Property="Foreground" Value="{StaticResource Nexus.Text.PrimaryBrush}"/>
    </Style>

    <Style x:Key="Nexus.Text.SubtitleStyle" TargetType="TextBlock">
        <Setter Property="FontFamily" Value="{StaticResource Nexus.Font.Family}"/>
        <Setter Property="FontSize" Value="{StaticResource Nexus.Font.Size.Caption}"/>
        <Setter Property="Foreground" Value="{StaticResource Nexus.Text.SecondaryBrush}"/>
        <Setter Property="Margin" Value="0,2,0,0"/>
    </Style>

    <Style x:Key="Nexus.Text.SectionStyle" TargetType="TextBlock" BasedOn="{StaticResource NexusSectionTitleStyle}"/>

    <!-- Glow / Shadow -->
    <DropShadowEffect x:Key="Nexus.Shadow.Window" Color="{StaticResource Nexus.Glow.Primary}" BlurRadius="32" ShadowDepth="0" Opacity="0.22"/>
    <DropShadowEffect x:Key="Nexus.Shadow.Card" Color="#2D9CFF" BlurRadius="20" ShadowDepth="0" Opacity="0.25"/>
    <DropShadowEffect x:Key="Nexus.Glow.Accent" Color="{StaticResource Nexus.Accent.Purple}" BlurRadius="22" ShadowDepth="0" Opacity="0.55"/>

    <!-- Animation -->
    <Duration x:Key="Nexus.Animation.Fast">0:0:0.15</Duration>
    <Duration x:Key="Nexus.Animation.Normal">0:0:0.2</Duration>
    <Duration x:Key="Nexus.Animation.Slow">0:0:0.35</Duration>

    <!-- ZIndex -->
    <sys:Int32 x:Key="Nexus.ZIndex.Base">0</sys:Int32>
    <sys:Int32 x:Key="Nexus.ZIndex.Content">10</sys:Int32>
    <sys:Int32 x:Key="Nexus.ZIndex.TitleBar">20</sys:Int32>
    <sys:Int32 x:Key="Nexus.ZIndex.Overlay">100</sys:Int32>
    <sys:Int32 x:Key="Nexus.ZIndex.Modal">200</sys:Int32>
    <sys:Int32 x:Key="Nexus.ZIndex.Toast">300</sys:Int32>

    <!-- ═══ Component styles ═══ -->

    <Style x:Key="NexusCardStyle" TargetType="Border">
        <Setter Property="CornerRadius" Value="{StaticResource Nexus.Radius.Lg}"/>
        <Setter Property="Padding" Value="{StaticResource Nexus.Padding.Card}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource NexusGlassBorderGradientBrush}"/>
        <Setter Property="Background">
            <Setter.Value>
                <SolidColorBrush Color="{StaticResource Nexus.SurfaceGlass}"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Effect" Value="{StaticResource Nexus.Shadow.Card}"/>
    </Style>

    <Style x:Key="NexusButtonStyle" TargetType="Button" BasedOn="{StaticResource NexusGlassButtonStyle}">
        <Setter Property="Height" Value="38"/>
        <Setter Property="Padding" Value="16,0"/>
        <Setter Property="FontSize" Value="{StaticResource Nexus.Font.Size.Body}"/>
        <Setter Property="MinWidth" Value="80"/>
    </Style>

    <Style x:Key="NexusButtonPrimaryStyle" TargetType="Button" BasedOn="{StaticResource NexusPrimaryActionButtonStyle}">
        <Setter Property="Height" Value="38"/>
        <Setter Property="Padding" Value="16,0"/>
        <Setter Property="FontSize" Value="{StaticResource Nexus.Font.Size.Body}"/>
        <Setter Property="MinWidth" Value="80"/>
    </Style>

    <Style x:Key="NexusIconButtonStyle2" TargetType="Button" BasedOn="{StaticResource NexusIconButtonStyle}">
        <Setter Property="Width" Value="36"/>
        <Setter Property="Height" Value="36"/>
        <Setter Property="Padding" Value="8"/>
    </Style>

    <Style x:Key="NexusSearchBoxControlStyle" TargetType="TextBox" BasedOn="{StaticResource NexusSearchBoxStyle}">
        <Setter Property="Height" Value="40"/>
        <Setter Property="Padding" Value="12,10"/>
        <Setter Property="FontSize" Value="{StaticResource Nexus.Font.Size.Subtitle}"/>
    </Style>

    <Style x:Key="NexusDataGridStyle" TargetType="DataGrid">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource Nexus.Text.PrimaryBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="RowBackground" Value="Transparent"/>
        <Setter Property="AlternatingRowBackground" Value="#0A1220"/>
        <Setter Property="GridLinesVisibility" Value="Horizontal"/>
        <Setter Property="HorizontalGridLinesBrush" Value="#1800D9FF"/>
        <Setter Property="HeadersVisibility" Value="Column"/>
        <Setter Property="FontFamily" Value="{StaticResource Nexus.Font.Family}"/>
        <Setter Property="FontSize" Value="{StaticResource Nexus.Font.Size.Body}"/>
    </Style>

    <Style x:Key="NexusDataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
        <Setter Property="Background" Value="#12081428"/>
        <Setter Property="Foreground" Value="{StaticResource Nexus.Text.SecondaryBrush}"/>
        <Setter Property="FontWeight" Value="SemiBold"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="Padding" Value="12,10"/>
        <Setter Property="BorderBrush" Value="#2200D9FF"/>
        <Setter Property="BorderThickness" Value="0,0,0,1"/>
    </Style>

    <Style x:Key="NexusStatusBadgeStyle" TargetType="Border">
        <Setter Property="CornerRadius" Value="{StaticResource Nexus.Radius.Pill}"/>
        <Setter Property="Padding" Value="10,4"/>
        <Setter Property="Background" Value="#2200D9FF"/>
        <Setter Property="BorderBrush" Value="#4400D9FF"/>
        <Setter Property="BorderThickness" Value="1"/>
    </Style>

    <Style x:Key="NexusProgressBarStyle" TargetType="ProgressBar">
        <Setter Property="Height" Value="6"/>
        <Setter Property="Foreground" Value="{StaticResource Nexus.Accent.CyanBrush}"/>
        <Setter Property="Background" Value="#18081428"/>
        <Setter Property="BorderThickness" Value="0"/>
    </Style>

    <Style x:Key="NexusTabItemStyle" TargetType="TabItem">
        <Setter Property="Foreground" Value="{StaticResource Nexus.Text.SecondaryBrush}"/>
        <Setter Property="FontSize" Value="{StaticResource Nexus.Font.Size.Body}"/>
        <Setter Property="Padding" Value="16,10"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabItem">
                    <Border x:Name="Root" Padding="{TemplateBinding Padding}" Background="Transparent"
                            BorderBrush="Transparent" BorderThickness="0,0,0,2" Margin="0,0,4,0">
                        <ContentPresenter ContentSource="Header" HorizontalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="Root" Property="BorderBrush" Value="{StaticResource Nexus.Accent.CyanBrush}"/>
                            <Setter Property="Foreground" Value="{StaticResource Nexus.Text.PrimaryBrush}"/>
                            <Setter Property="FontWeight" Value="SemiBold"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Root" Property="Background" Value="#1400D9FF"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="NexusTabsStyle" TargetType="TabControl">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="ItemContainerStyle" Value="{StaticResource NexusTabItemStyle}"/>
    </Style>

    <Style x:Key="NexusSideNavStyle" TargetType="Border">
        <Setter Property="Width" Value="220"/>
        <Setter Property="Background" Value="#08081428"/>
        <Setter Property="BorderBrush" Value="#1800D9FF"/>
        <Setter Property="BorderThickness" Value="0,0,1,0"/>
        <Setter Property="Padding" Value="12,16"/>
    </Style>

    <Style x:Key="NexusSideNavItemStyle" TargetType="Button">
        <Setter Property="Height" Value="40"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="Padding" Value="12,0"/>
        <Setter Property="Margin" Value="0,0,0,4"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="Foreground" Value="{StaticResource Nexus.Text.SecondaryBrush}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="FontSize" Value="{StaticResource Nexus.Font.Size.Body}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="Root" CornerRadius="{StaticResource Nexus.Radius.Md}"
                            Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
                        <ContentPresenter VerticalAlignment="Center"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Root" Property="Background" Value="#1800D9FF"/>
                            <Setter Property="Foreground" Value="{StaticResource Nexus.Text.PrimaryBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="NexusToastStyle" TargetType="Border">
        <Setter Property="CornerRadius" Value="{StaticResource Nexus.Radius.Md}"/>
        <Setter Property="Padding" Value="14,12"/>
        <Setter Property="Background" Value="#E00A1428"/>
        <Setter Property="BorderBrush" Value="#6600D9FF"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Effect" Value="{StaticResource Nexus.Shadow.Card}"/>
    </Style>

    <Style x:Key="NexusModalOverlayStyle" TargetType="Border">
        <Setter Property="Background" Value="{StaticResource NexusShellOverlayScrimBrush}"/>
    </Style>

    <Style x:Key="NexusModalPanelStyle" TargetType="Border" BasedOn="{StaticResource NexusCardStyle}">
        <Setter Property="CornerRadius" Value="{StaticResource Nexus.Radius.Xl}"/>
        <Setter Property="Padding" Value="24"/>
        <Setter Property="MinWidth" Value="360"/>
    </Style>

    <Style x:Key="NexusPreviewPanelStyle" TargetType="Border">
        <Setter Property="Background" Value="#08081428"/>
        <Setter Property="BorderBrush" Value="#2200D9FF"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="CornerRadius" Value="{StaticResource Nexus.Radius.Lg}"/>
        <Setter Property="Padding" Value="12"/>
    </Style>

    <Style x:Key="NexusCommandBarStyle" TargetType="Border">
        <Setter Property="Background" Value="#08081428"/>
        <Setter Property="BorderBrush" Value="#2200D9FF"/>
        <Setter Property="BorderThickness" Value="0,0,0,1"/>
        <Setter Property="Padding" Value="12,8"/>
    </Style>

    <!-- NexusWindow chrome template -->
    <Style x:Key="NexusAppWindowStyle" TargetType="controls:NexusWindow">
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="AllowsTransparency" Value="False"/>
        <Setter Property="ResizeMode" Value="CanResize"/>
        <Setter Property="Background" Value="{StaticResource Nexus.BackgroundBrush}"/>
        <Setter Property="FontFamily" Value="{StaticResource Nexus.Font.Family}"/>
        <Setter Property="ShowAmbientGlow" Value="True"/>
        <Setter Property="AnimateOnLoad" Value="True"/>
        <Setter Property="ShellCornerRadius" Value="22"/>
        <Setter Property="shell:WindowChrome.WindowChrome">
            <Setter.Value>
                <shell:WindowChrome CaptionHeight="0"
                                    CornerRadius="0"
                                    GlassFrameThickness="0"
                                    ResizeBorderThickness="8"
                                    UseAeroCaptionButtons="False"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:NexusWindow">
                    <Grid Margin="{StaticResource Nexus.Padding.Window}">
                        <Border x:Name="PART_ShellBorder"
                                CornerRadius="{TemplateBinding ShellCornerRadius}"
                                BorderBrush="{StaticResource Nexus.Border.CyanBrush}"
                                BorderThickness="1"
                                Opacity="0"
                                Effect="{StaticResource Nexus.Shadow.Window}">
                            <Border.Background>
                                <StaticResource ResourceKey="Nexus.WindowShellBrush"/>
                            </Border.Background>
                            <Grid>
                                <Ellipse x:Name="PART_GlowPurple" Width="420" Height="420"
                                         HorizontalAlignment="Left" VerticalAlignment="Top"
                                         Margin="-120,-140,0,0" IsHitTestVisible="False" Opacity="0.35">
                                    <Ellipse.Style>
                                        <Style TargetType="Ellipse">
                                            <Setter Property="Visibility" Value="Visible"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ShowAmbientGlow, RelativeSource={RelativeSource TemplatedParent}}" Value="False">
                                                    <Setter Property="Visibility" Value="Collapsed"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Ellipse.Style>
                                    <Ellipse.Fill>
                                        <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
                                            <GradientStop Color="#338A4FFF" Offset="0"/>
                                            <GradientStop Color="#00000000" Offset="1"/>
                                        </RadialGradientBrush>
                                    </Ellipse.Fill>
                                </Ellipse>
                                <Ellipse x:Name="PART_GlowCyan" Width="360" Height="360"
                                         HorizontalAlignment="Right" VerticalAlignment="Bottom"
                                         Margin="0,0,-80,-100" IsHitTestVisible="False" Opacity="0.28">
                                    <Ellipse.Style>
                                        <Style TargetType="Ellipse">
                                            <Setter Property="Visibility" Value="Visible"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding ShowAmbientGlow, RelativeSource={RelativeSource TemplatedParent}}" Value="False">
                                                    <Setter Property="Visibility" Value="Collapsed"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Ellipse.Style>
                                    <Ellipse.Fill>
                                        <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
                                            <GradientStop Color="#3300D9FF" Offset="0"/>
                                            <GradientStop Color="#00000000" Offset="1"/>
                                        </RadialGradientBrush>
                                    </Ellipse.Fill>
                                </Ellipse>

                                <Grid Panel.ZIndex="{StaticResource Nexus.ZIndex.Content}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <controls:NexusTitleBar Grid.Row="0"
                                                            AppTitle="{TemplateBinding AppTitle}"
                                                            AppSubtitle="{TemplateBinding AppSubtitle}"
                                                            IconData="{TemplateBinding IconData}"
                                                            ShowChromeButtons="{TemplateBinding ShowChromeButtons}"/>

                                    <Rectangle Grid.Row="0" VerticalAlignment="Bottom" Height="1"
                                               Margin="22,0" Fill="{StaticResource Nexus.DividerBrush}" Opacity="0.6"/>

                                    <controls:NexusContentLayout Grid.Row="1"
                                                                 Margin="{StaticResource Nexus.Padding.Content}"
                                                                 ShowSideNav="{TemplateBinding ShowSideNav}"
                                                                 ShowRightPanel="{TemplateBinding ShowRightPanel}"
                                                                 SideNavContent="{TemplateBinding SideNavContent}"
                                                                 MainContent="{TemplateBinding MainContent}"
                                                                 RightPanelContent="{TemplateBinding RightPanelContent}"/>

                                    <ContentPresenter Grid.Row="2"
                                                      Content="{TemplateBinding FooterContent}"
                                                      Margin="18,0,18,18"/>
                                </Grid>
                            </Grid>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="controls:NexusWindow" BasedOn="{StaticResource NexusAppWindowStyle}"/>

</ResourceDictionary>
