   @font-face {
      font-family: "aipi";
      src: url('/webfonts/2ED899_0_0.eot');
      src: url('/webfonts/2ED899_0_0.eot?#iefix') format('embedded-opentype'),
           url('/webfonts/2ED899_0_0.woff2') format('woff2'),
           url('/webfonts/2ED899_0_0.woff') format('woff'),
           url('/webfonts/2ED899_0_0.ttf') format('truetype');
      font-display: swap;
      font-weight: normal;
    }
    @font-face {
      font-family: "aipi";
      src: url('/webfonts/officina-bld.woff2') format('woff2'),
           url('/webfonts/officina-bld.woff') format('woff'),
           url('/webfonts/officina-bld.ttf') format('truetype');
      font-display: swap;
      font-weight: bold;
    }


:root {
  --bg-body: #f8fafc;
  --bg-header: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-hover: #e2e8f0;
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-subtle: #eef2ff;
  --primary-border: #c7d2fe;
  --danger: #e11d48;
  --danger-hover: #be123c;
  --danger-subtle: #ffe4e6;
  --danger-border: #fecdd3;
  --success: #10b981;
  --success-subtle: #d1fae5;
  --warning: #f59e0b;
  --warning-subtle: #fef3c7;
  --modal-overlay: rgba(15, 23, 42, 0.6);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

html.dark {
  --bg-body: #0b1120;
  --bg-header: #0f172a;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --bg-card-subtle: #141e33;
  --bg-input: #0b1120;
  --bg-hover: #334155;
  --border-color: #334155;
  --border-subtle: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-subtle: #1e1b4b;
  --primary-border: #3730a3;
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-subtle: #4c0519;
  --danger-border: #881337;
  --success: #10b981;
  --success-subtle: #064e3b;
  --warning: #f59e0b;
  --warning-subtle: #78350f;
  --modal-overlay: rgba(0, 0, 0, 0.75);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: aipi,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
html, body { height: 100%; overflow: hidden; }
body { background-color: var(--bg-body); color: var(--text-main); display: flex; flex-direction: column; user-select: none; transition: background-color 0.2s, color 0.2s; }

header {
  background-color: var(--bg-header); border-bottom: 1px solid var(--border-color); padding: 0.75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; box-shadow: var(--shadow-sm);
}

.header-logo-box {
  width: 2.5rem; height: 2.5rem; border-radius: 0.65rem; background-color: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}

.view-mode-tabs { display: flex; gap: 0.35rem; background-color: var(--bg-card-subtle); padding: 0.25rem; border-radius: 0.65rem; border: 1px solid var(--border-color); }
.view-mode-btn {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.9rem; border-radius: 0.5rem;
  font-size: 0.85rem; font-weight: 600; cursor: pointer; border: none; background: transparent; color: var(--text-muted); text-decoration: none; transition: all 0.15s;
}
.view-mode-btn.active { background-color: var(--bg-card); color: var(--primary); box-shadow: var(--shadow-sm); }

main { flex: 1; display: flex; height: calc(100vh - 65px); overflow: hidden; }
.sidebar-nav {
  width: 25%; max-width: 25%; min-width: 290px; border-right: 1px solid var(--border-color);
  background-color: var(--bg-sidebar); padding: 1rem; display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; height: 100%;
}
.workspace-main { width: 75%; flex: 1; background-color: var(--bg-body); padding: 1.75rem 2rem 5rem 2rem; overflow-y: auto; height: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.45rem 0.85rem;
  border-radius: 0.5rem; font-size: 0.85rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: all 0.15s; text-decoration: none;
}
.btn-primary { background-color: var(--primary); color: #ffffff; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: var(--bg-card); color: var(--text-main); border-color: var(--border-color); }
.btn-secondary:hover { background-color: var(--bg-hover); }
.btn-subtle-danger { background: transparent; color: var(--danger); border: none; font-size: 0.85rem; cursor: pointer; }
.btn-subtle-danger:hover { text-decoration: underline; }
.btn-icon { width: 1.85rem; height: 1.85rem; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 0.4rem; font-size: 0.8rem; }

.input-text, .select-input, .textarea-input {
  width: 100%; background-color: var(--bg-input); border: 1px solid var(--border-color); border-radius: 0.5rem;
  padding: 0.55rem 0.75rem; font-size: 0.9rem; color: var(--text-main); outline: none; transition: border-color 0.15s;
}
.input-text:focus, .select-input:focus, .textarea-input:focus { border-color: var(--primary); }
.code-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.85rem; line-height: 1.5; background-color: var(--bg-card-subtle); color: var(--text-main); }
.card { background-color: var(--bg-card); border: 1px solid var(--border-color); border-radius: 0.75rem; padding: 1.25rem; box-shadow: var(--shadow-sm); }

.drop-top { border-top: 3px solid var(--primary) !important; }
.drop-bottom { border-bottom: 3px solid var(--primary) !important; }
.drop-inside { outline: 2px dashed var(--primary) !important; background-color: rgba(99, 102, 241, 0.15) !important; }

.nav-row {
  display: flex; align-items: center; justify-content: space-between; padding: 0.55rem 0.75rem; border-radius: 0.65rem;
  border: 1px solid var(--border-subtle); background-color: var(--bg-card); cursor: pointer; margin-bottom: 0.35rem; transition: all 0.15s;
}
.nav-row:hover { background-color: var(--bg-hover); }
.nav-row.active { background-color: var(--primary-subtle); border-color: var(--primary); }

.page-pill {
  width: 1.65rem; height: 1.65rem; border-radius: 0.45rem; display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; border: 1px solid transparent; cursor: pointer; transition: transform 0.1s;
}
.page-pill:hover { transform: scale(1.08); }
.page-pill.active { outline: 2px solid var(--primary); transform: scale(1.1); }
.status-green { background: #dcfce7; color: #15803d; border-color: #86efac; }
.status-blue  { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.status-yellow{ background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.status-red   { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }

html.dark .status-green { background: #064e3b; color: #6ee7b7; border-color: #047857; }
html.dark .status-blue  { background: #1e3a8a; color: #93c5fd; border-color: #1d4ed8; }
html.dark .status-yellow{ background: #78350f; color: #fde68a; border-color: #b45309; }
html.dark .status-red   { background: #7f1d1d; color: #fca5a5; border-color: #b91c1c; }

.switch-toggle { position: relative; display: inline-block; width: 2.6rem; height: 1.4rem; }
.switch-toggle input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--border-color); transition: .2s; border-radius: 2rem; }
.slider:before { position: absolute; content: ""; height: 1.05rem; width: 1.05rem; left: 3px; bottom: 2.5px; background-color: white; transition: .2s; border-radius: 50%; }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(1.15rem); }

/* WYSIWYG Content, Tabellen & Bilder */
.wysiwyg-content {
  min-height: 130px; background-color: var(--bg-input); border: 1px solid var(--border-color); border-radius: 0.5rem;
  padding: 0.9rem; font-size: 0.95rem; color: var(--text-main); user-select: text;
}
.wysiwyg-content:focus { outline: none; border-color: var(--primary); }
.wysiwyg-content::after { content: ""; display: table; clear: both; }
.wysiwyg-content h2 { font-size: 1.5rem; font-weight: 700; margin-top: 0.5rem; margin-bottom: 0.6rem; color: var(--primary); }
.wysiwyg-content h3 { font-size: 1.25rem; font-weight: 600; margin-top: 0.4rem; margin-bottom: 0.5rem; }
.wysiwyg-content p { margin-bottom: 0.6rem; line-height: 1.65; }
.wysiwyg-content ul { list-style-type: disc; margin-left: 1.5rem; margin-bottom: 0.6rem; }
.wysiwyg-content ol { list-style-type: decimal; margin-left: 1.5rem; margin-bottom: 0.6rem; }
.wysiwyg-content blockquote { border-left: 4px solid var(--primary); padding-left: 0.85rem; font-style: italic; margin: 0.6rem 0; opacity: 0.85; }
.wysiwyg-content a { color: var(--primary); text-decoration: underline; }

.wysiwyg-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
.wysiwyg-content th, .wysiwyg-content td { border: 1px solid var(--border-color); padding: 0.6rem 0.75rem; text-align: left; }
.wysiwyg-content th { background-color: var(--bg-card-subtle); font-weight: 700; }
.wysiwyg-content tr:hover { background-color: rgba(99, 102, 241, 0.05); }

.wysiwyg-content figure { margin: 0.75rem 0; display: block; user-select: none; cursor: context-menu; }
.wysiwyg-content figure.align-left, .wysiwyg-content img.img-align-left { float: left; margin: 0.25rem 1.25rem 0.75rem 0; max-width: 50%; }
.wysiwyg-content figure.align-right, .wysiwyg-content img.img-align-right { float: right; margin: 0.25rem 0 0.75rem 1.25rem; max-width: 50%; }
.wysiwyg-content figure.align-center, .wysiwyg-content img.img-align-center { display: block; float: none; margin: 1rem auto; text-align: center; clear: both; }
.wysiwyg-content figure.align-full, .wysiwyg-content img.img-align-full { display: block; float: none; width: 100%; margin: 1rem 0; clear: both; }
.wysiwyg-content figure img, .wysiwyg-content img { border-radius: 0.5rem; max-width: 100%; height: auto; display: inline-block; box-shadow: var(--shadow-md); cursor: context-menu; }
.wysiwyg-content figure figcaption { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.35rem; font-style: italic; text-align: center; }

.custom-context-menu {
  position: fixed; z-index: 1000; background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 0.65rem; box-shadow: var(--shadow-xl); padding: 0.35rem 0; min-width: 190px; display: none;
}
.context-menu-item {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.9rem; font-size: 0.85rem; font-weight: 500;
  cursor: pointer; color: var(--text-main); transition: background 0.1s;
}
.context-menu-item:hover { background-color: var(--primary-subtle); color: var(--primary); }
.context-menu-divider { height: 1px; background-color: var(--border-color); margin: 0.3rem 0; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background-color: var(--modal-overlay);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
}
.modal-content {
  background-color: var(--bg-card); border: 1px solid var(--border-color); border-radius: 1rem;
  width: 100%; max-width: 650px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-xl); overflow: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }



/* Quelltext-Editor Verbesserungen */
.code-editor-container {
  position: relative;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: #0d1117;
}

.code-editor-container textarea {
  width: 100%;
  min-height: 240px;
  background-color: transparent;
  color: #e6edf3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 1rem;
  border: none;
  outline: none;
  tab-size: 2;
  white-space: pre;
  overflow-x: auto;
  resize: vertical;
}

.code-editor-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}
