:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --border: #dde2ea;
  --text: #1a1a1a;
  --muted: #667;
  --accent: #2b6cb0;
  --accent-dark: #1a4a80;
  --accent-light: #eaf1fb;
  --danger: #b02b2b;
  --danger-light: #fdecec;
  --warn: #a06a00;
  --warn-light: #fff8e6;
  --ok: #1a7a4a;
  --radius: 6px;
  --topbar-bg: #16324f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

#topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--topbar-bg);
  border-bottom: 3px solid var(--accent);
}
.brand { font-weight: 700; text-decoration: none; color: #fff; font-size: 1.1rem; }
.brand .brand-icon { margin-right: 0.35rem; }
#nav { display: flex; align-items: center; gap: 1.1rem; flex: 1; }
#nav a { color: #c8d6e8; text-decoration: none; display: inline-flex; align-items: center; gap: 0.3rem; }
#nav a:hover { color: #fff; }
#nav a.profile-link { color: #fff; font-weight: 600; }
#nav .spacer { flex: 1; }
#nav .icon { font-size: 1rem; }
.push-hint { font-size: 0.9rem; }

/* #app selbst ist absichtlich nicht mehr zentriert/breitenbegrenzt, damit
   Sidebar-Layouts am Fensterrand andocken können (siehe .sidebar-layout).
   Ansichten ohne Sidebar verwenden .page-container für die bisherige
   zentrierte, breitenbegrenzte Darstellung. */
#app { margin: 1.5rem 0 3rem; }
.page-container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; margin-top: 2rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.04);
}

/* "Dokument"-Karte: sichtbar farblich vom Seitenhintergrund abgesetzt. */
.document {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(20, 30, 50, 0.07);
  padding: 1.75rem 2rem;
  max-width: 860px;
  margin: 0 auto;
}

input, textarea, select, button {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
textarea { width: 100%; min-height: 5rem; }
input[type="text"], input[type="search"], input[type="password"], input[type="email"], input[type="datetime-local"], input[type="date"] {
  width: 100%;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button.secondary { background: #eef1f6; color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: #e2e7ee; }
button.secondary.active { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { background: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

form .row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
form label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.2rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
th { cursor: pointer; color: var(--muted); font-weight: 600; background: #f5f7fb; }
tbody tr:hover { background: var(--accent-light); }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  background: #eee;
  color: var(--muted);
  margin-left: 0.4rem;
}
.badge.locked { background: var(--danger-light); color: var(--danger); }
.badge.hidden { background: var(--warn-light); color: var(--warn); }
.badge.protected { background: var(--warn-light); color: var(--warn); }
.badge.encrypted { background: var(--accent-light); color: var(--accent-dark); }

.paragraph {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
  border-left: 3px solid var(--accent-light);
}
.paragraph h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.paragraph .meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.4rem; }
.paragraph .actions { margin-top: 0.5rem; display: flex; gap: 0.4rem; }
.paragraph.protected { border-left-color: var(--warn); }
.protection-actions { margin-top: 0.5rem; }
.protection-banner { margin-top: 0.6rem; }
.admin-protection-actions { margin-top: 0.75rem; }

/* Gerenderter Markdown-Inhalt (format = markdown_v1), siehe spa/js/markdown.js */
.content-view h1, .content-view h2, .content-view h3, .content-view h4 { margin: 0.6rem 0 0.3rem; }
.content-view h1 { font-size: 1.3rem; }
.content-view h2 { font-size: 1.15rem; }
.content-view h3 { font-size: 1.05rem; }
.content-view h4, .content-view h5, .content-view h6 { font-size: 1rem; }
.content-view p { margin: 0.4rem 0; }
.content-view code { background: var(--accent-light); border-radius: 4px; padding: 0.1rem 0.3rem; font-family: ui-monospace, Consolas, monospace; }
.content-view pre { background: var(--accent-light); border-radius: var(--radius); padding: 0.6rem 0.8rem; overflow-x: auto; }
.content-view pre code { background: none; padding: 0; }
.content-view blockquote { margin: 0.4rem 0; padding: 0.2rem 0.8rem; border-left: 3px solid var(--border); color: var(--muted); }
.content-view table { width: auto; max-width: 100%; margin: 0.4rem 0; }
.content-view th, .content-view td { border: 1px solid var(--border); }
.content-view img { max-width: 100%; height: auto; }
.content-view ul, .content-view ol { margin: 0.4rem 0; padding-left: 1.5rem; }

.md-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.5rem;
}
.md-toolbar { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.md-btn { padding: 0.3rem 0.5rem; min-width: 2rem; }
.md-bar .format-select { margin-left: auto; width: auto; }
.paragraph.encrypted { border-left-color: var(--accent-dark); }
.encryption-actions { margin-top: 0.75rem; }
.checkbox-line { display: flex; align-items: center; gap: 0.4rem; margin: 0.5rem 0; }
.checkbox-line input { margin: 0; }

/* Benachrichtigungs-Glocke in der Topbar */
.bell-link { position: relative; margin-right: 0.25rem; }
.notification-badge {
  position: absolute;
  top: -0.4rem;
  right: -0.6rem;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 0.65rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  min-width: 1rem;
  text-align: center;
}
.notification-item { border-left: 3px solid var(--warn); }

.error { color: var(--danger); background: var(--danger-light); border: 1px solid #f5c2c2; border-radius: var(--radius); padding: 0.5rem 0.75rem; margin-bottom: 1rem; }
.notice { color: var(--warn); background: var(--warn-light); border: 1px solid #f0ddaa; border-radius: var(--radius); padding: 0.5rem 0.75rem; margin-bottom: 1rem; }
.notice.ok { color: var(--ok); background: #e8f6ee; border-color: #b9e3c8; }
.muted { color: var(--muted); font-size: 0.85rem; }
.pill-list { display: flex; gap: 0.3rem; flex-wrap: wrap; margin: 0; }
.pill { background: var(--accent-light); color: var(--accent-dark); padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; }

/* Dropdown-Menüs (Artikel- und Absatz-Aktionen) */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.05rem 0.5rem;
  line-height: 1.4;
}
.dropdown-toggle:hover { background: var(--accent-light); }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 10;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  min-width: 210px;
  padding: 0.25rem;
  margin-top: 0.2rem;
}
.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
}
.dropdown-menu button:hover { background: var(--accent-light); }
.dropdown-menu button.danger-text { color: var(--danger); }

/* Artikel-Kopfbereich - Dropdown-Pfeil links neben dem Titel */
.article-header { display: flex; align-items: center; justify-content: flex-start; gap: 0.5rem; }
.article-header h1 { margin: 0; }

.keyword-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0 1.25rem; flex-wrap: wrap; }
.icon-btn {
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  line-height: 1.3;
  font-size: 0.85rem;
  flex: none;
}
.popover {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.6rem;
  margin-bottom: 1rem;
  max-width: 360px;
}

.paragraph-header { display: flex; align-items: center; justify-content: flex-start; gap: 0.4rem; }
.paragraph-header h3 { margin: 0; }
.inline-edit-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.1rem 0.3rem;
  font-size: 0.85rem;
}
.inline-edit-btn:hover { background: var(--accent-light); border-radius: 4px; }
.paragraph .meta { margin: 0.15rem 0 0.5rem; }
.attachment-thumb {
  display: block;
  max-width: 400px;
  max-height: 400px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 0.4rem 0;
}

.edit-content-wrap .edit-content { min-height: 50vh; }
.edit-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

/* Modal-Dialog (mittig über der Seite) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 35, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-width: 320px;
  max-width: 90vw;
  box-shadow: 0 8px 30px rgba(10, 20, 35, 0.3);
}
.modal-box h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

.field-narrow { width: 4.5rem; }
.field-line { width: 100%; }

/* Administration: quadratische Auswahl-Buttons */
.admin-section-buttons { display: flex; gap: 0.75rem; margin: 1rem 0 1.5rem; }
.admin-section-buttons button {
  width: 7rem;
  height: 7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 600;
  gap: 0.3rem;
}
.admin-section-buttons button .icon { font-size: 1.6rem; }
.admin-section-buttons button.active { background: var(--accent-dark); color: #fff; }

/* Passwortfeld mit Klartext-Umschalter ("Auge") */
.password-field { position: relative; }
.password-field input { padding-right: 2.2rem; }
.password-toggle {
  position: absolute;
  right: 0.15rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  padding: 0.2rem 0.4rem;
  cursor: pointer;
}
.password-toggle:hover { background: none; color: var(--text); }

/* Generisches Sidebar-Layout: Sidebar links am Fensterrand angedockt
   (Desktop, ab 900px), oben gestapelt als eigene Karte (Mobile). Verwendet
   von Artikel-Suche, Keyword-Suche und "Neues Konto anlegen". */
.sidebar-layout { display: flex; flex-direction: column; gap: 1rem; }
.sidebar-layout .sidebar {
  flex: none;
  margin: 0 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.04);
}
.sidebar-layout .sidebar .row { flex-direction: column; }
.sidebar-layout .sidebar label { margin-top: 0.5rem; }
.sidebar-layout .sidebar label:first-child { margin-top: 0; }
.sidebar-layout .content-pane { flex: 1; min-width: 0; padding: 0 1rem; }

@media (min-width: 900px) {
  .sidebar-layout { flex-direction: row; align-items: flex-start; }
  .sidebar-layout .sidebar {
    width: 270px;
    margin: 0;
    padding: 1rem 1.25rem 1rem 1.5rem;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
  }
  .sidebar-layout .content-pane { padding: 0 1.5rem; max-width: 960px; }
}

/* Klickbare Icons/Tags mit erklärendem Titel - Standard-Tooltip via title-Attribut */
[title] { cursor: help; }
button[title], a[title] { cursor: pointer; }
