:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --border: #e2e4e9;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --danger: #dc2626;
  --todo: #64748b;
  --bezig: #d97706;
  --klaar: #16a34a;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* Splash screen */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.splash.splash-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-content { text-align: center; color: white; }
.splash-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  animation: splash-pop 0.6s cubic-bezier(.34,1.56,.64,1);
}
.splash-title {
  font-weight: 700;
  font-size: 1.1rem;
  opacity: 0;
  animation: splash-fade-up 0.5s ease 0.15s forwards;
}
.splash-dots { margin-top: 14px; display: flex; gap: 6px; justify-content: center; }
.splash-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  animation: splash-bounce 1.1s ease-in-out infinite;
}
.splash-dots span:nth-child(2) { animation-delay: 0.15s; }
.splash-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes splash-pop {
  0% { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes splash-fade-up {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes splash-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Page fade-in */
.app, .login-screen { animation: page-fade-in 0.4s ease; }
@keyframes page-fade-in {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

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

.hidden { display: none !important; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
.login-card {
  background: var(--card-bg);
  padding: 32px 28px;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card h1 { margin: 0 0 8px; font-size: 1.5rem; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}
.login-card {
  animation: card-entrance 0.5s cubic-bezier(.22,1,.36,1);
}
@keyframes card-entrance {
  0% { opacity: 0; transform: translateY(16px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.login-card button {
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.login-card button:hover { background: var(--primary-dark); }
.login-card button:active { transform: scale(0.97); }
.auth-error { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Layout */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; }

.tabs { display: flex; gap: 4px; }
.tab-btn {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease;
}
.tab-btn:active { transform: scale(0.96); }
.tab-btn.active { background: #eef0ff; color: var(--primary); }
.tab-panel { animation: tab-fade-in 0.25s ease; }
@keyframes tab-fade-in {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

.user-box { display: flex; align-items: center; gap: 10px; }
.badge {
  background: var(--primary);
  color: white;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  animation: badge-in 0.4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes badge-in {
  0% { opacity: 0; transform: scale(0.7); }
  100% { opacity: 1; transform: scale(1); }
}
.link-btn {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
}

main { flex: 1; padding: 16px 20px 40px; max-width: 1400px; width: 100%; margin: 0 auto; }

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.board-header h2 { margin: 0; font-size: 1.2rem; }

.primary-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.primary-btn:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(79,70,229,0.3); }
.primary-btn:active { transform: scale(0.96); }
.danger-btn {
  background: none;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease, transform 0.1s ease;
}
.danger-btn:hover { background: #fee2e2; }
.danger-btn:active { transform: scale(0.96); }

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.column {
  background: #eceef3;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
}
.column-header.todo { border-color: var(--todo); color: var(--todo); }
.column-header.bezig { border-color: var(--bezig); color: var(--bezig); }
.column-header.klaar { border-color: var(--klaar); color: var(--klaar); }
.column-header .count {
  background: rgba(0,0,0,0.08);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1);
  display: inline-block;
}
.column-header .count.bump { transform: scale(1.3); }

@keyframes toast-in {
  0% { opacity: 0; transform: translateY(12px) translateX(-50%); }
  100% { opacity: 1; transform: translateY(0) translateX(-50%); }
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2430;
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 200;
  animation: toast-in 0.25s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
.toast.toast-error { background: var(--danger); }

.column-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 100px;
}
.column-body.drag-over { background: #dfe3ee; transform: scale(1.01); transition: background 0.15s ease, transform 0.15s ease; }
.column-body { transition: background 0.15s ease; }

.card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  cursor: grab;
  border: 1px solid var(--border);
  animation: card-in 0.3s cubic-bezier(.22,1,.36,1);
  transition: box-shadow 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}
.card:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: 0.4; transform: scale(0.97) rotate(-1deg); }
@keyframes card-in {
  0% { opacity: 0; transform: translateY(10px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.card h3 { margin: 0 0 6px; font-size: 0.95rem; }
.card p { margin: 0 0 8px; font-size: 0.82rem; color: var(--muted); white-space: pre-wrap; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.avatar-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
  color: white;
  font-weight: 600;
}
.due-chip {
  font-size: 0.72rem;
  color: var(--muted);
  background: #f1f2f6;
  padding: 3px 8px;
  border-radius: 999px;
}
.due-chip.overdue { color: var(--danger); background: #fee2e2; }

/* Resources */
.resource-filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-chip {
  border: 1px solid var(--border);
  background: var(--card-bg);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
}
.filter-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

.resource-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.resource-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.resource-card .rtype {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 5px;
  margin-bottom: 8px;
}
.rtype.link { background: #e0e7ff; color: #4338ca; }
.rtype.document { background: #dcfce7; color: #15803d; }
.rtype.notitie { background: #fef3c7; color: #b45309; }
.resource-card h4 { margin: 0 0 6px; font-size: 0.95rem; word-break: break-word; }
.resource-card a { color: var(--primary); font-size: 0.85rem; word-break: break-all; }
.resource-card a.file-link {
  display: inline-block;
  background: #eef0ff;
  padding: 4px 10px;
  border-radius: 6px;
  margin-top: 4px;
  text-decoration: none;
}
.modal input[type="file"] {
  padding: 8px;
  background: #f6f7fb;
  cursor: pointer;
}
.resource-card .rnotes { font-size: 0.82rem; color: var(--muted); margin: 8px 0 0; white-space: pre-wrap; }
.resource-card .rfooter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.resource-card .rmeta { font-size: 0.72rem; color: var(--muted); }
.resource-card .icon-btn {
  border: none;
  background: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.75rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 16px;
  overflow-y: auto;
  z-index: 100;
  animation: overlay-fade-in 0.2s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes overlay-fade-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  position: relative;
  animation: modal-in 0.28s cubic-bezier(.22,1,.36,1);
}
@keyframes modal-in {
  0% { opacity: 0; transform: translateY(24px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
  transition: transform 0.15s ease, color 0.15s ease;
}
.modal-close:hover { color: var(--danger); transform: rotate(90deg); }
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.modal h3 { margin: 0 0 16px; }
.modal form { display: flex; flex-direction: column; gap: 10px; }
.modal label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.modal input, .modal select, .modal textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  width: 100%;
  font-family: inherit;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

/* Subtasks */
.subtask-progress-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.subtask-progress-bar {
  flex: 1;
  height: 5px;
  background: #eceef3;
  border-radius: 999px;
  overflow: hidden;
}
.subtask-progress-fill {
  height: 100%;
  background: var(--klaar);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.subtask-progress-mini span { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }

.subtask-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; margin-bottom: 10px; }
.subtask-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f6f7fb;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  animation: card-in 0.2s ease;
}
.subtask-item.done .subtask-check span { text-decoration: line-through; color: var(--muted); }
.subtask-check { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; }
.subtask-check input { width: auto; accent-color: var(--primary); }
.subtask-remove { font-size: 1rem; line-height: 1; padding: 2px 6px; }

.comments-list { display: flex; flex-direction: column; gap: 10px; max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
.comment-item { font-size: 0.85rem; background: #f6f7fb; padding: 8px 10px; border-radius: 8px; }
.comment-item .cauthor { font-weight: 700; margin-right: 6px; }
.comment-item .ctime { color: var(--muted); font-size: 0.7rem; float: right; }
.comment-form { display: flex; gap: 8px; }
.comment-form input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; }
.comment-form button {
  border: none;
  background: var(--primary);
  color: white;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar { padding: 10px 14px; }
  main { padding: 12px 12px 30px; }
  .brand { font-size: 1rem; }
}

/* Auth */
.auth-error {
  background: #fee2e2;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 4px 0 0;
}
#login-form, #register-form { margin-bottom: 4px; }

/* Secondary button */
.secondary-btn {
  background: #eef0ff;
  color: var(--primary);
  border: 1px solid #d9dcfb;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
.secondary-btn:hover { background: #e0e3ff; }

/* Brand back link */
.brand-back {
  text-decoration: none;
  color: var(--muted);
  margin-right: 8px;
  font-weight: 700;
}

/* Room list */
.room-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.room-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  animation: card-in 0.3s cubic-bezier(.22,1,.36,1);
}
.room-card:hover { box-shadow: 0 8px 22px rgba(0,0,0,0.1); transform: translateY(-3px); }
.room-card:active { transform: translateY(-1px) scale(0.99); }
.room-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-card h3 { margin: 0; font-size: 1rem; }
.room-card p { color: var(--muted); font-size: 0.85rem; margin: 8px 0; }
.room-card-meta { font-size: 0.75rem; color: var(--muted); margin-top: 8px; }

.role-chip {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.role-chip.role-owner { background: #fef3c7; color: #b45309; }
.role-chip.role-editor { background: #dcfce7; color: #15803d; }
.role-chip.role-viewer { background: #e0e7ff; color: #4338ca; }

/* Viewer note */
.viewer-note {
  background: #e0e7ff;
  color: #4338ca;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  margin: 0 0 14px;
  display: inline-block;
}

/* Swipe hint buttons (touch) */
.swipe-hint {
  display: none;
  justify-content: space-between;
  margin-top: 8px;
}
.swipe-btn {
  border: 1px solid var(--border);
  background: #f6f7fb;
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.9rem;
  cursor: pointer;
}
@media (hover: none) and (pointer: coarse) {
  .swipe-hint { display: flex; }
  .card { touch-action: pan-y; }
}

/* Members */
.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.member-username { color: var(--muted); font-size: 0.82rem; }
.member-role-select {
  margin-left: auto;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
}
.member-row .icon-btn { margin-left: 0; }

.invite-box { margin-bottom: 14px; }
.invite-box-inner {
  background: #f6f7fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
}
.invite-box-inner code {
  background: #e5e7eb;
  padding: 2px 8px;
  border-radius: 5px;
  font-weight: 600;
}

/* Settings modal extras */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.checkbox-row input { width: auto; }
.invite-code-row { display: flex; gap: 8px; }
.invite-code-row input { flex: 1; background: #f6f7fb; font-family: monospace; }
