/* ===== Theme-Variablen ===== */
/* Light ist der Standard/aktuelle Look. Dark wird per [data-theme="dark"]
   auf <html> aktiviert (siehe auth.js/theme.js). Betrifft bewusst nur die
   App-Oberflaeche (Toolbars, Panels, Modals, Text) - nicht die Knoten-/
   Kantenfarben im Graph selbst, die sind ja schon frei vom Nutzer waehlbar
   und unabhaengig vom UI-Theme. */
:root {
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-surface-translucent: rgba(255, 255, 255, 0.85);
  --color-bg-secondary: #f4f4f4;
  --color-bg-tertiary: #eeeeee;
  --color-border: #cccccc;
  --color-border-strong: #bbbbbb;
  --color-text: #333333;
  --color-text-muted: #777777;
  --color-text-faint: #999999;
  --color-accent: #2b7ce9;
  --color-accent-hover: #2569c9;
  --color-accent-subtle: #e8f0fe;
  --color-danger-bg: #fde2e2;
  --color-danger-text: #c0392b;
  --color-warning-bg: #fff3cd;
  --color-warning-text: #a15c00;
  --color-overlay: rgba(0, 0, 0, 0.4);
  --shadow-color: rgba(0, 0, 0, 0.2);
  --color-icon: var(--color-text);
  --graph-bg-gradient: radial-gradient(circle, #ffffff 0%, #e2e2e2 100%);
}

[data-theme="dark"] {
  --color-bg: #1a1a1e;
  --color-surface: #24242a;
  --color-surface-translucent: rgba(36, 36, 42, 0.9);
  --color-bg-secondary: #202024;
  --color-bg-tertiary: #303038;
  --color-border: #3d3d45;
  --color-border-strong: #4a4a54;
  --color-text: #e8e8ea;
  --color-text-muted: #a8a8b0;
  --color-text-faint: #7a7a84;
  --color-accent: #5b9bf0;
  --color-accent-hover: #7cb0f5;
  --color-accent-subtle: #2a3a52;
  --color-danger-bg: #4a2626;
  --color-danger-text: #f28b82;
  --color-warning-bg: #4a3f1f;
  --color-warning-text: #e0b84d;
  --color-overlay: rgba(0, 0, 0, 0.6);
  --shadow-color: rgba(0, 0, 0, 0.5);
  --color-icon: var(--color-text);
  --graph-bg-gradient: radial-gradient(circle, #303038 0%, #1a1a1e 100%);
}

* {
  box-sizing: border-box;
}



html, body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
  touch-action: pan-x pan-y; /* Pinch-Zoom der Seite unterbinden, Scrollen/Wischen bleibt erlaubt */
  font-family: system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  transition: background-color 0.15s ease, color 0.15s ease;
}

body {
  display: block;
}

#app-root {
  display: none; /* per JS (auth.js) auf flex gesetzt, sobald eingeloggt */
  flex-direction: column;
  height: 100%;
}

#app-root.visible {
  display: flex;
}

#login-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--color-bg-secondary);
}

#login-overlay.hidden {
  display: none;
}

#login-box {
  width: min(320px, 90vw);
  background: var(--color-surface);
  border-radius: 8px;
  padding: 2rem 1.5rem;
  box-shadow: 0 4px 20px var(--shadow-color);
  text-align: center;
}

#login-box h1 {
  margin: 0 0 1.5rem;
  font-size: 1.4rem;
  color: var(--color-accent);
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#login-form input {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  font-size: 1rem;
}

#login-form button {
  padding: 0.6rem;
  border: none;
  border-radius: 4px;
  background: var(--color-accent);
  color: var(--color-surface);
  font-size: 1rem;
  cursor: pointer;
  margin-top: 0.3rem;
}

#login-form button:hover {
  background: var(--color-accent-hover);
}

#login-error {
  color: var(--color-danger-text);
  font-size: 0.85rem;
  min-height: 1.1rem;
  margin-top: 0.6rem;
}

#login-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.1rem 0;
  color: var(--color-text-faint);
  font-size: 0.8rem;
}

#login-divider::before,
#login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

#btn-guest-login {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  background: var(--color-surface);
  cursor: pointer;
  font-size: 0.95rem;
}

#btn-guest-login:hover {
  background: var(--color-bg-tertiary);
}

#guest-badge {
  display: none;
  font-size: 0.75rem;
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

#theme-toggle-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem 1rem;
}

.theme-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.85rem;
}

.theme-toggle-btn:hover {
  background: var(--color-bg-tertiary);
}

.theme-toggle-btn.active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-subtle);
}

#accent-color-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 1rem 1rem;
}

#accent-color-row label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--color-text);
}

#accent-color-picker {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

/* Browser-Eigenstyling des Farbfeld-Inneren entfernen, damit der Picker
   buendig ins restliche UI passt statt einen eigenen Rahmen/Padding mitzubringen. */
#accent-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}
#accent-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}
#accent-color-picker::-moz-color-swatch {
  border: none;
  border-radius: 3px;
}

#btn-accent-color-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

#btn-accent-color-reset:hover {
  background: var(--color-bg-tertiary);
}

#drawer-account-info {
  padding: 0.6rem 1rem 1rem;
}

#drawer-account-username {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

#app-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

#btn-menu-toggle {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

#btn-menu-toggle:hover {
  background: var(--color-bg-tertiary);
}

#app-title {
  font-weight: 600;
}

#graph-stats {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.75rem;
  color: var(--color-text);
  opacity: 0.45;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  cursor: default;
  transition: opacity 0.15s ease, background 0.15s ease;
  pointer-events: auto;
}

#graph-stats:hover {
  opacity: 1;
  background: var(--color-surface-translucent);
}

#app-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 1000;
}

#app-drawer-backdrop.open {
  display: block;
}

#app-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 85vw);
  background: var(--color-surface);
  z-index: 1001;
  transform: translateX(-100%);
  transition: transform 0.2s ease-out;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px var(--shadow-color);
}

#app-drawer.open {
  transform: translateX(0);
}

#app-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}

#btn-drawer-close {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

#btn-drawer-close:hover {
  background: var(--color-bg-tertiary);
}

.drawer-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.9rem 1rem;
  border: none;
  border-bottom: 1px solid var(--color-bg-tertiary);
  background: var(--color-surface);
  font-size: 1rem;
  cursor: pointer;
}

.drawer-item:hover:not(:disabled) {
  background: var(--color-bg-secondary);
}

.drawer-item:disabled {
  color: var(--color-text-faint);
  cursor: not-allowed;
}

.drawer-item .menu-badge {
  float: right;
  font-size: 0.7rem;
  background: var(--color-bg-tertiary);
  color: var(--color-text-faint);
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
}

.drawer-section-label {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faint);
}

#graph-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
  border-bottom: 1px solid var(--color-bg-tertiary);
}

.graph-list-item {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-bg-tertiary);
}

.graph-select-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-select-btn:hover {
  background: var(--color-bg-secondary);
}

.graph-list-item.active .graph-select-btn {
  font-weight: 600;
  color: var(--color-accent);
}

#preset-modal-backdrop,
#simple-tree-import-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 1100;
}

#preset-modal-backdrop.open,
#simple-tree-import-modal-backdrop.open {
  display: block;
}

#preset-modal,
#simple-tree-import-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 92vw);
  max-height: 85vh;
  background: var(--color-surface);
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--shadow-color);
  z-index: 1101;
  display: none;
  flex-direction: column;
}

#preset-modal.open,
#simple-tree-import-modal.open {
  display: flex;
}

#preset-modal-header,
#simple-tree-import-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  flex-shrink: 0;
}

#btn-preset-modal-close,
#btn-simple-tree-import-close {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

#btn-preset-modal-close:hover,
#btn-simple-tree-import-close:hover {
  background: var(--color-bg-tertiary);
}

#preset-modal-body,
#simple-tree-import-modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.preset-field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0.75rem 0 0.35rem;
}

#preset-template-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

#preset-template-select {
  flex: 1;
  min-width: 0;
  padding: 0.45rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  font-size: 0.9rem;
}

#preset-template-row button {
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  flex-shrink: 0;
}

#preset-template-row button:hover {
  background: var(--color-bg-tertiary);
}

.preset-prop-toggle {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.preset-prop-toggle input[type="checkbox"] {
  flex-shrink: 0;
  cursor: pointer;
}

#preset-background-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

#preset-background-preview {
  width: 64px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  background-color: var(--color-bg-tertiary);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

#preset-background-buttons {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

#preset-background-buttons button {
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

#preset-background-buttons button:hover {
  background: var(--color-bg-tertiary);
}

#preset-background-buttons button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#preset-label-style-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

#preset-label-style-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

#preset-label-backdrop-opacity-label {
  min-width: 140px;
}

#preset-modal-name,
#simple-tree-import-name,
#simple-tree-import-template-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  font-size: 1rem;
}

#preset-levels-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.preset-level-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem;
  background: var(--color-bg-tertiary);
  border-radius: 4px;
}

.preset-level-label {
  font-size: 0.85rem;
  color: var(--color-text);
  min-width: 4.5rem;
  flex-shrink: 0;
}

.preset-level-shape {
  flex-shrink: 0;
}

.preset-level-size {
  width: 4.5rem;
  flex-shrink: 0;
}

.preset-level-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}

.preset-level-remove:hover {
  background: var(--color-danger-bg);
  border-radius: 4px;
}

#btn-preset-add-level {
  margin-top: 0.6rem;
  padding: 0.4rem 0.8rem;
  border: 1px dashed var(--color-text-faint);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

#btn-preset-add-level:hover {
  background: var(--color-bg-tertiary);
}

#preset-named-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.preset-named-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem;
  background: var(--color-bg-tertiary);
  border-radius: 4px;
}

.preset-named-name {
  flex: 1;
  min-width: 0;
  padding: 0.35rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  font-size: 0.9rem;
}

.preset-named-size {
  width: 4.5rem;
  flex-shrink: 0;
}

.preset-named-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  flex-shrink: 0;
}

.preset-named-remove:hover {
  background: var(--color-danger-bg);
  border-radius: 4px;
}

#btn-preset-add-named {
  margin-top: 0.6rem;
  padding: 0.4rem 0.8rem;
  border: 1px dashed var(--color-text-faint);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

#btn-preset-add-named:hover {
  background: var(--color-bg-tertiary);
}

.preset-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-bg-tertiary);
  font-size: 0.9rem;
  cursor: pointer;
}

.preset-checkbox-label input {
  cursor: pointer;
}

#preset-modal-footer,
#simple-tree-import-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

#preset-modal-footer button,
#simple-tree-import-modal-footer button {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}

#btn-preset-cancel,
#btn-simple-tree-import-cancel {
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
}

#btn-preset-save,
#btn-simple-tree-import-confirm {
  border: none;
  background: var(--color-accent);
  color: var(--color-surface);
}

.graph-rename-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.5rem 0.4rem;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.graph-rename-btn:hover {
  background: var(--color-accent-subtle);
  border-radius: 4px;
}

.graph-delete-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.graph-delete-btn:hover {
  background: var(--color-danger-bg);
  border-radius: 4px;
}

#container {
  display: flex;
  flex: 1;
  min-height: 0;
}

.split {
  height: 100%;
  overflow: auto;
}

#left {
  display: flex;
  flex-direction: column;
  padding: 0;
}

#right {
  display: flex;
  flex-direction: column;
  padding: 0;
}

#breadcrumb-bar {
  display: none;
  flex-shrink: 0;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.75rem;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.breadcrumb-item {
  border: none;
  background: transparent;
  color: var(--color-accent);
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.breadcrumb-item:hover {
  background: var(--color-accent-subtle);
  text-decoration: underline;
}

.breadcrumb-item.current {
  color: var(--color-text);
  font-weight: 600;
  cursor: default;
}

.breadcrumb-item.current:hover {
  background: transparent;
  text-decoration: none;
}

.breadcrumb-separator {
  color: var(--color-text-faint);
  flex-shrink: 0;
}

#editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

#input-node-label {
  flex: 1;
  min-width: 0;
  padding: 0.5rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  font-size: 1.1rem;
  font-weight: 600;
}

#input-node-label:disabled {
  background: var(--color-bg-tertiary);
  color: var(--color-text-faint);
}

#btn-insert-node-link {
  flex-shrink: 0;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  color: var(--color-icon);
}

#btn-insert-node-link:hover:not(:disabled) {
  background: var(--color-bg-tertiary);
}

#btn-insert-node-link:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#node-link-picker {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  max-height: 40vh;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

#node-link-picker.open {
  display: flex;
}

#node-link-picker-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

#node-link-search-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--color-text);
}

#btn-node-link-picker-close {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  color: var(--color-icon);
  flex-shrink: 0;
}

#btn-node-link-picker-close:hover {
  background: var(--color-bg-tertiary);
}

#node-link-picker-results {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.node-link-result-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
  color: var(--color-text);
}

.node-link-result-item:hover {
  background: var(--color-accent-subtle);
}

.node-link-empty {
  padding: 0.6rem 0.75rem;
  color: var(--color-text-faint);
  font-size: 0.85rem;
}

/* @-Mention-Autocomplete im Editor: kompaktes, am Cursor positioniertes
   Dropdown (position:fixed, per JS gesetzt - analog zum ql-picker-Fix). */
#mention-autocomplete {
  display: none;
  position: fixed;
  z-index: 50;
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  min-width: 160px;
  max-width: 280px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#mention-autocomplete.open {
  display: block;
}

.mention-item {
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mention-item.active,
.mention-item:hover {
  background: var(--color-accent-subtle);
}

.mention-empty {
  padding: 0.4rem 0.75rem;
  color: var(--color-text-faint);
  font-size: 0.85rem;
}

/* Node-Links im Editor optisch von normalen Links unterscheiden */
.ql-editor a[href^="node:"] {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--color-accent);
  cursor: pointer;
}

.ql-editor a[href^="node:"]:hover {
  background: var(--color-accent-subtle);
}

#editor-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#quill-editor {
  flex: 1;
  min-height: 0;
}

.ql-toolbar.ql-snow {
  flex-shrink: 0;
  border: none;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.ql-toolbar.ql-snow .ql-picker-options {
  position: fixed;
  z-index: 2000;
}

.ql-toolbar.ql-snow .ql-formats {
  display: inline-block;
  vertical-align: middle;
}

.ql-container.ql-snow {
  border: none;
  height: 100%;
  font-size: 1rem;
}

.ql-editor {
  min-height: 100%;
}

#graph-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#graph-toolbar > * {
  flex-shrink: 0;
}

#graph-toolbar button {
  padding: 0.4rem 0.6rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  min-width: 2.4rem;
}

#graph-toolbar button:hover:not(:disabled) {
  background: var(--color-bg-tertiary);
}

#graph-toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#graph-toolbar select,
#graph-toolbar input[type="color"] {
  padding: 0.3rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

#graph-toolbar select:hover,
#graph-toolbar input[type="color"]:hover {
  background: var(--color-bg-tertiary);
}

#graph-toolbar select {
  width: 3rem;
  font-size: 1rem;
}

#graph-toolbar input[type="range"] {
  width: 5rem;
}

#graph-toolbar select:disabled,
#graph-toolbar input[type="color"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#graph-toolbar input[type="color"] {
  width: 2.4rem;
  height: 2rem;
  padding: 0.15rem;
}

#physics-panel {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

#physics-panel.open {
  display: flex;
}

.physics-panel-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.physics-panel-header span {
  flex: 1;
}

.physics-panel-header button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.physics-panel-header button:hover {
  background: var(--color-bg-tertiary);
}

.physics-slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
}

.physics-slider-row span {
  width: 5.5rem;
  flex-shrink: 0;
}

.physics-slider-row input[type="range"] {
  flex: 1;
}

#graph-search-bar {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  max-height: 40vh;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

#graph-search-bar.open {
  display: flex;
}

#graph-search-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-bg-tertiary);
  background: var(--color-surface);
}

#graph-search-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  font-size: 0.95rem;
}

#btn-search-close {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  flex-shrink: 0;
}

#btn-search-close:hover {
  background: var(--color-bg-tertiary);
}

#graph-search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.graph-search-result-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--color-bg-tertiary);
}

.graph-search-result-item:hover {
  background: var(--color-accent-subtle);
}

.graph-search-result-label {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
}

.graph-search-result-snippet {
  display: block;
  font-size: 0.78rem;
  color: var(--color-text-faint);
  margin-top: 0.1rem;
}

.graph-search-empty {
  padding: 0.6rem 0.75rem;
  color: var(--color-text-faint);
  font-size: 0.85rem;
}

#graph-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
}

#graph {
  width: 100%;
  height: 100%;
  touch-action: auto; /* vis.network verwaltet Pinch-Zoom/Pan hier selbst */
  background-image: var(--graph-bg-gradient);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

#left {
  background: var(--color-bg-secondary);
}

#right {
  background: var(--color-bg-secondary);
}

/* Split.js erzeugt zwischen den Panels ein .gutter-Element */
.gutter {
  background-color: var(--color-border);
  background-repeat: no-repeat;
  background-position: 50%;
}

.gutter.gutter-horizontal {
  cursor: col-resize;
}

.gutter.gutter-vertical {
  cursor: row-resize;
}

/* Portrait-Modus (hoeher als breit): untereinander, Editor oben (wegen Tastatur),
   Graph unten. Reagiert auf Seitenverhaeltnis statt fester Breite, damit auch
   Tablets im Hochformat (oft > 768px breit) korrekt umgeschaltet werden. */
@media (orientation: portrait) {
  #container {
    flex-direction: column;
  }

  #right {
    order: -1;
  }

  .split {
    height: auto;
  }
}

/* ===== Dark-Mode-Overrides fuer Quill (eigene CDN-Styles, reagieren nicht
   automatisch auf unsere CSS-Variablen) ===== */
[data-theme="dark"] .ql-toolbar.ql-snow {
  background: var(--color-bg-secondary);
  border-color: var(--color-border);
}

[data-theme="dark"] .ql-toolbar.ql-snow .ql-stroke {
  stroke: var(--color-text-muted);
}

[data-theme="dark"] .ql-toolbar.ql-snow .ql-fill {
  fill: var(--color-text-muted);
}

[data-theme="dark"] .ql-toolbar.ql-snow .ql-picker-label {
  color: var(--color-text-muted);
}

[data-theme="dark"] .ql-toolbar.ql-snow button:hover .ql-stroke,
[data-theme="dark"] .ql-toolbar.ql-snow button.ql-active .ql-stroke,
[data-theme="dark"] .ql-toolbar.ql-snow .ql-picker-label:hover .ql-stroke {
  stroke: var(--color-accent);
}

[data-theme="dark"] .ql-toolbar.ql-snow button:hover .ql-fill,
[data-theme="dark"] .ql-toolbar.ql-snow button.ql-active .ql-fill {
  fill: var(--color-accent);
}

[data-theme="dark"] .ql-picker-options {
  background: var(--color-surface);
  border-color: var(--color-border) !important;
}

[data-theme="dark"] .ql-picker-item {
  color: var(--color-text);
}

[data-theme="dark"] .ql-container.ql-snow {
  background: var(--color-surface);
  color: var(--color-text);
}

[data-theme="dark"] .ql-editor.ql-blank::before {
  color: var(--color-text-faint);
}

/* ===== SVG-Icon-System ===== */
/* Alle Icons nutzen stroke="currentColor" (siehe icons.js), erben ihre Farbe
   also automatisch vom umgebenden Element - hier zentral auf --color-icon
   gesetzt, reagiert dadurch automatisch auf Light/Dark. */
[data-icon] {
  color: var(--color-icon);
}

button[data-icon] svg,
.btn-icon svg {
  width: 1.1em;
  height: 1.1em;
  vertical-align: middle;
}

button[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
