Index: gui/gui.py
===================================================================
--- gui/gui.py	(revision aaaa4b88ba1d686bf0ed49967c79cccb30b41f94)
+++ gui/gui.py	(revision 0792ddd2b6441395b9201edc030441c8cbf79224)
@@ -5,7 +5,8 @@
 from pathlib import Path
 from datetime import datetime
-from flexoentity import FlexOID, logger
+from flexoentity import FlexOID, DomainManager, logger, Domain
 from builder.exam import Exam
 from builder.question_catalog import QuestionCatalog
+from builder.question_catalog import question_factory
 from builder.media_items import NullMediaItem
 from builder.catalog_manager import CatalogManager
@@ -13,4 +14,5 @@
 from builder.exam_elements import SingleChoiceQuestion, MultipleChoiceQuestion, InstructionBlock
 from .menu import AppMenu
+from gui.domain_management_dialog import DomainManagementDialog
 from .actions_panel import ActionsPanel
 from .select_panel import SelectPanel
@@ -26,4 +28,5 @@
     def __init__(self):
         super().__init__()
+        self.domain_manager = DomainManager()
         self.catalog_manager = CatalogManager()
         self.exam_manager = ExamManager()
@@ -47,5 +50,4 @@
 
         self._recent_actions = []
-        self.domain_set = set()
         self.clipboard = []  # holds copied Question objects
         self.clipboard_action = None  # "copy"
@@ -147,5 +149,5 @@
             simpledialog.askstring("Author", "Enter author:", parent=self) or "unknown"
         )
-        catalog = QuestionCatalog.with_domain(did)
+        catalog = QuestionCatalog.with_domain_id(did)
         catalog.title = title
         catalog.author =author
@@ -242,5 +244,5 @@
             return []
         # Always provide deterministic order (e.g. by question ID)
-        return sorted(self.active_catalog.questions, key=lambda q: q.id)
+        return sorted(self.active_catalog.questions, key=lambda q: q.flexo_id)
 
     def create_exam_dialog(self):
@@ -265,5 +267,5 @@
             self.target_exam_var.set(active_exam.title)
 
-    def get_question_editor_for(parent, question, available_domains):
+    def get_question_editor_for(self, parent, question, available_domains):
         """
         Return the appropriate editor dialog instance for a given question.
@@ -271,12 +273,12 @@
         """
         if question.qtype in ("single_choice", "multiple_choice"):
-            return OptionQuestionEditorDialog(parent, question, available_domains)
+            return OptionQuestionEditorDialog(parent, question.to_dict(), available_domains)
         if question.qtype in ("instruction", "text"):
             # even though InstructionBlock may subclass Question,
             # it doesn’t need options
-            return DefaultQuestionEditorDialog(parent, question, available_domains)
-        else:
-            # Fallback for any unknown or simple Question subclass
-            return DefaultQuestionEditorDialog(parent, question, available_domains)
+            return DefaultQuestionEditorDialog(parent, question.to_dict(), available_domains)
+        
+        # Fallback for any unknown or simple Question subclass
+        return DefaultQuestionEditorDialog(parent, question.to_dict(), available_domains)
 
     def add_question(self):
@@ -290,31 +292,27 @@
         media = []
 
-        if qtype == "single_choice":
-            q = SingleChoiceQuestion(text="Neue Frage",
-                                     options=[], media=media)
-        elif qtype == "multiple_choice":
-            q = MultipleChoiceQuestion(text="Neue Mehrfachfrage",
-                                       options=[], media=media)
+        if qtype in ["single_choice", "multiple_choice"]:
+            question_dict = {"qtype": qtype,
+                             "text": "Neue Frage",
+                             "options": [],
+                             "media": media}
         elif qtype == "instruction":
-            q = InstructionBlock(text="Neue Instruktion", media=media)
+            question_dict = InstructionBlock(text="Neue Instruktion", media=media)
         else:
             messagebox.showerror("Error", f"Unknown question type: {qtype}")
             return
 
-        dlg = OptionQuestionEditorDialog(self, q, self.domain_set)
+        print(self.domain_manager.all_domain_ids())
+        dlg = OptionQuestionEditorDialog(self, question_dict, self.domain_manager.all_domain_ids())
         self.wait_window(dlg)
-        current_question = dlg.result
-
-        if current_question:
-            current_question.flexo_id = FlexOID.generate(
-                current_question.domain,
-                current_question.entity_type,
-                current_question.state,
-                current_question.text_seed
-            )
+        question_dict = dlg.result
+
+        if question_dict:
+            question_dict["qtype"] = "single_choice"
+            current_question = question_factory(question_dict)
             active_catalog.add_questions([current_question])
             self.refresh_all()
-            self.log_action(f"Updated - Question {q.id} updated.")
-            self.log_action(f"New Question ID - Assigned ID: {current_question.id}")
+            self.log_action(f"Updated - Question {current_question.flexo_id} updated.")
+            self.log_action(f"New Question ID - Assigned ID: {current_question.flexo_id}")
 
     def add_selected_question_to_exam(self):
@@ -332,11 +330,11 @@
             return
 
-        if not messagebox.askyesno("Delete", f"Delete question {q.id}?"):
+        if not messagebox.askyesno("Delete", f"Delete question {q.flexo_id}?"):
             return
 
         try:
-            if self.active_catalog.remove(q.id):
+            if self.active_catalog.remove(q.flexo_id):
                 self.refresh_all()
-                self.log_action(f"Deleted - Question {q.id} removed.")
+                self.log_action(f"Deleted - Question {q.flexo_id} removed.")
         except ValueError as e:
             messagebox.showerror("Forbidden", str(e))
@@ -358,5 +356,5 @@
     def edit_selected_question(self):
         q = self.require_selected_question()
-        dlg = self.get_question_editor_for(q, self.domain_set)
+        dlg = self.get_question_editor_for(self, q, self.domain_manager.all_domain_ids())
         self.wait_window(dlg)
         current_question = dlg.result
@@ -364,5 +362,5 @@
             self.active_catalog.add_questions([current_question])
             self.refresh_all()
-            self.log_action(f"Updated - Question {q.id} updated.")
+            self.log_action(f"Updated - Question {q.flexo_id} updated.")
 
     def import_exam_as_temp_catalog(self, exam_path: str):
@@ -484,5 +482,5 @@
             return
 
-        catalogs = self.catalog_manager.catalogs()
+        catalogs = self.catalog_manager.catalogs
         if len(catalogs) < 2:
             messagebox.showinfo(action.title(), "You need at least two catalogs.")
@@ -606,14 +604,12 @@
             return
 
-        entry = simpledialog.askstring("Add Domain",
-                                       "Enter domain (e.g. ELEK_Elektrotechnik):",
-                                       parent=self)
-        if not entry:
+        dlg = DomainManagementDialog(self, self.domain_manager)
+        self.wait_window()
+        if not dlg:
             return
 
         try:
-            active.add_domain(entry)
-            self.domain_set.update([entry])
-            self.log_action(f"Added - Domain '{entry}' added to catalog '{active.catalog_id}'.")
+            self.domain_manager.register(Domain.with_domain_id(dlg.result))
+            self.log_action(f"Added - Domain '{dlg.result}' added to catalog '{active.catalog_id}'.")
         except ValueError as e:
             messagebox.showerror("Invalid Input", str(e))
