:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-soft: #ccfbf1;
  --danger: #dc2626;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2e;
    --surface-2: #0f1726;
    --border: #243049;
    --text: #e6edf6;
    --muted: #93a3b8;
    --primary: #2dd4bf;
    --primary-dark: #14b8a6;
    --primary-soft: #134e4a;
    --amber-soft: #422006;
    --red-soft: #450a0a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

/* Stellt sicher, dass das hidden-Attribut immer ausblendet – auch wenn ein
   Element zusätzlich eine Klasse mit display (z. B. grid/flex) hat. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0; }
button { font-family: inherit; cursor: pointer; }

/* ---------------- Buttons / Inputs ---------------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn-sm {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.btn-sm.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-sm:hover { filter: brightness(.97); }
.btn-icon {
  border: none; background: transparent; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 8px;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
select { cursor: pointer; }

.link {
  background: none; border: none; color: var(--primary);
  font-weight: 600; font-size: 13px; padding: 0; cursor: pointer;
}
.link:hover { text-decoration: underline; }

.field { display: block; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.muted { color: var(--muted); }

/* ---------------- Login ---------------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--primary-soft), transparent 60%),
    var(--bg);
}
.login-box { width: 100%; max-width: 400px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand-mark { font-size: 30px; }
.brand h1 { font-size: 22px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.brand.small { gap: 8px; }
.brand.small .brand-mark { font-size: 22px; }
.login-card h2 { font-size: 18px; margin-bottom: 4px; }
.login-card .field { margin-top: 14px; }
.login-card .btn { margin-top: 18px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------------- Topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 860px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
}
.user-area { position: relative; display: flex; align-items: center; gap: 8px; }

/* Glocke / Erwähnungen */
.bell {
  position: relative; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; width: 38px; height: 38px; font-size: 17px; line-height: 1;
  display: grid; place-items: center; color: var(--text);
}
.bell:hover { background: var(--surface-2); }
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--surface);
}
.bell-menu { min-width: 300px; max-width: 340px; max-height: 70vh; overflow: auto; padding: 8px; }
.menu-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .03em; padding: 4px 8px 8px;
}
.bell-empty { padding: 12px 8px; font-size: 13px; }
.bell-item {
  display: flex; gap: 9px; width: 100%; text-align: left; align-items: flex-start;
  background: none; border: none; padding: 9px 8px; border-radius: 8px; color: var(--text);
}
.bell-item:hover { background: var(--surface-2); }
.bi-head { font-size: 12.5px; }
.bi-task { font-size: 13px; font-weight: 600; }
.bi-body { font-size: 12.5px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 4px 12px 4px 4px; font-weight: 600; font-size: 14px;
  color: var(--text);
}
.user-chip:hover { background: var(--surface-2); }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 200px; z-index: 30;
}
.menu button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; color: var(--text);
  padding: 9px 12px; border-radius: 8px; font-size: 14px;
}
.menu button:hover { background: var(--surface-2); }

/* ---------------- Tabs ---------------- */
.tabs { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 53px; z-index: 15; }
.tabs-inner { max-width: 860px; margin: 0 auto; display: flex; gap: 4px; padding: 0 16px; }
.tab {
  background: none; border: none; padding: 13px 14px; font-weight: 600; font-size: 14px;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------------- Container ---------------- */
.container { max-width: 860px; margin: 0 auto; padding: 18px 16px 80px; }

/* ---------------- Composer ---------------- */
.composer { padding: 14px; }
.composer-top { display: flex; gap: 10px; }
.composer-top input { flex: 1; }
.composer-top .btn { white-space: nowrap; }
.toggle { display: inline-block; margin-top: 10px; }
.composer-extra {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px;
  padding-top: 12px; border-top: 1px dashed var(--border);
}

/* ---------------- Filters ---------------- */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 2px 8px; }
.filter { width: auto; min-width: 160px; flex: 1; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.check-inline input { width: auto; }

.archive-tools { padding: 14px; }
.archive-tools .filters { margin-bottom: 0; }

/* ---------------- Feed / Task ---------------- */
.feed { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.task {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.task.done { opacity: .72; }
.task-head { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; }

.check { position: relative; flex: none; width: 22px; height: 22px; margin-top: 1px; }
.check input { position: absolute; opacity: 0; width: 22px; height: 22px; margin: 0; cursor: pointer; }
.check span {
  display: block; width: 22px; height: 22px; border-radius: 7px;
  border: 2px solid var(--border); background: var(--surface); transition: .15s;
}
.check input:checked + span { background: var(--primary); border-color: var(--primary); }
.check input:checked + span::after {
  content: "✓"; color: #fff; font-size: 14px; font-weight: 800;
  position: absolute; left: 4px; top: -1px;
}
.check input:disabled + span { opacity: .5; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; word-wrap: break-word; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.chip.cat { color: var(--primary-dark); background: var(--primary-soft); border-color: transparent; }
.chip.assign { color: var(--text); }
.chip.prio-wichtig { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.chip.prio-dringend { color: var(--danger); background: var(--red-soft); border-color: transparent; }
.chip.due.today { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.chip.due.over { color: var(--danger); background: var(--red-soft); border-color: transparent; }

.task-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-top: 10px; font-size: 12.5px; color: var(--muted);
}
.task-meta .link { margin-left: auto; }
.done-tag { color: var(--primary-dark); font-weight: 600; }

.task-actions { display: flex; gap: 6px; align-items: center; flex: none; }

.avatar {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 999px;
  color: #fff; font-size: 10px; font-weight: 700; flex: none;
}

/* ---------------- Expanded panel ---------------- */
.panel { border-top: 1px solid var(--border); background: var(--surface-2); padding: 14px 16px; }
.edit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed var(--border);
}
.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { display: flex; gap: 9px; }
.comment .c-head { font-size: 12.5px; }
.comment .c-head b { font-size: 13px; }
.comment .c-body { font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.mention {
  color: var(--primary-dark); background: var(--primary-soft);
  border-radius: 5px; padding: 0 3px; font-weight: 600;
}
.mention.me { color: #fff; background: var(--primary); }

/* @-Autovervollständigung */
.mention-pop {
  position: absolute; z-index: 70; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 5px; max-height: 220px; overflow: auto; min-width: 180px;
}
.mp-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; padding: 7px 9px; border-radius: 7px;
  color: var(--text); font-size: 14px; font-weight: 600;
}
.mp-item:hover, .mp-item.active { background: var(--primary-soft); }
.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.comment-form input { flex: 1; }

/* ---------------- Team modal ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .5);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; max-width: 520px;
  max-height: 88vh; overflow: auto; padding: 20px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
}
.team-row.inactive { opacity: .55; }
.team-row > span:first-child { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.team-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.add-user { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.add-user h3 { font-size: 15px; margin-bottom: 10px; }
.add-user-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.add-user-row input[type="text"], .add-user-row input[type="password"] { flex: 1; min-width: 120px; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s; z-index: 60;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); color: #fff; }

/* ---------------- Responsive ---------------- */
@media (max-width: 560px) {
  .composer-extra, .edit-grid { grid-template-columns: 1fr; }
  .composer-top { flex-direction: column; }
  .composer-top .btn { width: 100%; }
  .filter { min-width: 0; }
  .task-actions { flex-direction: column; }
}
