/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface2: #f1f3f7;
  --border: #e2e6ed;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --transition: 0.18s ease;

  /* Priority colors */
  --priority-low: #22c55e;
  --priority-medium: #eab308;
  --priority-high: #ef4444;

}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Layout ===== */
body { display: flex; height: 100vh; overflow: hidden; }

.app-wrapper { display: flex; width: 100%; height: 100vh; overflow: hidden; }

/* ===== Login Screen ===== */
.login-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 48px 40px;
  width: 100%; max-width: 380px;
  text-align: center;
}

.login-logo {
  font-size: 20px; font-weight: 700;
  color: var(--accent); letter-spacing: -0.3px;
  margin-bottom: 24px;
}

.login-title {
  font-size: 24px; font-weight: 700;
  color: var(--text); margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px; color: var(--text-muted);
  margin-bottom: 32px;
}

.btn-google {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 15px; font-weight: 500;
  color: var(--text); cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow);
}
.btn-google:hover { background: var(--surface2); box-shadow: var(--shadow-md); }
.btn-google:disabled { opacity: 0.6; cursor: not-allowed; }

.google-icon { width: 20px; height: 20px; flex-shrink: 0; }

.login-error {
  margin-top: 16px; font-size: 13px;
  color: var(--danger); background: #fee2e2;
  border-radius: var(--radius-sm); padding: 8px 12px;
}

/* ===== Sidebar Footer (user info + sign out) ===== */
.sidebar-footer {
  margin-top: auto; padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  flex-wrap: wrap;
}

.user-info {
  display: flex; align-items: center; gap: 8px;
  overflow: hidden; flex: 1; min-width: 0;
}

.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border);
}

.user-name {
  font-size: 13px; font-weight: 500;
  color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.btn-signout {
  flex-shrink: 0;
  padding: 4px 10px;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px;
  color: var(--text-muted); cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-align: center; white-space: nowrap;
}
.btn-signout:hover { background: #fee2e2; color: var(--danger); border-color: var(--danger); }

/* ===== Undo Button ===== */
.btn-undo {
  color: var(--text-muted);
}
.btn-undo:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}
.btn-undo:not(:disabled):hover { background: #eef2ff; }
.btn-undo:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Column Drag & Drop ===== */
.col-drag-handle {
  cursor: grab;
}
.col-drag-handle:active { cursor: grabbing; }

.col-drag-icon {
  font-size: 12px; color: var(--border);
  letter-spacing: -2px; margin-right: 2px;
  user-select: none;
  transition: color 0.15s;
}
.col-drag-handle:hover .col-drag-icon { color: var(--text-muted); }

.column.dragging-col {
  opacity: 0.4;
  cursor: grabbing;
}

.col-drop-indicator {
  width: 3px; min-width: 3px;
  background: var(--accent);
  border-radius: 3px;
  align-self: stretch;
  min-height: 60px;
  margin: 0 4px;
  pointer-events: none;
}

/* ===== Share Button ===== */
.btn-share {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 500;
}
.btn-share:hover { background: #eef2ff; }

/* ===== Share Modal ===== */
.share-desc {
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 14px; line-height: 1.6;
}

.share-link-box {
  display: flex; gap: 8px; align-items: center;
}

.share-link-box input {
  flex: 1; padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-muted);
  background: var(--surface2);
  font-family: monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.share-copied {
  margin-top: 8px; font-size: 12px;
  color: var(--priority-low); font-weight: 500;
}

/* ===== Sidebar ===== */
.sidebar {
  position: relative;
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  transition: width var(--transition), min-width var(--transition);
  overflow: hidden;
  z-index: 10;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.sidebar-toggle:hover { background: var(--surface2); color: var(--text); }

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 16px 16px 6px;
  white-space: nowrap;
}

.sidebar-header .sidebar-section-label {
  padding: 0;
}

.board-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

/* ── Section headers ── */
.board-section-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  padding: 10px 12px 4px;
  list-style: none;
  pointer-events: none;
  user-select: none;
}

/* Archive header — clickable to collapse/expand */
.board-section-header.archive-header {
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.board-section-header.archive-header:hover {
  background: var(--surface2);
  color: var(--accent);
}
.archive-label { flex: 1; }
.archive-toggle {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
}
.board-section-zone.archive-collapsed {
  display: none;
}

/* ── Thick divider between sections ── */
.board-section-divider {
  list-style: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 8px 10px;
}

/* ── Drop zone (inner ul) ── */
.board-section-zone {
  list-style: none;
  padding: 0 6px;
  min-height: 28px; /* always droppable even when empty */
}

/* ── Individual board row ── */
.board-section-zone li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: default;
  color: var(--text-muted);
  font-size: 13.5px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.board-section-zone li:hover { background: var(--surface2); color: var(--text); }
.board-section-zone li.active { background: #ede9fe; color: var(--accent); font-weight: 600; }
.board-section-zone li.board-dragging { opacity: 0.4; }

/* ── Grab handle ── */
.board-grab {
  cursor: grab;
  color: var(--border);
  font-size: 12px;
  letter-spacing: -3px;
  flex-shrink: 0;
  line-height: 1;
  padding: 0 2px;
  transition: color var(--transition);
  user-select: none;
}
.board-section-zone li:hover .board-grab { color: var(--text-muted); }
.board-grab:active { cursor: grabbing; }

.board-name-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.board-dupe-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  font-size: 11px;
  line-height: 1;
  opacity: 0;
  flex-shrink: 0;
  margin-left: auto;
  transition: opacity var(--transition);
  color: inherit;
}
.board-section-zone li:hover .board-dupe-btn { opacity: 0.55; }
.board-section-zone li.active .board-dupe-btn { opacity: 0.6; }
.board-dupe-btn:hover { opacity: 1 !important; color: var(--accent); }

.btn-new-board {
  margin: 3px 12px;
  padding: 8px 12px;
  background: none;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  white-space: nowrap;
}
.btn-new-board:hover { border-color: var(--accent-hover); color: var(--accent-hover); background: #ede9fe44; }

/* Template and blank buttons — same unified style */
.btn-template, .btn-blank {
  background: #ede9fe33;
}

/* ===== Main ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-open-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: none;
  transition: background var(--transition);
}
.sidebar-open-btn:hover { background: var(--surface2); }
.sidebar.collapsed ~ .main .sidebar-open-btn { display: inline-flex; }

.board-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.btn-topbar {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.btn-topbar:hover { background: var(--surface); color: var(--accent); border-color: var(--accent); }

/* Email a Backup — prominent button */
.btn-email-backup-prominent {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #6d28d9;
  color: #fff;
  border: 2px solid #5b21b6;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(109,40,217,0.25);
  transition: background var(--transition), box-shadow var(--transition), transform 0.1s;
  margin-right: 6px;
}
.btn-email-backup-prominent:hover {
  background: #5b21b6;
  box-shadow: 0 4px 14px rgba(109,40,217,0.35);
  transform: translateY(-1px);
}
.btn-email-backup-prominent:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(109,40,217,0.2);
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 2px;
}

/* ===== Auto-backup status ===== */
.autosave-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background var(--transition);
}

.autosave-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  transition: background 0.3s;
}

/* States */
.autosave-status.saving  { background: #fef9c3; border-color: #eab308; color: #a16207; }
.autosave-status.saving .autosave-dot  { background: #eab308; animation: pulse 0.8s infinite; }

.autosave-status.saved   { background: #dcfce7; border-color: #22c55e; color: #16a34a; }
.autosave-status.saved .autosave-dot   { background: #22c55e; }

.autosave-status.live     { background: #dcfce7; border-color: #22c55e; color: #16a34a; }
.autosave-status.live .autosave-dot     { background: #22c55e; }

.autosave-status.error    { background: #fee2e2; border-color: #ef4444; color: #b91c1c; }
.autosave-status.error .autosave-dot    { background: #ef4444; }

.autosave-status.connecting { background: var(--surface2); border-color: var(--border); color: var(--text-muted); }
.autosave-status.connecting .autosave-dot { background: #94a3b8; animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.btn-topbar-toggle {
  font-size: 12px;
  padding: 5px 10px;
}

/* ===== Buttons ===== */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: none;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ===== Deliverable Links Bar ===== */
.link-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.link-bar-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.link-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

/* Individual link chip */
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 16px 7px 13px;
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative;
}
.link-chip:hover {
  background: #ede9fe;
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(109,40,217,0.10);
}
.link-chip-icon {
  font-size: 11px;
  flex-shrink: 0;
  opacity: 0.7;
}
.link-chip-label {
  white-space: nowrap;
}
.link-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  padding: 0 0 0 3px;
  border-radius: 50%;
  display: none;
  transition: color var(--transition);
  flex-shrink: 0;
}
.link-chip:hover .link-chip-remove { display: inline; }
.link-chip-remove:hover { color: var(--danger); }

.link-chip[draggable="true"] { cursor: grab; }
.link-chip[draggable="true"]:active { cursor: grabbing; }
.link-chip.chip-dragging {
  opacity: 0.45;
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

/* Add Link button */
.btn-add-link {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 11px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-add-link:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--text-muted);
  border-style: solid;
}

/* ===== Board Area ===== */
.board-area {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 28px 24px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

/* Custom scrollbar for board area */
.board-area::-webkit-scrollbar {
  height: 10px;
}
.board-area::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 10px;
}
.board-area::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 10px;
  border: 2px solid var(--border);
}
.board-area::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.8;
}

/* ===== Column ===== */
.column {
  background: var(--surface2);
  border-radius: var(--radius);
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  border: 1px solid var(--border);
  transition: width 0.2s ease, min-width 0.2s ease;
}

/* Collapsed column — narrow strip showing only the header */
.column-collapsed {
  width: 52px;
  min-width: 52px;
  overflow: hidden;
}
.column-collapsed .column-header {
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  gap: 6px;
}
.column-collapsed .column-title-wrap {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.column-collapsed .column-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  max-height: 180px;
}
.column-collapsed .column-count {
  display: none;
}
.column-collapsed .col-drag-icon {
  display: none;
}
.column-collapsed .column-actions {
  flex-direction: column;
  gap: 4px;
}
.column-collapsed .rename-col-btn,
.column-collapsed .delete-col-btn {
  display: none;
}
.column-collapsed .cards-list,
.column-collapsed .btn-add-card {
  display: none;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  gap: 8px;
}

.column-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.column-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.column-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 1px 7px;
  flex-shrink: 0;
}

.column-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.col-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}
.col-btn:hover { background: var(--border); color: var(--text); }
.col-btn.danger:hover { background: #fee2e2; color: var(--danger); }

.cards-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

/* Drag-over highlight */
.cards-list.drag-over {
  background: #ede9fe55;
  border-radius: var(--radius-sm);
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 30px 13px 28px 13px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: default;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
}

.card:hover { box-shadow: var(--shadow-md); }
.card.dragging { opacity: 0.45; transform: scale(0.98); cursor: grabbing; }

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 6px;
}

.card-title-clickable {
  cursor: pointer;
}
.card-title-clickable:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Quill editor in modal */
.card-desc-editor {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
}
.card-desc-editor .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  padding: 6px 8px;
}
.card-desc-editor .ql-container {
  border: none;
  font-size: 14px;
  min-height: 270px;
  max-height: 510px;
  overflow-y: auto;
}
.card-desc-editor .ql-editor {
  min-height: 270px;
  padding: 10px 12px;
  color: var(--text);
}
.card-desc-editor .ql-editor.ql-blank::before {
  color: var(--text-muted);
  font-style: normal;
}
/* Quill rendered HTML on card face */
.card-desc.ql-editor {
  padding: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
  max-height: 3em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}
.card-desc.ql-editor p { margin: 0; }
.card-desc.ql-editor ul, .card-desc.ql-editor ol { padding-left: 16px; margin: 0; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-priority-select,
.card-status-select {
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 6px;
  border: none;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: none;
  transition: background var(--transition), color var(--transition);
}
.card-priority-select:hover,
.card-status-select:hover { opacity: 0.85; }

/* Priority colors */
.card-priority-select.none   { background: #f1f5f9; color: #94a3b8; }
.card-priority-select.low    { background: #dbeafe; color: #2563eb; }
.card-priority-select.medium { background: #fef9c3; color: #a16207; }
.card-priority-select.high   { background: #fee2e2; color: #dc2626; }

/* Status colors */
.card-status-select.not-started { background: #f1f5f9; color: #64748b; }
.card-status-select.in-process  { background: #fef9c3; color: #a16207; }
.card-status-select.complete    { background: #dcfce7; color: #16a34a; }

/* Card drag handle — top-left */
.card-drag-handle {
  position: absolute;
  top: 7px;
  left: 7px;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
  padding: 2px 3px;
  border-radius: 3px;
}
.card-drag-handle:active { cursor: grabbing; }
.card:hover .card-drag-handle { opacity: 1; }

.card-drag-icon {
  font-size: 16px;
  color: var(--text);
  letter-spacing: -2px;
  user-select: none;
}

/* Card delete button — top-right */
.card-delete-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background var(--transition), color var(--transition);
}
.card:hover .card-delete-btn { opacity: 1; }
.card-delete-btn:hover { background: #fee2e2; color: var(--danger); }

/* Card edit button — bottom-right on hover */
.card-edit-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background var(--transition), color var(--transition);
}
.card:hover .card-edit-btn { opacity: 1; }
.card-edit-btn:hover { background: var(--surface2); color: var(--accent); }

.card-dupe-btn {
  position: absolute;
  bottom: 8px;
  right: 34px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background var(--transition), color var(--transition);
}
.card:hover .card-dupe-btn { opacity: 1; }
.card-dupe-btn:hover { background: var(--surface2); color: var(--accent); }


/* ===== Add Card Button ===== */
.btn-add-card {
  margin: 0 10px 12px;
  padding: 8px 12px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.btn-add-card:hover { border-color: var(--accent); color: var(--accent); background: #ede9fe33; }

/* ===== Add Column Button ===== */
.btn-add-column {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  width: 32px;
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  align-self: flex-start;
  flex-shrink: 0;
  margin-top: 2px;
}
.btn-add-column:hover { border-color: var(--accent); color: var(--accent); background: #ede9fe33; }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  animation: modalIn 0.18s ease;
}
/* Card / task editor modal — 1.5× wider than base */
#cardModal {
  width: 720px;
  max-width: 95vw;
}
.modal.modal-sm { width: 360px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 0;
}
.modal-header h2 { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--surface2); }

.modal-body {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-body label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
  display: block;
}
.modal-body input[type="text"],
.modal-body input[type="date"],
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
  resize: vertical;
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus { border-color: var(--accent); }

.modal-row { display: flex; gap: 14px; }
.modal-col { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.required { color: var(--danger); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 22px 20px;
}


/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #c1c9d4; }

/* ===== In-app Toast Notification ===== */
.app-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 22px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 4px 18px rgba(0,0,0,0.10);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  white-space: nowrap;
}
.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.app-toast.toast-success {
  border-color: #22c55e;
  color: #15803d;
  background: #f0fdf4;
}
.app-toast.toast-error {
  border-color: #ef4444;
  color: #b91c1c;
  background: #fef2f2;
}

/* ===== Card Updated-At Timestamp ===== */
.card-updated-at {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ===== Comments / Notes Log ===== */
.comments-log {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface2);
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comments-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
}

.comment-entry {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.comment-entry:last-child { border-bottom: none; padding-bottom: 0; }

.comment-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
}

.comment-ts {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.comment-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.comment-textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}
.comment-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
  white-space: nowrap;
}

/* ===== Comment View / Edit Mode ===== */
.comment-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.comment-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
.comment-entry:hover .comment-actions { opacity: 1; }

.comment-btn-edit,
.comment-btn-delete {
  background: none;
  border: none;
  padding: 1px 5px;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.comment-btn-edit   { color: var(--accent); }
.comment-btn-edit:hover   { background: #ede9fe; }
.comment-btn-delete { color: var(--danger, #ef4444); }
.comment-btn-delete:hover { background: #fee2e2; }

.comment-edit-mode { margin-top: 2px; }

.comment-edit-textarea {
  width: 100%;
  margin-bottom: 6px;
}

.comment-edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
