:root {
  --bg: #0f1720;
  --surface: #17212b;
  --surface-2: #1e2a37;
  --border: #2b3a4a;
  --text: #e7eef5;
  --muted: #92a4b5;
  --accent: #ff7a1a;
  --accent-2: #2f81f7;
  --green: #2ea043;
  --green-bg: #133021;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* Muss VOR den .modal/.view-Regeln greifen: hidden immer respektieren. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 19px; margin: 0; font-weight: 650; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* Layout */
.view { max-width: 900px; margin: 22px auto; padding: 0 16px; display: grid; gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.list-head h2 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }

/* Form */
form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
input[type=text], input[type=url], input[type=date], input[type=time], select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); }
textarea { resize: vertical; line-height: 1.6; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.check input { width: auto; margin: 0; }
.check.small { font-size: 13px; margin: 0; }
.conflict { border-radius: 8px; padding: 9px 12px; margin: 0 0 12px; font-size: 13px; line-height: 1.5; }
.conflict.warn { background: #3a2e12; border: 1px solid #7a5c1a; color: #f0c060; }
.conflict.danger { background: #3a1516; border: 1px solid #7a2222; color: #ff8a8a; font-weight: 600; }
.conflict-sub { display: inline-block; margin-top: 4px; font-weight: 400; opacity: 0.85; }
.vorlese { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 4px 0 14px; }
.vorlese legend { padding: 0 6px; font-size: 13px; color: var(--muted); }
.mode-toggle { display: flex; gap: 18px; margin-bottom: 10px; }
.radio { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--text); cursor: pointer; }
.radio input { width: auto; margin: 0; }

/* Buttons */
.actions { display: flex; gap: 10px; }
.btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 9px 18px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn:hover { border-color: var(--accent-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1206; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.danger:hover { border-color: #f85149; color: #f85149; }

/* Planungs-Liste */
.plan-list { display: grid; gap: 8px; }
.plan-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 11px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.plan-when { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; font-size: 14px; }
.plan-main { min-width: 0; }
.plan-thema { font-weight: 600; }
.plan-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-tools { display: flex; gap: 6px; }

/* Moderator */
.mod-list { display: grid; gap: 18px; }
.day-group h3 {
  margin: 0 0 8px; font-size: 14px; color: var(--accent);
  text-transform: capitalize; letter-spacing: .3px;
}
.mod-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 13px 15px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; transition: border-color .15s;
}
.mod-card.done { opacity: .62; }
.mod-time { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mod-body { min-width: 0; }
.mod-thema {
  font-size: 16px; font-weight: 650; cursor: pointer; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.mod-thema:hover { color: var(--accent-2); text-decoration: underline; }
.mod-firma { font-size: 13px; color: var(--muted); }
.badges { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.badge.sold { color: var(--accent); border-color: var(--accent); }
.badge.lueck { color: var(--accent-2); border-color: var(--accent-2); }
.badge.link { color: var(--accent-2); border-color: var(--accent-2); cursor: pointer; text-decoration: none; }
a.badge.link:hover { background: var(--accent-2); color: #0b1220; }
.mod-check { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.done-tag {
  font-size: 12px; color: var(--green); background: var(--green-bg);
  border: 1px solid #1c4a2b; padding: 4px 10px; border-radius: 999px; font-weight: 600; white-space: nowrap;
}

/* Modals */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; width: 100%; max-width: 440px; box-shadow: var(--shadow);
}
.read-box { max-width: 720px; max-height: 88vh; display: flex; flex-direction: column; }
.read-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.read-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.read-head h2 { margin: 4px 0 0; font-size: 22px; }
.read-meta { font-size: 13px; color: var(--muted); }
.read-body {
  overflow-y: auto; font-size: 23px; line-height: 1.85;
  padding-right: 6px; max-width: 62ch; letter-spacing: .2px;
}
.read-body p { margin: 0 0 1.1em; }
.read-body p:last-child { margin-bottom: 0; }
.read-body a { color: var(--accent-2); }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow); z-index: 60; font-size: 14px;
}

.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

/* Nutzerbereich in der Topbar */
.user-area { display: flex; align-items: center; gap: 10px; margin-left: auto; }
#preview-btn.preview-active { border-color: var(--accent); color: var(--accent); }
#user-name { white-space: nowrap; }
.topbar .tabs { margin-left: 8px; }

/* Login-Seite */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow);
}
.brand.center { justify-content: center; margin-bottom: 18px; }
.login-box h2 { margin: 6px 0 16px; font-size: 17px; }
.btn.wide { width: 100%; margin-top: 4px; justify-content: center; }
.linkbtn {
  display: block; margin: 14px auto 0; background: none; border: none; color: var(--accent-2);
  cursor: pointer; font-size: 13px; text-decoration: underline;
}
.login-msg { min-height: 18px; font-size: 13px; margin: 10px 0 0; text-align: center; }
.login-msg.error { color: #f85149; }
.login-msg.ok { color: var(--green); }

/* Admin: Zugangszeilen */
.user-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  padding: 11px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.user-main { min-width: 0; }
.user-email { font-weight: 600; }
.role-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 8px;
  border: 1px solid var(--border); color: var(--muted); }
.role-badge.admin { color: var(--accent); border-color: var(--accent); }

/* ===== Druck / PDF ===== */
#print-area { display: none; }

@media print {
  /* Alles ausblenden, nur den Druckbereich zeigen */
  body > *:not(#print-area) { display: none !important; }
  body { background: #fff; color: #000; }
  #print-area {
    display: block !important;
    color: #111;
    font-family: Arial, Helvetica, sans-serif;
    max-width: 17cm;
    margin: 0 auto;
  }
  .print-kicker {
    font-family: Arial, sans-serif; font-size: 10pt; color: #666; margin-bottom: 6pt;
  }
  #print-thema { font-size: 25pt; line-height: 1.25; margin: 0 0 6pt; font-weight: 700; }
  .print-meta {
    font-family: Arial, sans-serif; font-size: 11pt; color: #555; margin: 0 0 12pt;
  }
  .print-rule { border: none; border-top: 0.75pt solid #999; margin: 0 0 18pt; }
  .print-text { font-size: 15pt; line-height: 1.9; }
  .print-text p { margin: 0 0 12pt; }
  .print-text p:last-child { margin-bottom: 0; }
  .print-foot {
    font-family: Arial, sans-serif; font-size: 9pt; color: #999;
    margin-top: 26pt; border-top: 0.5pt solid #ddd; padding-top: 6pt;
  }
  @page { margin: 2cm; }
}

@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; }
  .mod-card, .plan-row { grid-template-columns: auto 1fr; }
  .mod-check, .plan-tools { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; }
}
