/* Wiki-Editor (TipTap) — Quelle: tools/wiki_editor/src/wiki_editor.css */

.wiki-editor {
  --we-bg: #ffffff;
  --we-fg: #1c1b1f;
  --we-muted: #5f6368;
  --we-border: #c4c7c5;
  --we-toolbar: #f3f4f6;
  --we-hover: #e3e5e8;
  --we-active: #d3e3fd;
  --we-active-fg: #0b57d0;
  --we-code-bg: #f1f3f4;
  --we-table-head: #eef1f5;
  --we-select: rgba(11, 87, 208, 0.18);

  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 1px solid var(--we-border);
  border-radius: 6px;
  background: var(--we-bg);
  color: var(--we-fg);
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  overflow: hidden;
}

.wiki-editor.wiki-dark {
  --we-bg: #1e1f22;
  --we-fg: #e6e1e5;
  --we-muted: #a8a8ad;
  --we-border: #45464f;
  --we-toolbar: #2a2b2f;
  --we-hover: #3a3b40;
  --we-active: #2f4a78;
  --we-active-fg: #a8c7fa;
  --we-code-bg: #2c2d31;
  --we-table-head: #2c2f36;
  --we-select: rgba(168, 199, 250, 0.22);
}

/* ---------- Toolbar ---------- */
.we-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--we-toolbar);
  border-bottom: 1px solid var(--we-border);
  flex: 0 0 auto;
}
.we-toolbar[hidden] { display: none; }
.we-kontext { background: var(--we-bg); }

.we-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--we-fg);
  cursor: pointer;
}
.we-btn:hover { background: var(--we-hover); }
.we-btn.we-active { background: var(--we-active); color: var(--we-active-fg); }

.we-select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--we-border);
  border-radius: 6px;
  background: var(--we-bg);
  color: var(--we-fg);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.we-sep {
  width: 1px;
  height: 22px;
  margin: 0 6px;
  background: var(--we-border);
}

.we-label {
  margin: 0 6px 0 2px;
  font-size: 13px;
  color: var(--we-muted);
}

.we-menu-wrap { position: relative; display: inline-flex; }
.we-pop {
  position: absolute;
  top: 36px;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(6, 22px);
  gap: 6px;
  padding: 8px;
  background: var(--we-bg);
  border: 1px solid var(--we-border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.we-pop[hidden] { display: none; }
.we-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--we-border);
  border-radius: 4px;
  cursor: pointer;
}
.we-swatch-none {
  background: linear-gradient(135deg, transparent 45%, #c62828 45%, #c62828 55%, transparent 55%);
}

/* ---------- Inhalt ---------- */
.we-content {
  flex: 1 1 auto;
  overflow-y: auto;
  cursor: text;
}
.we-content .ProseMirror {
  min-height: 100%;
  box-sizing: border-box;
  padding: 16px 20px 40px;
  outline: none;
}
.we-content .ProseMirror > * + * { margin-top: 0.6em; }
.we-content .ProseMirror p { margin: 0; }
.we-content h1 { font-size: 1.7em; margin: 0.8em 0 0.3em; line-height: 1.25; }
.we-content h2 { font-size: 1.4em; margin: 0.8em 0 0.3em; line-height: 1.3; }
.we-content h3 { font-size: 1.18em; margin: 0.8em 0 0.3em; }
.we-content a { color: var(--we-active-fg); text-decoration: underline; }
.we-content ul, .we-content ol { padding-left: 1.6em; margin: 0.3em 0; }
.we-content blockquote {
  margin: 0.6em 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--we-border);
  color: var(--we-muted);
}
.we-content code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--we-code-bg);
  font-family: "Roboto Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.we-content pre {
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--we-code-bg);
  overflow-x: auto;
}
.we-content pre code { padding: 0; background: none; }
.we-content hr { border: none; border-top: 1px solid var(--we-border); margin: 1em 0; }
.we-content mark { border-radius: 2px; padding: 0 2px; color: inherit; }

/* Checklisten */
.we-content ul[data-type="taskList"] { list-style: none; padding-left: 0.3em; }
.we-content ul[data-type="taskList"] li { display: flex; gap: 8px; align-items: flex-start; }
.we-content ul[data-type="taskList"] li > label { margin-top: 3px; user-select: none; }
.we-content ul[data-type="taskList"] li > div { flex: 1 1 auto; }

/* Tabellen */
.we-content table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  margin: 0.6em 0;
  overflow: hidden;
}
.we-content td, .we-content th {
  position: relative;
  min-width: 60px;
  padding: 6px 8px;
  border: 1px solid var(--we-border);
  vertical-align: top;
  box-sizing: border-box;
}
.we-content th { background: var(--we-table-head); font-weight: 600; text-align: left; }
.we-content .selectedCell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--we-select);
  pointer-events: none;
}
.we-content .column-resize-handle {
  position: absolute;
  top: 0;
  right: -2px;
  bottom: -2px;
  width: 4px;
  background: var(--we-active-fg);
  pointer-events: none;
}
.we-content .tableWrapper { overflow-x: auto; }
.we-content.resize-cursor, .we-content .resize-cursor { cursor: col-resize; }

/* Bilder (inkl. Resize-Container von TipTap) */
.we-content img { max-width: 100%; height: auto; display: block; }
.we-content [data-resize-container] { max-width: 100%; justify-content: flex-start; }
.we-content [data-resize-container]:has(img[data-align="center"]) { justify-content: center; }
.we-content [data-resize-container]:has(img[data-align="right"]) { justify-content: flex-end; }
.we-content img[data-align="center"] { margin-left: auto; margin-right: auto; }
.we-content img[data-align="right"] { margin-left: auto; }
.we-content .ProseMirror-selectednode img,
.we-content img.ProseMirror-selectednode,
.we-content [data-resize-container].ProseMirror-selectednode img {
  outline: 2px solid var(--we-active-fg);
  outline-offset: 2px;
}
.we-content [data-resize-handle] {
  width: 10px;
  height: 10px;
  background: var(--we-bg);
  border: 2px solid var(--we-active-fg);
  border-radius: 2px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.12s;
}
/* Griffe nur beim Überfahren oder am markierten Bild */
.we-content [data-resize-container]:hover [data-resize-handle],
.we-content .ProseMirror-selectednode [data-resize-handle],
.we-content [data-resize-container].ProseMirror-selectednode [data-resize-handle] {
  opacity: 1;
}

/* Platzhalter bei leerem Dokument */
.we-content p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  color: var(--we-muted);
  pointer-events: none;
}
