:root {
  --navy: #0b1f3a;
  --navy-2: #12305a;
  --cyan: #22d3ee;
  --cyan-dark: #0891b2;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #17263d;
  --muted: #64748b;
  --border: #dbe4f0;
  --danger: #dc2626;
  --success: #059669;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(11, 31, 58, 0.08), 0 4px 16px rgba(11, 31, 58, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  flex-wrap: wrap;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.12em;
}
.brand-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cyan);
}
.topbar nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
}
.topbar nav a { color: #cbe9f4; text-decoration: none; }
.topbar nav a:hover { color: var(--cyan); }
.nav-user { color: #9fb3d1; }
.nav-user strong { color: #fff; }

/* ---------- Flash ---------- */
.flash {
  max-width: 860px;
  margin: 16px auto -8px;
  padding: 10px 16px;
  background: #e6fbf3;
  border: 1px solid #a7e8d0;
  color: #065f46;
  border-radius: var(--radius);
  font-size: 0.92rem;
}

/* ---------- Cards ---------- */
.intro-card, .page-card, .outro-card, .auth-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 28px;
}
.intro-card h1, .page-card h1 { margin: 0 0 12px; font-size: 1.45rem; color: var(--navy); }
.greeting { font-weight: 600; }
.outro-card { border-left: 4px solid var(--cyan); }
.outro-card h3 { margin-top: 0; color: var(--navy); }

.auth-card {
  max-width: 420px;
  margin: 8vh auto 0;
}
.auth-card h1 { margin: 0 0 8px; font-size: 1.3rem; color: var(--navy); }

/* ---------- Progress ---------- */
.progress {
  margin-top: 18px;
  position: relative;
  background: #e6edf7;
  border-radius: 999px;
  height: 28px;
  overflow: hidden;
}
.progress-bar {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--cyan-dark), var(--cyan));
  transition: width 0.3s;
}
.progress-label {
  position: relative;
  display: block;
  text-align: center;
  font-size: 0.82rem;
  line-height: 28px;
  font-weight: 600;
  color: var(--navy);
}

/* ---------- Sektionen ---------- */
.agenda-section { margin-bottom: 36px; }
.agenda-section h2 {
  font-size: 1.15rem;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
}
.section-num {
  background: var(--navy);
  color: var(--cyan);
  width: 28px; height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex: none;
}
.section-intro { margin: 0 0 14px; color: var(--muted); font-size: 0.92rem; }

/* ---------- Item-Cards ---------- */
.item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.item[open] { border-color: var(--cyan-dark); }
.item.done { background: #f6fdf9; }
.item summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-radius: calc(var(--radius) - 1px);
}
.item[open] summary { border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.item summary::-webkit-details-marker { display: none; }
.item summary:hover { background: #f8fafd; }
.status {
  width: 22px; height: 22px; flex: none;
  border: 2px solid var(--border);
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.item.done .status { background: var(--success); border-color: var(--success); }
.item-title { font-weight: 600; flex: 1 1 auto; }
.item.done .item-title { color: var(--success); }
.item-meta { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.item-body { padding: 4px 18px 20px; border-top: 1px solid var(--border); }
.item-text { color: var(--text); }

/* ---------- Badges ---------- */
.badge {
  flex: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--muted);
}

/* Phasen-Erklärung als Tooltip am Badge (Hover, Fokus, Klick) */
.badge[data-hint] { position: relative; cursor: help; }
.badge[data-hint]::after {
  content: attr(data-hint);
  position: absolute;
  left: 0;
  top: calc(100% + 7px);
  background: var(--navy);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: normal;
  padding: 5px 10px;
  border-radius: 7px;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 30;
}
.badge[data-hint]::before {
  content: '';
  position: absolute;
  left: 14px;
  top: calc(100% + 3px);
  width: 8px;
  height: 8px;
  background: var(--navy);
  transform: rotate(45deg) translateY(-2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 31;
}
.badge[data-hint]:hover::after,
.badge[data-hint]:focus-visible::after,
.badge[data-hint].hint-open::after {
  opacity: 1;
  transform: translateY(0);
}
.badge[data-hint]:hover::before,
.badge[data-hint]:focus-visible::before,
.badge[data-hint].hint-open::before {
  opacity: 1;
}
.phase-P0 { background: #e11d48; }
.phase-P1 { background: #d97706; }
.phase-P2 { background: var(--cyan-dark); }
.phase-P3 { background: #7c3aed; }
.phase-P4 { background: var(--success); }
.phase-Laufend { background: #64748b; }

/* ---------- Done-Row ---------- */
.done-row { margin: 10px 0 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-done {
  background: #fff;
  color: var(--success);
  border: 1.5px solid var(--success);
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-done:hover { background: #ecfdf5; }
.done-info { color: var(--success); font-weight: 600; font-size: 0.9rem; }

/* ---------- Thread ---------- */
.thread-section h4, .docs-section h4 {
  margin: 20px 0 10px;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.thread { list-style: none; margin: 0 0 14px; padding: 0; }
.fb {
  background: #f8fafd;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.fb.mine { border-left: 3px solid var(--cyan); }
.fb-head { font-size: 0.82rem; color: var(--muted); margin-bottom: 4px; }
.fb-head strong { color: var(--navy); }
.edited { font-style: italic; }
.fb-body { white-space: normal; overflow-wrap: anywhere; }
.edit-box { margin-top: 8px; font-size: 0.85rem; }
.edit-box summary { cursor: pointer; color: var(--cyan-dark); }
.edit-box textarea { margin-top: 8px; }

/* ---------- Dokumente ---------- */
.docs { list-style: none; margin: 0 0 14px; padding: 0; }
.doc {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
  background: #f8fafd;
}
.doc-name { font-weight: 600; color: var(--navy-2); text-decoration: none; overflow-wrap: anywhere; }
.doc-name:hover { color: var(--cyan-dark); text-decoration: underline; }
.doc-meta { color: var(--muted); font-size: 0.8rem; }
.delete-form { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- Formulare ---------- */
label { display: block; margin-bottom: 12px; font-size: 0.9rem; font-weight: 600; color: var(--navy); }
input, textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 12px;
  font: inherit;
  font-weight: 400;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
input:focus, textarea:focus { outline: none; border-color: var(--cyan-dark); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2); }
textarea { min-height: 84px; resize: vertical; }
input[type="file"] { border-style: dashed; padding: 14px 12px; }

button {
  font: inherit;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--navy);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
}
button:hover { border-color: var(--cyan-dark); color: var(--cyan-dark); }
button.primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
button.primary:hover { background: var(--navy-2); color: var(--cyan); }
button.danger { border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: #fef2f2; }
button.small, .small { font-size: 0.8rem; padding: 4px 10px; }
button.linklike {
  border: none; background: none; padding: 0;
  color: var(--cyan-dark);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
}
.topbar button.linklike { color: #cbe9f4; }
.topbar button.linklike:hover { color: var(--cyan); }
.form-row { display: flex; align-items: center; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.fb-form textarea { margin-top: 0; }
.inline { display: inline; }

.hint { color: var(--muted); font-size: 0.8rem; }
.muted { color: var(--muted); }
.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

/* ---------- Einladungen ---------- */
.invite-form { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 22px; }
.invite-form input { flex: 1 1 240px; margin-top: 0; }
.invite-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.invite-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  padding: 8px 10px;
}
.invite-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.invite-link {
  display: inline-block;
  max-width: 320px;
  overflow-wrap: anywhere;
  background: #f1f5fb;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
}
.tag { font-size: 0.78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.tag.open { background: #ecfeff; color: var(--cyan-dark); border: 1px solid #a5f3fc; }
.tag.used { background: #f1f5f9; color: var(--muted); border: 1px solid var(--border); }

.btn {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
}

.page-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 24px 16px 32px;
}

@media (max-width: 600px) {
  .item summary { flex-wrap: wrap; }
  .item-meta { width: 100%; padding-left: 32px; }
  .auth-card { margin-top: 4vh; }
}

/* ---------- Chat ---------- */
:root { --chat-w: clamp(480px, 38vw, 640px); }
body.chat-anim { transition: padding-right 0.25s ease; }
body.chat-sidebar-open { padding-right: var(--chat-w); }

.chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 18px 8px 8px;
  box-shadow: 0 4px 20px rgba(11, 31, 58, 0.35);
  cursor: pointer;
}
.chat-launcher:hover { background: var(--navy-2); color: #fff; }
.chat-launcher.hidden { display: none; }
.chat-launcher-label { font-weight: 600; }
.chat-avatar {
  position: relative;
  width: 34px; height: 34px;
  background: var(--cyan-dark);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.chat-dot {
  position: absolute;
  right: -1px; bottom: -1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid var(--navy);
  background: #94a3b8;
}
.chat-dot.on { background: #22c55e; }
.chat-dot.off { background: #94a3b8; }
.chat-unread-total {
  display: none;
  background: #e11d48;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
  padding: 2px 6px;
}
.chat-unread-total.visible { display: inline-block; }

/* Panel (kleines Overlay) */
.chat-panel {
  display: none;
  position: fixed;
  right: 20px;
  bottom: 84px;
  z-index: 95;
  width: 340px;
  height: min(480px, calc(100vh - 120px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(11, 31, 58, 0.25);
  flex-direction: column;
  overflow: hidden;
}
.chat-panel.open { display: flex; }
.chat-panel-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* Sidebar-Sheet */
.chat-sidebar {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 95;
  width: var(--chat-w);
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(11, 31, 58, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
}
body.chat-anim .chat-sidebar { transition: transform 0.25s ease; }
body.chat-sidebar-open .chat-sidebar { transform: none; }
.chat-sidebar-body {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
}
.chat-sidebar-body .chat-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
@media (max-width: 900px) {
  :root { --chat-w: 100vw; }
  body.chat-sidebar-open { padding-right: 0; }
  .chat-sidebar-body { grid-template-columns: 180px 1fr; }
}

/* Kopfzeile */
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--navy);
  color: #fff;
  padding: 10px 14px;
  flex: none;
}
.chat-header-title { font-weight: 700; letter-spacing: 0.04em; }
.chat-header-spacer { flex: 1; }
.chat-iconbtn {
  background: none;
  border: none;
  color: #cbe9f4;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.chat-iconbtn:hover { background: var(--navy-2); color: var(--cyan); }

/* Konversationsliste */
.chat-list { display: flex; flex-direction: column; overflow-y: auto; flex: 1; min-height: 0; }
.chat-conv {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text);
  border-radius: 0;
}
.chat-conv:hover { background: #f4f9fc; border-color: var(--border); }
.chat-conv.active { background: #e9f7fb; }
.chat-conv-avatar {
  position: relative;
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--cyan);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.chat-conv-avatar .chat-dot { border-color: #fff; }
.chat-conv-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-conv-title { font-weight: 600; font-size: 0.9rem; }
.chat-conv-preview {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.chat-conv-preview.empty { font-style: italic; }
.chat-conv-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.chat-conv-time { font-size: 0.7rem; color: var(--muted); }
.chat-unread {
  background: #e11d48;
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
  padding: 1px 5px;
}

/* Raum */
.chat-room { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-room-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.chat-room-header .chat-iconbtn { color: var(--navy); font-size: 1.3rem; }
.chat-room-header .chat-iconbtn:hover { background: #eef4fb; color: var(--cyan-dark); }
.chat-room-title { font-weight: 700; color: var(--navy); }
.chat-presence { font-size: 0.75rem; }
.chat-presence.on { color: #16a34a; }
.chat-presence.off { color: var(--muted); }

.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f6f9fc;
  min-height: 0;
}
.chat-empty { color: var(--muted); font-size: 0.85rem; text-align: center; margin: auto; }
.chat-older {
  align-self: center;
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: 999px;
}
.chat-bubble-row { display: flex; }
.chat-bubble-row.mine { justify-content: flex-end; }
.chat-bubble {
  max-width: 82%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  padding: 7px 11px;
}
.chat-bubble-row.mine .chat-bubble {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  border-radius: 12px 12px 4px 12px;
}
.chat-bubble-from { font-size: 0.72rem; font-weight: 700; color: var(--cyan-dark); margin-bottom: 2px; }
.chat-bubble-body { font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-bubble-time { font-size: 0.66rem; color: var(--muted); text-align: right; margin-top: 3px; }
.chat-bubble-row.mine .chat-bubble-time { color: #9fb3d1; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  flex: none;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  margin: 0;
  min-height: 38px;
  max-height: 120px;
  resize: none;
  font-size: 0.9rem;
}
.chat-send {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  flex: none;
}
.chat-send:hover { background: var(--navy-2); color: var(--cyan); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 600px) {
  .chat-panel { right: 10px; left: 10px; width: auto; }
}
