[data-tooltip] {
  position: relative;
  cursor: help;
}

/* When a global tooltip is active, disable per-element pseudo tooltips */
body.has-global-tooltip [data-tooltip]::after,
body.has-global-tooltip [data-tooltip]::before {
  content: none !important;
}

/* Global floating tooltip (used by JS manager) */
#global-tooltip {
  position: fixed;
  display: none;
  pointer-events: none;
  z-index: 100500;
  left: 0;
  top: 0;
  will-change: transform, opacity;
}

#global-tooltip .tooltip-content {
  background: rgba(2, 6, 23, 0.92);
  color: #ffffff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.35;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.5);
  pointer-events: auto;
}

#global-tooltip .tooltip-arrow {
  position: absolute;
  width: 0;
  height: 0;
}

#global-tooltip[data-pos='top'] .tooltip-arrow {
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(2, 6, 23, 0.92);
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
}

#global-tooltip[data-pos='bottom'] .tooltip-arrow {
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(2, 6, 23, 0.92);
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
}

#global-tooltip[data-pos='right'] .tooltip-arrow {
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid rgba(2, 6, 23, 0.92);
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
}

#global-tooltip[data-pos='left'] .tooltip-arrow {
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid rgba(2, 6, 23, 0.92);
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
}

#global-tooltip.visible {
  display: block;
  opacity: 1;
}

/* Interactive elements with tooltips should show pointer (finger) */
button[data-tooltip]:not(:disabled),
a[data-tooltip],
.tab-dropdown-item[data-tooltip]:not(:disabled),
.tool-btn[data-tooltip]:not(:disabled),
.header-btn[data-tooltip]:not(:disabled),
.rel-btn[data-tooltip]:not(:disabled),
.attr-key-toggle[data-tooltip],
.prop-related-link[data-tooltip],
.quest-circle[data-tooltip],
[role='button'][data-tooltip]:not(:disabled) {
  cursor: pointer;
}

/* Sicherstellen, dass der Diagramm-Titel zentriert bleibt, auch wenn
   title->data-tooltip migriert wurde (verhindert ein Verrutschen). */
#tabs .erm-title-wrap[data-tooltip],
#tabs .erm-title-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

@media (max-width: 480px) {
  #global-tooltip .tooltip-content {
    font-size: 0.95rem;
    max-width: calc(100vw - 40px);
  }
}

/* ============================================================
   ER-Diagramm Editor – Stylesheet
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-entity: #2563eb;
  --color-entity-bg: #dbeafe;
  --color-attr: #d97706;
  --color-attr-bg: #fef3c7;
  --color-rel: #16a34a;
  --color-rel-bg: #dcfce7;
  --color-toolbar: #1e293b;
  --color-toolbar-rgb: 30, 41, 59;
  --color-header: #0f172a;
  --color-header-rgb: 15, 23, 42;
  --color-btn: #334155;
  --color-btn-hover: #475569;
  --font-base: system-ui, 'Segoe UI', sans-serif;
  --radius: 6px;
  --toolbar-width: 170px;
  --relmodel-width: 460px;
}

html,
body {
  height: 100%;
  font-family: var(--font-base);
  font-size: 15px;
  background: #f1f5f9;
  color: #1e293b;
  overflow: hidden;
}

body.is-resizing-drawer {
  cursor: col-resize;
  user-select: none;
}

/* ===== HEADER ===== */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-header);
  color: #f8fafc;
  padding: 0 16px;
  height: 52px;
  flex-shrink: 0;
  gap: 12px;
}

#app-title {
  font-size: 1.15rem;
  font-weight: 700;
  width: calc(var(--toolbar-width) - 16px);
  flex: 0 0 calc(var(--toolbar-width) - 16px);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

#header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

#header-layout-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border: 1px solid #334155;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.7);
  cursor: pointer !important;
}

.header-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.header-switch-track {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: #475569;
  border: 1px solid #64748b;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.header-switch-track::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: transform 0.15s;
}

.header-switch input:checked + .header-switch-track {
  background: rgba(59, 130, 246, 0.45);
  border-color: #60a5fa;
}

.header-switch input:checked + .header-switch-track::after {
  transform: translateX(12px);
}

.header-switch-label {
  font-size: 0.78rem;
  color: #dbeafe;
  letter-spacing: 0.01em;
}

/* Stelle sicher, dass der Mauszeiger überall am Toggle als Pointer angezeigt wird */
.header-switch,
.header-switch-track,
.header-switch-label,
.header-switch-track::after {
  cursor: pointer;
}

.header-layout-btn {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.header-layout-btn:focus-visible,
.header-switch:has(input:focus-visible) {
  outline: 2px solid rgba(191, 219, 254, 0.95);
  outline-offset: 2px;
}

#header-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

#header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-btn {
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: var(--radius);
  padding: 5px 11px;
  cursor: pointer;
  font-size: 0.82rem;
  white-space: nowrap;
  transition: background 0.15s;
}
.header-btn:hover {
  background: #475569;
  color: #fff;
}
.header-btn.danger {
  background: #7f1d1d;
  border-color: #991b1b;
  color: #fca5a5;
}
.header-btn.danger:hover {
  background: #991b1b;
  color: #fff;
}

/* ===== TABS ===== */
#tabs {
  display: flex;
  align-items: stretch;
  background: #1e293b;
  border-bottom: 2px solid #3b82f6;
  flex-shrink: 0;
  position: relative;
}

.tabs-spacer {
  flex: 1;
}

.tab-dropdown {
  position: relative;
  display: flex;
}

.erm-title-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.erm-title-label {
  font-size: 0.8rem;
  color: #94a3b8;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.erm-title-input {
  width: 220px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
  padding: 0 10px;
  font-size: 0.82rem;
  text-align: center;
}

.erm-title-input::placeholder {
  color: #94a3b8;
}

.erm-title-input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.tab-btn {
  background: transparent;
  color: #94a3b8;
  border: none;
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.tab-btn:hover {
  color: #e2e8f0;
}
.tab-btn.active {
  color: #fff;
  border-bottom-color: #3b82f6;
}

.tab-btn-static {
  cursor: default;
  user-select: none;
  width: var(--toolbar-width);
  flex: 0 0 var(--toolbar-width);
  padding-left: 0;
  padding-right: 0;
  text-align: center;
}

.tab-btn-static:hover {
  color: #fff;
}

.tab-btn-dropdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.quest-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f97316;
  flex-shrink: 0;
}
.quest-dot--pulse {
  animation: quest-dot-pulse 1.2s ease-in-out infinite;
}
@keyframes quest-dot-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.7);
  }
}

.tab-dropdown-chevron {
  display: inline-block;
  font-style: normal;
  font-size: 0.75rem;
  opacity: 0.7;
  transition:
    transform 0.2s ease,
    opacity 0.15s;
}

.tab-dropdown.open .tab-dropdown-chevron {
  transform: rotate(90deg);
  opacity: 1;
}

.tab-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 268px;
  padding: 5px;
  border-radius: 0 0 10px 10px;
  border: 1px solid rgba(71, 85, 105, 0.9);
  border-top: none;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.98));
  box-shadow:
    0 14px 30px rgba(2, 6, 23, 0.4),
    0 1px 0 rgba(148, 163, 184, 0.08) inset;
  z-index: 1002;
}

.tab-dropdown-item {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s,
    transform 0.12s;
}

.tab-dropdown-item:hover {
  background: rgba(51, 65, 85, 0.55);
  border-color: rgba(100, 116, 139, 0.7);
  color: #ffffff;
  transform: translateX(1px);
}

.tab-dropdown-item:focus-visible {
  outline: none;
  background: rgba(30, 64, 175, 0.28);
  border-color: rgba(125, 211, 252, 0.7);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.45) inset;
}

.tab-dropdown-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tab-dropdown-item-subtitle {
  font-size: 0.72rem;
  color: #93c5fd;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.88;
}

/* Kleine Punkt-Markierung an Quest-Items (rechts) */
.quest-item-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f97316;
  flex-shrink: 0;
  margin-left: 8px;
}

/* Ensure the left text block wraps and leaves space for the dot */
.tab-dropdown-item-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}
.tab-dropdown-item .quest-item-dot {
  align-self: center;
  margin-left: 12px;
}

.tab-btn-right {
  margin-left: auto;
  border-left: 1px solid #334155;
  padding-right: 16px;
}

.relmodel-toggle-chevron {
  display: inline-block;
  font-style: normal;
  margin-left: 5px;
  font-size: 0.75rem;
  opacity: 0.7;
  transition:
    transform 0.2s ease,
    opacity 0.15s;
}

#btn-relmodel-toggle:hover .relmodel-toggle-chevron {
  opacity: 1;
}

#btn-relmodel-toggle.active .relmodel-toggle-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* ===== MAIN LAYOUT ===== */
#main-layout {
  display: flex;
  position: relative;
  height: calc(100vh - 52px - 41px); /* minus header + tabs */
  overflow: hidden;
}

/* ===== TOOLBAR / SIDEBAR ===== */
#toolbar {
  width: var(--toolbar-width);
  background: var(--color-toolbar);
  color: #e2e8f0;
  padding: 10px 8px;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tool-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  padding: 8px 4px 4px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.16), rgba(37, 99, 235, 0.08));
  border: 1px solid rgba(96, 165, 250, 0.42);
  border-radius: var(--radius);
  color: #eff6ff;
  padding: 9px 11px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.15s,
    box-shadow 0.15s;
  text-align: left;
  width: 100%;
}
.tool-btn:hover {
  background: linear-gradient(180deg, rgba(96, 165, 250, 0.28), rgba(37, 99, 235, 0.18));
  color: #ffffff;
  border-color: rgba(147, 197, 253, 0.85);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.24);
}
.tool-btn:focus-visible {
  outline: 2px solid rgba(191, 219, 254, 0.95);
  outline-offset: 2px;
}
.tool-btn.active {
  background: #1d4ed8;
  color: #fff;
  border-color: #3b82f6;
}

.tool-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}
.tool-label {
  font-size: 0.88rem;
}

.tool-divider {
  border: none;
  border-top: 1px solid #334155;
  margin: 6px 0;
}
.toolbar-hint {
  margin-top: 10px;
  padding: 8px 9px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.25);
  color: #cbd5e1;
  font-size: 0.78rem;
  line-height: 1.35;
}

/* === Properties Panel === */
#properties-panel {
  padding: 4px 0;
}

.prop-hint {
  font-size: 0.8rem;
  color: #64748b;
  padding: 4px 6px;
}

.prop-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px 4px;
}
.prop-label {
  font-size: 0.78rem;
  color: #94a3b8;
}
.prop-input-wrap {
  position: relative;
}
.prop-input {
  width: 100%;
  background: #334155;
  border: 1px solid #475569;
  border-radius: 4px;
  color: #f1f5f9;
  padding: 5px 28px 5px 7px;
  font-size: 0.85rem;
}
.prop-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.prop-input::placeholder {
  color: #94a3b8;
}

/* Modal-specific: restore dark input style for relationship name to match other inputs */
#modal-name {
  background: #334155;
  border: 1px solid #475569;
  border-radius: 4px;
  color: #f1f5f9;
  padding: 5px 28px 5px 7px;
  font-size: 0.85rem;
}
#modal-name:focus {
  outline: none;
  border-color: #3b82f6;
}
#modal-name::placeholder {
  color: #94a3b8;
}

.prop-input-icon {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  color: #cbd5e1;
  font-size: 0.85rem;
  pointer-events: none;
  line-height: 1;
}

.prop-select {
  background: #334155;
  border: 1px solid #475569;
  border-radius: 4px;
  color: #f1f5f9;
  padding: 4px 6px;
  font-size: 0.85rem;
  cursor: pointer;
}
.prop-value {
  font-size: 0.85rem;
  color: #e2e8f0;
}

.prop-related-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  background: #334155;
  border: 1px solid #475569;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #e2e8f0;
}

/* Äußere Box in Diagrammfarben je Typ */
.prop-related-list[data-node-type='entity'] {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1e293b;
}
.prop-related-list[data-node-type='relationship'] {
  background: #dcfce7;
  border-color: #16a34a;
  color: #1e293b;
}
.prop-related-list[data-node-type='attribute'] {
  background: #fef3c7;
  border-color: #d97706;
  color: #1e293b;
}

.prop-related-item {
  line-height: 1.35;
}

.prop-related-link {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.3);
  color: inherit;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.15s;
}

.prop-related-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

.prop-related-list[data-node-type='entity'] .prop-related-link:hover {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.4);
}
.prop-related-list[data-node-type='relationship'] .prop-related-link:hover {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.4);
}
.prop-related-list[data-node-type='attribute'] .prop-related-link:hover {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.4);
}

.prop-related-link:focus-visible {
  outline: 2px solid rgba(191, 219, 254, 0.95);
  outline-offset: 1px;
}

.prop-related-empty {
  color: #94a3b8;
  font-style: italic;
}

#prop-pk-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #e2e8f0;
  cursor: pointer;
}
#prop-pk {
  cursor: pointer;
}

/* === Legende === */
.legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* Ensure legend symbols and toolbar icons share the same width and alignment */
.legend-box,
.legend-ellipse,
.legend-diamond,
.tool-icon {
  width: 20px;
  min-width: 20px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex-shrink: 0;
}

.legend-box {
  width: 20px;
  height: 12px;
  border: 2px solid;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-ellipse {
  width: 20px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--color-attr);
  background: var(--color-attr-bg);
  flex-shrink: 0;
}

/* Small centered underline inside the ellipse (like PK underline) */
.legend-ellipse-pk {
  position: relative;
}
.legend-ellipse-pk::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 2px;
  width: 10px;
  height: 2px;
  background: var(--color-attr);
  border-radius: 1px;
}
.legend-diamond {
  /* Use an inline SVG background for a reliable diamond (20x12) — no underline */
  width: 20px;
  height: 12px;
  display: inline-block;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='12' viewBox='0 0 20 12'><polygon points='10,0 20,6 10,12 0,6' fill='%23dcfce7' stroke='%2316a34a' stroke-width='2'/></svg>");
  background-size: 20px 12px;
  background-repeat: no-repeat;
}

.entity-color {
  background: var(--color-entity-bg);
  border-color: var(--color-entity);
}
.attribute-color {
  background: var(--color-attr-bg);
  border-color: var(--color-attr);
}

/* ===== CANVAS ===== */
#canvas-container {
  flex: 1;
  position: relative;
  background: #fff;
  overflow: hidden;
}

#viewport-controls {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  gap: 6px;
  z-index: 20;
}

.viewport-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  border-radius: 8px;
  min-width: 40px;
  height: 34px;
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.viewport-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.viewport-btn:active {
  transform: translateY(1px);
}

.zoom-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #94a3b8;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  color: #0f172a;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  user-select: none;
}

#er-canvas {
  width: 100%;
  height: 100%;
  cursor: default;
  display: block;
}

#er-canvas.tool-entity {
  cursor: crosshair;
}
#er-canvas.tool-relationship {
  cursor: crosshair;
}
#er-canvas.tool-pan {
  cursor: grab;
}
#er-canvas.is-panning {
  cursor: grabbing;
}
/* ===== SVG NODE STYLES (per class, animations) ===== */
.node {
  cursor: grab;
}
.node:active {
  cursor: grabbing;
}

.edge-line {
  stroke: #475569;
  stroke-width: 2;
  cursor: pointer;
}
.edge-line:hover {
  stroke: #7c3aed;
  stroke-width: 2.5;
}
.edge-label {
  font-size: 13px;
  font-weight: 700;
  fill: #1e293b;
  pointer-events: none;
  user-select: none;
}
.edge-hit {
  stroke: transparent;
  stroke-width: 12;
  fill: none;
  cursor: pointer;
}

/* Inline edit input on canvas */
.svg-inline-input {
  background: #fff;
  border: 2px solid #3b82f6;
  border-radius: 4px;
  font-size: 14px;
  padding: 2px 6px;
  outline: none;
  width: 130px;
}

/* ===== RELATIONEN-MODELL ===== */
#relmodel-drawer {
  width: var(--relmodel-width);
  min-width: 320px;
  max-width: 72vw;
  overflow: hidden;
  border-left: 1px solid #cbd5e1;
  background: #f8fafc;
  flex-shrink: 0;
}

#relmodel-resizer {
  width: 10px;
  flex-shrink: 0;
  cursor: col-resize;
  position: relative;
  background: linear-gradient(
    180deg,
    rgba(226, 232, 240, 0) 0%,
    rgba(226, 232, 240, 0.9) 50%,
    rgba(226, 232, 240, 0) 100%
  );
}

#relmodel-resizer::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 56px;
  border-radius: 999px;
  background: linear-gradient(180deg, #94a3b8 0%, #64748b 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55);
}

#relmodel-resizer:hover::before,
#relmodel-resizer.is-dragging::before {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
}

#relmodel-drawer.collapsed {
  width: 0;
  min-width: 0;
  max-width: 0;
  border-left: none;
  overflow: hidden;
}

#relmodel-resizer.collapsed {
  width: 0;
  overflow: hidden;
}

#relmodel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 25;
}

#relmodel-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

#relmodel-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 20px 24px;
  background: #f8fafc;
}

#relmodel-header h2 {
  font-size: 1.25rem;
  margin-bottom: 6px;
}
.relmodel-intro {
  font-size: 0.88rem;
  color: #475569;
  margin-bottom: 14px;
  line-height: 1.5;
  max-width: 800px;
}
.relmodel-intro code {
  background: #e2e8f0;
  border-radius: 3px;
  padding: 0 4px;
  font-family: monospace;
}

#relmodel-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

#relmodel-io-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.rel-btn {
  padding: 7px 16px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  background: #fff;
  color: #1e293b;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.rel-btn:hover {
  background: #f1f5f9;
}

.app-top-toast {
  position: fixed;
  top: calc(52px + 41px + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #b91c1c;
  color: #fff;
  border: 1px solid #7f1d1d;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.92rem;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.app-top-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.rel-btn.primary {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}
.rel-btn.primary:hover {
  background: #1d4ed8;
}
.rel-btn.success {
  background: #16a34a;
  color: #fff;
  border-color: #15803d;
}
.rel-btn.success:hover {
  background: #15803d;
}
.rel-btn.warning {
  background: #d97706;
  color: #fff;
  border-color: #b45309;
}
.rel-btn.warning:hover {
  background: #b45309;
}
.rel-btn.danger {
  background: #dc2626;
  color: #fff;
  border-color: #b91c1c;
}
.rel-btn.danger:hover {
  background: #b91c1c;
}

/* Feedback */
#feedback-area {
  margin-bottom: 16px;
  min-height: 0;
  transition: min-height 0.2s;
}
.feedback-box {
  position: relative;
  border-radius: var(--radius);
  padding: 10px 38px 10px 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  max-width: 860px;
}
.feedback-close {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  line-height: 1;
  cursor: pointer;
}
.feedback-close:hover {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}
.feedback-box.success {
  background: #dcfce7;
  border: 1px solid #16a34a;
  color: #166534;
}
.feedback-box.error {
  background: #fee2e2;
  border: 1px solid #dc2626;
  color: #7f1d1d;
}
.feedback-box ul {
  margin: 6px 0 0 18px;
}
.feedback-summary {
  font-weight: 600;
  margin-bottom: 8px;
  padding-right: 28px;
}
.feedback-details-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  padding: 3px 10px 3px 8px;
  border: 1px solid currentColor;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.feedback-details-toggle:hover {
  opacity: 1;
}
.feedback-details-toggle .feedback-group-chevron,
.feedback-group-toggle .feedback-group-chevron {
  transition: transform 0.2s;
  font-size: 0.72rem;
}
.feedback-details-toggle.open .feedback-group-chevron,
.feedback-group-toggle.open .feedback-group-chevron {
  transform: rotate(90deg);
}
.feedback-details-body {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.feedback-details-body[hidden] {
  display: none;
}
.feedback-group {
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
}
.feedback-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  gap: 8px;
}
.feedback-group-toggle:hover {
  background: rgba(0, 0, 0, 0.11);
}
.feedback-group-toggle.warning {
  background: rgba(180, 120, 0, 0.1);
}
.feedback-group-toggle.warning:hover {
  background: rgba(180, 120, 0, 0.18);
}
.feedback-group-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.75;
  white-space: nowrap;
  flex-shrink: 0;
}
.feedback-group-body {
  padding: 6px 10px 8px 10px;
  background: rgba(255, 255, 255, 0.35);
}
.feedback-group-body[hidden] {
  display: none;
}
.feedback-group-body--nested {
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.feedback-group-body ul {
  margin: 0;
  padding-left: 18px;
}

/* Columns */
#relmodel-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}

#student-input-area {
  flex: 1 1 260px;
  min-width: 0;
}
#solution-area {
  flex: 1 1 260px;
  min-width: 0;
}

#student-input-area h3,
#solution-area h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #334155;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 4px;
}

#solution-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

#solution-actions-row .rel-btn {
  margin: 0;
}

.solution-hide-btn {
  background: #64748b;
  color: #fff;
  border-color: #475569;
}

.solution-hide-btn:hover {
  background: #475569;
}

/* Relation Card */
.relation-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.relation-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}
.relation-card-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.relation-name-input {
  flex: 1;
  min-width: 80px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 5px 9px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
}
.relation-name-input:focus {
  outline: none;
  border-color: #3b82f6;
}
.btn-toggle-relation-mode {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: #2563eb;
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
}
.btn-toggle-relation-mode:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.btn-del-relation {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: #dc2626;
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
}
.btn-del-relation:hover {
  background: #fee2e2;
  border-color: #fecaca;
}

.relation-attrs {
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.relation-inline-error {
  margin: 8px 12px 0;
  padding: 6px 9px;
  border-radius: 6px;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #9f1239;
  font-size: 0.8rem;
  line-height: 1.35;
}

.attr-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.attr-input {
  flex: 1;
  min-width: 60px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.85rem;
  color: #1e293b;
}
.attr-input:focus {
  outline: none;
  border-color: #3b82f6;
}
.attr-pk-checkbox {
  cursor: pointer !important;
  flex-shrink: 0;
}
.attr-key-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.attr-pk-label {
  font-size: 1rem;
  color: #64748b;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.attr-fk-checkbox {
  cursor: pointer !important;
  accent-color: #2563eb;
  flex-shrink: 0;
}
.attr-fk-label {
  font-size: 0.95rem;
  color: #2563eb;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.btn-del-attr {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-left: auto;
}
.btn-del-attr:hover {
  color: #dc2626;
  background: #fee2e2;
}

.btn-add-attr {
  background: transparent;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  color: #64748b;
  font-size: 0.82rem;
  padding: 4px 10px;
  cursor: pointer;
  margin-top: 2px;
  width: 100%;
  text-align: left;
}
.btn-add-attr:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #334155;
}

.relation-preview {
  padding: 8px 12px 10px;
}

.relation-preview-output {
  margin-bottom: 0;
}

.relation-preview-inline {
  flex: 1;
  padding: 0;
  min-width: 0;
}

.relation-preview-output-inline {
  padding: 4px 8px;
  margin: 0;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}

.solution-relation.relation-preview-output-inline {
  margin-bottom: 0;
}

#student-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Lösung */
.solution-relation {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 10px;
  font-family: monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.solution-relation-name {
  font-weight: 700;
  color: #1e293b;
  font-size: 0.95rem;
}
.solution-attr-list {
  color: #475569;
}
.solution-attr.pk {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-weight: 600;
  color: inherit;
}
.solution-attr.fk {
  color: var(--color-entity);
}
.solution-attr.fkpk {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-weight: 600;
  color: var(--color-entity);
}

/* ===== INFO-MODALS (Info & Regeln) ===== */
.info-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 3100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.info-modal-card {
  background: #fff;
  border-radius: 10px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
}

.info-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: 10px 10px 0 0;
}

.info-modal-header h3 {
  font-size: 1.05rem;
  color: #1e293b;
  margin: 0;
}

.info-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.info-modal-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.info-modal-body {
  padding: 18px 22px 22px;
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.6;
}

.info-modal-body p {
  margin-bottom: 10px;
}

.info-modal-body h4 {
  font-size: 0.92rem;
  color: #1e293b;
  margin: 16px 0 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid #e2e8f0;
}

.info-modal-body ul {
  padding-left: 20px;
  margin-bottom: 10px;
}

.info-modal-body li {
  margin-bottom: 6px;
}

.info-modal-body code {
  background: #f1f5f9;
  border-radius: 3px;
  padding: 0 4px;
  font-family: monospace;
}

.table-preview-modal-card {
  max-width: min(980px, 96vw);
}

/* ===== RECHTLICHE HINWEISE (Impressum/Datenschutz) ===== */
#legal-links {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  font-size: 0.72rem;
}

#legal-links button {
  background: none;
  border: none;
  padding: 2px 4px;
  font-size: inherit;
  color: #94a3b8;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
}

#legal-links button:hover {
  color: #e2e8f0;
  text-decoration-color: currentColor;
}

.table-preview-hint {
  font-size: 0.84rem;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
}

.table-preview-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.table-preview-empty {
  color: #64748b;
  font-size: 0.9rem;
  margin: 0;
}

.table-preview-relation {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  padding: 6px 8px;
}

.info-modal-body .table-preview-relation-title {
  margin: 0 0 6px;
  padding-bottom: 0;
  border-bottom: none;
  font-size: 0.95rem;
  color: #1e293b;
}

.table-preview-table-wrap {
  overflow-x: auto;
}

.table-preview-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table-preview-table th,
.table-preview-table td {
  border: 1px solid #cbd5e1;
  padding: 7px 10px;
  text-align: left;
  white-space: nowrap;
}

.table-preview-table th {
  padding: 4px 8px;
}

.table-preview-table th {
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 700;
}

.table-preview-table td {
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

/* ===== MODAL ===== */
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 3200;
  display: flex;
  align-items: center;
  justify-content: center;
}

#modal-card {
  background: #fff;
  border-radius: 10px;
  padding: 24px 28px;
  min-width: 340px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
#modal-card h3 {
  font-size: 1.1rem;
  margin-bottom: 6px;
}

@keyframes modal-shake {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
  100% {
    transform: translateX(0);
  }
}

#modal-card.shake {
  animation: modal-shake 340ms ease-in-out;
}

.modal-row {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.modal-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.modal-entity-field {
  min-width: 200px;
}
.modal-summary-field {
  min-width: 180px;
  max-width: 220px;
}
.modal-field label {
  font-size: 0.85rem;
  color: #475569;
}

.modal-cardinality-row {
  justify-content: center;
  align-items: end;
}

.modal-subtitle {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

#context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 180px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.ctx-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: #1e293b;
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
}

.ctx-item:hover {
  background: #eff6ff;
}

.ctx-item.danger {
  color: #b91c1c;
}

.ctx-item.danger:hover {
  background: #fee2e2;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* ===== Responsive minimal ===== */
@media (max-width: 860px) {
  #app-title {
    display: none;
  }
  #toolbar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--toolbar-width);
    padding: 10px 8px;
    overflow-x: hidden;
    z-index: 35;
    box-shadow: 8px 0 18px rgba(15, 23, 42, 0.18);
    clip-path: inset(0 calc(var(--toolbar-width) - 52px) 0 0);
    will-change: clip-path;
    transition: clip-path 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }

  #toolbar::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 36px;
    width: 20px;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.42) 65%, rgba(15, 23, 42, 0.72) 100%);
    filter: blur(1.8px);
    opacity: 1;
    transition: opacity 0.16s ease 0.1s;
  }

  #toolbar:hover,
  #toolbar:focus-within {
    clip-path: inset(0 0 0 0);
  }

  #toolbar:hover::after,
  #toolbar:focus-within::after {
    opacity: 0;
    transition-delay: 0s;
  }

  #tabs {
    gap: 0;
  }

  .tab-dropdown-menu {
    left: 8px;
    right: auto;
    min-width: min(280px, calc(100vw - 24px));
  }

  .erm-title-input {
    width: 160px;
  }

  .erm-title-wrap {
    position: static;
    transform: none;
    margin-left: 6px;
  }

  .erm-title-label {
    display: none;
  }

  #relmodel-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    min-width: min(320px, 92vw);
    width: min(420px, 92vw);
    max-width: 92vw;
    z-index: 30;
    box-shadow: -18px 0 36px rgba(15, 23, 42, 0.22);
  }

  #relmodel-resizer {
    display: none;
  }

  #relmodel-resizer.collapsed {
    display: none;
  }

  #relmodel-drawer.collapsed {
    transform: translateX(100%);
    width: min(420px, 92vw);
    min-width: min(320px, 92vw);
    max-width: 92vw;
    border-left: 1px solid #cbd5e1;
  }

  #relmodel-drawer,
  #relmodel-drawer.collapsed {
    transition: transform 0.18s ease;
  }
}

/* ============================================================
   QUEST-PANEL & GAMIFICATION
   ============================================================ */

/* Quest-Panel Container */
#quest-panel {
  position: fixed;
  bottom: 0;
  left: var(--toolbar-width);
  right: 0; /* JS passt den Wert an wenn der Relationsmodell-Drawer geöffnet ist */
  height: 300px;
  min-height: 180px;
  max-height: 60vh;
  background: rgba(30, 41, 59, 0.98);
  border-top: 3px solid #2563eb;
  color: #f8fafc;
  z-index: 1000;
  display: none;
  flex-direction: column;
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.15);
  font-family: var(--font-base);
  overflow: hidden;
  transition: right 0.2s ease;
}

#quest-panel.visible {
  display: flex;
}

/* Quest-Panel Resizer (obere Kante) wird per JS .visible gesteuert */
.quest-panel-resizer {
  display: none;
  position: fixed;
  bottom: 300px; /* JS synchronisiert diesen Wert mit der Panel-Höhe */
  left: var(--toolbar-width);
  right: 0;
  height: 7px;
  cursor: row-resize;
  z-index: 1001;
  background: transparent;
}

.quest-panel-resizer.visible {
  display: block;
}

.quest-panel-resizer::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #94a3b8 0%, #64748b 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.45);
  transition: background 0.15s ease;
}

.quest-panel-resizer:hover::before,
.quest-panel-resizer.is-dragging::before {
  background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 100%);
}

/* Quest Header */
.quest-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-bottom: 1px solid #475569;
}

.quest-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.quest-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.quest-progress {
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-right: 8px;
}

.quest-reset-btn {
  background: #f59e0b;
  border: none;
  color: #1f2937;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  margin-right: 8px;
  transition: background 0.2s ease;
}

.quest-reset-btn:hover {
  background: #fbbf24;
}

.quest-close-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.quest-close-btn:hover {
  opacity: 1;
}

/* Progress Bar */
.quest-progress-bar {
  height: 4px;
  background: #6b7280;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.quest-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #22c55e);
  transition: width 0.4s ease;
  border-radius: 2px;
}

/* Progress Circles */
.quest-circles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quest-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #475569;
  border: 2px solid #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quest-circle:hover:not(.locked):not(.completed):not(.current):not(.up-next) {
  background: #64748b;
  border-color: #94a3b8;
}

.quest-circle.completed {
  background: #16a34a;
  border-color: #22c55e;
  color: #f8fafc;
  font-weight: bold;
}

.quest-circle.completed:hover {
  background: #15803d;
  border-color: #16a34a;
}

.quest-circle.current {
  background: #2563eb;
  border-color: #3b82f6;
  color: #f8fafc;
  font-weight: bold;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
}

.quest-circle.current:hover {
  background: #1d4ed8;
  border-color: #2563eb;
}

.quest-circle.up-next {
  background: #e5e7eb; /* light gray */
  border-color: #d1d5db;
  color: #374151;
  font-weight: 700;
  box-shadow: none;
}

.quest-circle.up-next:hover {
  background: #d1d5db;
  border-color: #9ca3af;
  box-shadow: none;
}

.quest-circle.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Quest Content */
#quest-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Side-by-Side Layout: Text links, Checkliste rechts */
.quest-body-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.quest-body-row > .quest-section {
  flex: 1;
  min-width: 0;
}

.quest-body-row > .quest-checklist {
  flex: 0 0 200px;
  margin-top: 0;
  position: sticky;
  top: 0;
}

.quest-section {
  margin-bottom: 8px;
}

.quest-section h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #cbd5e1;
}

.quest-concept {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid #3b82f6;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.quest-concept p {
  margin: 0;
  font-size: 0.85rem;
  color: #dbeafe;
}

.quest-concept ul,
.quest-concept ol {
  margin: 6px 0 0;
  padding-left: 20px;
}

.quest-concept li {
  margin: 0 0 4px;
  color: #dbeafe;
}

.quest-task p,
.quest-task li {
  margin: 0 0 4px 0;
  font-size: 0.9rem;
  color: #e2e8f0;
}

.quest-task ol,
.quest-task ul {
  margin: 4px 0;
  padding-left: 20px;
}

.quest-task strong {
  color: #fbbf24;
  font-weight: 600;
}

/* Quest Feedback deaktiviert */
#quest-feedback {
  display: none !important;
}

#quest-feedback:empty {
  padding: 0;
}

#quest-feedback.success {
  background: #16a34a;
  color: #f0fdf4;
  padding: 10px 16px;
}

#quest-feedback.error {
  background: #dc2626;
  color: #fff;
  padding: 10px 16px;
}

#quest-feedback.progress {
  background: #d97706;
  color: #fff;
  padding: 10px 16px;
}

/* Quest Actions */
.quest-actions {
  display: none;
  margin-top: 10px;
}

.quest-actions.quest-actions-visible {
  display: flex;
  gap: 10px;
}

.quest-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quest-btn-check {
  background: #2563eb;
  color: white;
}

.quest-btn-check:hover {
  background: #1d4ed8;
}

.quest-btn-load-erm {
  background: #475569;
  color: #f8fafc;
  margin-top: 10px;
  flex: none;
}

.quest-btn-load-erm:hover {
  background: #64748b;
}

.quest-btn-menu {
  background: #475569;
  color: #f8fafc;
}

.quest-btn-menu:hover {
  background: #64748b;
}

/* Erfolgs-Modal (einzelne Quest) */
#quest-success-modal {
  position: fixed;
  inset: 0;
  background: rgba(var(--color-header-rgb), 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1900;
  animation: fadeIn 0.2s ease;
}

.quest-success-card {
  position: relative;
  overflow: hidden;
  background: var(--color-toolbar);
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 36px 40px 28px;
  text-align: center;
  min-width: 280px;
  max-width: 720px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28);
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quest-success-icon {
  font-size: 3rem;
  color: #93c5fd;
  line-height: 1;
  margin-bottom: 8px;
}

.quest-success-title {
  font-size: 1.5rem;
  color: #e2e8f0;
  margin: 0 0 6px;
}

.quest-success-message {
  color: #cbd5e1;
  font-size: 0.9rem;
  margin: 0 0 18px;
}

.quest-success-bar-track {
  height: 12px;
  background: #334155;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 20px;
}

.quest-success-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 25%, #f59e0b 50%, #ef4444 75%, #a78bfa 100%);
  background-repeat: no-repeat;
  background-position: left center;
  border-radius: 6px;
}

.quest-success-ok-btn {
  padding: 9px 28px;
  background: var(--color-entity);
  color: #ffffff;
  border: none;
  border-radius: 7px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.quest-success-ok-btn:hover {
  background: #1d4ed8;
}

/* Disabled state for OK button in success modal */
.quest-success-ok-btn:disabled {
  /* keep the same blue background while disabled to avoid a color flash on enable */
  opacity: 0.75;
  cursor: not-allowed;
  background: var(--color-entity);
  color: #f8fafc;
  box-shadow: none;
}

/* Modal-specific variant of the info box */
.quest-success-concept {
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid #3b82f6;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  color: #dbeafe;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: left;
}

/* Single Pastell-Gradient utility (used by the success bar) */
.quest-success-gradient {
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 25%, #f59e0b 50%, #ef4444 75%, #a78bfa 100%);
}

/* Ensure paragraph and list text inside the success concept use the larger size */
.quest-success-concept p,
.quest-success-concept li {
  font-size: 1.15rem;
  line-height: 1.45;
  color: #dbeafe;
}

/* Glückwunsch-Modal */
.quest-congratulations-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(var(--color-header-rgb), 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3300;
  animation: fadeIn 0.3s ease;
}

.quest-congratulations-modal.visible {
  display: flex !important;
}

.quest-congratulations-content {
  position: relative;
  overflow: hidden;
  background: var(--color-toolbar);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  max-width: 720px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quest-congratulations-content h2 {
  font-size: 2rem;
  color: #e2e8f0;
  margin-bottom: 8px;
}

.quest-congratulations-content p {
  color: #cbd5e1;
  margin-bottom: 16px;
  line-height: 1.6;
}

.quest-congratulations-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.quest-btn-next {
  flex: 1;
  padding: 12px 16px;
  background: var(--color-entity);
  color: #f8fafc;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.quest-btn-next:hover {
  background: #1d4ed8;
}

.quest-btn-menu-main {
  flex: 1;
  padding: 12px 16px;
  background: #334155;
  color: #e2e8f0;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.quest-btn-menu-main:hover {
  background: #475569;
}

/* Globales App-Dialog-Modal (ersetzt alert/confirm) */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(var(--color-header-rgb), 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 3400;
  animation: fadeIn 0.22s ease;
}

.app-modal-card {
  width: min(440px, 100%);
  background: var(--color-toolbar);
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(var(--color-header-rgb), 0.34);
  animation: slideUp 0.26s ease;
}

.app-modal-header {
  padding: 16px 18px 10px;
}

.app-modal-header h3 {
  margin: 0;
  font-size: 1.06rem;
  color: #e2e8f0;
}

.app-modal-body {
  padding: 0 18px 14px;
}

.app-modal-body p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.55;
}

.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 18px 16px;
}

.app-modal-btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.app-modal-btn-primary {
  background: var(--color-entity);
  color: #f8fafc;
}

.app-modal-btn-primary:hover {
  background: #1d4ed8;
}

.app-modal-btn-secondary {
  background: #334155;
  color: #e2e8f0;
}

.app-modal-btn-secondary:hover {
  background: #475569;
}

.quest-confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}

.quest-confetti-fullscreen {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2600;
}

.quest-confetti-piece {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: var(--size);
  height: calc(var(--size) * 1.6);
  border-radius: 2px;
  opacity: 0;
  transform: translate3d(0, 0, 0) rotate(0deg);
  animation: questConfettiFall var(--dur) ease-out var(--delay) forwards;
}

.quest-confetti-piece-screen {
  animation-name: questConfettiFallScreen;
}

/* Konfetti-Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes questConfettiFall {
  0% {
    opacity: 0;
    transform: translate3d(0, -6px, 0) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), 210px, 0) rotate(var(--rot));
  }
}

@keyframes questConfettiFallScreen {
  0% {
    opacity: 0;
    transform: translate3d(0, -10px, 0) rotate(0deg);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), 105vh, 0) rotate(var(--rot));
  }
}

/* Responsive Quest Panel */
@media (max-width: 768px) {
  #quest-panel {
    left: 0;
    right: 0 !important; /* Immer volle Breite auf Mobile */
    height: 280px;
    min-height: 240px;
  }

  .quest-panel-resizer {
    left: 0;
    right: 0 !important;
  }

  .quest-body-row {
    flex-direction: column;
  }

  .quest-body-row > .quest-checklist {
    flex: none;
    width: 100%;
  }

  #quest-content {
    font-size: 0.85rem;
  }

  .quest-circles {
    gap: 4px;
  }

  .quest-circle {
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
  }
}

/* ===== Disabled Dropdown-Eintrag (coming soon) ===== */
.tab-dropdown-item-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: auto;
}

.tab-dropdown-item-disabled:hover {
  background: transparent;
}

/* ===== Experten-Checkliste ===== */
.quest-checklist {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(100, 116, 139, 0.12);
  border: 1px solid #334155;
  border-radius: 8px;
}

.quest-body-row > .quest-checklist {
  margin-top: 0;
}

.quest-checklist h4 {
  font-size: 0.82rem;
  font-weight: 600;
  color: #94a3b8;
  margin: 0 0 8px;
}

.quest-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 0.83rem;
  color: #94a3b8;
  transition:
    background 0.25s ease,
    color 0.25s ease;
}

.quest-checklist-item--done {
  color: #4ade80;
}

.quest-checklist-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  background: #334155;
  color: #94a3b8;
  transition:
    background 0.25s ease,
    color 0.25s ease,
    transform 0.25s ease;
}

.quest-checklist-item--done .quest-checklist-icon {
  background: #16a34a;
  color: #f0fdf4;
}

.quest-checklist-label {
  transition: color 0.25s ease;
}

/* Check-Animation: Bounce + Grün-Flash */
@keyframes checklist-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.18);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

.quest-checklist-item--just-checked {
  animation: checklist-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: rgba(34, 197, 94, 0.12);
}

.quest-checklist-item--just-checked .quest-checklist-icon {
  animation: checklist-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Custom styled tooltips (convert title -> data-tooltip via JS) */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:focus {
  outline: none;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(2, 6, 23, 0.92);
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 0.85rem;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
  z-index: 6000;
  max-width: 360px;
  text-align: center;
}

[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(2, 6, 23, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

[data-tooltip]:hover::before,
[data-tooltip]:focus::before,
[data-tooltip]:focus-visible::before {
  opacity: 1;
}

/* Right-positioned tooltip support */
[data-tooltip][data-tooltip-pos='right']::after {
  left: calc(100% + 10px);
  bottom: 50%;
  transform: translateY(-50%);
  text-align: left;
}

[data-tooltip][data-tooltip-pos='right']::before {
  left: 100%;
  bottom: 50%;
  transform: translateY(-50%);
  border-left: 6px solid rgba(2, 6, 23, 0.92);
  border-top: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

/* Small screens: allow multi-line tooltips */
@media (max-width: 480px) {
  [data-tooltip]::after {
    white-space: normal;
    left: 50%;
    right: 12px;
    transform: translateX(-50%) translateY(4px);
    max-width: calc(100vw - 40px);
  }
}
