:root {
  --bg1: #134e4a;
  --bg2: #1e3a5f;
  --col: #eef0f3;
  --card: #ffffff;
  --text: #172b4d;
  --muted: #5e6c84;
  --line: #dfe1e6;
  --accent: #0f766e;
  --accent-2: #0d9488;
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 1px rgba(9,30,66,.18), 0 0 1px rgba(9,30,66,.2);
  --col-w: 300px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: linear-gradient(135deg, var(--bg1), var(--bg2)) fixed;
  display: flex; flex-direction: column;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600;
  background: #e9ecef; color: var(--text); display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: #dde1e6; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.danger:hover { background: #fdecea; }
.btn.ghost { background: rgba(255,255,255,.16); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.26); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.icon-btn {
  border: 0; background: transparent; border-radius: 8px; width: 32px; height: 32px;
  display: inline-grid; place-items: center; color: var(--muted); font-size: 16px;
}
.icon-btn:hover { background: rgba(9,30,66,.08); color: var(--text); }
.pill {
  background: rgba(255,255,255,.25); border-radius: 999px; padding: 0 7px; font-size: 12px; min-width: 20px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(0,0,0,.22); color: #fff; flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
#search {
  flex: 1 1 auto; min-width: 0; width: 100%; max-width: 320px; margin-left: auto; border: 0; border-radius: 8px;
  padding: 8px 12px; background: rgba(255,255,255,.18); color: #fff;
}
#search::placeholder { color: rgba(255,255,255,.75); }
#search:focus { outline: none; background: #fff; color: var(--text); }
.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 42px; background: #fff; color: var(--text); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); min-width: 200px; padding: 6px; z-index: 50;
}
.menu-head { padding: 8px 10px; font-weight: 700; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 6px; }
.menu button:hover { background: #f1f2f4; }
.menu form { margin: 0; }

/* ---------- Avatare ---------- */
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700; border: 0; flex: 0 0 auto; background: #64748b;
}
.avatar.me { width: 34px; height: 34px; font-size: 14px; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.avatars { display: flex; gap: 4px; margin-left: auto; }

/* ---------- Board ---------- */
.board {
  flex: 1 1 auto; display: flex; align-items: flex-start; gap: 14px;
  padding: 16px; overflow-x: auto; overflow-y: hidden;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.column {
  flex: 0 0 var(--col-w); width: var(--col-w); max-height: 100%;
  background: var(--col); border-radius: var(--radius); display: flex; flex-direction: column;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.col-head { display: flex; align-items: center; gap: 6px; padding: 12px 10px 6px 14px; }
.col-head h2 { font-size: 15px; margin: 0; flex: 1; }
.col-count { color: var(--muted); font-size: 13px; font-weight: 600; margin-right: 2px; }
.cards {
  flex: 1 1 auto; overflow-y: auto; padding: 4px 8px 4px; min-height: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.col-foot { padding: 6px 8px 10px; }
.add-card-btn {
  width: 100%; text-align: left; border: 0; background: transparent; color: var(--muted);
  padding: 8px 8px; border-radius: 8px; font-weight: 600;
}
.add-card-btn:hover { background: rgba(9,30,66,.08); color: var(--text); }
.add-form textarea {
  width: 100%; border: 0; border-radius: 8px; padding: 8px 10px; resize: none; box-shadow: var(--shadow);
  min-height: 58px; margin-bottom: 6px;
}
.add-form .row { display: flex; gap: 6px; align-items: center; }

/* ---------- Karten ---------- */
.card {
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow); cursor: pointer;
  overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  flex: 0 0 auto; position: relative; -webkit-tap-highlight-color: transparent;
}
.card:hover { box-shadow: 0 0 0 2px var(--accent-2); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card .cover { display: block; width: 100%; max-height: 180px; object-fit: cover; background: #ddd; pointer-events: none; }
.card .inner { padding: 9px 11px 9px; }
.card .title { font-size: 15px; line-height: 1.3; word-wrap: break-word; }
.card .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.card .meta:empty { display: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 5px; }
.badge.date { background: #f1f2f4; }
.badge.date.soon { background: #fef3c7; color: #92400e; }
.badge.date.today { background: #fde2e1; color: #b42318; font-weight: 600; }
.badge.date.past { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }
.card.hidden-by-search { display: none; }

/* Drag & Drop */
.placeholder { border-radius: 10px; background: rgba(9,30,66,.12); flex: 0 0 auto; }
.drag-ghost {
  position: fixed; z-index: 1000; pointer-events: none; transform: rotate(3deg);
  box-shadow: 0 12px 28px rgba(0,0,0,.3); opacity: .95;
}
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 40px 12px;
}
.modal {
  background: #f8f9fa; border-radius: 14px; width: 100%; max-width: 720px; position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,.35); overflow: hidden;
}
.modal .m-cover { width: 100%; max-height: 260px; object-fit: contain; background: #1f2937; display: block; }
.modal .m-body { padding: 18px 20px 20px; }
.modal .m-close { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.9); z-index: 2; }
.modal h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 8px; }
.m-title {
  width: 100%; font-size: 20px; font-weight: 700; border: 2px solid transparent; border-radius: 8px;
  background: transparent; padding: 4px 6px; resize: none; overflow: hidden; margin-right: 36px;
}
.m-title:hover { background: #fff; }
.m-title:focus { border-color: var(--accent); background: #fff; outline: none; }
.m-sub { color: var(--muted); font-size: 14px; padding: 0 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.m-sub select { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; background: #fff; }
.archived-note { background: #fff7d6; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.field-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field-row label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.field-row input { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; min-width: 0; }
.members { display: flex; gap: 8px; flex-wrap: wrap; }
.member-toggle {
  display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--line); background: #fff;
  border-radius: 999px; padding: 3px 12px 3px 3px; font-weight: 600;
}
.member-toggle.on { border-color: var(--accent); background: #e6f4f1; }
.member-toggle:not(.on) .avatar { opacity: .4; }
.desc-view {
  background: #fff; border-radius: 8px; padding: 10px 12px; min-height: 48px; white-space: pre-wrap;
  word-wrap: break-word; line-height: 1.5; cursor: text; border: 1px solid var(--line);
}
.desc-view.empty { color: var(--muted); }
.desc-view a { color: #0c66e4; }
.desc-edit textarea {
  width: 100%; min-height: 140px; border: 2px solid var(--accent); border-radius: 8px; padding: 10px 12px;
  line-height: 1.5; resize: vertical; background: #fff;
}
.desc-edit .row { display: flex; gap: 8px; margin-top: 6px; }
.attachments { display: flex; flex-direction: column; gap: 8px; }
.att {
  display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 8px; padding: 8px;
  border: 1px solid var(--line);
}
.att .thumb {
  width: 64px; height: 48px; border-radius: 6px; flex: 0 0 auto; display: grid; place-items: center;
  background: #e9ecef; color: var(--muted); font-weight: 700; font-size: 12px; overflow: hidden; text-decoration: none;
}
.att .thumb img { width: 100%; height: 100%; object-fit: cover; }
.att .info { flex: 1 1 auto; min-width: 0; }
.att .name { font-weight: 600; color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .name:hover { text-decoration: underline; }
.att .sub { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.att .sub button, .att .sub a { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; font-size: 12px; }
.att .sub button:hover, .att .sub a:hover { color: var(--text); }
.dropzone {
  border: 2px dashed #c1c7d0; border-radius: 10px; padding: 14px; text-align: center; color: var(--muted);
  font-size: 14px; margin-top: 8px;
}
.dropzone.over { border-color: var(--accent); background: #e6f4f1; color: var(--accent); }
.dropzone .btn { margin-top: 6px; }
.m-foot { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); }
.meta-small { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* Archiv / Dialoge */
.modal.narrow { max-width: 460px; }
.modal h2 { margin: 0 0 12px; font-size: 20px; }
.archive-search { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; }
.archive-list { display: flex; flex-direction: column; gap: 8px; }
.archive-item {
  display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 8px; padding: 10px 12px;
  border: 1px solid var(--line); cursor: pointer;
}
.archive-item:hover { border-color: var(--accent); }
.archive-item .t { flex: 1; min-width: 0; }
.archive-item .t b { display: block; font-weight: 600; }
.archive-item .t small { color: var(--muted); }
.empty-note { color: var(--muted); text-align: center; padding: 24px; }
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.form-stack input, .form-stack select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--text); }
.map-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.map-row span { flex: 1; }
.map-row select { border: 1px solid var(--line); border-radius: 6px; padding: 5px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2937; color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 300; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 90vw;
}
.toast.error { background: var(--danger); }

/* ---------- Login / Setup ---------- */
.login-page { display: grid; place-items: center; overflow: auto; padding: 20px; }
.login-box {
  background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-box h1 { margin: 0; text-align: center; font-size: 22px; }
.login-logo { width: 56px; height: 56px; margin: 0 auto; }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.login-box input { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 16px; color: var(--text); }
.login-box input[type=color] { padding: 2px; height: 42px; width: 60px; }
.login-box .btn { justify-content: center; padding: 11px; font-size: 16px; }
.login-error { background: #fdecea; color: var(--danger); padding: 8px 12px; border-radius: 8px; margin: 0; font-size: 14px; }
.setup-box { max-width: 560px; }
.setup-box fieldset { border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.setup-box legend { font-weight: 700; padding: 0 6px; }
.row2 { display: flex; gap: 10px; }
.row2 label { flex: 1; }
.row2 label.short { flex: 0 0 72px; }
.checks { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.checks .ok { color: #15803d; }
.checks .bad { color: var(--danger); font-weight: 600; }

/* ---------- Handy ---------- */
@media (max-width: 640px) {
  :root { --col-w: 86vw; }
  .board { scroll-snap-type: x mandatory; padding: 12px; gap: 10px; }
  .column { scroll-snap-align: center; }
  body.dragging .board { scroll-snap-type: none; }
  .brand span { display: none; }
  #search { max-width: none; }
  .topbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  #btn-archive .label { display: none; }
  #btn-archive { padding: 8px 10px; }
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
  .m-body { padding: 16px; }
  .row2 { flex-direction: column; }
  .row2 label.short { flex: 1; }
}
