<Styles xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ctrl="using:ClawdDotNet.Desktop.Controls">

  <!--
    Die gemeinsame Anmutung — Umsetzung des Entwurfs aus Mockup/.

    Warum eigene ControlTheme statt Fluent umzufärben: Avalonia 12 hat die Ressourcen des
    Fluent-Themas umgebaut. Die aus 11er-Anleitungen bekannten Schlüssel (ButtonBackground,
    TextControlBackground, ControlCornerRadius …) existieren nicht mehr; ein Setter darauf
    ist wirkungslos und fällt nicht auf, weil er weder Build noch Test bricht. Für die
    prägenden Steuerelemente steht die Vorlage deshalb hier vollständig. Fluent bleibt
    darunter als Grundlage für alles Übrige (Bildlaufleisten, Menüs, Popup-Rahmen).

    Regel wie gehabt: keine festen Farbwerte. Alles über DynamicResource aus Theme.axaml,
    sonst überlebt es den Wechsel zwischen hell und dunkel nicht.
  -->

  <Styles.Resources>
    <ResourceDictionary>

      <ResourceDictionary.MergedDictionaries>
        <ResourceInclude Source="avares://ClawdDotNet/Styles/Theme.axaml" />
        <ResourceInclude Source="avares://ClawdDotNet/Styles/Icons.axaml" />
      </ResourceDictionary.MergedDictionaries>

      <!-- ════════════════════════════ Schaltflächen ════════════════════════════

           Grundform ist die sekundäre Schaltfläche des Entwurfs: durchsichtig, eine
           Haarlinie Rahmen, eckig. Die Spielarten kommen als Klasse dazu:
             .primary / .accent  gefüllt in Akzentfarbe
             .toolbar            kleiner, Fließtextschrift — für Werkzeugleisten
             .ghost              ohne Rahmen, Akzentfarbe
             .flat               ohne Rahmen, Textfarbe (Schließen, Einklappen)
             .icon               quadratisch, ohne Innenabstand
           .accent bleibt neben .primary bestehen: Die noch nicht überarbeiteten Dialoge
           verwenden diesen Namen. -->
      <ControlTheme x:Key="{x:Type Button}" TargetType="Button">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CornerRadius" Value="0" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="FontFamily" Value="{DynamicResource HeadingFont}" />
        <Setter Property="FontWeight" Value="SemiBold" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Padding" Value="12,7" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
          <ControlTemplate>
            <ContentPresenter Name="PART_ContentPresenter"
                              Background="{TemplateBinding Background}"
                              BorderBrush="{TemplateBinding BorderBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}"
                              CornerRadius="{TemplateBinding CornerRadius}"
                              Padding="{TemplateBinding Padding}"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                              RecognizesAccessKey="True" />
          </ControlTemplate>
        </Setter>

        <Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource HoverBrush}" />
        </Style>
        <Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource PressedBrush}" />
        </Style>
        <Style Selector="^:disabled">
          <Setter Property="Opacity" Value="0.45" />
          <Setter Property="Cursor" Value="Arrow" />
        </Style>

        <Style Selector="^.primary, ^.accent">
          <Setter Property="Background" Value="{DynamicResource AccentBrush}" />
          <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
          <Setter Property="Foreground" Value="{DynamicResource BgBrush}" />
        </Style>
        <Style Selector="^.primary:pointerover /template/ ContentPresenter#PART_ContentPresenter,
                         ^.accent:pointerover /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource Accent600Brush}" />
        </Style>
        <Style Selector="^.primary:pressed /template/ ContentPresenter#PART_ContentPresenter,
                         ^.accent:pressed /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource Accent700Brush}" />
        </Style>

        <Style Selector="^.toolbar">
          <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
          <Setter Property="FontWeight" Value="Normal" />
          <Setter Property="FontSize" Value="12.5" />
          <Setter Property="Padding" Value="10,6" />
        </Style>

        <Style Selector="^.ghost">
          <Setter Property="BorderBrush" Value="Transparent" />
          <Setter Property="Foreground" Value="{DynamicResource AccentBrush}" />
          <Setter Property="Padding" Value="6,4" />
        </Style>

        <Style Selector="^.flat">
          <Setter Property="BorderBrush" Value="Transparent" />
          <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
          <Setter Property="FontWeight" Value="Normal" />
          <Setter Property="Padding" Value="6,4" />
        </Style>

        <Style Selector="^.icon">
          <Setter Property="Width" Value="32" />
          <Setter Property="Height" Value="32" />
          <Setter Property="Padding" Value="0" />
        </Style>
      </ControlTheme>

      <!-- Umschalt-Schaltfläche: dieselbe Form, plus ausgewählter Zustand.
           Trägt im Entwurf die Segmentleiste über den Aufgaben-Listen. -->
      <ControlTheme x:Key="{x:Type ToggleButton}" TargetType="ToggleButton">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CornerRadius" Value="0" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
        <Setter Property="FontSize" Value="13" />
        <Setter Property="Padding" Value="14,7" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
          <ControlTemplate>
            <ContentPresenter Name="PART_ContentPresenter"
                              Background="{TemplateBinding Background}"
                              BorderBrush="{TemplateBinding BorderBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}"
                              CornerRadius="{TemplateBinding CornerRadius}"
                              Padding="{TemplateBinding Padding}"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
          </ControlTemplate>
        </Setter>

        <Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource HoverBrush}" />
        </Style>
        <Style Selector="^:checked">
          <Setter Property="Foreground" Value="{DynamicResource BgBrush}" />
        </Style>
        <Style Selector="^:checked /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource AccentBrush}" />
        </Style>
        <Style Selector="^:disabled">
          <Setter Property="Opacity" Value="0.45" />
        </Style>
      </ControlTheme>

      <!-- ════════════════════════════ Eingabefelder ════════════════════════════ -->
      <ControlTheme x:Key="{x:Type TextBox}" TargetType="TextBox">
        <Setter Property="Background" Value="{DynamicResource SurfaceBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CornerRadius" Value="0" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="CaretBrush" Value="{DynamicResource AccentBrush}" />
        <Setter Property="SelectionBrush" Value="{DynamicResource AccentSoftBrush}" />
        <Setter Property="SelectionForegroundBrush" Value="{DynamicResource TextBrush}" />
        <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="MinHeight" Value="32" />
        <Setter Property="Padding" Value="9,5" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
          <ControlTemplate>
            <Panel>
              <Border Name="PART_BorderElement"
                      Background="{TemplateBinding Background}"
                      BorderBrush="{TemplateBinding BorderBrush}"
                      BorderThickness="{TemplateBinding BorderThickness}"
                      CornerRadius="{TemplateBinding CornerRadius}"
                      MinHeight="{TemplateBinding MinHeight}" />

              <DockPanel Margin="{TemplateBinding Padding}">
                <ContentPresenter Content="{TemplateBinding InnerLeftContent}" DockPanel.Dock="Left" />
                <ContentPresenter Content="{TemplateBinding InnerRightContent}" DockPanel.Dock="Right" />

                <ScrollViewer Name="PART_ScrollViewer"
                              HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
                              VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
                  <Panel>
                    <!-- Der Platzhalter verschwindet, sobald etwas im Feld steht. Über
                         IsVisible statt Opacity, damit er keine Maus-Ereignisse abfängt. -->
                    <TextBlock Name="PART_Watermark"
                               Text="{TemplateBinding PlaceholderText}"
                               Foreground="{DynamicResource TextGhostBrush}"
                               TextAlignment="{TemplateBinding TextAlignment}"
                               TextWrapping="{TemplateBinding TextWrapping}"
                               IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNullOrEmpty}}"
                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                               VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

                    <TextPresenter Name="PART_TextPresenter"
                                   Text="{TemplateBinding Text, Mode=TwoWay}"
                                   CaretIndex="{TemplateBinding CaretIndex}"
                                   SelectionStart="{TemplateBinding SelectionStart}"
                                   SelectionEnd="{TemplateBinding SelectionEnd}"
                                   TextAlignment="{TemplateBinding TextAlignment}"
                                   TextWrapping="{TemplateBinding TextWrapping}"
                                   PasswordChar="{TemplateBinding PasswordChar}"
                                   RevealPassword="{TemplateBinding RevealPassword}"
                                   SelectionBrush="{TemplateBinding SelectionBrush}"
                                   SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
                                   CaretBrush="{TemplateBinding CaretBrush}"
                                   HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                   VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                  </Panel>
                </ScrollViewer>
              </DockPanel>
            </Panel>
          </ControlTemplate>
        </Setter>

        <Style Selector="^:pointerover /template/ Border#PART_BorderElement">
          <Setter Property="BorderBrush" Value="{DynamicResource TextGhostBrush}" />
        </Style>
        <Style Selector="^:focus /template/ Border#PART_BorderElement">
          <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
        </Style>
        <Style Selector="^:disabled">
          <Setter Property="Opacity" Value="0.5" />
        </Style>

        <!-- Mehrzeilig: Text oben beginnen lassen, nicht mittig. -->
        <Style Selector="^[AcceptsReturn=True]">
          <Setter Property="VerticalContentAlignment" Value="Top" />
        </Style>
      </ControlTheme>

      <!-- ════════════════════════════ Auswahlfeld ════════════════════════════ -->
      <ControlTheme x:Key="{x:Type ComboBox}" TargetType="ComboBox">
        <Setter Property="Background" Value="{DynamicResource SurfaceBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CornerRadius" Value="0" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="MinHeight" Value="32" />
        <Setter Property="Padding" Value="9,5" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="PlaceholderForeground" Value="{DynamicResource TextGhostBrush}" />
        <Setter Property="Template">
          <ControlTemplate>
            <Grid ColumnDefinitions="*,Auto">
              <Border Name="Background" Grid.ColumnSpan="2"
                      Background="{TemplateBinding Background}"
                      BorderBrush="{TemplateBinding BorderBrush}"
                      BorderThickness="{TemplateBinding BorderThickness}"
                      CornerRadius="{TemplateBinding CornerRadius}"
                      MinHeight="{TemplateBinding MinHeight}" />

              <TextBlock Name="PlaceholderTextBlock" Grid.Column="0"
                         Text="{TemplateBinding PlaceholderText}"
                         Foreground="{TemplateBinding PlaceholderForeground}"
                         Margin="{TemplateBinding Padding}"
                         VerticalAlignment="Center"
                         IsVisible="{TemplateBinding SelectionBoxItem, Converter={x:Static ObjectConverters.IsNull}}" />

              <ContentControl Name="ContentPresenter" Grid.Column="0"
                              Content="{TemplateBinding SelectionBoxItem}"
                              ContentTemplate="{TemplateBinding ItemTemplate}"
                              Margin="{TemplateBinding Padding}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="Center" />

              <ctrl:StrokeIcon Grid.Column="1" Data="{StaticResource IconChevronDown}"
                               Width="12" Height="12" Margin="0,0,9,0"
                               VerticalAlignment="Center" IsHitTestVisible="False" />

              <Popup Name="PART_Popup"
                     IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}"
                     MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
                     PlacementTarget="Background"
                     IsLightDismissEnabled="True">
                <Border Background="{DynamicResource SurfaceBrush}"
                        BorderBrush="{DynamicResource DividerBrush}"
                        BorderThickness="1" CornerRadius="0" Padding="0,2">
                  <ScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="320">
                    <ItemsPresenter Name="PART_ItemsPresenter"
                                    ItemsPanel="{TemplateBinding ItemsPanel}" />
                  </ScrollViewer>
                </Border>
              </Popup>
            </Grid>
          </ControlTemplate>
        </Setter>

        <Style Selector="^:pointerover /template/ Border#Background">
          <Setter Property="BorderBrush" Value="{DynamicResource TextGhostBrush}" />
        </Style>
        <Style Selector="^:focus /template/ Border#Background">
          <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
        </Style>
        <Style Selector="^:disabled">
          <Setter Property="Opacity" Value="0.5" />
        </Style>
      </ControlTheme>

      <ControlTheme x:Key="{x:Type ComboBoxItem}" TargetType="ComboBoxItem">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Padding" Value="10,6" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
          <ControlTemplate>
            <ContentPresenter Name="PART_ContentPresenter"
                              Background="{TemplateBinding Background}"
                              Padding="{TemplateBinding Padding}"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
          </ControlTemplate>
        </Setter>
        <Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource HoverBrush}" />
        </Style>
        <Style Selector="^:selected /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource AccentSelectedBrush}" />
        </Style>
      </ControlTheme>

      <!-- ════════════════════ Kontrollkästchen & Auswahlknopf ════════════════════

           Beide teilen sich die Form aus dem Entwurf: 16 px Marke, 1.5 px Rand, im
           gewählten Zustand mit Akzent gefüllt. Unterschied ist allein die Rundung —
           eckig für Mehrfach-, rund für Einfachauswahl. -->
      <ControlTheme x:Key="{x:Type CheckBox}" TargetType="CheckBox">
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
          <ControlTemplate>
            <StackPanel Orientation="Horizontal" Spacing="8" Background="Transparent">
              <Border Name="Mark" Width="16" Height="16" CornerRadius="3"
                      BorderBrush="{DynamicResource DividerBrush}" BorderThickness="1.5"
                      Background="Transparent" VerticalAlignment="Center">
                <ctrl:StrokeIcon Name="Glyph" Width="12" Height="12" StrokeThickness="3"
                                 Foreground="{DynamicResource BgBrush}"
                                 Data="M4 12l5 5L20 6" IsVisible="False" />
              </Border>
              <ContentPresenter Name="PART_ContentPresenter"
                                Content="{TemplateBinding Content}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                VerticalAlignment="Center" />
            </StackPanel>
          </ControlTemplate>
        </Setter>

        <Style Selector="^:pointerover /template/ Border#Mark">
          <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
        </Style>
        <Style Selector="^:checked /template/ Border#Mark">
          <Setter Property="Background" Value="{DynamicResource AccentBrush}" />
          <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
        </Style>
        <Style Selector="^:checked /template/ ctrl|StrokeIcon#Glyph">
          <Setter Property="IsVisible" Value="True" />
        </Style>
        <Style Selector="^:indeterminate /template/ Border#Mark">
          <Setter Property="Background" Value="{DynamicResource AccentSoftBrush}" />
          <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
        </Style>
        <Style Selector="^:disabled">
          <Setter Property="Opacity" Value="0.5" />
        </Style>
      </ControlTheme>

      <ControlTheme x:Key="{x:Type RadioButton}" TargetType="RadioButton">
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
          <ControlTemplate>
            <StackPanel Orientation="Horizontal" Spacing="8" Background="Transparent">
              <Border Name="Mark" Width="16" Height="16" CornerRadius="8"
                      BorderBrush="{DynamicResource DividerBrush}" BorderThickness="1.5"
                      Background="Transparent" VerticalAlignment="Center">
                <!-- Der innere Punkt entsteht wie im Entwurf durch einen Ring in
                     Hintergrundfarbe, nicht durch eine zweite Ellipse. -->
                <Border Name="Dot" CornerRadius="8" Margin="3"
                        Background="{DynamicResource BgBrush}" IsVisible="False" />
              </Border>
              <ContentPresenter Name="PART_ContentPresenter"
                                Content="{TemplateBinding Content}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                VerticalAlignment="Center" />
            </StackPanel>
          </ControlTemplate>
        </Setter>

        <Style Selector="^:pointerover /template/ Border#Mark">
          <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
        </Style>
        <Style Selector="^:checked /template/ Border#Mark">
          <Setter Property="Background" Value="{DynamicResource AccentBrush}" />
          <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
        </Style>
        <Style Selector="^:checked /template/ Border#Dot">
          <Setter Property="IsVisible" Value="True" />
        </Style>
        <Style Selector="^:disabled">
          <Setter Property="Opacity" Value="0.5" />
        </Style>
      </ControlTheme>

      <!-- ════════════════════════════ Listen ════════════════════════════ -->
      <ControlTheme x:Key="{x:Type ListBox}" TargetType="ListBox">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Template">
          <ControlTemplate>
            <Border Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}">
              <ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
                            VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
                <ItemsPresenter Name="PART_ItemsPresenter"
                                ItemsPanel="{TemplateBinding ItemsPanel}"
                                Margin="{TemplateBinding Padding}" />
              </ScrollViewer>
            </Border>
          </ControlTemplate>
        </Setter>
      </ControlTheme>

      <ControlTheme x:Key="{x:Type ListBoxItem}" TargetType="ListBoxItem">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Padding" Value="7" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
          <ControlTemplate>
            <ContentPresenter Name="PART_ContentPresenter"
                              Background="{TemplateBinding Background}"
                              Padding="{TemplateBinding Padding}"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
          </ControlTemplate>
        </Setter>
        <Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource RowHoverBrush}" />
        </Style>
        <Style Selector="^:selected /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource AccentRowBrush}" />
        </Style>
        <Style Selector="^:selected:pointerover /template/ ContentPresenter#PART_ContentPresenter">
          <Setter Property="Background" Value="{DynamicResource AccentSelectedBrush}" />
        </Style>
      </ControlTheme>

      <!-- ════════════════════════════ Rahmen mit Eckmarken ════════════════════════════

           Die vier Marken liegen halb außerhalb des Rahmens; sie sitzen deshalb in einem
           Grid über dem Rahmen und nicht in ihm. IsHitTestVisible=False, damit sie
           Klicks auf den Inhalt nicht abfangen. -->
      <ControlTheme x:Key="{x:Type ctrl:BlueprintFrame}" TargetType="ctrl:BlueprintFrame">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Padding" Value="14" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Template">
          <ControlTemplate>
            <Grid>
              <Border Background="{TemplateBinding Background}"
                      BorderBrush="{TemplateBinding BorderBrush}"
                      BorderThickness="{TemplateBinding BorderThickness}"
                      Padding="{TemplateBinding Padding}">
                <ContentPresenter Content="{TemplateBinding Content}"
                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                  HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                  VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
              </Border>

              <Panel Width="11" Height="11" Margin="-6,-6,0,0" IsHitTestVisible="False"
                     HorizontalAlignment="Left" VerticalAlignment="Top">
                <Rectangle Width="1" Height="11" Margin="5,0,0,0" HorizontalAlignment="Left"
                           Fill="{DynamicResource TextFaintBrush}" />
                <Rectangle Width="11" Height="1" Margin="0,5,0,0" VerticalAlignment="Top"
                           Fill="{DynamicResource TextFaintBrush}" />
              </Panel>
              <Panel Width="11" Height="11" Margin="0,-6,-6,0" IsHitTestVisible="False"
                     HorizontalAlignment="Right" VerticalAlignment="Top">
                <Rectangle Width="1" Height="11" Margin="5,0,0,0" HorizontalAlignment="Left"
                           Fill="{DynamicResource TextFaintBrush}" />
                <Rectangle Width="11" Height="1" Margin="0,5,0,0" VerticalAlignment="Top"
                           Fill="{DynamicResource TextFaintBrush}" />
              </Panel>
              <Panel Width="11" Height="11" Margin="-6,0,0,-6" IsHitTestVisible="False"
                     HorizontalAlignment="Left" VerticalAlignment="Bottom">
                <Rectangle Width="1" Height="11" Margin="5,0,0,0" HorizontalAlignment="Left"
                           Fill="{DynamicResource TextFaintBrush}" />
                <Rectangle Width="11" Height="1" Margin="0,5,0,0" VerticalAlignment="Top"
                           Fill="{DynamicResource TextFaintBrush}" />
              </Panel>
              <Panel Width="11" Height="11" Margin="0,0,-6,-6" IsHitTestVisible="False"
                     HorizontalAlignment="Right" VerticalAlignment="Bottom">
                <Rectangle Width="1" Height="11" Margin="5,0,0,0" HorizontalAlignment="Left"
                           Fill="{DynamicResource TextFaintBrush}" />
                <Rectangle Width="11" Height="1" Margin="0,5,0,0" VerticalAlignment="Top"
                           Fill="{DynamicResource TextFaintBrush}" />
              </Panel>
            </Grid>
          </ControlTemplate>
        </Setter>
      </ControlTheme>

    </ResourceDictionary>
  </Styles.Resources>

  <!-- ══════════════════════════════════════════════════════════════════════════
       Grundlagen: Fenster, Schrift, Trenner
       ══════════════════════════════════════════════════════════════════════ -->

  <Style Selector="Window">
    <Setter Property="Background" Value="{DynamicResource BgBrush}" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
    <Setter Property="FontSize" Value="14" />
  </Style>

  <Style Selector="UserControl">
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
  </Style>

  <!-- Überschriften laufen in Barlow Condensed, Fließtext in Barlow — das ist der
       auffälligste Zug des Entwurfs und darf nirgends per Hand gesetzt werden. -->
  <Style Selector="TextBlock.h1">
    <Setter Property="FontFamily" Value="{DynamicResource HeadingFont}" />
    <Setter Property="FontWeight" Value="SemiBold" />
    <Setter Property="FontSize" Value="20" />
  </Style>

  <Style Selector="TextBlock.h2">
    <Setter Property="FontFamily" Value="{DynamicResource HeadingFont}" />
    <Setter Property="FontWeight" Value="SemiBold" />
    <Setter Property="FontSize" Value="17" />
  </Style>

  <!-- Bestandsname aus der ersten Portierung; die noch nicht überarbeiteten Dialoge
       binden darauf. -->
  <Style Selector="TextBlock.heading">
    <Setter Property="FontFamily" Value="{DynamicResource HeadingFont}" />
    <Setter Property="FontWeight" Value="SemiBold" />
    <Setter Property="FontSize" Value="17" />
    <Setter Property="Margin" Value="0,0,0,8" />
  </Style>

  <!-- Die kleine Versalzeile über jedem Abschnitt — im Entwurf durchgehend in
       Akzentfarbe, 10 px, weit gesperrt. -->
  <Style Selector="TextBlock.kicker">
    <Setter Property="FontSize" Value="10" />
    <Setter Property="LetterSpacing" Value="1" />
    <Setter Property="Foreground" Value="{DynamicResource AccentBrush}" />
    <Setter Property="Margin" Value="0,0,0,4" />
  </Style>

  <Style Selector="TextBlock.caption">
    <Setter Property="FontSize" Value="12" />
    <Setter Property="Foreground" Value="{DynamicResource TextFaintBrush}" />
  </Style>

  <Style Selector="TextBlock.muted">
    <Setter Property="Foreground" Value="{DynamicResource TextSubtleBrush}" />
  </Style>

  <Style Selector="TextBlock.label">
    <Setter Property="FontSize" Value="12" />
    <Setter Property="Foreground" Value="{DynamicResource TextMutedBrush}" />
    <Setter Property="Margin" Value="0,0,0,4" />
  </Style>

  <Style Selector="TextBlock.mono, SelectableTextBlock.mono">
    <Setter Property="FontFamily" Value="{DynamicResource MonoFont}" />
    <Setter Property="FontSize" Value="12.5" />
  </Style>

  <Style Selector="SelectableTextBlock">
    <Setter Property="SelectionBrush" Value="{DynamicResource AccentSoftBrush}" />
  </Style>

  <!-- Log-Stufen. Über Klassen statt über einen Pinsel aus einem Konverter, damit die
       Farben beim Wechsel auf Dunkel mitziehen. -->
  <Style Selector="SelectableTextBlock.warn">
    <Setter Property="Foreground" Value="{DynamicResource WarningBrush}" />
  </Style>

  <Style Selector="SelectableTextBlock.err, SelectableTextBlock.ftl">
    <Setter Property="Foreground" Value="{DynamicResource DangerBrush}" />
  </Style>

  <!-- ══════════════════════════════════════════════════════════════════════════
       Flächen
       ══════════════════════════════════════════════════════════════════════ -->

  <!-- Karte: eckig, Haarlinie, durchsichtig — der Entwurf setzt bewusst keine
       Füllfarbe, damit die Kästen als Zeichnung und nicht als Kacheln wirken. -->
  <Style Selector="Border.card">
    <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="CornerRadius" Value="0" />
    <Setter Property="Padding" Value="10" />
    <Setter Property="Background" Value="Transparent" />
  </Style>

  <!-- Karte in Akzent hinterlegt — eigene Chat-Nachrichten. -->
  <Style Selector="Border.card.accent">
    <Setter Property="Background" Value="{DynamicResource AccentSoftBrush}" />
  </Style>

  <Style Selector="Border.surface">
    <Setter Property="Background" Value="{DynamicResource SurfaceBrush}" />
  </Style>

  <Style Selector="Border.statusbar">
    <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
    <Setter Property="BorderThickness" Value="0,1,0,0" />
    <Setter Property="Padding" Value="24,6" />
  </Style>

  <Style Selector="Border.topbar">
    <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
    <Setter Property="BorderThickness" Value="0,0,0,1" />
    <Setter Property="Padding" Value="24,14" />
  </Style>

  <!-- Konsolenfläche der Log-Ansicht -->
  <Style Selector="Border.console">
    <Setter Property="Background" Value="{DynamicResource SurfaceBrush}" />
    <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="Padding" Value="14" />
  </Style>

  <!-- Senkrechter Strich zwischen Gruppen einer Werkzeugleiste -->
  <Style Selector="Border.sep">
    <Setter Property="Width" Value="1" />
    <Setter Property="Height" Value="20" />
    <Setter Property="Margin" Value="4,0" />
    <Setter Property="Background" Value="{DynamicResource DividerBrush}" />
    <Setter Property="VerticalAlignment" Value="Center" />
  </Style>

  <Style Selector="Border.hr">
    <Setter Property="Height" Value="1" />
    <Setter Property="Background" Value="{DynamicResource DividerBrush}" />
  </Style>

  <!-- ══════════════════════════════════════════════════════════════════════════
       Werkzeugleisten
       ══════════════════════════════════════════════════════════════════════ -->

  <Style Selector="StackPanel.toolbar">
    <Setter Property="Orientation" Value="Horizontal" />
    <Setter Property="Spacing" Value="6" />
    <Setter Property="Margin" Value="0,0,0,10" />
  </Style>

  <Style Selector="WrapPanel.toolbar">
    <Setter Property="Orientation" Value="Horizontal" />
    <Setter Property="ItemSpacing" Value="6" />
    <Setter Property="LineSpacing" Value="6" />
    <Setter Property="Margin" Value="0,0,0,10" />
  </Style>

  <!-- ══════════════════════════════════════════════════════════════════════════
       Tabellen

       Von Hand statt DataGrid: Der Entwurf zeigt eine Kopfzeile in Versalien und
       Zeilen mit Haarlinie darunter — mehr nicht, kein Sortieren, kein Spaltenziehen.
       Ein umgefärbtes DataGrid wäre hier deutlich mehr Aufwand als eine ListBox, und
       das Ergebnis säße am Ende doch nicht auf dem Raster des Entwurfs.
       ══════════════════════════════════════════════════════════════════════ -->

  <!-- Kopfzelle -->
  <Style Selector="TextBlock.th">
    <Setter Property="FontSize" Value="11" />
    <Setter Property="LetterSpacing" Value="0.9" />
    <Setter Property="Foreground" Value="{DynamicResource TextSubtleBrush}" />
    <Setter Property="VerticalAlignment" Value="Center" />
  </Style>

  <!-- Kopfzeile: trägt die Linie, die die Spaltentitel vom Inhalt trennt -->
  <Style Selector="Border.thead">
    <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
    <Setter Property="BorderThickness" Value="0,0,0,1" />
    <Setter Property="Padding" Value="7" />
  </Style>

  <!-- Zeile: Haarlinie unten, schwächer als die der Kopfzeile -->
  <Style Selector="Border.tr">
    <Setter Property="BorderBrush" Value="{DynamicResource RowLineBrush}" />
    <Setter Property="BorderThickness" Value="0,0,0,1" />
  </Style>

  <Style Selector="ListBox.table > ListBoxItem">
    <Setter Property="Padding" Value="0" />
  </Style>

  <!-- Zelltext -->
  <Style Selector="TextBlock.td">
    <Setter Property="VerticalAlignment" Value="Center" />
    <Setter Property="TextTrimming" Value="CharacterEllipsis" />
  </Style>

  <Style Selector="TextBlock.td.dim">
    <Setter Property="FontSize" Value="12" />
    <Setter Property="Foreground" Value="{DynamicResource TextSubtleBrush}" />
  </Style>

  <!-- ══════════════════════════════════════════════════════════════════════════
       Etiketten (Status in Tabellen)
       ══════════════════════════════════════════════════════════════════════ -->

  <Style Selector="Border.tag">
    <Setter Property="Padding" Value="9,2" />
    <Setter Property="CornerRadius" Value="0" />
    <Setter Property="Background" Value="{DynamicResource Neutral100Brush}" />
    <Setter Property="HorizontalAlignment" Value="Left" />
    <Setter Property="VerticalAlignment" Value="Center" />
  </Style>

  <Style Selector="Border.tag > TextBlock">
    <Setter Property="FontSize" Value="11" />
    <Setter Property="Foreground" Value="{DynamicResource Neutral800Brush}" />
  </Style>

  <Style Selector="Border.tag.ok">
    <Setter Property="Background" Value="{DynamicResource AccentSoftBrush}" />
  </Style>
  <Style Selector="Border.tag.ok > TextBlock">
    <Setter Property="Foreground" Value="{DynamicResource Accent700Brush}" />
  </Style>

  <Style Selector="Border.tag.bad">
    <Setter Property="Background" Value="{DynamicResource DangerSoftBrush}" />
  </Style>
  <Style Selector="Border.tag.bad > TextBlock">
    <Setter Property="Foreground" Value="{DynamicResource DangerTextBrush}" />
  </Style>

  <!-- ══════════════════════════════════════════════════════════════════════════
       Seitenleiste
       ══════════════════════════════════════════════════════════════════════ -->

  <Style Selector="Border.sidebar">
    <Setter Property="Background" Value="{DynamicResource SurfaceBrush}" />
    <Setter Property="BorderBrush" Value="{DynamicResource DividerBrush}" />
    <Setter Property="BorderThickness" Value="0,0,1,0" />
  </Style>

  <!-- Gruppentitel „Arbeiten“ / „Analyse“ / „System“ -->
  <Style Selector="TextBlock.navgroup">
    <Setter Property="FontSize" Value="10" />
    <Setter Property="LetterSpacing" Value="1.2" />
    <Setter Property="Foreground" Value="{DynamicResource TextGhostBrush}" />
    <Setter Property="Margin" Value="8,0,8,6" />
  </Style>

  <!-- Navigationszeile: Grundzustand durchsichtig, gewählt mit Akzent hinterlegt.
       Als Button und nicht als ListBoxItem, damit Tastaturbedienung und Tooltip im
       eingeklappten Zustand ohne Zusatzarbeit funktionieren. -->
  <Style Selector="Button.nav">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
    <Setter Property="FontSize" Value="13.5" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="Padding" Value="10,9" />
    <Setter Property="HorizontalAlignment" Value="Stretch" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
  </Style>

  <Style Selector="Button.nav.selected">
    <Setter Property="Background" Value="{DynamicResource AccentSelectedBrush}" />
    <Setter Property="Foreground" Value="{DynamicResource AccentBrush}" />
    <Setter Property="FontWeight" Value="SemiBold" />
  </Style>

  <!-- Eingeklappt: nur das Symbol, mittig -->
  <Style Selector="Button.nav.collapsed">
    <Setter Property="Padding" Value="9" />
    <Setter Property="HorizontalContentAlignment" Value="Center" />
  </Style>

  <!-- Instanz-Schalter oben in der Seitenleiste — einziger Knopf mit Akzentrahmen -->
  <Style Selector="Button.instance">
    <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="FontFamily" Value="{DynamicResource BodyFont}" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="Padding" Value="10,9" />
    <Setter Property="HorizontalAlignment" Value="Stretch" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
  </Style>

  <!-- ══════════════════════════════════════════════════════════════════════════
       Teiler zwischen den Bereichen der Agenten-Seite
       ══════════════════════════════════════════════════════════════════════ -->

  <Style Selector="GridSplitter">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="MinWidth" Value="0" />
    <Setter Property="MinHeight" Value="0" />
  </Style>

  <!-- Waagerechter Teiler: eine sichtbare Leiste mit Griffstrich, wie im Entwurf -->
  <Style Selector="GridSplitter.horizontal">
    <Setter Property="Height" Value="10" />
    <Setter Property="Background" Value="{DynamicResource SurfaceBrush}" />
    <Setter Property="Cursor" Value="SizeNorthSouth" />
    <Setter Property="Template">
      <ControlTemplate>
        <Border Background="{TemplateBinding Background}"
                BorderBrush="{DynamicResource DividerBrush}"
                BorderThickness="0,1">
          <Rectangle Width="36" Height="2" Fill="{DynamicResource DividerBrush}"
                     HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Border>
      </ControlTemplate>
    </Setter>
  </Style>

  <!-- Senkrechter Teiler: unsichtbar bis auf den Mauszeiger, wie im Entwurf -->
  <Style Selector="GridSplitter.vertical">
    <Setter Property="Width" Value="10" />
    <Setter Property="Cursor" Value="SizeWestEast" />
  </Style>

</Styles>
