:root {
  --bg: #f7f6f3;
  --card-bg: #ffffff;
  --text: #23211d;
  --muted: #6b6558;
  --border: #e4e0d6;
  --accent: #a15c2c;
  --accent-hover: #874a22;
  --danger: #b33a3a;
  --danger-hover: #932f2f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a17;
    --card-bg: #26231f;
    --text: #ede9e1;
    --muted: #a89f8e;
    --border: #3a352c;
    --accent: #d98a4f;
    --accent-hover: #e39a63;
    --danger: #e06666;
    --danger-hover: #e88080;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

.brand-title { font-size: 1.3rem; margin: 0; }

/* Titel/Info/Suche sitzen NICHT im Header-Balken, sondern direkt über der
   Trivia-Liste, im normalen Seitenhintergrund. */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  margin-bottom: 1rem;
}

#pageTitleDisplay { font-size: 1.05rem; font-weight: 600; margin: 0; }

.list-toolbar-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem 1rem;
}

.title-row { display: flex; }

.title-display,
.title-edit {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.title-edit input[type="text"] {
  width: auto;
  min-width: 10rem;
  margin-top: 0;
}

.info-popover { position: relative; }
.info-popover summary {
  cursor: pointer;
  list-style: none;
  font-size: 1.1rem;
}
.info-popover summary::-webkit-details-marker { display: none; }
.info-content {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  margin-top: .4rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  width: max-content;
  max-width: min(32rem, 90vw);
}
.info-content ul { margin: .25rem 0 .75rem 1.2rem; padding: 0; }
.info-content li { margin-bottom: .25rem; }

.list-search {
  width: auto;
  max-width: 220px;
  margin-top: 0;
  flex-shrink: 0;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}

.hint { color: var(--muted); font-size: .9rem; }

.form-card { margin-bottom: 1.5rem; }
.form-card h2 { margin-top: 0; }

input, textarea, button {
  font-family: inherit;
  font-size: 1rem;
}

input[type="text"],
input[type="password"],
input[type="search"],
textarea {
  width: 100%;
  margin-top: .3rem;
  padding: .55rem .7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

textarea { resize: vertical; }

#fContent { min-height: 5rem; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row .grow { flex: 1 1 200px; }

.form-actions { align-items: center; }

button {
  padding: .55rem 1.1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover { background: var(--border); }
button.danger { background: var(--danger); }
button.danger:hover { background: var(--danger-hover); }
button.small { padding: .3rem .65rem; font-size: .85rem; }

.hidden { display: none !important; }

.error {
  color: var(--danger);
  font-size: .9rem;
}

.trivia-list {
  list-style: disc;
  margin: 1.5rem 0;
  padding-left: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.trivia-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .7rem 1rem;
  margin-left: -.3rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
}

.trivia-item .trivia-text {
  flex: 1 1 260px;
  white-space: pre-wrap;
}

.trivia-item.editing {
  flex-direction: column;
  align-items: stretch;
}

.trivia-edit-textarea {
  min-height: 4.5rem;
}

.trivia-item-actions {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  padding: 1rem;
}

.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: .6rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.toast.show { opacity: 1; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  max-width: 360px;
  width: 100%;
}
.modal-box h3 { margin-top: 0; margin-bottom: .3rem; }
.modal-box input[type="password"] { margin-top: .5rem; }

/* Danger Zone: erst sichtbar, nachdem das Admin-Passwort einmal per
   POST /api/admin/login geprüft wurde. */
.admin-danger-zone {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: .5rem;
}
#adminActionsView { flex-direction: column; align-items: stretch; }
#adminActionsView button { width: 100%; }
