/* === Reset / Basis === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #0f172a;
  color: #e5e7eb;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: #94a3b8; font-size: 14px; }
.error { color: #fca5a5; font-size: 14px; min-height: 18px; margin-top: 8px; }

/* === Login === */
.screen { width: 100%; height: 100dvh; }
#login-screen {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1e293b, #0f172a);
}
.login-card {
  background: #1f2937;
  padding: 28px;
  border-radius: 14px;
  width: min(360px, 90vw);
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-top: 16px;
  background: #0f172a; color: #e5e7eb;
  border: 1px solid #334155; border-radius: 8px; font-size: 16px;
}
.login-card button {
  width: 100%; padding: 12px; margin-top: 12px;
  background: #2563eb; color: white; border: 0;
  border-radius: 8px; font-size: 16px; font-weight: 500; cursor: pointer;
}
.login-card button:hover { background: #1d4ed8; }

/* === App-Layout === */
#app-screen { display: flex; flex-direction: column; }
.topbar {
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: #111827;
  border-bottom: 1px solid #1f2937;
  padding-top: env(safe-area-inset-top);
  height: calc(52px + env(safe-area-inset-top));
}
.brand { font-weight: 600; font-size: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: #cbd5e1; border: 0; cursor: pointer;
}
.icon-btn:hover { background: #1f2937; color: #fff; }
.sync-indicator {
  width: 10px; height: 10px; border-radius: 50%;
  background: #10b981; margin-right: 8px;
  transition: background .2s;
}
.sync-indicator.syncing { background: #f59e0b; }
.sync-indicator.offline { background: #ef4444; }

/* === Board === */
.board {
  flex: 1;
  display: flex; gap: 12px;
  padding: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.column {
  flex: 0 0 300px;
  background: #111827;
  border-radius: 12px;
  display: flex; flex-direction: column;
  max-height: 100%;
  scroll-snap-align: start;
}
.column-header {
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #1f2937;
}
.column-title {
  background: transparent; color: #f3f4f6;
  border: 0; outline: none; font-size: 15px; font-weight: 600;
  flex: 1; padding: 4px;
}
.column-title:focus { background: #0f172a; border-radius: 4px; }
.column-menu {
  background: transparent; color: #94a3b8;
  border: 0; cursor: pointer; padding: 4px 8px; font-size: 18px;
}
.column-menu:hover { color: #fff; }
.cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 40px;
}
.card {
  background: #1f2937;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color .15s;
  user-select: none;
}
.card:hover { border-color: #334155; }
.card.completed { opacity: .55; }
.card.completed .card-title-text { text-decoration: line-through; }
.card-top {
  display: flex; align-items: flex-start; gap: 8px;
}
.card-check {
  flex: 0 0 auto; width: 18px; height: 18px;
  border: 2px solid #475569; border-radius: 4px;
  margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.card-check.done {
  background: #10b981; border-color: #10b981;
}
.card-check.done::after {
  content: ""; width: 4px; height: 8px;
  border: solid white; border-width: 0 2px 2px 0;
  transform: rotate(45deg); margin-bottom: 2px;
}
.card-title-text {
  flex: 1; font-size: 14px; line-height: 1.35;
  word-break: break-word;
}
/* Beschreibungs-Vorschau auf der Karte – einzeilig mit Ellipsis */
.card-desc {
  margin-top: 4px;
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 26px; /* an Titel ausrichten (Checkbox 18px + Gap 8px) */
}

/* Subtasks inline auf der Karte (eingerückt unter dem Titel) */
.card-subtasks {
  margin-top: 8px;
  padding-left: 26px; /* an Titel ausrichten */
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-subtask {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.35;
}
.card-subtask-check {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border: 1.5px solid #475569;
  border-radius: 3px;
  margin-top: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.card-subtask-check.done {
  background: #10b981;
  border-color: #10b981;
}
.card-subtask-check.done::after {
  content: "";
  width: 3px;
  height: 6px;
  border: solid white;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  margin-bottom: 1px;
}
.card-subtask-title {
  flex: 1;
  word-break: break-word;
}
.card-subtask.done .card-subtask-title {
  text-decoration: line-through;
  color: #64748b;
}
.card-meta {
  margin-top: 8px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  font-size: 12px; color: #94a3b8;
}
.label-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; color: #fff; font-weight: 500;
}
.due {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px; border-radius: 4px;
  background: #0f172a;
}
.due.overdue { background: #7f1d1d; color: #fee2e2; }
.due.soon    { background: #78350f; color: #fde68a; }
.subtask-progress {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px; border-radius: 4px; background: #0f172a;
}

.add-card {
  margin: 6px 8px 10px;
  padding: 8px;
  background: transparent;
  color: #94a3b8;
  border: 1px dashed #334155;
  border-radius: 8px;
  cursor: pointer; font-size: 14px;
}
.add-card:hover { background: #0f172a; color: #fff; }
.add-card-form {
  margin: 6px 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.add-card-form textarea {
  background: #0f172a; color: #e5e7eb;
  border: 1px solid #334155; border-radius: 6px;
  padding: 8px; min-height: 56px; font-size: 14px; font-family: inherit;
  resize: vertical;
}
.add-card-form .row { display: flex; gap: 6px; }
.add-card-form button {
  background: #2563eb; color: white; border: 0;
  padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.add-card-form button.cancel { background: transparent; color: #94a3b8; }

.add-column {
  flex: 0 0 280px;
  align-self: flex-start;
  background: rgba(255,255,255,.04);
  border: 1px dashed #334155;
  color: #94a3b8;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer; font-size: 14px;
}
.add-column:hover { background: rgba(255,255,255,.08); color: #fff; }

/* === Drag & Drop === */
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.sortable-drag { transform: rotate(2deg); }

/* === Modals === */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.6);
}
.modal-panel {
  position: relative;
  background: #111827;
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  border-radius: 14px 14px 0 0;
  display: flex; flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0,0,0,.5);
  animation: slide-up .2s ease-out;
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes slide-up { from { transform: translateY(20px); opacity: 0; } }
.modal-header {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #1f2937;
}
.modal-header h2 { margin: 0; font-size: 16px; flex: 1; }
.card-title-input {
  flex: 1;
  background: transparent; color: #f3f4f6;
  border: 0; outline: none;
  font-size: 17px; font-weight: 600;
  padding: 4px;
}
.card-title-input:focus { background: #0f172a; border-radius: 4px; }
.modal-body {
  padding: 16px;
  overflow-y: auto;
}
.field {
  display: flex; flex-direction: column;
  margin-bottom: 18px;
}
.field > span {
  font-size: 12px; text-transform: uppercase;
  color: #94a3b8; margin-bottom: 6px; letter-spacing: .04em;
}
.field input[type=date], .field textarea {
  background: #0f172a; color: #e5e7eb;
  border: 1px solid #334155; border-radius: 6px;
  padding: 8px 10px; font-size: 15px; font-family: inherit;
}
.field textarea { resize: vertical; }
.labels-row { display: flex; flex-wrap: wrap; gap: 6px; }
.labels-row .label-chip {
  cursor: pointer; padding: 4px 10px;
  opacity: .35; border: 1px solid transparent;
}
.labels-row .label-chip.active { opacity: 1; }

.subtasks { list-style: none; padding: 0; margin: 0 0 8px; }
.subtask {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
}
.subtask-check {
  width: 18px; height: 18px; flex: 0 0 auto;
  border: 2px solid #475569; border-radius: 4px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.subtask-check.done { background: #10b981; border-color: #10b981; }
.subtask-check.done::after {
  content: ""; width: 4px; height: 8px;
  border: solid white; border-width: 0 2px 2px 0;
  transform: rotate(45deg); margin-bottom: 2px;
}
.subtask-title {
  flex: 1; background: transparent; color: #e5e7eb;
  border: 0; outline: none; font-size: 14px; padding: 4px;
}
.subtask.done .subtask-title { text-decoration: line-through; color: #94a3b8; }
.subtask-delete {
  background: transparent; border: 0; color: #64748b;
  cursor: pointer; font-size: 18px; padding: 4px 8px;
}
.subtask-delete:hover { color: #f87171; }
.add-subtask {
  display: flex; gap: 6px; margin-top: 6px;
}
.add-subtask input {
  flex: 1; background: #0f172a; color: #e5e7eb;
  border: 1px solid #334155; border-radius: 6px;
  padding: 8px; font-size: 14px;
}
.add-subtask button {
  background: #2563eb; color: white; border: 0;
  width: 36px; border-radius: 6px; cursor: pointer; font-size: 18px;
}

.danger-btn {
  background: transparent; border: 1px solid #7f1d1d;
  color: #fca5a5; padding: 10px 14px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.danger-btn:hover { background: #7f1d1d; color: #fff; }

/* Aktions-Zeile am unteren Rand des Card-Modals: kleiner Löschen-Button + großer Schließen-Button */
.modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #1f2937;
}
.btn-delete-small {
  background: transparent;
  color: #94a3b8;
  border: 0;
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-delete-small:hover { color: #f87171; }
.btn-close-large {
  flex: 1;
  background: #2563eb;
  color: white;
  border: 0;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.btn-close-large:hover { background: #1d4ed8; }

/* Labels-Modal */
.labels-list { list-style: none; padding: 0; margin: 0 0 16px; }
.labels-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid #1f2937;
}
.labels-list input[type=text] {
  flex: 1; background: #0f172a; color: #e5e7eb;
  border: 1px solid #334155; border-radius: 6px;
  padding: 6px 8px; font-size: 14px;
}
.labels-list input[type=color] {
  width: 36px; height: 30px; border: 0; background: transparent; cursor: pointer;
}
.labels-list button {
  background: transparent; border: 0; color: #64748b;
  cursor: pointer; font-size: 18px;
}
.labels-list button:hover { color: #f87171; }
.add-label {
  display: flex; gap: 6px; margin-top: 8px;
}
.add-label input[type=text] {
  flex: 1; background: #0f172a; color: #e5e7eb;
  border: 1px solid #334155; border-radius: 6px;
  padding: 8px; font-size: 14px;
}
.add-label input[type=color] {
  width: 40px; height: 36px; border: 0; background: transparent; cursor: pointer;
}
.add-label button {
  background: #2563eb; color: white; border: 0;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 14px;
}

/* === Desktop === */
@media (min-width: 768px) {
  .modal { align-items: center; }
  .modal-panel {
    border-radius: 14px;
    max-height: 80vh;
  }
}
