/* Princes of the Apocalypse — subtile Element-Akzente */
:root {
  --bg: #1a1410;
  --bg-2: #221a14;
  --panel: #2a201a;
  --panel-2: #332821;
  --border: #4a3a2c;
  --text: #e8dcc4;
  --text-dim: #a89878;
  --gold: #d4a574;
  --gold-bright: #e8c184;

  /* Element colors */
  --fire: #c2410c;
  --water: #0e7490;
  --air: #94a3b8;
  --earth: #92400e;

  --shadow: 0 4px 20px rgba(0,0,0,0.5);
  --radius: 10px;
}

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

html, body {
  height: 100%;
  font-family: 'EB Garamond', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

body {
  background:
    radial-gradient(ellipse at top, rgba(194,65,12,0.05), transparent 50%),
    radial-gradient(ellipse at bottom, rgba(14,116,144,0.05), transparent 50%),
    var(--bg);
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: 'Cinzel', serif;
  color: var(--gold-bright);
  font-weight: 500;
  letter-spacing: 0.5px;
}

a { color: var(--gold); }
a:hover { color: var(--gold-bright); }

input, textarea, select {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
}

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}
button:hover {
  background: var(--panel-2);
  border-color: var(--gold);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #b8915c);
  color: #1a1410;
  border-color: var(--gold);
  font-weight: 600;
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #0e0a06;
}
.btn-secondary {
  background: var(--panel-2);
  border-color: var(--border);
}
.btn-subtle {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-subtle:hover {
  color: var(--text);
  border-color: var(--gold);
}
.btn-subtle.small { padding: 6px 10px; font-size: 11px; }
.full { width: 100%; }

.hidden { display: none !important; }
.error { color: #f87171; margin-top: 8px; min-height: 1em; font-family: 'EB Garamond', serif; }
.hint { color: var(--text-dim); font-size: 14px; margin: 12px 0; font-style: italic; }
.empty-state { color: var(--text-dim); text-align: center; padding: 40px; font-style: italic; }
.field-label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--text-dim); font-family: 'Cinzel', serif; }

/* ============ MODAL ============ */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow);
  position: relative;
  /* Phase 2.11: Modale duerfen die Viewport-Höhe nicht überschreiten.
     Sonst wachsen lange Inhalte (z.B. Detail-Ansichten, Import-Reports)
     unsichtbar über den Bildschirmrand hinaus. */
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content::before {
  content: "";
  position: absolute; inset: 4px;
  border: 1px solid rgba(212,165,116,0.2);
  border-radius: calc(var(--radius) - 2px);
  pointer-events: none;
}
.modal-large { max-width: 800px; max-height: 90vh; overflow-y: auto; }
.modal-content h2 { margin-bottom: 16px; text-align: center; }
.modal-content p { color: var(--text-dim); margin-bottom: 16px; }
.modal-content input, .modal-content textarea, .modal-content select {
  margin-bottom: 12px;
}
.modal-content button { margin-right: 8px; margin-top: 8px; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
}

.help-details {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 12px 0;
}
.help-details summary { cursor: pointer; color: var(--gold); font-family: 'Cinzel', serif; font-size: 13px; }
.help-details ol { margin: 12px 0 0 24px; color: var(--text-dim); font-size: 14px; }
.help-details li { margin-bottom: 6px; }
.help-details code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--gold);
}

.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-list-manage { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; margin: 12px 0; }
.user-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-2); padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--border);
}
.user-row .remove-user {
  background: transparent; border: none; color: #f87171; padding: 4px 8px;
  font-family: inherit; font-size: 18px;
}
.user-list button.user-choice {
  width: 100%; text-align: left; padding: 14px 16px;
  background: var(--bg-2); font-size: 15px;
}
.user-list button.user-choice:hover {
  background: var(--panel-2); border-color: var(--gold);
}
.add-user-row { display: flex; gap: 8px; margin-top: 12px; }
.add-user-row input { flex: 1; margin: 0; }
.link-subtle { color: var(--text-dim); font-size: 14px; text-decoration: none; }
.link-subtle:hover { color: var(--gold); }

/* ============ APP LAYOUT ============ */
.app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.logo {
  font-family: 'Cinzel', serif;
  font-size: 19px;
  color: var(--gold-bright);
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.user-pill {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 14px;
}
#currentUserName { color: var(--gold); font-family: 'Cinzel', serif; }
#switchUserBtn { padding: 4px 8px; font-size: 12px; background: transparent; }

.nav-tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 12px 8px;
  font-size: 12px;
  border-radius: 0;
}
.tab:hover { background: var(--panel); color: var(--text); }
.tab.active {
  color: var(--gold-bright);
  border-bottom-color: var(--gold);
  background: var(--panel);
}

.tab-content {
  display: none;
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.tab-content.active { display: flex; flex-direction: column; gap: 10px; }

.filter-section { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.filter-section label { font-size: 12px; color: var(--text-dim); font-family: 'Cinzel', serif; letter-spacing: 0.5px; }

.chat-sessions {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 12px;
}
.chat-session-item {
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-dim);
  display: flex; justify-content: space-between; align-items: center;
  font-family: 'EB Garamond', serif;
  text-align: left;
}
.chat-session-item:hover { background: var(--panel); color: var(--text); }
.chat-session-item.active { background: var(--panel-2); border-color: var(--gold); color: var(--text); }
.chat-session-item .del { opacity: 0; transition: opacity 0.2s; padding: 2px 6px; background: transparent; border: none; color: #f87171; }
.chat-session-item:hover .del { opacity: 1; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

/* ============ MAIN VIEW ============ */
.main { display: flex; flex-direction: column; overflow: hidden; }
.view { display: none; flex-direction: column; height: 100%; }
.view.active { display: flex; }

.view-header {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.view-header h1 { font-size: 22px; }

.stats-bar { display: flex; gap: 14px; font-size: 13px; color: var(--text-dim); }
.stats-bar strong { color: var(--gold); }

/* ============ CHAT ============ */
.messages {
  flex: 1; overflow-y: auto;
  padding: 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.message {
  display: flex; gap: 12px; animation: fade 0.3s;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.message.user { flex-direction: row-reverse; }
.bubble {
  max-width: 75%; padding: 12px 16px;
  border-radius: 14px; line-height: 1.55;
  white-space: pre-wrap; word-wrap: break-word;
}
.message.assistant .bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.message.user .bubble {
  background: linear-gradient(135deg, var(--earth), #6b3209);
  color: var(--text);
  border-bottom-right-radius: 4px;
}
.message-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.message.assistant .message-avatar { color: var(--gold); }

.sources {
  margin-top: 10px; padding: 10px 12px;
  background: var(--bg-2); border-left: 3px solid var(--gold);
  border-radius: 6px; font-size: 13px;
}
.sources .src-label { color: var(--gold); font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 0.5px; margin-bottom: 6px; }
.sources a { display: block; padding: 2px 0; }

.input-area {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  display: flex; gap: 10px;
}
#userInput {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 200px;
}
#sendBtn { align-self: flex-end; }

.typing { display: flex; gap: 5px; padding: 4px 0; }
.typing span {
  width: 7px; height: 7px; background: var(--gold);
  border-radius: 50%; animation: bounce 1.4s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* ============ LIBRARY ============ */
.entry-grid {
  flex: 1; overflow-y: auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  align-content: start;
}
.entry-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
}
.entry-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.entry-card-title {
  font-family: 'Cinzel', serif;
  font-size: 15px;
  color: var(--gold-bright);
}
.entry-card-meta { font-size: 12px; color: var(--text-dim); display: flex; gap: 10px; }
.entry-card-preview {
  font-size: 14px; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.5px;
  background: var(--bg-2);
  border: 1px solid var(--border);
}
.cat-NPC { color: var(--fire); border-color: var(--fire); }
.cat-Ort { color: var(--earth); border-color: var(--earth); }
.cat-Quest { color: var(--gold); border-color: var(--gold); }
.cat-Session { color: var(--air); border-color: var(--air); }
.cat-Lore { color: var(--water); border-color: var(--water); }
.cat-Item { color: #a78bfa; border-color: #a78bfa; }
.cat-Monster { color: #f87171; border-color: #f87171; }

.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 11px; padding: 2px 8px;
  background: var(--bg-2); border-radius: 10px;
  color: var(--text-dim); border: 1px solid var(--border);
}

.entry-meta { color: var(--text-dim); font-size: 13px; }
.entry-content-display {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 15px;
  max-height: 50vh;
  overflow-y: auto;
  color: var(--text);
}
.entry-view-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }

/* duplicate warning inside entry editor */
.duplicate-warning {
  background: rgba(194,65,12,0.1);
  border: 1px solid var(--fire);
  border-radius: var(--radius);
  padding: 12px;
  margin: 12px 0;
  font-size: 14px;
}
.duplicate-warning strong { color: var(--fire); }
.duplicate-warning ul { margin: 8px 0 0 18px; }
.duplicate-warning li { margin: 2px 0; color: var(--text); }

/* ============ TIMELINE ============ */
.timeline {
  flex: 1; overflow-y: auto;
  padding: 24px;
  position: relative;
}
.timeline::before {
  content: ""; position: absolute;
  left: 100px; top: 24px; bottom: 24px;
  width: 2px; background: linear-gradient(180deg, var(--gold), transparent);
}
.timeline-day { margin-bottom: 24px; }
.timeline-day-label {
  font-family: 'Cinzel', serif; color: var(--gold);
  font-size: 13px; letter-spacing: 1px;
  margin-bottom: 12px; padding-left: 0;
  width: 90px;
  display: inline-block;
}
.timeline-entry {
  display: flex; align-items: center;
  gap: 16px;
  margin-left: 0;
  padding-left: 0;
  position: relative;
  margin-bottom: 6px;
}
.timeline-time { width: 90px; color: var(--text-dim); font-size: 12px; text-align: right; }
.timeline-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--bg);
  z-index: 1; flex-shrink: 0;
}
.timeline-card {
  flex: 1;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.timeline-card:hover { border-color: var(--gold); }
.timeline-card-title { font-family: 'Cinzel', serif; color: var(--gold-bright); font-size: 14px; }
.timeline-card-meta { font-size: 12px; color: var(--text-dim); margin-top: 3px; display: flex; gap: 10px; }

/* ============ SEARCH ============ */
.search-results {
  flex: 1; overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.search-result-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  cursor: pointer; transition: all 0.2s;
}
.search-result-card:hover { border-color: var(--gold); }
.search-result-card .similarity {
  float: right; font-family: 'Cinzel', serif;
  font-size: 12px; color: var(--gold);
}
.search-result-card .snippet {
  margin-top: 8px; color: var(--text-dim); font-size: 14px;
  font-style: italic;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }

/* duplicate pairs list */
.dup-pair {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 8px 0;
  display: flex; justify-content: space-between; align-items: center;
}
.dup-pair .pair-title { display: flex; gap: 8px; align-items: center; }
.dup-pair .sim-badge {
  background: var(--fire); color: white;
  padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-family: 'Cinzel', serif;
}

/* responsive */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}


/* ============================================================
   v2.1 – Auth/Account/Manage Erweiterungen
   ============================================================ */

/* User-Pill: Buttons fürs Konto und Logout */
.user-pill { display: flex; align-items: center; gap: 6px; }
.user-pill button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--gold);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.user-pill button:hover { border-color: var(--gold); background: rgba(212,165,116,0.08); }
.user-badge {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--gold-bright);
  border: 1px solid var(--gold);
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
}

/* Footer-Erweiterung: zusätzlicher Manage-Button + Versions-Tag */
.sidebar-footer { display: flex; flex-direction: column; gap: 6px; }
.sidebar-footer .btn-subtle.small { width: 100%; text-align: left; }
.version-tag {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 4px;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.05em;
  opacity: 0.6;
}

/* User-Liste in Manage: Aktions-Buttons rechts */
.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}
.user-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.user-row-actions .btn-subtle.small {
  font-size: 11px;
  padding: 3px 8px;
}
.user-row .remove-user {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.user-row .remove-user:hover {
  border-color: var(--fire);
  color: var(--fire);
}

/* Add-User-Zeile mit drei Feldern */
.add-user-row {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Account-Modal Headlines */
#accountModal h3 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.success {
  color: #6cb37a;
  margin-top: 8px;
  font-size: 13px;
}

/* Login-Modal Passwort-Schritt */
#loginPwSection input[type="password"] { width: 100%; }

/* Hint-Text */
.hint {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 4px;
}

/* Search-Card (war im app.js mit Klasse "search-card" aber CSS heißt "search-result-card")
   - wir machen beide Klassen kompatibel */
.search-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  cursor: pointer; transition: all 0.2s;
  margin: 4px 0;
}
.search-card:hover { border-color: var(--gold); }
.search-card-header {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 6px;
}
.search-card-header .search-title {
  font-family: 'Cinzel', serif;
  color: var(--gold-bright);
  font-size: 14px;
  flex: 1;
}
.search-card .search-snippet {
  color: var(--text-dim); font-size: 14px;
  font-style: italic;
}
.search-card .sim-badge {
  background: var(--fire); color: white;
  padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-family: 'Cinzel', serif;
}

/* ====================== Phase 2.2-C: Visibility ====================== */
.badge-private,
.badge-shared {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
}
.badge-private {
  background: #4a2230;
  color: #ffb4c8;
  border: 1px solid #6a3450;
}
.badge-shared {
  background: #1f3340;
  color: #9bc8e8;
  border: 1px solid #2d4a5e;
}
.entry-owner {
  opacity: 0.85;
  font-style: italic;
}
.visibility-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.visibility-label {
  font-size: 0.85rem;
  color: var(--text-muted, #aaa);
  white-space: nowrap;
}
#entryVisibility {
  flex: 1;
  min-width: 0;
}

/* ====================== Phase 2.3-B: Admin ====================== */
.admin-only.hidden { display: none !important; }

.admin-table-wrapper {
  overflow-x: auto;
  padding: 0 24px 24px 24px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #2a2a2a);
  vertical-align: middle;
  text-align: left;
}
.admin-table th {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted, #999);
  letter-spacing: 0.04em;
}
.admin-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.role-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.role-badge.admin  { background: #3a2a48; color: #d4b6f5; border: 1px solid #553771; }
.role-badge.user   { background: #243441; color: #9bc8e8; border: 1px solid #2d4a5e; }
.role-badge.legacy { background: #3a2a1c; color: #d4a87a; border: 1px solid #5a4028; }

.entry-counts-detail { color: var(--text-muted, #999); font-size: 0.85rem; }
.pw-pending { color: #f3c969; }
.me-tag     { color: var(--text-muted, #999); font-style: italic; font-size: 0.85rem; }

.admin-actions { white-space: nowrap; }
.admin-actions .btn-subtle.small,
.admin-actions .btn-danger.small {
  padding: 4px 9px;
  font-size: 0.8rem;
  margin-right: 4px;
}
.btn-danger {
  background: #5a2330;
  color: #ffd2dc;
  border: 1px solid #7a2f44;
}
.btn-danger:hover { background: #6a2a3a; }
.btn-danger[disabled] { opacity: 0.4; cursor: not-allowed; }

.radio-group {
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 12px 0;
}
.radio-group legend { padding: 0 6px; font-size: 0.85rem; color: var(--text-muted, #999); }
.radio-group label { display: block; padding: 4px 0; cursor: pointer; }

.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0;
  cursor: pointer;
}
.error-msg {
  color: #ff8a99;
  background: rgba(255, 70, 90, 0.08);
  padding: 8px 10px;
  border-radius: 4px;
  margin: 8px 0;
}

/* ====================== Phase 2.11: Admin-Scroll-Fix ====================== */
/* Die Admin-View hat - anders als #view-chat / #view-entries / #view-search - keinen
   eigenen Scroll-Container im HTML, sondern viele .admin-section direkt unter .view.
   Da .main { overflow: hidden } ist, wuchs bisher der Inhalt über die Viewport-Höhe
   hinaus, ohne Scrollbar. Loesung: Die View selbst scrollt, der Header bleibt sticky. */
#view-admin.active { overflow-y: auto; }
#view-admin > .view-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
}

/* ====================== Phase 2.3-C: Admin-System & Privacy ====================== */
.admin-section {
  padding: 0 24px 24px 24px;
}
.admin-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 24px 0 10px 0;
  color: var(--text-muted, #aaa);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.admin-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 8px;
  padding: 12px 14px;
}
.admin-card-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted, #999);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.admin-card-body {
  font-size: 0.95rem;
  line-height: 1.5;
}
.card-sub {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
}
.path-text {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.private-summary {
  margin: 8px 0 12px 0;
}
.private-owner-pill {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border, #2a2a2a);
  font-size: 0.85rem;
}
.private-table {
  font-size: 0.9rem;
}

/* ====================== Phase 2.3-D: Backup ====================== */
.admin-backup-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0 4px 0;
  flex-wrap: wrap;
}
.btn-backup {
  background: #2a3f4a;
  color: #b8e0f0;
  border: 1px solid #3a5566;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-backup:hover { background: #34505e; }
.btn-backup:disabled { opacity: 0.5; cursor: wait; }
.backup-status {
  font-size: 0.9rem;
  color: var(--text-muted, #aaa);
}
.backup-status.error-msg {
  color: #ff8a99;
}

/* ====================== Phase 2.4-B: Export ====================== */
.export-row {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #2a2a2a);
}
.export-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted, #aaa);
  margin-bottom: 6px;
}
.export-buttons {
  display: flex;
  gap: 6px;
}
.btn-export {
  flex: 1;
  background: rgba(255,255,255,0.05);
  color: var(--text, #ddd);
  border: 1px solid var(--border, #2a2a2a);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-export:hover {
  background: rgba(255,255,255,0.1);
  border-color: #4a6580;
}
.btn-export:disabled {
  opacity: 0.5;
  cursor: wait;
}
.export-status {
  display: block;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted, #aaa);
}
.export-status.error-msg {
  color: #ff8a99;
}

/* ====================== Phase 2.4-D: Export-Filter ====================== */
.export-filters {
  margin: 8px 0;
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 4px;
  font-size: 0.85rem;
}
.export-filters > summary {
  cursor: pointer;
  user-select: none;
  color: var(--text-muted, #aaa);
  padding: 2px 0;
}
.export-filters[open] > summary {
  margin-bottom: 6px;
  color: var(--text, #ddd);
}
.filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 6px 0;
}
.filter-grid label {
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
  color: var(--text-muted, #aaa);
  gap: 2px;
}
.filter-grid input,
.filter-grid select {
  padding: 4px 6px;
  background: rgba(0,0,0,0.2);
  color: var(--text, #ddd);
  border: 1px solid var(--border, #333);
  border-radius: 3px;
  font-size: 0.85rem;
}
.btn-subtle.small {
  font-size: 0.78rem;
  padding: 3px 8px;
}
.filter-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  font-style: italic;
}

/* ====================== Phase 2.5-C: Import-UI ====================== */
.import-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #2a2a2a);
}
.import-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted, #aaa);
  margin-bottom: 6px;
}
.import-buttons {
  display: flex;
  gap: 6px;
}
.btn-import {
  flex: 1;
  background: rgba(96, 165, 250, 0.08);
  color: var(--text, #ddd);
  border: 1px solid #3b5876;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-import:hover {
  background: rgba(96, 165, 250, 0.18);
  border-color: #5a85b3;
}
.import-status {
  display: block;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted, #aaa);
}

.import-dropzone {
  border: 2px dashed #4a6580;
  border-radius: 6px;
  padding: 18px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  margin: 10px 0;
  transition: background 0.15s, border-color 0.15s;
}
.import-dropzone.dragover {
  background: rgba(96, 165, 250, 0.15);
  border-color: #6aa0d8;
}
.import-dropzone .dz-hint {
  color: var(--text-muted, #aaa);
  margin: 0 0 8px 0;
  font-size: 0.9rem;
}
.import-file-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
  text-align: left;
  max-height: 140px;
  overflow-y: auto;
}
.import-file-list li {
  padding: 3px 6px;
  font-size: 0.85rem;
  color: var(--text, #ddd);
  background: rgba(255,255,255,0.03);
  border-radius: 3px;
  margin-bottom: 2px;
}
.dz-size {
  color: var(--text-muted, #888);
  font-size: 0.78rem;
  margin-left: 4px;
}

.import-fieldset {
  margin: 10px 0;
  padding: 8px 10px;
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
}
.import-fieldset > legend {
  padding: 0 6px;
  font-size: 0.85rem;
  color: var(--text-muted, #aaa);
}
.import-fieldset label {
  display: block;
  padding: 3px 0;
  font-size: 0.88rem;
  color: var(--text, #ddd);
  cursor: pointer;
}
.import-fieldset input[type="radio"] {
  margin-right: 6px;
}
.import-fieldset select {
  display: block;
  margin-top: 4px;
  padding: 4px 6px;
  background: rgba(0,0,0,0.2);
  color: var(--text, #ddd);
  border: 1px solid var(--border, #333);
  border-radius: 3px;
  font-size: 0.85rem;
}

.import-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.import-summary-card {
  text-align: center;
  padding: 10px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border, #2a2a2a);
}
.import-summary-card .card-num {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--text, #ddd);
}
.import-summary-card .card-label {
  font-size: 0.78rem;
  color: var(--text-muted, #aaa);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.import-summary-card.ok    .card-num { color: #7bd87b; }
.import-summary-card.info  .card-num { color: #6aa0d8; }
.import-summary-card.muted .card-num { color: #aaa; }
.import-summary-card.warn  .card-num { color: #ff8a99; }

.import-detail-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.88rem;
}
.import-detail-list li {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border, #222);
  color: var(--text, #ddd);
}
.import-detail-list li.action-imported { color: #7bd87b; }
.import-detail-list li.action-updated  { color: #6aa0d8; }
.import-detail-list li.action-skipped  { color: #aaa; }
.import-detail-list li.action-error    { color: #ff8a99; }

/* ====================== Phase 2.5-D: Preview-Banner ====================== */
.preview-banner {
  margin: 8px 0 12px 0;
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid #b07a23;
  color: #f4c98a;
  font-size: 0.88rem;
}


/* ============================================================
   Audit-Tab (Phase 2.6-C)
   ============================================================ */

.audit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.audit-toolbar .audit-filter {
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
}
.audit-toolbar input[type="text"].audit-filter {
  min-width: 200px;
  flex: 1 1 200px;
}

.audit-table th, .audit-table td {
  font-size: 0.88rem;
  vertical-align: top;
}
.audit-table .audit-ts {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}
.audit-table .audit-ip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
}
.audit-table .audit-details-short {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: #555;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audit-table .audit-row {
  cursor: pointer;
}
.audit-table .audit-row:hover {
  background: rgba(0,0,0,0.04);
}

.audit-anon {
  color: #aaa;
  font-style: italic;
}

/* Action-Tags */
.audit-tag {
  display: inline-block;
  padding: 1px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  border-radius: 999px;
  background: #eee;
  color: #444;
  white-space: nowrap;
}
.audit-tag-auth   { background: #e3eaff; color: #2840a0; }
.audit-tag-entry  { background: #e6f5e0; color: #2a6b1a; }
.audit-tag-import { background: #fff1d6; color: #8a5a00; }
.audit-tag-export { background: #ffe1ee; color: #9a2767; }
.audit-tag-admin  { background: #f3dcff; color: #5b1a85; }

.audit-pager {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.audit-pager .hint {
  margin: 0;
  font-size: 0.85rem;
}

/* Drawer */
.audit-drawer {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: block;
}
.audit-drawer.hidden { display: none; }
.audit-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}
.audit-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 100%);
  background: #fff;
  box-shadow: -2px 0 10px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
}
.audit-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
}
.audit-drawer-header h3 {
  margin: 0;
  font-size: 1.05rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.audit-drawer-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}
.audit-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 0.85rem;
  margin: 0;
}
.audit-dl dt {
  font-weight: 600;
  color: #555;
  font-size: 0.85rem;
  align-self: start;
}
.audit-dl dd {
  margin: 0;
  font-size: 0.92rem;
  word-break: break-word;
}
.audit-pre {
  margin: 0;
  padding: 0.5rem 0.6rem;
  background: #f6f6f6;
  border: 1px solid #e6e6e6;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

@media (prefers-color-scheme: dark) {
  .audit-table .audit-row:hover { background: rgba(255,255,255,0.06); }
  .audit-pre {
    background: #20242b;
    border-color: #2b323d;
    color: #d4dae4;
  }
  .audit-drawer-panel { background: #15181d; }
  .audit-drawer-header { border-bottom-color: #2b323d; }
  .audit-tag         { background: #2b323d; color: #c8d0dc; }
  .audit-tag-auth    { background: #1f2a55; color: #c5d0ff; }
  .audit-tag-entry   { background: #1f3a1d; color: #c8e8c0; }
  .audit-tag-import  { background: #443410; color: #f1d59c; }
  .audit-tag-export  { background: #3d1f30; color: #f4c8db; }
  .audit-tag-admin   { background: #341846; color: #dcc4f0; }
  .audit-table .audit-details-short { color: #a8b1be; }
  .audit-table .audit-ip { color: #777f8a; }
}


/* History-Modal (Phase 2.6-D) */
.entry-history-body {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.5rem 0;
}
.hist-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.hist-item {
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid #eee;
}
.hist-item:last-child { border-bottom: 0; }
.hist-line1 {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
}
.hist-ts {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #666;
  white-space: nowrap;
}
.hist-actor { font-weight: 600; }
.hist-details {
  margin-top: 0.25rem;
  margin-left: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  color: #555;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}
.hist-kv { white-space: nowrap; }
.hist-note {
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #fff7e0;
  border-left: 3px solid #d99a00;
  font-size: 0.88rem;
}
@media (prefers-color-scheme: dark) {
  .hist-item    { border-bottom-color: #2b323d; }
  .hist-ts      { color: #a8b1be; }
  .hist-details { color: #a8b1be; }
  .hist-note    { background: #3a2a05; border-left-color: #d99a00; color: #f1d59c; }
}

/* ============================================================
   Phase 2.7-C: Tag-Verwaltung
   ============================================================ */
.tags-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.tags-toolbar input,
.tags-toolbar select {
  min-width: 12ch;
}
.tags-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tags-table .actions {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.tags-table .tag-row td {
  vertical-align: middle;
}
.tag-name {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.18);
  font-size: 0.95em;
}
.modal-narrow {
  max-width: 480px;
}
.tag-merge-sources {
  list-style: none;
  margin: 0; padding: 0.4rem 0.6rem;
  background: rgba(127, 127, 127, 0.10);
  border-radius: 6px;
  max-height: 14em;
  overflow-y: auto;
}
.tag-merge-sources li {
  padding: 0.15rem 0;
  font-family: var(--font-mono, monospace);
}
.form-error {
  color: #c33;
  margin: 0.4rem 0 0 0;
  font-size: 0.9em;
}



/* ============================================================
   Phase 2.8-B: Bulk-Selection (Multi-Select in der Bibliothek)
   ============================================================ */

/* Bulk-Bar über dem Karten-Grid */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem 0;
  padding: 0.4rem 0;
  flex-wrap: wrap;
}
.bulk-bar .bulk-bar-info {
  margin-left: auto;
  font-size: 0.9em;
  opacity: 0.8;
}

/* Karten-Layout um Checkbox erweitern */
.entry-card {
  position: relative;
}
.entry-card .bulk-checkbox {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  width: 1.15rem;
  height: 1.15rem;
  cursor: pointer;
  z-index: 2;
  margin: 0;
}
.entry-card.is-selected {
  outline: 2px solid var(--accent, #c39b6a);
  outline-offset: -2px;
}
.entry-card .entry-card-title,
.entry-card .entry-card-meta,
.entry-card .entry-card-preview {
  margin-left: 1.6rem;
}
.entry-card .tag-list {
  margin-left: 1.6rem;
}

/* Sticky Status-Footer */
.bulk-status-footer {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: var(--bg-elev, #2b2317);
  color: var(--fg, #f0e6d2);
  border: 1px solid var(--border, #4a3a22);
  border-radius: 0.5rem;
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  z-index: 100;
  max-width: calc(100% - 2rem);
}
.bulk-status-footer.hidden { display: none; }
.bulk-status-footer .bulk-footer-text {
  font-weight: 600;
}
.bulk-status-footer .bulk-footer-actions {
  display: flex;
  gap: 0.5rem;
}


/* ============================================================
   Phase 2.8-C: Bulk-Action-Modal
   ============================================================ */
.bulk-action-sub {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--accent, #c39b6a);
  background: rgba(195,155,106,0.06);
  border-radius: 0.25rem;
}
.bulk-confirm-warn {
  color: #d97;
  font-weight: 600;
  margin-top: 0.5rem;
}
.bulk-result { margin-top: 0.75rem; }
.bulk-result-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0 0;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.92em;
  border: 1px solid var(--border, #4a3a22);
  border-radius: 0.3rem;
}
.bulk-result-list li {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.bulk-result-list li:last-child { border-bottom: none; }
.bulk-result-list li.ok    { color: #9c9; }
.bulk-result-list li.err   { color: #d97; }


/* ============================================================
   Phase 2.9-C: Wiki-Links + Backlinks-Section
   ============================================================ */

/* Wiki-Link im Eintragsinhalt */
.wiki-link {
  color: var(--accent, #c39b6a);
  text-decoration: underline;
  cursor: pointer;
}
.wiki-link:hover { filter: brightness(1.15); }

.wiki-link-dead {
  color: rgba(195,155,106,0.55);
  text-decoration: underline dashed rgba(195,155,106,0.5);
  cursor: help;
}
.wiki-link-dead:hover { filter: none; }

/* Im <pre>-Block gerenderter Inhalt (Forward-Links setzen den HTML-Inhalt
   aktiv, daher müssen wir 'pre' weichmachen) */
pre.entry-content-display {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Forward-/Backlinks-Sections */
.entry-links-section {
  margin-top: 1rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border, #4a3a22);
}
.entry-links-headline {
  font-size: 1em;
  margin: 0 0 0.4rem 0;
  font-weight: 600;
  opacity: 0.92;
}
.entry-links-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
.entry-links-list li {
  padding: 0.25rem 0;
  font-size: 0.95em;
}
.entry-links-list li .link-owner {
  opacity: 0.65;
  font-size: 0.88em;
  margin-left: 0.4rem;
}
.entry-links-list li.empty {
  opacity: 0.6;
  font-style: italic;
}
